Search in sources :

Example 1 with HashedWheelTimer

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());
}
Also used : NioDatagramChannelFactory(org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory) NioServerSocketChannelFactory(org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory) IdleStateHandler(org.jboss.netty.handler.timeout.IdleStateHandler) HashedWheelTimer(org.jboss.netty.util.HashedWheelTimer) ChannelPipelineFactory(org.jboss.netty.channel.ChannelPipelineFactory) ServerBootstrap(org.jboss.netty.bootstrap.ServerBootstrap) ChannelPipeline(org.jboss.netty.channel.ChannelPipeline) ConnectionlessBootstrap(org.jboss.netty.bootstrap.ConnectionlessBootstrap)

Example 2 with HashedWheelTimer

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"));
}
Also used : ThreadFactory(java.util.concurrent.ThreadFactory) NioClientSocketChannelFactory(org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory) HashedWheelTimer(org.jboss.netty.util.HashedWheelTimer)

Example 3 with HashedWheelTimer

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);
}
Also used : ThreadFactory(java.util.concurrent.ThreadFactory) NioClientBossPool(org.jboss.netty.channel.socket.nio.NioClientBossPool) NioWorkerPool(org.jboss.netty.channel.socket.nio.NioWorkerPool) NioClientSocketChannelFactory(org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory) ClientBootstrap(org.jboss.netty.bootstrap.ClientBootstrap) HashedWheelTimer(org.jboss.netty.util.HashedWheelTimer)

Example 4 with HashedWheelTimer

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;
}
Also used : HashedWheelTimer(org.jboss.netty.util.HashedWheelTimer)

Example 5 with HashedWheelTimer

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();
    }
}
Also used : RequestPacket(com.navercorp.pinpoint.rpc.packet.RequestPacket) TestAwaitTaskUtils(com.navercorp.pinpoint.rpc.TestAwaitTaskUtils) Future(com.navercorp.pinpoint.rpc.Future) DefaultFuture(com.navercorp.pinpoint.rpc.DefaultFuture) HashedWheelTimer(org.jboss.netty.util.HashedWheelTimer) Test(org.junit.Test)

Aggregations

HashedWheelTimer (org.jboss.netty.util.HashedWheelTimer)16 LocalMetricRegistry (org.graylog2.plugin.LocalMetricRegistry)3 NioClientSocketChannelFactory (org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory)3 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)2 DefaultFuture (com.navercorp.pinpoint.rpc.DefaultFuture)2 Future (com.navercorp.pinpoint.rpc.Future)2 RequestPacket (com.navercorp.pinpoint.rpc.packet.RequestPacket)2 ThreadFactory (java.util.concurrent.ThreadFactory)2 ThroughputCounter (org.graylog2.plugin.inputs.util.ThroughputCounter)2 ClientBootstrap (org.jboss.netty.bootstrap.ClientBootstrap)2 Before (org.junit.Before)2 Test (org.junit.Test)2 TypeLiteral (com.google.inject.TypeLiteral)1 FactoryModuleBuilder (com.google.inject.assistedinject.FactoryModuleBuilder)1 TestAwaitTaskUtils (com.navercorp.pinpoint.rpc.TestAwaitTaskUtils)1 ClientConfig (com.twitter.distributedlog.client.ClientConfig)1 DefaultRegionResolver (com.twitter.distributedlog.client.resolver.DefaultRegionResolver)1 ClientStats (com.twitter.distributedlog.client.stats.ClientStats)1 ConnectException (java.net.ConnectException)1 InetSocketAddress (java.net.InetSocketAddress)1