Search in sources :

Example 1 with ClientController

use of org.mobicents.tools.heartbeat.impl.ClientController in project load-balancer by RestComm.

the class HttpServer method start.

public void start() {
    executor = Executors.newCachedThreadPool();
    nioServerSocketChannelFactory = new NioServerSocketChannelFactory(executor, executor);
    serverBootstrap = new ServerBootstrap(nioServerSocketChannelFactory);
    serverBootstrap.setPipelineFactory(new TestHttpServerPipelineFactory(true, requestCount, requests, chunkedresponse, badSever));
    serverChannel = serverBootstrap.bind(new InetSocketAddress("127.0.0.1", httpPort));
    serverSecureBootstrap = new ServerBootstrap(nioServerSocketChannelFactory);
    serverSecureBootstrap.setPipelineFactory(new TestHttpServerPipelineFactory(false, requestCount, requests, chunkedresponse, badSever));
    serverSecureChannel = serverSecureBootstrap.bind(new InetSocketAddress("127.0.0.1", sslPort));
    // ping
    node = new Node("HttpServer", "127.0.0.1");
    node.getProperties().put("version", "0");
    node.getProperties().put("httpPort", "" + httpPort);
    node.getProperties().put("udpPort", "" + udpPort);
    node.getProperties().put("sslPort", "" + sslPort);
    node.getProperties().put(Protocol.SESSION_ID, "" + System.currentTimeMillis());
    node.getProperties().put(Protocol.HEARTBEAT_PORT, "" + heartbeatPort);
    if (instanceId != null)
        node.getProperties().put("Restcomm-Instance-Id", instanceId);
    clientController = new ClientController(this, lbAddress, lbPort, node, 5000, heartbeatPeriod, executor);
    clientController.startClient();
}
Also used : NioServerSocketChannelFactory(org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory) InetSocketAddress(java.net.InetSocketAddress) Node(org.mobicents.tools.heartbeat.api.Node) ClientController(org.mobicents.tools.heartbeat.impl.ClientController) ServerBootstrap(org.jboss.netty.bootstrap.ServerBootstrap)

Example 2 with ClientController

use of org.mobicents.tools.heartbeat.impl.ClientController in project load-balancer by RestComm.

the class BackToBackUserAgent method start.

public void start() {
    SipFactory sipFactory = null;
    sipFactory = SipFactory.getInstance();
    sipFactory.setPathName("gov.nist");
    this.protocolObjects = new ProtocolObjects("backtobackua", "gov.nist", transport, true, true, false);
    try {
        messageFactory = protocolObjects.messageFactory;
        lp = protocolObjects.sipStack.createListeningPoint("127.0.0.1", port, transport);
        sp = protocolObjects.sipStack.createSipProvider(lp);
        sp.addSipListener(this);
        protocolObjects.start();
        node = new Node("Node", "127.0.0.1");
        node.getProperties().put(transport.toLowerCase() + "Port", "" + port);
        node.getProperties().put("version", "0");
        node.getProperties().put(Protocol.SESSION_ID, "" + System.currentTimeMillis());
        node.getProperties().put(Protocol.HEARTBEAT_PORT, "" + heartbeatPort);
        clientController = new ClientController(this, lbAddress, lbHBPort, node, 2000, heartbeatPeriod, executor);
        clientController.startClient();
    } catch (Exception ex) {
    }
}
Also used : ProtocolObjects(org.mobicents.tools.sip.balancer.ProtocolObjects) Node(org.mobicents.tools.heartbeat.api.Node) SipFactory(javax.sip.SipFactory) ClientController(org.mobicents.tools.heartbeat.impl.ClientController) InvalidArgumentException(javax.sip.InvalidArgumentException) ParseException(java.text.ParseException) SipException(javax.sip.SipException)

Example 3 with ClientController

use of org.mobicents.tools.heartbeat.impl.ClientController in project load-balancer by RestComm.

the class AppServer method start.

