use of org.jboss.netty.bootstrap.ServerBootstrap in project crate by crate.
the class HttpTestServer method run.
public void run() {
// Configure the server.
ServerBootstrap bootstrap = new ServerBootstrap(this.channelFactory);
// Set up the pipeline factory.
bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
public ChannelPipeline getPipeline() throws Exception {
// Create a default pipeline implementation.
ChannelPipeline pipeline = Channels.pipeline();
// Uncomment the following line if you want HTTPS
//SSLEngine engine = SecureChatSslContextFactory.getServerContext().createSSLEngine();
//engine.setUseClientMode(false);
//pipeline.addLast("ssl", new SslHandler(engine));
pipeline.addLast("decoder", new HttpRequestDecoder());
// Uncomment the following line if you don't want to handle HttpChunks.
//pipeline.addLast("aggregator", new HttpChunkAggregator(1048576));
pipeline.addLast("encoder", new HttpResponseEncoder());
// Remove the following line if you don't want automatic content compression.
pipeline.addLast("deflater", new HttpContentCompressor());
pipeline.addLast("handler", new HttpTestServerHandler());
return pipeline;
}
});
// Bind and start to accept incoming connections.
channel = bootstrap.bind(new InetSocketAddress(port));
}
use of org.jboss.netty.bootstrap.ServerBootstrap in project weave by continuuity.
the class TrackerService method startUp.
@Override
protected void startUp() throws Exception {
Executor bossThreads = Executors.newFixedThreadPool(NUM_BOSS_THREADS, new ThreadFactoryBuilder().setDaemon(true).setNameFormat("boss-thread").build());
Executor workerThreads = Executors.newCachedThreadPool(new ThreadFactoryBuilder().setDaemon(true).setNameFormat("worker-thread#%d").build());
ChannelFactory factory = new NioServerSocketChannelFactory(bossThreads, workerThreads);
bootstrap = new ServerBootstrap(factory);
bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
public ChannelPipeline getPipeline() {
ChannelPipeline pipeline = Channels.pipeline();
pipeline.addLast("decoder", new HttpRequestDecoder());
pipeline.addLast("aggregator", new HttpChunkAggregator(MAX_INPUT_SIZE));
pipeline.addLast("encoder", new HttpResponseEncoder());
pipeline.addLast("compressor", new HttpContentCompressor());
pipeline.addLast("handler", new ReportHandler(resourceReport));
return pipeline;
}
});
Channel channel = bootstrap.bind(new InetSocketAddress(host, 0));
bindAddress = (InetSocketAddress) channel.getLocalAddress();
url = URI.create(String.format("http://%s:%d", host, bindAddress.getPort())).resolve(TrackerService.PATH).toURL();
channelGroup.add(channel);
}
use of org.jboss.netty.bootstrap.ServerBootstrap in project socket.io-netty by ibdknox.
the class FlashPolicyServer method start.
public static void start() {
// Configure the server.
bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool()));
// Set up the event pipeline factory.
bootstrap.setPipelineFactory(new FlashPolicyServerPipelineFactory());
bootstrap.setOption("child.tcpNoDelay", true);
bootstrap.setOption("child.keepAlive", true);
// Bind and start to accept incoming connections.
serverChannel = bootstrap.bind(new InetSocketAddress(843));
}
use of org.jboss.netty.bootstrap.ServerBootstrap in project databus by linkedin.
the class TestRelayCommandsLocal method setUp.
@BeforeMethod
public void setUp() throws Exception {
// creates an event factory for us
_relay = new HttpRelay(_staticConfig, null);
_eventBuffer = _relay.getEventBuffer();
DatabusEventProducer randomEventProducer = new DatabusEventRandomProducer(_eventBuffer, 10, 1, 10, _staticConfig.getSourceIds(), null, null);
RequestProcessorRegistry processorRegistry = _relay.getProcessorRegistry();
processorRegistry.register(EchoRequestProcessor.COMMAND_NAME, new EchoRequestProcessor(null));
processorRegistry.register(GenerateDataEventsRequestProcessor.COMMAND_NAME, new GenerateDataEventsRequestProcessor(null, _relay, randomEventProducer));
// Configure the server.
_bootstrap = new ServerBootstrap(new DefaultLocalServerChannelFactory());
// Set up the event pipeline factory.
_bootstrap.setPipelineFactory(new HttpServerPipelineFactory(_relay));
_serverAddress = new LocalAddress(10);
_serverChannel = _bootstrap.bind(_serverAddress);
}
use of org.jboss.netty.bootstrap.ServerBootstrap in project hadoop by apache.
the class ShuffleHandler method serviceStart.
// TODO change AbstractService to throw InterruptedException
@Override
protected void serviceStart() throws Exception {
Configuration conf = getConfig();
userRsrc = new ConcurrentHashMap<String, String>();
secretManager = new JobTokenSecretManager();
recoverState(conf);
ServerBootstrap bootstrap = new ServerBootstrap(selector);
try {
pipelineFact = new HttpPipelineFactory(conf);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
bootstrap.setOption("backlog", conf.getInt(SHUFFLE_LISTEN_QUEUE_SIZE, DEFAULT_SHUFFLE_LISTEN_QUEUE_SIZE));
bootstrap.setOption("child.keepAlive", true);
bootstrap.setPipelineFactory(pipelineFact);
port = conf.getInt(SHUFFLE_PORT_CONFIG_KEY, DEFAULT_SHUFFLE_PORT);
Channel ch = bootstrap.bind(new InetSocketAddress(port));
accepted.add(ch);
port = ((InetSocketAddress) ch.getLocalAddress()).getPort();
conf.set(SHUFFLE_PORT_CONFIG_KEY, Integer.toString(port));
pipelineFact.SHUFFLE.setPort(port);
LOG.info(getName() + " listening on port " + port);
super.serviceStart();
sslFileBufferSize = conf.getInt(SUFFLE_SSL_FILE_BUFFER_SIZE_KEY, DEFAULT_SUFFLE_SSL_FILE_BUFFER_SIZE);
connectionKeepAliveEnabled = conf.getBoolean(SHUFFLE_CONNECTION_KEEP_ALIVE_ENABLED, DEFAULT_SHUFFLE_CONNECTION_KEEP_ALIVE_ENABLED);
connectionKeepAliveTimeOut = Math.max(1, conf.getInt(SHUFFLE_CONNECTION_KEEP_ALIVE_TIME_OUT, DEFAULT_SHUFFLE_CONNECTION_KEEP_ALIVE_TIME_OUT));
mapOutputMetaInfoCacheSize = Math.max(1, conf.getInt(SHUFFLE_MAPOUTPUT_META_INFO_CACHE_SIZE, DEFAULT_SHUFFLE_MAPOUTPUT_META_INFO_CACHE_SIZE));
}
Aggregations