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)");
}
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)");
}
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();
}
}
Aggregations