public void start() {
    ExecutorService executor = Executors.newCachedThreadPool();
    protocolObjects = new ProtocolObjects(name, "gov.nist", transport, false, false, true);
    if (!isSendResponse) {
        sipListener = new TestSipListener(isIpv6, port, lbSIPint, protocolObjects, false);
        sipListener.abortProcessing = true;
    } else if (!isDummy) {
        if (!isMediaFailure || !isFirstStart) {
            sipListener = new TestSipListener(isIpv6, port, lbSIPint, protocolObjects, false);
        } else {
            sipListener = new TestSipListener(isIpv6, port, lbSIPint, protocolObjects, false);
            sipListener.setRespondWithError(Response.SERVICE_UNAVAILABLE);
        }
    } else {
        sipListener = new TestSipListener(isIpv6, port + 1, lbSIPint, protocolObjects, false);
    }
    sipListener.appServer = this;
    try {
        sipProvider = sipListener.createProvider();
        sipProvider.addSipListener(sipListener);
        protocolObjects.start();
    } catch (Exception e) {
        e.printStackTrace();
    }
    // generate node
    if (!isIpv6)
        node = new Node(name, "127.0.0.1");
    else
        node = new Node(name, "::1");
    node.getProperties().put(transport.toLowerCase() + "Port", "" + port);
    node.getProperties().put(Protocol.VERSION, version);
    node.getProperties().put(Protocol.SESSION_ID, "" + System.currentTimeMillis());
    node.getProperties().put(Protocol.HEARTBEAT_PORT, "" + heartbeatPort);
    nioServerSocketChannelFactory = new NioServerSocketChannelFactory(executor, executor);
    serverBootstrap = new ServerBootstrap(nioServerSocketChannelFactory);
    serverBootstrap.setPipelineFactory(new ServerPipelineFactory(this));
    serverChannel = serverBootstrap.bind(new InetSocketAddress(node.getIp(), heartbeatPort));
    logger.info("Heartbeat service listen on " + heartbeatAddress + ":" + heartbeatPort + " (Node's side)");
    // start client
    if (balancers == null)
        clientController = new ClientController(this, lbAddress, lbPort, node, 5000, heartbeatPeriod, executor);
    else {
        String[] lbs = balancers.split(",");
        clientControllers = new ClientController[lbs.length];
        for (int i = 0; i < lbs.length; i++) {
            if (!isIpv6)
                node = new Node(name, "127.0.0.1");
            else
                node = new Node(name, "::1");
            node.getProperties().put(transport.toLowerCase() + "Port", "" + port);
            node.getProperties().put(Protocol.VERSION, version);
            node.getProperties().put(Protocol.HEARTBEAT_PORT, "" + heartbeatPort);
            clientControllers[i] = new ClientController(this, lbs[i].split(":")[0], Integer.parseInt(lbs[i].split(":")[1]), node, 5000, heartbeatPeriod, executor);
            clientControllers[i].startClient();
        }
    }
    if (sendHeartbeat) {
        if (balancers == null)
            clientController.startClient();
    }
}
Also used : NioServerSocketChannelFactory(org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory) InetSocketAddress(java.net.InetSocketAddress) Node(org.mobicents.tools.heartbeat.api.Node) ClientController(org.mobicents.tools.heartbeat.impl.ClientController) ServerBootstrap(org.jboss.netty.bootstrap.ServerBootstrap) ServerPipelineFactory(org.mobicents.tools.heartbeat.server.ServerPipelineFactory) ExecutorService(java.util.concurrent.ExecutorService)

Aggregations

Node (org.mobicents.tools.heartbeat.api.Node)3 ClientController (org.mobicents.tools.heartbeat.impl.ClientController)3 InetSocketAddress (java.net.InetSocketAddress)2 ServerBootstrap (org.jboss.netty.bootstrap.ServerBootstrap)2 NioServerSocketChannelFactory (org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory)2 ParseException (java.text.ParseException)1 ExecutorService (java.util.concurrent.ExecutorService)1 InvalidArgumentException (javax.sip.InvalidArgumentException)1 SipException (javax.sip.SipException)1 SipFactory (javax.sip.SipFactory)1 ServerPipelineFactory (org.mobicents.tools.heartbeat.server.ServerPipelineFactory)1 ProtocolObjects (org.mobicents.tools.sip.balancer.ProtocolObjects)1