PageRenderTime 94ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/protocols/ss7/m3ua/impl/src/main/java/org/mobicents/protocols/ss7/m3ua/impl/M3UAManagement.java

http://mobicents.googlecode.com/
Java | 659 lines | 430 code | 126 blank | 103 comment | 94 complexity | 42ebf0f39ab4ee71257acdca8dad0ef1 MD5 | raw file
Possible License(s): LGPL-3.0, GPL-3.0, LGPL-2.1, GPL-2.0, CC-BY-SA-3.0, CC0-1.0, Apache-2.0, BSD-3-Clause
  1. /*
  2. * JBoss, Home of Professional Open Source
  3. * Copyright 2011, Red Hat, Inc. and individual contributors
  4. * by the @authors tag. See the copyright.txt in the distribution for a
  5. * full listing of individual contributors.
  6. *
  7. * This is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU Lesser General Public License as
  9. * published by the Free Software Foundation; either version 2.1 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This software is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this software; if not, write to the Free
  19. * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20. * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  21. */
  22. package org.mobicents.protocols.ss7.m3ua.impl;
  23. import java.io.File;
  24. import java.io.FileInputStream;
  25. import java.io.FileNotFoundException;
  26. import java.io.FileOutputStream;
  27. import java.io.IOException;
  28. import java.util.concurrent.Executors;
  29. import java.util.concurrent.ScheduledExecutorService;
  30. import java.util.concurrent.TimeUnit;
  31. import javolution.text.TextBuilder;
  32. import javolution.util.FastList;
  33. import javolution.util.FastMap;
  34. import javolution.xml.XMLObjectReader;
  35. import javolution.xml.XMLObjectWriter;
  36. import javolution.xml.stream.XMLStreamException;
  37. import org.apache.log4j.Logger;
  38. import org.mobicents.protocols.api.Association;
  39. import org.mobicents.protocols.api.Management;
  40. import org.mobicents.protocols.ss7.m3ua.ExchangeType;
  41. import org.mobicents.protocols.ss7.m3ua.Functionality;
  42. import org.mobicents.protocols.ss7.m3ua.IPSPType;
  43. import org.mobicents.protocols.ss7.m3ua.impl.fsm.FSM;
  44. import org.mobicents.protocols.ss7.m3ua.impl.message.MessageFactoryImpl;
  45. import org.mobicents.protocols.ss7.m3ua.impl.oam.M3UAOAMMessages;
  46. import org.mobicents.protocols.ss7.m3ua.impl.parameter.ParameterFactoryImpl;
  47. import org.mobicents.protocols.ss7.m3ua.impl.scheduler.M3UAScheduler;
  48. import org.mobicents.protocols.ss7.m3ua.message.MessageClass;
  49. import org.mobicents.protocols.ss7.m3ua.message.MessageFactory;
  50. import org.mobicents.protocols.ss7.m3ua.message.MessageType;
  51. import org.mobicents.protocols.ss7.m3ua.message.transfer.PayloadData;
  52. import org.mobicents.protocols.ss7.m3ua.parameter.NetworkAppearance;
  53. import org.mobicents.protocols.ss7.m3ua.parameter.ParameterFactory;
  54. import org.mobicents.protocols.ss7.m3ua.parameter.ProtocolData;
  55. import org.mobicents.protocols.ss7.m3ua.parameter.RoutingContext;
  56. import org.mobicents.protocols.ss7.m3ua.parameter.TrafficModeType;
  57. import org.mobicents.protocols.ss7.mtp.Mtp3PausePrimitive;
  58. import org.mobicents.protocols.ss7.mtp.Mtp3ResumePrimitive;
  59. import org.mobicents.protocols.ss7.mtp.Mtp3StatusPrimitive;
  60. import org.mobicents.protocols.ss7.mtp.Mtp3TransferPrimitive;
  61. import org.mobicents.protocols.ss7.mtp.Mtp3UserPartBaseImpl;
  62. /**
  63. * @author amit bhayani
  64. *
  65. */
  66. public class M3UAManagement extends Mtp3UserPartBaseImpl {
  67. private static final Logger logger = Logger.getLogger(M3UAManagement.class);
  68. private static final String AS_LIST = "asList";
  69. private static final String ASP_FACTORY_LIST = "aspFactoryList";
  70. private static final String DPC_VS_AS_LIST = "route";
  71. private static final String M3UA_PERSIST_DIR_KEY = "m3ua.persist.dir";
  72. private static final String USER_DIR_KEY = "user.dir";
  73. private static final String PERSIST_FILE_NAME = "m3ua.xml";
  74. private static final M3UAXMLBinding binding = new M3UAXMLBinding();
  75. private static final String TAB_INDENT = "\t";
  76. private static final String CLASS_ATTRIBUTE = "type";
  77. protected FastList<As> appServers = new FastList<As>();
  78. protected FastList<AspFactory> aspfactories = new FastList<AspFactory>();
  79. protected M3UAScheduler m3uaScheduler = new M3UAScheduler();
  80. private final TextBuilder persistFile = TextBuilder.newInstance();
  81. private final String name;
  82. private String persistDir = null;
  83. protected ParameterFactory parameterFactory = new ParameterFactoryImpl();
  84. protected MessageFactory messageFactory = new MessageFactoryImpl();
  85. protected Management transportManagement = null;
  86. private ScheduledExecutorService fsmTicker;
  87. protected int maxAsForRoute = 4;
  88. private M3UARouteManagement routeManagement = null;
  89. public M3UAManagement(String name) {
  90. this.name = name;
  91. binding.setClassAttribute(CLASS_ATTRIBUTE);
  92. binding.setAlias(AspFactory.class, "aspFactory");
  93. binding.setAlias(As.class, "as");
  94. binding.setAlias(Asp.class, "asp");
  95. this.routeManagement = new M3UARouteManagement(this);
  96. }
  97. public String getName() {
  98. return name;
  99. }
  100. public String getPersistDir() {
  101. return persistDir;
  102. }
  103. public void setPersistDir(String persistDir) {
  104. this.persistDir = persistDir;
  105. }
  106. public int getMaxAsForRoute() {
  107. return maxAsForRoute;
  108. }
  109. public void setMaxAsForRoute(int maxAsForRoute) {
  110. this.maxAsForRoute = maxAsForRoute;
  111. }
  112. public Management getTransportManagement() {
  113. return transportManagement;
  114. }
  115. public void setTransportManagement(Management transportManagement) {
  116. this.transportManagement = transportManagement;
  117. }
  118. public void start() throws Exception {
  119. if (this.transportManagement == null) {
  120. throw new NullPointerException("TransportManagement is null");
  121. }
  122. if (maxAsForRoute < 1 || maxAsForRoute > 4) {
  123. throw new Exception("Max AS for a route can be minimum 1 or maximum 4");
  124. }
  125. super.start();
  126. this.persistFile.clear();
  127. if (persistDir != null) {
  128. this.persistFile.append(persistDir).append(File.separator).append(this.name).append("_")
  129. .append(PERSIST_FILE_NAME);
  130. } else {
  131. persistFile.append(System.getProperty(M3UA_PERSIST_DIR_KEY, System.getProperty(USER_DIR_KEY)))
  132. .append(File.separator).append(this.name).append("_").append(PERSIST_FILE_NAME);
  133. }
  134. logger.info(String.format("M3UA configuration file path %s", persistFile.toString()));
  135. binding.setM3uaManagement(this);
  136. try {
  137. this.load();
  138. } catch (FileNotFoundException e) {
  139. logger.warn(String.format("Failed to load the SS7 configuration file. \n%s", e.getMessage()));
  140. }
  141. this.routeManagement.reset();
  142. fsmTicker = Executors.newSingleThreadScheduledExecutor();
  143. fsmTicker.scheduleAtFixedRate(m3uaScheduler, 500, 500, TimeUnit.MILLISECONDS);
  144. logger.info("Started M3UAManagement");
  145. }
  146. public void stop() throws Exception {
  147. super.stop();
  148. this.store();
  149. fsmTicker.shutdown();
  150. }
  151. public FastList<As> getAppServers() {
  152. return appServers;
  153. }
  154. public FastList<AspFactory> getAspfactories() {
  155. return aspfactories;
  156. }
  157. public FastMap<String, As[]> getRoute() {
  158. return this.routeManagement.route;
  159. }
  160. protected As getAs(String asName) {
  161. for (FastList.Node<As> n = appServers.head(), end = appServers.tail(); (n = n.getNext()) != end;) {
  162. As as = n.getValue();
  163. if (as.getName().equals(asName)) {
  164. return as;
  165. }
  166. }
  167. return null;
  168. }
  169. /**
  170. * <p>
  171. * Create new {@link As}
  172. * </p>
  173. * <p>
  174. * Command is m3ua as create <as-name> <AS | SGW | IPSP> mode <SE | DE>
  175. * ipspType < client | server > rc <routing-context> traffic-mode <traffic
  176. * mode>
  177. * </p>
  178. * <p>
  179. * where mode is optional, by default SE. ipspType should be specified if
  180. * type is IPSP. rc is optional and traffi-mode is also optional, default is
  181. * Loadshare
  182. * </p>
  183. *
  184. * @param args
  185. * @return
  186. * @throws Exception
  187. */
  188. public As createAs(String asName, Functionality functionality, ExchangeType exchangeType, IPSPType ipspType,
  189. RoutingContext rc, TrafficModeType trafficMode, NetworkAppearance na) throws Exception {
  190. As as = this.getAs(asName);
  191. if (as != null) {
  192. throw new Exception(String.format(M3UAOAMMessages.CREATE_AS_FAIL_NAME_EXIST, asName));
  193. }
  194. // TODO check if RC is already taken?
  195. if (exchangeType == null) {
  196. exchangeType = ExchangeType.SE;
  197. }
  198. if (functionality == Functionality.IPSP && ipspType == null) {
  199. ipspType = IPSPType.CLIENT;
  200. }
  201. as = new As(asName, rc, trafficMode, functionality, exchangeType, ipspType, na);
  202. as.setM3UAManagement(this);
  203. FSM localFSM = as.getLocalFSM();
  204. this.m3uaScheduler.execute(localFSM);
  205. FSM peerFSM = as.getPeerFSM();
  206. this.m3uaScheduler.execute(peerFSM);
  207. appServers.add(as);
  208. this.store();
  209. return as;
  210. }
  211. public As destroyAs(String asName) throws Exception {
  212. As as = this.getAs(asName);
  213. if (as == null) {
  214. throw new Exception(String.format(M3UAOAMMessages.ADD_ASP_TO_AS_FAIL_NO_AS, asName));
  215. }
  216. if (as.getAspList().size() != 0) {
  217. throw new Exception(String.format(
  218. "As=%s still has ASP's assigned. Unassign Asp's before destroying this As", asName));
  219. }
  220. for (FastMap.Entry<String, As[]> e = this.routeManagement.route.head(), end = this.routeManagement.route.tail(); (e = e
  221. .getNext()) != end;) {
  222. As[] asList = e.getValue();
  223. for (int count = 0; count < asList.length; count++) {
  224. As asTemp = asList[count];
  225. if (asTemp != null && asTemp.equals(as)) {
  226. throw new Exception(String.format("As=%s used in route=%s. Remove from route", asName, e.getKey()));
  227. }
  228. }
  229. }
  230. FSM asLocalFSM = as.getLocalFSM();
  231. if (asLocalFSM != null) {
  232. asLocalFSM.cancel();
  233. }
  234. FSM asPeerFSM = as.getPeerFSM();
  235. if (asPeerFSM != null) {
  236. asPeerFSM.cancel();
  237. }
  238. appServers.remove(as);
  239. this.store();
  240. return as;
  241. }
  242. /**
  243. * Create new {@link AspFactory}
  244. *
  245. * @param args
  246. * @return
  247. * @throws Exception
  248. */
  249. public AspFactory createAspFactory(String aspName, String associationName) throws Exception {
  250. AspFactory factory = this.getAspFactory(aspName);
  251. if (factory != null) {
  252. throw new Exception(String.format(M3UAOAMMessages.CREATE_ASP_FAIL_NAME_EXIST, aspName));
  253. }
  254. Association association = this.transportManagement.getAssociation(associationName);
  255. if (association == null) {
  256. throw new Exception(String.format("No Association found for name=%s", associationName));
  257. }
  258. if (association.isStarted()) {
  259. throw new Exception(String.format("Association=%s is started", associationName));
  260. }
  261. if (association.getAssociationListener() != null) {
  262. throw new Exception(String.format("Association=%s is already associated", associationName));
  263. }
  264. factory = new AspFactory(aspName);
  265. factory.setAssociation(association);
  266. factory.setTransportManagement(this.transportManagement);
  267. aspfactories.add(factory);
  268. this.store();
  269. return factory;
  270. }
  271. public AspFactory destroyAspFactory(String aspName) throws Exception {
  272. AspFactory aspFactroy = this.getAspFactory(aspName);
  273. if (aspFactroy == null) {
  274. throw new Exception(String.format(M3UAOAMMessages.ADD_ASP_TO_AS_FAIL_NO_ASP, aspName));
  275. }
  276. if (aspFactroy.getAspList().size() != 0) {
  277. throw new Exception("Asp are still assigned to As. Unassign all");
  278. }
  279. aspFactroy.unsetAssociation();
  280. this.aspfactories.remove(aspFactroy);
  281. this.store();
  282. return aspFactroy;
  283. }
  284. /**
  285. * Associate {@link Asp} to {@link As}
  286. *
  287. * @param asName
  288. * @param aspName
  289. * @return
  290. * @throws Exception
  291. */
  292. public Asp assignAspToAs(String asName, String aspName) throws Exception {
  293. // check ASP and AS exist with given name
  294. As as = this.getAs(asName);
  295. if (as == null) {
  296. throw new Exception(String.format(M3UAOAMMessages.ADD_ASP_TO_AS_FAIL_NO_AS, asName));
  297. }
  298. AspFactory aspFactroy = this.getAspFactory(aspName);
  299. if (aspFactroy == null) {
  300. throw new Exception(String.format(M3UAOAMMessages.ADD_ASP_TO_AS_FAIL_NO_ASP, aspName));
  301. }
  302. // If ASP already assigned to AS we don't want to re-assign
  303. for (FastList.Node<Asp> n = as.getAspList().head(), end = as.getAspList().tail(); (n = n.getNext()) != end;) {
  304. Asp asp = n.getValue();
  305. if (asp.getName().equals(aspName)) {
  306. throw new Exception(String.format(
  307. "Cannot assign ASP=%s to AS=%s. This ASP is already assigned to this AS", aspName, asName));
  308. }
  309. }
  310. FastList<Asp> asps = aspFactroy.getAspList();
  311. // Checks for RoutingContext. We know that for null RC there will always
  312. // be a single ASP assigned to AS and ASP cannot be shared
  313. if (as.getRoutingContext() == null) {
  314. // If AS has Null RC, this should be the first assignment of ASP to
  315. // AS
  316. if (asps.size() != 0) {
  317. throw new Exception(String.format(
  318. "Cannot assign ASP=% to AS=%. This ASP is already assigned to other AS.", aspName, asName));
  319. }
  320. } else if (asps.size() > 0) {
  321. // RoutingContext is not null, make sure there is no ASP that is
  322. // assigned to AS with null RC
  323. Asp asp = asps.get(0);
  324. if (asp != null && asp.getAs().getRoutingContext() == null) {
  325. throw new Exception(
  326. String.format(
  327. "Cannot assign ASP=% to AS=%. This ASP is already assigned to other AS which has null RoutingContext.",
  328. aspName, asName));
  329. }
  330. }
  331. if (aspFactroy.getFunctionality() != null && aspFactroy.getFunctionality() != as.getFunctionality()) {
  332. throw new Exception(String.format(
  333. "Cannot assign ASP=% to AS=%. This ASP is already assigned to other AS of type=%s", aspName,
  334. asName, aspFactroy.getFunctionality()));
  335. }
  336. if (aspFactroy.getExchangeType() != null && aspFactroy.getExchangeType() != as.getExchangeType()) {
  337. throw new Exception(String.format(
  338. "Cannot assign ASP=% to AS=%. This ASP is already assigned to other AS of ExchangeType=%s",
  339. aspName, asName, aspFactroy.getExchangeType()));
  340. }
  341. if (aspFactroy.getIpspType() != null && aspFactroy.getIpspType() != as.getIpspType()) {
  342. throw new Exception(String.format(
  343. "Cannot assign ASP=% to AS=%. This ASP is already assigned to other AS of which has IPSP type=%s",
  344. aspName, asName, aspFactroy.getIpspType()));
  345. }
  346. aspFactroy.setExchangeType(as.getExchangeType());
  347. aspFactroy.setFunctionality(as.getFunctionality());
  348. aspFactroy.setIpspType(as.getIpspType());
  349. Asp asp = aspFactroy.createAsp();
  350. FSM aspLocalFSM = asp.getLocalFSM();
  351. m3uaScheduler.execute(aspLocalFSM);
  352. FSM aspPeerFSM = asp.getPeerFSM();
  353. m3uaScheduler.execute(aspPeerFSM);
  354. as.addAppServerProcess(asp);
  355. this.store();
  356. return asp;
  357. }
  358. public Asp unassignAspFromAs(String asName, String aspName) throws Exception {
  359. // check ASP and AS exist with given name
  360. As as = this.getAs(asName);
  361. if (as == null) {
  362. throw new Exception(String.format(M3UAOAMMessages.ADD_ASP_TO_AS_FAIL_NO_AS, asName));
  363. }
  364. Asp asp = as.removeAppServerProcess(aspName);
  365. asp.getAspFactory().destroyAsp(asp);
  366. this.store();
  367. return asp;
  368. }
  369. /**
  370. * This method should be called by management to start the ASP
  371. *
  372. * @param aspName
  373. * The name of the ASP to be started
  374. * @throws Exception
  375. */
  376. public void startAsp(String aspName) throws Exception {
  377. AspFactory aspFactory = this.getAspFactory(aspName);
  378. if (aspFactory == null) {
  379. throw new Exception(String.format("No ASP found by name=%s", aspName));
  380. }
  381. if (aspFactory.getStatus()) {
  382. throw new Exception(String.format("ASP name=%s already started", aspName));
  383. }
  384. if (aspFactory.getAspList().size() == 0) {
  385. throw new Exception(String.format("ASP name=%s not assigned to any AS yet", aspName));
  386. }
  387. aspFactory.start();
  388. this.store();
  389. }
  390. /**
  391. * This method should be called by management to stop the ASP
  392. *
  393. * @param aspName
  394. * The name of the ASP to be stopped
  395. * @throws Exception
  396. */
  397. public void stopAsp(String aspName) throws Exception {
  398. AspFactory aspFactory = this.getAspFactory(aspName);
  399. if (aspFactory == null) {
  400. throw new Exception(String.format("No ASP found by name=%s", aspName));
  401. }
  402. if (!aspFactory.getStatus()) {
  403. throw new Exception(String.format("ASP name=%s already stopped", aspName));
  404. }
  405. aspFactory.stop();
  406. this.store();
  407. }
  408. public void addRoute(int dpc, int opc, int si, String asName) throws Exception {
  409. this.routeManagement.addRoute(dpc, opc, si, asName);
  410. }
  411. public void removeRoute(int dpc, int opc, int si, String asName) throws Exception {
  412. this.routeManagement.removeRoute(dpc, opc, si, asName);
  413. }
  414. public void sendTransferMessageToLocalUser(Mtp3TransferPrimitive msg, int seqControl) {
  415. super.sendTransferMessageToLocalUser(msg, seqControl);
  416. }
  417. public void sendPauseMessageToLocalUser(Mtp3PausePrimitive msg) {
  418. super.sendPauseMessageToLocalUser(msg);
  419. }
  420. public void sendResumeMessageToLocalUser(Mtp3ResumePrimitive msg) {
  421. super.sendResumeMessageToLocalUser(msg);
  422. }
  423. public void sendStatusMessageToLocalUser(Mtp3StatusPrimitive msg) {
  424. super.sendStatusMessageToLocalUser(msg);
  425. }
  426. private AspFactory getAspFactory(String aspName) {
  427. for (FastList.Node<AspFactory> n = aspfactories.head(), end = aspfactories.tail(); (n = n.getNext()) != end;) {
  428. AspFactory aspFactory = n.getValue();
  429. if (aspFactory.getName().equals(aspName)) {
  430. return aspFactory;
  431. }
  432. }
  433. return null;
  434. }
  435. /**
  436. * Persist
  437. */
  438. public void store() {
  439. // TODO : Should we keep reference to Objects rather than recreating
  440. // everytime?
  441. try {
  442. XMLObjectWriter writer = XMLObjectWriter.newInstance(new FileOutputStream(persistFile.toString()));
  443. writer.setBinding(binding);
  444. // Enables cross-references.
  445. // writer.setReferenceResolver(new XMLReferenceResolver());
  446. writer.setIndentation(TAB_INDENT);
  447. writer.write(aspfactories, ASP_FACTORY_LIST, FastList.class);
  448. writer.write(appServers, AS_LIST, FastList.class);
  449. writer.write(this.routeManagement.route, DPC_VS_AS_LIST, RouteMap.class);
  450. writer.close();
  451. } catch (Exception e) {
  452. logger.error("Error while persisting the Rule state in file", e);
  453. }
  454. }
  455. /**
  456. * Load and create LinkSets and Link from persisted file
  457. *
  458. * @throws Exception
  459. */
  460. public void load() throws FileNotFoundException {
  461. XMLObjectReader reader = null;
  462. try {
  463. reader = XMLObjectReader.newInstance(new FileInputStream(persistFile.toString()));
  464. reader.setBinding(binding);
  465. aspfactories = reader.read(ASP_FACTORY_LIST, FastList.class);
  466. appServers = reader.read(AS_LIST, FastList.class);
  467. this.routeManagement.route = reader.read(DPC_VS_AS_LIST, RouteMap.class);
  468. // Create Asp's and assign to each of the AS. Schedule the FSM's
  469. for (FastList.Node<As> n = appServers.head(), end = appServers.tail(); (n = n.getNext()) != end;) {
  470. As as = n.getValue();
  471. as.setM3UAManagement(this);
  472. FSM asLocalFSM = as.getLocalFSM();
  473. m3uaScheduler.execute(asLocalFSM);
  474. FSM asPeerFSM = as.getPeerFSM();
  475. m3uaScheduler.execute(asPeerFSM);
  476. // All the Asp's for this As added in temp list
  477. FastList<Asp> tempAsp = new FastList<Asp>();
  478. tempAsp.addAll(as.getAspList());
  479. // Claer Asp's from this As
  480. as.getAspList().clear();
  481. for (FastList.Node<Asp> n1 = tempAsp.head(), end1 = tempAsp.tail(); (n1 = n1.getNext()) != end1;) {
  482. Asp asp = n1.getValue();
  483. try {
  484. // Now let the Asp's be created from respective
  485. // AspFactory and added to As
  486. this.assignAspToAs(as.getName(), asp.getName());
  487. } catch (Exception e) {
  488. logger.error("Error while assigning Asp to As on loading from xml file", e);
  489. }
  490. }
  491. }
  492. // Set the transportManagement
  493. for (FastList.Node<AspFactory> n = aspfactories.head(), end = aspfactories.tail(); (n = n.getNext()) != end;) {
  494. AspFactory factory = n.getValue();
  495. factory.setTransportManagement(this.transportManagement);
  496. try {
  497. factory.setAssociation(this.transportManagement.getAssociation(factory.associationName));
  498. } catch (Exception e1) {
  499. logger.error(String.format(
  500. "Error setting Assciation=%s for the AspFactory=%s while loading from XML",
  501. factory.associationName, factory.getName()), e1);
  502. }
  503. if (factory.getStatus()) {
  504. try {
  505. factory.start();
  506. } catch (Exception e) {
  507. logger.error(
  508. String.format("Error starting the AspFactory=%s while loading from XML",
  509. factory.getName()), e);
  510. }
  511. }
  512. }
  513. } catch (XMLStreamException ex) {
  514. // this.logger.info(
  515. // "Error while re-creating Linksets from persisted file", ex);
  516. }
  517. }
  518. @Override
  519. public void sendMessage(Mtp3TransferPrimitive mtp3TransferPrimitive) throws IOException {
  520. ProtocolData data = this.parameterFactory.createProtocolData(mtp3TransferPrimitive);
  521. PayloadData payload = (PayloadData) messageFactory.createMessage(MessageClass.TRANSFER_MESSAGES,
  522. MessageType.PAYLOAD);
  523. payload.setData(data);
  524. As as = this.routeManagement.getAsForRoute(data.getDpc(), data.getOpc(), data.getSI(), data.getSLS());
  525. if (as == null) {
  526. logger.error(String.format("Tx : No AS found for routing message %s", payload));
  527. return;
  528. }
  529. payload.setNetworkAppearance(as.getNetworkAppearance());
  530. payload.setRoutingContext(as.getRoutingContext());
  531. as.write(payload);
  532. }
  533. }