Search in sources :

Example 1 with SMSCShellExecutor

use of org.mobicents.smsc.domain.SMSCShellExecutor in project smscgateway by RestComm.

the class SmscService method initSmscShellExecutor.

private SMSCShellExecutor initSmscShellExecutor() throws StartException {
    try {
        SMSCShellExecutor smscShellExecutor = new SMSCShellExecutor();
        smscShellExecutor.setSmscManagement(smscManagementMBean);
        smscShellExecutor.start();
        return smscShellExecutor;
    } catch (Exception e) {
        throw new StartException("SmscExecutor MBean creating is failed: " + e.getMessage(), e);
    }
}
Also used : SMSCShellExecutor(org.mobicents.smsc.domain.SMSCShellExecutor)

Example 2 with SMSCShellExecutor

use of org.mobicents.smsc.domain.SMSCShellExecutor in project smscgateway by RestComm.

the class SmscService method start.

@Override
public void start(StartContext context) throws StartException {
    log.info("Starting SmscService");
    this.smscManagementMBean = initSmscManagementMBean(smppService.getValue().getSmppManagementMBean());
    this.statsProviderJmx = new SmscStatProviderJmx(ss7Service.getValue().getSs7Management());
    if (shellExecutorExists()) {
        this.schedulerMBean = initSchedulerMBean();
        this.smscShellExecutor = initSmscShellExecutor();
        shellExecutorMBean = null;
        try {
            FastList<ShellExecutor> shellExecutors = new FastList<ShellExecutor>();
            shellExecutors.add(smscShellExecutor);
            shellExecutors.add(ss7Service.getValue().getBeanTcapExecutor());
            shellExecutors.add(ss7Service.getValue().getBeanM3uaShellExecutor());
            shellExecutors.add(ss7Service.getValue().getBeanSctpShellExecutor());
            shellExecutors.add(ss7Service.getValue().getBeanSccpExecutor());
            shellExecutors.add(smppService.getValue().getSmppShellExecutor());
            String address = getPropertyString("ShellExecutor", "address", "127.0.0.1");
            int port = getPropertyInt("ShellExecutor", "port", 3435);
            String securityDomain = getPropertyString("ShellExecutor", "securityDomain", "jmx-console");
            shellExecutorMBean = new ShellServerWildFly(schedulerMBean, shellExecutors);
            shellExecutorMBean.setAddress(address);
            shellExecutorMBean.setPort(port);
            shellExecutorMBean.setSecurityDomain(securityDomain);
        } catch (Exception e) {
            throw new StartException("ShellExecutor MBean creating is failed: " + e.getMessage(), e);
        }
        // starting
        try {
            schedulerMBean.start();
            shellExecutorMBean.start();
        } catch (Exception e) {
            throw new StartException("MBeans starting is failed: " + e.getMessage(), e);
        }
    }
    try {
        statsProviderJmx.start();
    } catch (Exception e) {
        throw new StartException("Failed to start smsc statistics privider: " + e.getMessage(), e);
    }
}
Also used : SmscStatProviderJmx(org.mobicents.smsc.domain.SmscStatProviderJmx) ShellServerWildFly(org.mobicents.ss7.management.console.ShellServerWildFly) ShellExecutor(org.mobicents.ss7.management.console.ShellExecutor) SMSCShellExecutor(org.mobicents.smsc.domain.SMSCShellExecutor) FastList(javolution.util.FastList)

Example 3 with SMSCShellExecutor

use of org.mobicents.smsc.domain.SMSCShellExecutor in project smscgateway by RestComm.

the class SMSCShellExecutorTest method testShellExecutor_DatabaseRoutingRules.

