use of org.jboss.netty.util.HashedWheelTimer in project hadoop by apache.
the class Portmap method start.
void start(final int idleTimeMilliSeconds, final SocketAddress tcpAddress, final SocketAddress udpAddress) {
tcpServer = new ServerBootstrap(new NioServerSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool()));
tcpServer.setPipelineFactory(new ChannelPipelineFactory() {
private final HashedWheelTimer timer = new HashedWheelTimer();
private final IdleStateHandler idleStateHandler = new IdleStateHandler(timer, 0, 0, idleTimeMilliSeconds, TimeUnit.MILLISECONDS);
@Override
public ChannelPipeline getPipeline() throws Exception {
return Channels.pipeline(RpcUtil.constructRpcFrameDecoder(), RpcUtil.STAGE_RPC_MESSAGE_PARSER, idleStateHandler, handler, RpcUtil.STAGE_RPC_TCP_RESPONSE);
}
});
tcpServer.setOption("reuseAddress", true);
tcpServer.setOption("child.reuseAddress", true);
udpServer = new ConnectionlessBootstrap(new NioDatagramChannelFactory(Executors.newCachedThreadPool()));
udpServer.setPipeline(Channels.pipeline(RpcUtil.STAGE_RPC_MESSAGE_PARSER, handler, RpcUtil.STAGE_RPC_UDP_RESPONSE));
udpServer.setOption("reuseAddress", true);
tcpChannel = tcpServer.bind(tcpAddress);
udpChannel = udpServer.bind(udpAddress);
allChannels.add(tcpChannel);
allChannels.add(udpChannel);
LOG.info("Portmap server started at tcp://" + tcpChannel.getLocalAddress() + ", udp://" + udpChannel.getLocalAddress());
}
use of org.jboss.netty.util.HashedWheelTimer in project storm by apache.
the class Context method prepare.
/**
* initialization per Storm configuration
*/
@SuppressWarnings("rawtypes")
public void prepare(Map storm_conf) {
this.storm_conf = storm_conf;
connections = new HashMap<>();
//each context will have a single client channel factory
int maxWorkers = Utils.getInt(storm_conf.get(Config.STORM_MESSAGING_NETTY_CLIENT_WORKER_THREADS));
ThreadFactory bossFactory = new NettyRenameThreadFactory("client" + "-boss");
ThreadFactory workerFactory = new NettyRenameThreadFactory("client" + "-worker");
if (maxWorkers > 0) {
clientChannelFactory = new NioClientSocketChannelFactory(Executors.newCachedThreadPool(bossFactory), Executors.newCachedThreadPool(workerFactory), maxWorkers);
} else {
clientChannelFactory = new NioClientSocketChannelFactory(Executors.newCachedThreadPool(bossFactory), Executors.newCachedThreadPool(workerFactory));
}
clientScheduleService = new HashedWheelTimer(new NettyRenameThreadFactory("client-schedule-service"));
}
use of org.jboss.netty.util.HashedWheelTimer in project weave by continuuity.
the class SimpleKafkaClient method startUp.
@Override
protected void startUp() throws Exception {
brokerCache.startAndWait();
ThreadFactory threadFactory = Threads.createDaemonThreadFactory("kafka-client-netty-%d");
NioClientBossPool bossPool = new NioClientBossPool(Executors.newSingleThreadExecutor(threadFactory), 1, new HashedWheelTimer(threadFactory), null);
NioWorkerPool workerPool = new NioWorkerPool(Executors.newFixedThreadPool(4, threadFactory), 4);
bootstrap = new ClientBootstrap(new NioClientSocketChannelFactory(bossPool, workerPool));
bootstrap.setPipelineFactory(new KafkaChannelPipelineFactory());
connectionPool = new ConnectionPool(bootstrap);
}
use of org.jboss.netty.util.HashedWheelTimer in project pinpoint by naver.
the class TcpDataSender method createTimer.
private Timer createTimer() {
HashedWheelTimer timer = TimerFactory.createHashedWheelTimer("Pinpoint-DataSender-Timer", 100, TimeUnit.MILLISECONDS, 512);
timer.start();
return timer;
}
use of org.jboss.netty.util.HashedWheelTimer in project pinpoint by naver.
the class RequestManagerTest method testRegisterRequest.
@Test
public void testRegisterRequest() throws Exception {
HashedWheelTimer timer = getTimer();
RequestManager requestManager = new RequestManager(timer, 3000);
try {
RequestPacket packet = new RequestPacket(new byte[0]);
final Future future = requestManager.register(packet, 50);
TestAwaitUtils.await(new TestAwaitTaskUtils() {
@Override
public boolean checkCompleted() {
return future.isReady();
}
}, 10, 200);
Assert.assertTrue(future.isReady());
Assert.assertFalse(future.isSuccess());
Assert.assertTrue(future.getCause().getMessage().contains("timeout"));
logger.debug(future.getCause().getMessage());
} finally {
requestManager.close();
timer.stop();
}
}
Aggregations