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