Search in sources :

Example 1 with ServerPipelineFactory

use of org.mobicents.tools.heartbeat.server.ServerPipelineFactory in project load-balancer by RestComm.

the class Server method start.

@Override
public void start() {
    executor = Executors.newCachedThreadPool();
    nioServerSocketChannelFactory = new NioServerSocketChannelFactory(executor, executor);
    serverBootstrap = new ServerBootstrap(nioServerSocketChannelFactory);
    serverBootstrap.setPipelineFactory(new ServerPipelineFactory(serverListener));
    serverChannel = serverBootstrap.bind(new InetSocketAddress(lbAddress, lbPort));
    logger.info("Heartbeat service started on " + lbAddress + ":" + lbPort + " (Load balancer's side)");
}
Also used : ServerPipelineFactory(org.mobicents.tools.heartbeat.server.ServerPipelineFactory) NioServerSocketChannelFactory(org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory) InetSocketAddress(java.net.InetSocketAddress) ServerBootstrap(org.jboss.netty.bootstrap.ServerBootstrap)

Example 2 with ServerPipelineFactory

use of org.mobicents.tools.heartbeat.server.ServerPipelineFactory in project load-balancer by RestComm.

the class HeartbeatService method start.

public void start() {
    serverBootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(executor, executor));
    serverBootstrap.setPipelineFactory(new ServerPipelineFactory(this));
    serverChannel = serverBootstrap.bind(new InetSocketAddress(heartBeatIp, heartBeatPort));
    this.started.set(true);
    logger.info("Heartbeat service listen on " + heartBeatIp + ":" + heartBeatPort + " (Node's side)");
}
Also used : ServerPipelineFactory(org.mobicents.tools.heartbeat.server.ServerPipelineFactory) NioServerSocketChannelFactory(org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory) InetSocketAddress(java.net.InetSocketAddress) ServerBootstrap(org.jboss.netty.bootstrap.ServerBootstrap)

Example 3 with ServerPipelineFactory

use of org.mobicents.tools.heartbeat.server.ServerPipelineFactory 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

InetSocketAddress (java.net.InetSocketAddress)3 ServerBootstrap (org.jboss.netty.bootstrap.ServerBootstrap)3 NioServerSocketChannelFactory (org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory)3 ServerPipelineFactory (org.mobicents.tools.heartbeat.server.ServerPipelineFactory)3 ExecutorService (java.util.concurrent.ExecutorService)1 Node (org.mobicents.tools.heartbeat.api.Node)1 ClientController (org.mobicents.tools.heartbeat.impl.ClientController)1