@Test(groups = { "ShellExecutor" })
public void testShellExecutor_DatabaseRoutingRules() throws Exception {
    // Date dt = new Date();
    // String s1 = dt.toGMTString();
    // 
    // long l2 = Date.parse(s1);
    // Date d2 = new Date(l2);
    TT_PersistenceProxy sbb = new TT_PersistenceProxy();
    boolean cassandraDbInited = sbb.testCassandraAccess();
    if (!cassandraDbInited)
        return;
    SmscManagement smscManagement = SmscManagement.getInstance("Test");
    smscManagement.setSmsRoutingRuleClass("org.mobicents.smsc.domain.DatabaseSmsRoutingRule");
    SmppManagement smppManagement = SmppManagement.getInstance("Test");
    smscManagement.setSmppManagement(smppManagement);
    smscManagement.start();
    SMSCShellExecutor exec = new SMSCShellExecutor();
    exec.setSmscManagement(smscManagement);
    String[] args = new String[2];
    args[0] = "stat";
    args[1] = "get";
    exec.execute(args);
    args = "smsc databaserule update 2222 ttt1".split(" ");
    String s = exec.execute(args);
    args = "smsc databaserule update 2222 ttt2 networkid 2".split(" ");
    s = exec.execute(args);
    args = "smsc databaserule update 2222 ttt3 SIP".split(" ");
    s = exec.execute(args);
    args = "smsc databaserule update 2222 ttt4 SIP networkid 2".split(" ");
    s = exec.execute(args);
    args = "smsc databaserule get 2222".split(" ");
    s = exec.execute(args);
    args = "smsc databaserule get 2222 networkid 2".split(" ");
    s = exec.execute(args);
    args = "smsc databaserule get 2222 SIP".split(" ");
    s = exec.execute(args);
    args = "smsc databaserule get 2222 SIP networkid 2".split(" ");
    s = exec.execute(args);
    args = "smsc databaserule delete 2222 networkid 2".split(" ");
    s = exec.execute(args);
    args = "smsc databaserule delete 2222".split(" ");
    s = exec.execute(args);
    args = "smsc databaserule delete 2222 SIP".split(" ");
    s = exec.execute(args);
    args = "smsc databaserule delete 2222 SIP networkid 2".split(" ");
    s = exec.execute(args);
    smscManagement.stop();
}
Also used : SMSCShellExecutor(org.mobicents.smsc.domain.SMSCShellExecutor) SmppManagement(org.restcomm.smpp.SmppManagement) Test(org.testng.annotations.Test)

Example 4 with SMSCShellExecutor

use of org.mobicents.smsc.domain.SMSCShellExecutor in project smscgateway by RestComm.

the class SMSCShellExecutorTest method testShellExecutor_MProc.

