Search in sources :

Example 1 with DefaultSmppSessionHandler

use of com.cloudhopper.smpp.impl.DefaultSmppSessionHandler in project smscgateway by RestComm.

the class SmppTestingForm method start.

private void start() {
    this.messagesSent = new AtomicInteger();
    this.segmentsSent = new AtomicInteger();
    this.responsesRcvd = new AtomicInteger();
    this.messagesRcvd = new AtomicInteger();
    this.addMessage("Trying to start a new " + this.param.getSmppSessionType() + " session", "");
    this.executor = (ThreadPoolExecutor) Executors.newCachedThreadPool();
    this.monitorExecutor = (ScheduledThreadPoolExecutor) Executors.newScheduledThreadPool(1, new ThreadFactory() {

        private AtomicInteger sequence = new AtomicInteger(0);

        @Override
        public Thread newThread(Runnable r) {
            Thread t = new Thread(r);
            t.setName("SmppClientSessionWindowMonitorPool-" + sequence.getAndIncrement());
            return t;
        }
    });
    if (this.param.getSmppSessionType() == SmppSession.Type.CLIENT) {
        clientBootstrap = new TestSmppClient(Executors.newCachedThreadPool(), 1, monitorExecutor);
        DefaultSmppSessionHandler sessionHandler = new ClientSmppSessionHandler(this);
        SmppSessionConfiguration config0 = new SmppSessionConfiguration();
        config0.setWindowSize(this.param.getWindowSize());
        config0.setName("Tester.Session.0");
        config0.setType(this.param.getBindType());
        config0.setHost(this.param.getHost());
        config0.setPort(this.param.getPort());
        config0.setConnectTimeout(this.param.getConnectTimeout());
        config0.setSystemId(this.param.getSystemId());
        config0.setPassword(this.param.getPassword());
        config0.setAddressRange(new Address((byte) 1, (byte) 1, this.param.getAddressRange()));
        config0.getLoggingOptions().setLogBytes(true);
        // to enable monitoring (request expiration)
        config0.setRequestExpiryTimeout(this.param.getRequestExpiryTimeout());
        config0.setWindowMonitorInterval(this.param.getWindowMonitorInterval());
        config0.setCountersEnabled(true);
        try {
            session0 = clientBootstrap.bind(config0, sessionHandler);
        } catch (Exception e) {
            this.addMessage("Failure to start a new session", e.toString());
            return;
        }
        enableStart(false);
        setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
        this.addMessage("Session has been successfully started", "");
    } else {
        SmppServerConfiguration configuration = new SmppServerConfiguration();
        configuration.setName("Test SMPP server");
        configuration.setPort(this.param.getPort());
        configuration.setBindTimeout(5000);
        configuration.setSystemId(this.param.getSystemId());
        configuration.setAutoNegotiateInterfaceVersion(true);
        configuration.setInterfaceVersion(SmppConstants.VERSION_3_4);
        configuration.setMaxConnectionSize(SmppConstants.DEFAULT_SERVER_MAX_CONNECTION_SIZE);
        configuration.setNonBlockingSocketsEnabled(true);
        configuration.setDefaultRequestExpiryTimeout(SmppConstants.DEFAULT_REQUEST_EXPIRY_TIMEOUT);
        configuration.setDefaultWindowMonitorInterval(SmppConstants.DEFAULT_WINDOW_MONITOR_INTERVAL);
        configuration.setDefaultWindowSize(SmppConstants.DEFAULT_WINDOW_SIZE);
        configuration.setDefaultWindowWaitTimeout(SmppConstants.DEFAULT_WINDOW_WAIT_TIMEOUT);
        configuration.setDefaultSessionCountersEnabled(true);
        configuration.setJmxEnabled(false);
        this.defaultSmppServer = new DefaultSmppServer(configuration, new DefaultSmppServerHandler(this), executor, monitorExecutor);
        try {
            this.defaultSmppServer.start();
        } catch (SmppChannelException e1) {
            this.addMessage("Failure to start a defaultSmppServer", e1.toString());
            return;
        }
        enableStart(false);
        setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
        this.addMessage("SMPP Server has been successfully started", "");
    }
}
Also used : ThreadFactory(java.util.concurrent.ThreadFactory) Address(com.cloudhopper.smpp.type.Address) DefaultSmppSessionHandler(com.cloudhopper.smpp.impl.DefaultSmppSessionHandler) SmppServerConfiguration(com.cloudhopper.smpp.SmppServerConfiguration) SmppChannelException(com.cloudhopper.smpp.type.SmppChannelException) CharacterCodingException(java.nio.charset.CharacterCodingException) SmppSessionConfiguration(com.cloudhopper.smpp.SmppSessionConfiguration) DefaultSmppServer(com.cloudhopper.smpp.impl.DefaultSmppServer) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TestSmppClient(org.mobicents.smsc.tools.smppsimulator.testsmpp.TestSmppClient) SmppChannelException(com.cloudhopper.smpp.type.SmppChannelException)

