@Override public Server addServer(String serverName, String hostAddress, int port, IpChannelType ipChannelType, boolean acceptAnonymousConnections, int maxConcurrentConnectionsCount, String[] extraHostAddresses) throws Exception { this.wrappedSctpManagement.addServer(serverName, hostAddress, port, ipChannelType, acceptAnonymousConnections, maxConcurrentConnectionsCount, extraHostAddresses); return null; }
@Override public Association addServerAssociation(String peerAddress, int peerPort, String serverName, String assocName) throws Exception { this.wrappedSctpManagement.addServerAssociation(peerAddress, peerPort, serverName, assocName); return null; } @Override
public void destroy() throws Exception { // Stop the SCTP logger.debug("Destroying SCTP Server"); if (remoteClientAssociation != null) { this.management.stopAssociation(remoteClientAssociationName); this.management.removeAssociation(remoteClientAssociationName); remoteClientAssociation = null; } if (serverAssociation != null) { this.management.stopAssociation(serverAssociationName); this.management.removeAssociation(serverAssociationName); this.management.stopServer(serverName); this.management.removeServer(serverName); this.management.stop(); serverAssociation = null; } }
this.sctpManagement.addServer(serverName, primaryAddress, hostPort, ipChnnelType, secondaryAddresses); return String.format(SCTPOAMMessages.ADD_SERVER_SUCCESS, serverName, this.sctpManagement.getName()); this.sctpManagement.modifyServer(serverName, hostAddress, port, ipChannelType, acceptAnonymousConnections, maxConcurrentConnectionsCount, extraHostAddresses); return String.format(SCTPOAMMessages.MODIFY_SERVER_SUCCESS, serverName, this.sctpManagement.getName()); this.sctpManagement.removeServer(serverName); return String.format(SCTPOAMMessages.REMOVE_SERVER_SUCCESS, serverName, this.sctpManagement.getName()); this.sctpManagement.startServer(serverName); return String.format(SCTPOAMMessages.START_SERVER_SUCCESS, serverName, this.sctpManagement.getName()); } else if (command.equals("stop")) { this.sctpManagement.stopServer(serverName); return String.format(SCTPOAMMessages.STOP_SERVER_SUCCESS, serverName, this.sctpManagement.getName()); } else if (command.equals("show")) { return this.showServers(args); this.sctpManagement.addAssociation(primaryAddress, hostPort, peerIp, peerPort, assocName, ipChnnelType, secondaryAddresses); this.sctpManagement.getName()); } else if (type.equals("SERVER")) { String serverName = args[5]; this.sctpManagement.addServerAssociation(peerIp, peerPort, serverName, assocName, ipChnnelType); return String.format(SCTPOAMMessages.ADD_SERVER_ASSOCIATION_SUCCESS, assocName, this.sctpManagement.getName());
this.management = new ManagementImpl("server-management-" + origAddress.getAddress().getHostAddress() + "." + origAddress.getPort()); this.management.setBufferSize(Integer.valueOf(System.getProperty( SCTPTransportClient.SCTP_BUFFER_SIZE_PARAMETER, SCTPTransportClient.SCTP_BUFFER_SIZE_DEFAULT))); logger.debug("SCTP Server Buffer Size set to {}", this.management.getBufferSize()); this.management.setSingleThread(true); this.management.start(); this.management.removeAllResourses(); for (Server s : management.getServers()) { if (s.getName().equals(serverName)) { server = s; server = this.management.addServer(serverName, origAddress.getAddress().getHostAddress(), origAddress.getPort(), IpChannelType.SCTP, true, 10, null); Association a = management.getAssociation(assocName); if (a.getName().equals(serverAssociationName)) { serverAssociation = a; serverAssociation = this.management.addServerAssociation(origAddress.getAddress().getHostAddress(), origAddress.getPort(), serverName, serverAssociationName, IpChannelType.SCTP); this.management.setServerListener(new ServerEventListener()); serverAssociation.setAssociationListener(new ServerAssociationListener()); this.management.startAssociation(serverAssociationName); if (!server.isStarted()) { logger.debug("Starting server");
this.sctpManagement.addServer(serverName, primaryAddress, hostPort, ipChnnelType, secondaryAddresses); return String.format(SCTPOAMMessages.ADD_SERVER_SUCCESS, serverName, this.sctpManagement.getName()); this.sctpManagement.removeServer(serverName); return String.format(SCTPOAMMessages.REMOVE_SERVER_SUCCESS, serverName, this.sctpManagement.getName()); this.sctpManagement.startServer(serverName); return String.format(SCTPOAMMessages.START_SERVER_SUCCESS, serverName, this.sctpManagement.getName()); } else if (command.equals("stop")) { this.sctpManagement.stopServer(serverName); return String.format(SCTPOAMMessages.STOP_SERVER_SUCCESS, serverName, this.sctpManagement.getName()); } else if (command.equals("show")) { return this.showServers(args); this.sctpManagement.addAssociation(primaryAddress, hostPort, peerIp, peerPort, assocName, ipChnnelType, secondaryAddresses); this.sctpManagement.getName()); } else if (type.equals("SERVER")) { String serverName = args[5]; this.sctpManagement.addServerAssociation(peerIp, peerPort, serverName, assocName, ipChnnelType); return String.format(SCTPOAMMessages.ADD_SERVER_ASSOCIATION_SUCCESS, assocName, this.sctpManagement.getName()); this.sctpManagement.removeAssociation(assocName); return String.format(SCTPOAMMessages.REMOVE_ASSOCIATION_SUCCESS, assocName, this.sctpManagement.getName());
@Override public void onCommunicationRestart(Association association) { logger.warn(String.format("Communication channel restart for AspFactroy=%s Association=%s", this.name, association.getName())); //TODO : Is this correct way to handle? try { this.transportManagement.stopAssociation(this.associationName); } catch (Exception e) { logger.warn(String.format("Error while trying to stop underlying Association for AspFactpry=%s", this.getName()), e); } try { this.transportManagement.startAssociation(this.associationName); } catch (Exception e) { logger.error(String.format("Error while trying to start underlying Association for AspFactpry=%s", this.getName()), e); } }
@Override public void stopAssociation(String assocName) throws Exception { this.wrappedSctpManagement.stopAssociation(assocName); }
@Override public void start() throws Exception { synchronized (this) { lstServers.clear(); lstAssociations.clear(); this.ss7Management.registerMBean(Ss7Layer.SCTP, SctpManagementType.MANAGEMENT, this.getName(), this); this.wrappedSctpManagement.addManagementEventListener(this); this.wrappedSctpManagement.addCongestionListener(this); List<Server> lstSrv = wrappedSctpManagement.getServers(); for (Server srv : lstSrv) { this.addServerToManagement(srv); } Map<String, Association> lstAss = wrappedSctpManagement.getAssociations(); for (String s : lstAss.keySet()) { Association asso = lstAss.get(s); this.addAssociationToManagement(asso); } } }
List<Server> servers = this.sctpManagement.getServers(); if (servers.size() == 0) { return String.format(SCTPOAMMessages.NO_SERVER_DEFINED_YET, this.sctpManagement.getName());
@Override public void onCommunicationShutdown(Association association) { logger.debug("onCommunicationShutdown called for [{}]", this); try { getParent().onDisconnect(); if (remoteClientAssociation != null) { management.stopAssociation(remoteClientAssociationName); management.removeAssociation(remoteClientAssociationName); remoteClientAssociation = null; } } catch (Exception e) { logger.debug("Error", e); } }
private void removeAllResourcesFromManagement() { // TODO Logic is bad here. wrappedSctpManagement will no more have list // of server and associations any more synchronized (this) { Map<String, Association> lstAss = wrappedSctpManagement.getAssociations(); for (String s : lstAss.keySet()) { Association asso = lstAss.get(s); this.removeAssociationFromManagement(asso); } List<Server> lstServ = wrappedSctpManagement.getServers(); for (Server srv : lstServ) { this.removeServerFromManagement(srv); } } }
@Override public void startAssociation(String assocName) throws Exception { this.wrappedSctpManagement.startAssociation(assocName); }
@Override public void removeAssociation(String assocName) throws Exception { this.wrappedSctpManagement.removeAssociation(assocName); }
@Override public void removeServer(String serverName) throws Exception { this.wrappedSctpManagement.removeServer(serverName); }
@Override public void stopServer(String serverName) throws Exception { this.wrappedSctpManagement.stopServer(serverName); }
@Override public void startServer(String serverName) throws Exception { this.wrappedSctpManagement.startServer(serverName); }
/** * SctpManagementJmxMBean Methods */ @Override public Association addAssociation(String hostAddress, int hostPort, String peerAddress, int peerPort, String assocName) throws Exception { this.wrappedSctpManagement.addAssociation(hostAddress, hostPort, peerAddress, peerPort, assocName); return null; }
@Override public void onCommunicationRestart(Association association) { logger.warn(String.format("Communication channel restart for AspFactroy=%s Association=%s", this.name, association.getName())); //TODO : Is this correct way to handle? try { this.transportManagement.stopAssociation(this.associationName); } catch (Exception e) { logger.warn(String.format("Error while trying to stop underlying Association for AspFactpry=%s", this.getName()), e); } try { this.transportManagement.startAssociation(this.associationName); } catch (Exception e) { logger.error(String.format("Error while trying to start underlying Association for AspFactpry=%s", this.getName()), e); } }
public void stop() throws Exception { logger.debug("Stopping SCTP Server"); // Note we never stop the server association as it is always listening - we only stop the remote client association if (remoteClientAssociation != null) { this.management.stopAssociation(remoteClientAssociationName); } }