@Test(groups = { "ShellExecutor" })
public void testShellExecutor_MProc() throws Exception {
    TT_PersistenceProxy sbb = new TT_PersistenceProxy();
    boolean cassandraDbInited = sbb.testCassandraAccess();
    if (!cassandraDbInited)
        return;
    MProcManagement mProcManagement = MProcManagement.getInstance();
    SmscManagement smscManagement = SmscManagement.getInstance("Test");
    SmppManagement smppManagement = SmppManagement.getInstance("Test");
    smscManagement.setSmppManagement(smppManagement);
    mProcManagement.setSmscManagement(smscManagement);
    smscManagement.registerRuleFactory(new MProcRuleFactoryDefault());
    smscManagement.start();
    SMSCShellExecutor exec = new SMSCShellExecutor();
    exec.setSmscManagement(smscManagement);
    mProcManagement.mprocs.clear();
    mProcManagement.store();
    assertEquals(mProcManagement.mprocs.size(), 0);
    String[] args = "smsc mproc add mproc 10 desttonmask 2 destnpimask 3 destdigmask ^[0-9a-zA-Z]* originatingmask SS7_MO networkidmask 21 newnetworkid 22 newdestton 4 newdestnpi 5 adddestdigprefix 47 makecopy true".split(" ");
    String s = exec.execute(args);
    assertEquals(mProcManagement.mprocs.size(), 1);
    MProcRuleDefaultImpl rule = (MProcRuleDefaultImpl) mProcManagement.getMProcRuleById(10);
    assertNotNull(rule);
    assertEquals(rule.getId(), 10);
    assertEquals(rule.getDestTonMask(), 2);
    assertEquals(rule.getDestNpiMask(), 3);
    assertEquals(rule.getDestDigMask(), "^[0-9a-zA-Z]*");
    assertEquals(rule.getOriginatingMask(), OrigType.SS7_MO);
    assertEquals(rule.getNetworkIdMask(), 21);
    assertEquals(rule.getNewNetworkId(), 22);
    assertEquals(rule.getNewDestTon(), 4);
    assertEquals(rule.getNewDestNpi(), 5);
    assertEquals(rule.getAddDestDigPrefix(), "47");
    assertTrue(rule.isMakeCopy());
    args = "smsc mproc modify 10 newnetworkid 23".split(" ");
    s = exec.execute(args);
    assertEquals(mProcManagement.mprocs.size(), 1);
    rule = (MProcRuleDefaultImpl) mProcManagement.getMProcRuleById(10);
    assertNotNull(rule);
    assertEquals(rule.getId(), 10);
    assertEquals(rule.getDestTonMask(), 2);
    assertEquals(rule.getDestNpiMask(), 3);
    assertEquals(rule.getDestDigMask(), "^[0-9a-zA-Z]*");
    assertEquals(rule.getOriginatingMask(), OrigType.SS7_MO);
    assertEquals(rule.getNetworkIdMask(), 21);
    assertEquals(rule.getNewNetworkId(), 23);
    assertEquals(rule.getNewDestTon(), 4);
    assertEquals(rule.getNewDestNpi(), 5);
    assertEquals(rule.getAddDestDigPrefix(), "47");
    assertTrue(rule.isMakeCopy());
    args = "smsc mproc modify 11 newnetworkid 24".split(" ");
    s = exec.execute(args);
    assertEquals(mProcManagement.mprocs.size(), 1);
    rule = (MProcRuleDefaultImpl) mProcManagement.getMProcRuleById(10);
    assertNotNull(rule);
    assertEquals(rule.getNewNetworkId(), 23);
    args = "smsc mproc add mproc 9 networkidmask 31 newnetworkid 32".split(" ");
    s = exec.execute(args);
    assertEquals(mProcManagement.mprocs.size(), 2);
    rule = (MProcRuleDefaultImpl) mProcManagement.getMProcRuleById(9);
    assertNotNull(rule);
    assertEquals(rule.getDestDigMask(), "-1");
    assertNull(rule.getOriginatingMask());
    assertEquals(rule.getNetworkIdMask(), 31);
    assertEquals(rule.getNewNetworkId(), 32);
    rule = (MProcRuleDefaultImpl) mProcManagement.getMProcRuleById(10);
    assertNotNull(rule);
    rule = (MProcRuleDefaultImpl) mProcManagement.getMProcRuleById(15);
    assertNull(rule);
    mProcManagement.mprocs.clear();
    assertEquals(mProcManagement.mprocs.size(), 0);
    mProcManagement.load();
    assertEquals(mProcManagement.mprocs.size(), 2);
    rule = (MProcRuleDefaultImpl) mProcManagement.getMProcRuleById(10);
    assertNotNull(rule);
    assertEquals(rule.getId(), 10);
    assertEquals(rule.getDestTonMask(), 2);
    assertEquals(rule.getDestNpiMask(), 3);
    assertEquals(rule.getDestDigMask(), "^[0-9a-zA-Z]*");
    assertEquals(rule.getOriginatingMask(), OrigType.SS7_MO);
    assertEquals(rule.getNetworkIdMask(), 21);
    assertEquals(rule.getNewNetworkId(), 23);
    assertEquals(rule.getNewDestTon(), 4);
    assertEquals(rule.getNewDestNpi(), 5);
    assertEquals(rule.getAddDestDigPrefix(), "47");
    assertTrue(rule.isMakeCopy());
    rule = (MProcRuleDefaultImpl) mProcManagement.getMProcRuleById(9);
    assertNotNull(rule);
    assertEquals(rule.getDestDigMask(), "-1");
    assertNull(rule.getOriginatingMask());
    assertEquals(rule.getNetworkIdMask(), 31);
    assertEquals(rule.getNewNetworkId(), 32);
    rule = (MProcRuleDefaultImpl) mProcManagement.getMProcRuleById(10);
    assertNotNull(rule);
    rule = (MProcRuleDefaultImpl) mProcManagement.getMProcRuleById(15);
    assertNull(rule);
    args = "smsc mproc show 9".split(" ");
    s = exec.execute(args);
    args = "smsc mproc show".split(" ");
    s = exec.execute(args);
    args = "smsc mproc remove 9".split(" ");
    s = exec.execute(args);
    assertEquals(mProcManagement.mprocs.size(), 1);
    rule = (MProcRuleDefaultImpl) mProcManagement.getMProcRuleById(10);
    assertNotNull(rule);
    rule = (MProcRuleDefaultImpl) mProcManagement.getMProcRuleById(9);
    assertNull(rule);
    mProcManagement.mprocs.clear();
    smscManagement.stop();
}
Also used : MProcRuleFactoryDefault(org.mobicents.smsc.mproc.impl.MProcRuleFactoryDefault) SMSCShellExecutor(org.mobicents.smsc.domain.SMSCShellExecutor) SmppManagement(org.restcomm.smpp.SmppManagement) MProcRuleDefaultImpl(org.mobicents.smsc.mproc.impl.MProcRuleDefaultImpl) Test(org.testng.annotations.Test)

Aggregations

SMSCShellExecutor (org.mobicents.smsc.domain.SMSCShellExecutor)4 SmppManagement (org.restcomm.smpp.SmppManagement)2 Test (org.testng.annotations.Test)2 FastList (javolution.util.FastList)1 SmscStatProviderJmx (org.mobicents.smsc.domain.SmscStatProviderJmx)1 MProcRuleDefaultImpl (org.mobicents.smsc.mproc.impl.MProcRuleDefaultImpl)1 MProcRuleFactoryDefault (org.mobicents.smsc.mproc.impl.MProcRuleFactoryDefault)1 ShellExecutor (org.mobicents.ss7.management.console.ShellExecutor)1 ShellServerWildFly (org.mobicents.ss7.management.console.ShellServerWildFly)1