Search in sources :

Example 1 with TestSmppClient

use of org.mobicents.smsc.tools.smppsimulator.testsmpp.TestSmppClient 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)

Aggregations

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