RestComm / sbc

Restcomm Session Border Controller
http://www.restcomm.com/
21 stars 27 forks source link

JBoss AS compatibility #53

Closed ocarriles closed 5 years ago

ocarriles commented 7 years ago

issues arise in migration process from Tomcat, mainly on JMX components

ocarriles commented 7 years ago

JMX implmentation under JBoss AS, while it honours add/remove sip-connector operations, seems to lack of an operator to enumerate such objects,

ocarriles commented 6 years ago

@marca56 @knosach @deruelle

SBC approach regarding JMX relies on a provider interface that has to be implemented by code dependant on container hooks.

public interface JMXProvider  {     
    public boolean removeSipConnector(String ipAddress, int port, String transport) throws InstanceNotFoundException, MBeanException, ReflectionException, IOException;   
    public boolean addSipConnector(String ipAddress, int port, String transport) throws InstanceNotFoundException, MBeanException, ReflectionException, IOException;
    public List<Connector> getConnectors();    
    ... 
}

Tomcat implementation is easier because the SipConnector has no dependencies on other upper layer // objects.

public class TomcatProvider implements JMXProvider,
 NotificationListener, SipConnectorListener {

    ...     

    public boolean removeSipConnector(String ipAddress, int port, String transport) throws InstanceNotFoundException, MBeanException, ReflectionException, IOException {     
        Boolean stat=(Boolean) mbsc.invoke(objectName, "removeSipConnector",
                new Object[] {ipAddress , port, transport},
                new String[]{String.class.getCanonicalName(), int.class.getCanonicalName(), String.class.getCanonicalName()});
        return stat;

    }

    public boolean addSipConnector(String ipAddress, int port, String transport) throws InstanceNotFoundException, MBeanException, ReflectionException, IOException {       
        // adding connector
        SipConnector sipConnector = new SipConnector();
        sipConnector.setIpAddress(ipAddress);
        sipConnector.setPort(port);
        sipConnector.setTransport(transport);

        Boolean stat = (Boolean) mbsc.invoke(objectName, "addSipConnector",
                new Object[] {sipConnector},
                new String[]{SipConnector.class.getCanonicalName()});
        return stat;
    }
}

JBOSS implementation SipConnector has dependencies on other upper layer objects.

This works, but addConnector JMX operator adds the connector to the current connector-group that also depends on interface definition

public boolean addSipConnector(String ipAddress, int port, String transport) throws InstanceNotFoundException, MBeanException, ReflectionException, IOException {

        // adding connector
        transport=transport.toLowerCase();

        Boolean stat = (Boolean) mbsc.invoke(sipMBeanName, "addConnector",
                new Object[] {
                             "SipConnector",      // name
                             port,                // loadBalancerSip Port           
                             false,               // useStun
                             ipAddress,           // staticServerAddress
                             port,                // staticServerPort
                             "sip-"+transport,    // socketBinding
                             "",                  // loadBalancerAddress
                             "sip",               // scheme
                             "sip-"+transport,    // name
                             false,               // useStaticAddress
                             ipAddress,           // hostNames
                             "",                  // stunServerAddress
                             true,                // enabled
                             "SIP/2.0",           // protocol
                             1099,                // loadBalancerRMIPort
                             3079,                // stunServerPort
                             false                // useLoadBalancer
                             },
                new String[] {
                             String.class.getCanonicalName(),
                             Integer.class.getCanonicalName(),
                             Boolean.class.getCanonicalName(),
                             String.class.getCanonicalName(),
                             Integer.class.getCanonicalName(),
                             String.class.getCanonicalName(),
                             String.class.getCanonicalName(),
                             String.class.getCanonicalName(),
                             String.class.getCanonicalName(),
                             Boolean.class.getCanonicalName(),
                             String.class.getCanonicalName(),
                             String.class.getCanonicalName(),
                             Boolean.class.getCanonicalName(),
                             String.class.getCanonicalName(),
                             Integer.class.getCanonicalName(),
                             Integer.class.getCanonicalName(),
                             Boolean.class.getCanonicalName()
                             });

        return true;
    }

issue to solve:

Although creating this dependancies first seems to work succesfully, interface adding is not reflected in the DOM query from jconsole.

objectMBeanName=new ObjectName(objectNamePointer);
        Set<ObjectInstance> mbeans = mbsc.queryMBeans(objectMBeanName, null);
        ObjectName interfaceMBeanName = new ObjectName("jboss.as:interface=mz-201");   
        //Interface interfaceMBean=new Interface();
        //interfaceMBean.setName("mz-201");
        //interfaceMBean.setInetAddress("192.168.88.2");
        MBeanServer server = ManagementFactory.getPlatformMBeanServer();

            InterfaceMBean interfaceProxy = JMX.newMBeanProxy(
                     mbsc, interfaceMBeanName, InterfaceMBean.class);
            interfaceProxy.setName("mz-201");
            interfaceProxy.setInetAddress("192.168.88.2");
        //    ObjectInstance instance = server.registerMBean(interfaceMBean, interfaceMBeanName);
        //    System.out.println("Instance="+instance);
        //    System.out.println("Oname="+instance.getObjectName());
ocarriles commented 6 years ago

@deruelle Sip Servlets implementation for Tomcat/WildFly10 is in 3.1.1 at: https://mobicents.ci.cloudbees.com/job/RestcommSipServlets-Specify-Branch/lastSuccessfulBuild/artifact

Cannot find any other functional link

deruelle commented 6 years ago

try https://github.com/RestComm/sip-servlets/releases/tag/3.2.0-89

ocarriles commented 6 years ago

Finally, my approach now relies on JBOSS management interface rather than on JMX beans management. Looks cleaner and much more related to JBOSS design philosofy. Hot Object pulgins are encapsulated in just one Provider,

ocarriles commented 6 years ago

@deruelle must close

ocarriles commented 5 years ago

closed on no comments