Search in sources :

Example 1 with MBalancerDispatcher

use of org.mobicents.tools.smpp.multiplexer.MBalancerDispatcher in project load-balancer by RestComm.

the class SmppBalancerRunner method start.

public void start() {
    SmppServerConfiguration regularConfiguration = new SmppServerConfiguration();
    regularConfiguration.setName("SMPP Load Balancer");
    String smppHost = balancerRunner.balancerContext.lbConfig.getSmppConfiguration().getSmppExternalHost();
    if (smppHost == null || smppHost.equals("")) {
        smppHost = balancerRunner.balancerContext.lbConfig.getSmppConfiguration().getSmppHost();
    }
    regularConfiguration.setHost(smppHost);
    regularConfiguration.setPort(balancerRunner.balancerContext.lbConfig.getSmppConfiguration().getSmppPort());
    regularConfiguration.setMaxConnectionSize(balancerRunner.balancerContext.lbConfig.getSmppConfiguration().getMaxConnectionSize());
    regularConfiguration.setNonBlockingSocketsEnabled(balancerRunner.balancerContext.lbConfig.getSmppConfiguration().isNonBlockingSocketsEnabled());
    regularConfiguration.setDefaultSessionCountersEnabled(balancerRunner.balancerContext.lbConfig.getSmppConfiguration().isDefaultSessionCountersEnabled());
    regularConfiguration.setUseSsl(false);
    SmppServerConfiguration securedConfiguration = null;
    Integer smppSslPort = balancerRunner.balancerContext.lbConfig.getSmppConfiguration().getSmppSslPort();
    if (smppSslPort != null) {
        securedConfiguration = new SmppServerConfiguration();
        String smppSslHost = balancerRunner.balancerContext.lbConfig.getSmppConfiguration().getSmppExternalHost();
        if (smppSslHost == null || smppSslHost.equals("")) {
            smppSslHost = balancerRunner.balancerContext.lbConfig.getSmppConfiguration().getSmppHost();
        }
        securedConfiguration.setHost(smppSslHost);
        securedConfiguration.setPort(smppSslPort);
        securedConfiguration.setMaxConnectionSize(balancerRunner.balancerContext.lbConfig.getSmppConfiguration().getMaxConnectionSize());
        securedConfiguration.setNonBlockingSocketsEnabled(balancerRunner.balancerContext.lbConfig.getSmppConfiguration().isNonBlockingSocketsEnabled());
        securedConfiguration.setDefaultSessionCountersEnabled(balancerRunner.balancerContext.lbConfig.getSmppConfiguration().isDefaultSessionCountersEnabled());
        securedConfiguration.setUseSsl(true);
        SslConfiguration sslConfig = new SslConfiguration();
        sslConfig.setKeyStorePath(balancerRunner.balancerContext.lbConfig.getSslConfiguration().getKeyStore());
        sslConfig.setKeyStorePassword(balancerRunner.balancerContext.lbConfig.getSslConfiguration().getKeyStorePassword());
        sslConfig.setTrustStorePath(balancerRunner.balancerContext.lbConfig.getSslConfiguration().getTrustStore());
        sslConfig.setTrustStorePassword(balancerRunner.balancerContext.lbConfig.getSslConfiguration().getTrustStorePassword());
        String sProtocols = balancerRunner.balancerContext.lbConfig.getSslConfiguration().getTlsClientProtocols();
        String sCipherSuites = balancerRunner.balancerContext.lbConfig.getSslConfiguration().getEnabledCipherSuites();
        if (sProtocols != null) {
            String[] protocols = sProtocols.split(",");
            sslConfig.setIncludeProtocols(protocols);
        }
        if (sCipherSuites != null) {
            String[] cipherSuites = sCipherSuites.split(",");
            sslConfig.setIncludeCipherSuites(cipherSuites);
        }
        securedConfiguration.setSslConfiguration(sslConfig);
    }
    // TODO manage MUX or LB
    if (balancerRunner.balancerContext.lbConfig.getSmppConfiguration().isMuxMode()) {
        logger.info("MUX mode enabled for SMPP");
        dispatcher = new MBalancerDispatcher(balancerRunner, monitorExecutor);
        mSmppLbServer = new MServer(regularConfiguration, securedConfiguration, executor, balancerRunner, (MBalancerDispatcher) dispatcher, monitorExecutor);
        mSmppLbServer.start();
    } else {
        logger.info("Load balance mode enabled for SMPP");
        dispatcher = new BalancerDispatcher(balancerRunner, monitorExecutor);
        smppLbServer = new BalancerServer(regularConfiguration, securedConfiguration, executor, balancerRunner, (BalancerDispatcher) dispatcher, monitorExecutor);
        smppLbServer.start();
    }
}
Also used : SslConfiguration(com.cloudhopper.smpp.ssl.SslConfiguration) MBalancerDispatcher(org.mobicents.tools.smpp.multiplexer.MBalancerDispatcher) MServer(org.mobicents.tools.smpp.multiplexer.MServer) SmppServerConfiguration(com.cloudhopper.smpp.SmppServerConfiguration) MBalancerDispatcher(org.mobicents.tools.smpp.multiplexer.MBalancerDispatcher)

Aggregations

SmppServerConfiguration (com.cloudhopper.smpp.SmppServerConfiguration)1 SslConfiguration (com.cloudhopper.smpp.ssl.SslConfiguration)1 MBalancerDispatcher (org.mobicents.tools.smpp.multiplexer.MBalancerDispatcher)1 MServer (org.mobicents.tools.smpp.multiplexer.MServer)1