Example 2 with DefaultSmppSessionHandler

use of com.cloudhopper.smpp.impl.DefaultSmppSessionHandler in project smscgateway by RestComm.

the class SMPPInitializer method init.

@Override
public void init(GlobalContext ctx) throws Exception {
    DefaultSmppClient clientBootstrap = new DefaultSmppClient(Executors.newCachedThreadPool(), ctx.getIntegerProp("smppp.smppStack.sessionCount"), ctx.executor);
    // same configuration for each client runner
    SmppSessionConfiguration config = new SmppSessionConfiguration();
    config.setWindowSize(ctx.getIntegerProp("smppp.smppStack.windowSize"));
    config.setName(ctx.getProperty("smppp.smppStack.name"));
    config.setType(SmppBindType.valueOf(ctx.getProperty("smppp.smppStack.type")));
    config.setHost(ctx.getProperty("smppp.smppStack.host"));
    config.setPort(ctx.getIntegerProp("smppp.smppStack.port"));
    config.setConnectTimeout(ctx.getIntegerProp("smppp.smppStack.connectTimeout"));
    config.setSystemId(ctx.getProperty("smppp.smppStack.systemId"));
    config.setPassword(ctx.getProperty("smppp.smppStack.password"));
    config.getLoggingOptions().setLogBytes(Boolean.valueOf(ctx.getProperty("smppp.smppStack.logBytes")));
    // to enable monitoring (request expiration)
    config.setRequestExpiryTimeout(ctx.getIntegerProp("smppp.smppStack.requestExpiryTimeout"));
    config.setWindowMonitorInterval(ctx.getIntegerProp("smppp.smppStack.windowMonitorInterval"));
    config.setCountersEnabled(Boolean.valueOf(ctx.getProperty("smppp.smppStack.countersEnabled")));
    DefaultSmppSessionHandler sessionHandler = (DefaultSmppSessionHandler) ctx.scenario;
    List<SmppSession> sessionList = new ArrayList(ctx.getIntegerProp("smppp.smppStack.sessionCount"));
    for (int i = 0; i < ctx.getIntegerProp("smppp.smppStack.sessionCount"); i++) {
        sessionList.add(clientBootstrap.bind(config, sessionHandler));
    }
    ctx.data.put("SMPPSessionList", sessionList);
    CyclicCounter sessionCounter = new CyclicCounter(ctx.getIntegerProp("smppp.smppStack.sessionCount"));
    ctx.data.put("sessionCounter", sessionCounter);
    ctx.fsm.fire(GlobalEvent.ASSOCIATION_UP, ctx);
}
Also used : SmppSessionConfiguration(com.cloudhopper.smpp.SmppSessionConfiguration) SmppSession(com.cloudhopper.smpp.SmppSession) DefaultSmppClient(com.cloudhopper.smpp.impl.DefaultSmppClient) DefaultSmppSessionHandler(com.cloudhopper.smpp.impl.DefaultSmppSessionHandler) ArrayList(java.util.ArrayList)

Aggregations

SmppSessionConfiguration (com.cloudhopper.smpp.SmppSessionConfiguration)2 DefaultSmppSessionHandler (com.cloudhopper.smpp.impl.DefaultSmppSessionHandler)2 SmppServerConfiguration (com.cloudhopper.smpp.SmppServerConfiguration)1 SmppSession (com.cloudhopper.smpp.SmppSession)1 DefaultSmppClient (com.cloudhopper.smpp.impl.DefaultSmppClient)1 DefaultSmppServer (com.cloudhopper.smpp.impl.DefaultSmppServer)1 Address (com.cloudhopper.smpp.type.Address)1 SmppChannelException (com.cloudhopper.smpp.type.SmppChannelException)1 CharacterCodingException (java.nio.charset.CharacterCodingException)1 ArrayList (java.util.ArrayList)1 ThreadFactory (java.util.concurrent.ThreadFactory)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 TestSmppClient (org.mobicents.smsc.tools.smppsimulator.testsmpp.TestSmppClient)1