use of org.jboss.netty.bootstrap.ServerBootstrap 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.jboss.netty.bootstrap.ServerBootstrap 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.jboss.netty.bootstrap.ServerBootstrap in project load-balancer by RestComm.
the class HttpBalancerForwarder method start.
public void start() {
executor = Executors.newCachedThreadPool();
nioServerSocketChannelFactory = new NioServerSocketChannelFactory(executor, executor);
nioClientSocketChannelFactory = new NioClientSocketChannelFactory(executor, executor);
HttpChannelAssociations.serverBootstrap = new ServerBootstrap(nioServerSocketChannelFactory);
HttpChannelAssociations.serverSecureBootstrap = new ServerBootstrap(nioServerSocketChannelFactory);
HttpChannelAssociations.serverApiBootstrap = new ServerBootstrap(nioServerSocketChannelFactory);
HttpChannelAssociations.inboundBootstrap = new ClientBootstrap(nioClientSocketChannelFactory);
HttpChannelAssociations.channels = new ConcurrentHashMap<AdvancedChannel, AdvancedChannel>();
if (balancerRunner.getConfiguration().getHttpConfiguration().getUrlrewriteRule() != null) {
HttpChannelAssociations.urlRewriteFilter = new BalancerUrlRewriteFilter();
try {
HttpChannelAssociations.urlRewriteFilter.init(balancerRunner);
} catch (ServletException e) {
throw new IllegalStateException("Can't init url filter due to [ " + e.getMessage() + " ] ", e);
}
}
// https://telestax.atlassian.net/browse/LB-7 making the default port the same
Integer httpPort = 2080;
if (balancerRunner.balancerContext.lbConfig != null)
httpPort = balancerRunner.balancerContext.lbConfig.getHttpConfiguration().getHttpPort();
logger.info("HTTP LB listening on port " + httpPort);
HttpChannelAssociations.serverBootstrap.setPipelineFactory(new HttpServerPipelineFactory(balancerRunner, false));
HttpChannelAssociations.serverBootstrap.setOption("child.tcpNoDelay", true);
HttpChannelAssociations.serverBootstrap.setOption("child.keepAlive", true);
serverChannel = HttpChannelAssociations.serverBootstrap.bind(new InetSocketAddress(httpPort));
Integer httpsPort = balancerRunner.balancerContext.lbConfig.getHttpConfiguration().getHttpsPort();
if (httpsPort != null) {
logger.info("HTTPS LB listening on port " + httpsPort);
HttpChannelAssociations.serverSecureBootstrap.setPipelineFactory(new HttpServerPipelineFactory(balancerRunner, true));
serverSecureChannel = HttpChannelAssociations.serverSecureBootstrap.bind(new InetSocketAddress(httpsPort));
if (!balancerRunner.balancerContext.terminateTLSTraffic) {
HttpChannelAssociations.inboundSecureBootstrap = new ClientBootstrap(nioClientSocketChannelFactory);
HttpChannelAssociations.inboundSecureBootstrap.setPipelineFactory(new HttpClientPipelineFactory(balancerRunner, true));
HttpChannelAssociations.inboundSecureBootstrap.setOption("child.tcpNoDelay", true);
HttpChannelAssociations.inboundSecureBootstrap.setOption("child.keepAlive", true);
}
}
Integer apiPort = balancerRunner.balancerContext.lbConfig.getCommonConfiguration().getStatisticPort();
if (apiPort != null) {
logger.info("Load balancer API port : " + apiPort);
HttpChannelAssociations.serverApiBootstrap.setPipelineFactory(new HttpServerPipelineFactory(balancerRunner, false));
HttpChannelAssociations.serverApiChannel = HttpChannelAssociations.serverApiBootstrap.bind(new InetSocketAddress(apiPort));
}
HttpChannelAssociations.inboundBootstrap.setPipelineFactory(new HttpClientPipelineFactory(balancerRunner, false));
}
use of org.jboss.netty.bootstrap.ServerBootstrap in project traccar by tananaev.
the class TrackerServer method start.
public void start() {
InetSocketAddress endpoint;
if (address == null) {
endpoint = new InetSocketAddress(port);
} else {
endpoint = new InetSocketAddress(address, port);
}
Channel channel = null;
if (bootstrap instanceof ServerBootstrap) {
channel = ((ServerBootstrap) bootstrap).bind(endpoint);
} else if (bootstrap instanceof ConnectionlessBootstrap) {
channel = ((ConnectionlessBootstrap) bootstrap).bind(endpoint);
}
if (channel != null) {
getChannelGroup().add(channel);
}
}
use of org.jboss.netty.bootstrap.ServerBootstrap in project traccar by tananaev.
the class AdmProtocol method initTrackerServers.
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 2, 1, -3, 0));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("objectEncoder", new AdmProtocolEncoder());
pipeline.addLast("objectDecoder", new AdmProtocolDecoder(AdmProtocol.this));
}
};
server.setEndianness(ByteOrder.LITTLE_ENDIAN);
serverList.add(server);
}
Aggregations