Search in sources :

Example 6 with HashedWheelTimer

use of org.jboss.netty.util.HashedWheelTimer in project pinpoint by naver.

the class DefaultPinpointClientFactory method createTimer.

private Timer createTimer() {
    HashedWheelTimer timer = TimerFactory.createHashedWheelTimer("Pinpoint-SocketFactory-Timer", 100, TimeUnit.MILLISECONDS, 512);
    timer.start();
    return timer;
}
Also used : HashedWheelTimer(org.jboss.netty.util.HashedWheelTimer)

Example 7 with HashedWheelTimer

use of org.jboss.netty.util.HashedWheelTimer in project pinpoint by naver.

the class RequestManagerTest method testTimerStartTiming.

//    @Test
public void testTimerStartTiming() throws InterruptedException {
    HashedWheelTimer timer = new HashedWheelTimer(1000, TimeUnit.MILLISECONDS);
    timer.start();
    timer.stop();
}
Also used : HashedWheelTimer(org.jboss.netty.util.HashedWheelTimer)

Example 8 with HashedWheelTimer

use of org.jboss.netty.util.HashedWheelTimer in project pinpoint by naver.

the class RequestManagerTest method testRemoveMessageFuture.

@Test
public void testRemoveMessageFuture() throws Exception {
    HashedWheelTimer timer = getTimer();
    RequestManager requestManager = new RequestManager(timer, 3000);
    try {
        RequestPacket packet = new RequestPacket(1, new byte[0]);
        DefaultFuture future = requestManager.register(packet, 2000);
        future.setFailure(new RuntimeException());
        Future nullFuture = requestManager.removeMessageFuture(packet.getRequestId());
        Assert.assertNull(nullFuture);
    } finally {
        requestManager.close();
        timer.stop();
    }
}
Also used : RequestPacket(com.navercorp.pinpoint.rpc.packet.RequestPacket) Future(com.navercorp.pinpoint.rpc.Future) DefaultFuture(com.navercorp.pinpoint.rpc.DefaultFuture) HashedWheelTimer(org.jboss.netty.util.HashedWheelTimer) DefaultFuture(com.navercorp.pinpoint.rpc.DefaultFuture) Test(org.junit.Test)

Example 9 with HashedWheelTimer

use of org.jboss.netty.util.HashedWheelTimer in project camel by apache.

the class ClientModeTCPNettyServerBootstrapFactory method startServerBootstrap.

protected void startServerBootstrap() {
    // prefer using explicit configured thread pools
    BossPool bp = configuration.getBossPool();
    WorkerPool wp = configuration.getWorkerPool();
    if (bp == null) {
        // create new pool which we should shutdown when stopping as its not shared
        bossPool = new NettyClientBossPoolBuilder().withTimer(new HashedWheelTimer()).withBossCount(configuration.getBossCount()).withName("NettyClientTCPBoss").build();
        bp = bossPool;
    }
    if (wp == null) {
        // create new pool which we should shutdown when stopping as its not shared
        workerPool = new NettyWorkerPoolBuilder().withWorkerCount(configuration.getWorkerCount()).withName("NettyServerTCPWorker").build();
        wp = workerPool;
    }
    channelFactory = new NioClientSocketChannelFactory(bp, wp);
    serverBootstrap = new ClientBootstrap(channelFactory);
    serverBootstrap.setOption("keepAlive", configuration.isKeepAlive());
    serverBootstrap.setOption("tcpNoDelay", configuration.isTcpNoDelay());
    serverBootstrap.setOption("reuseAddress", configuration.isReuseAddress());
    serverBootstrap.setOption("connectTimeoutMillis", configuration.getConnectTimeout());
    if (configuration.getBacklog() > 0) {
        serverBootstrap.setOption("backlog", configuration.getBacklog());
    }
    // set any additional netty options
    if (configuration.getOptions() != null) {
        for (Map.Entry<String, Object> entry : configuration.getOptions().entrySet()) {
            serverBootstrap.setOption(entry.getKey(), entry.getValue());
        }
    }
    LOG.debug("Created ServerBootstrap {} with options: {}", serverBootstrap, serverBootstrap.getOptions());
    // set the pipeline factory, which creates the pipeline for each newly created channels
    serverBootstrap.setPipelineFactory(pipelineFactory);
    LOG.info("ServerBootstrap connecting to {}:{}", configuration.getHost(), configuration.getPort());
    ChannelFuture connectFuture = serverBootstrap.connect(new InetSocketAddress(configuration.getHost(), configuration.getPort()));
    try {
        channel = openChannel(connectFuture);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : ChannelFuture(org.jboss.netty.channel.ChannelFuture) NioClientSocketChannelFactory(org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory) InetSocketAddress(java.net.InetSocketAddress) HashedWheelTimer(org.jboss.netty.util.HashedWheelTimer) CamelException(org.apache.camel.CamelException) ConnectException(java.net.ConnectException) BossPool(org.jboss.netty.channel.socket.nio.BossPool) WorkerPool(org.jboss.netty.channel.socket.nio.WorkerPool) ClientBootstrap(org.jboss.netty.bootstrap.ClientBootstrap) Map(java.util.Map)

Example 10 with HashedWheelTimer

use of org.jboss.netty.util.HashedWheelTimer in project distributedlog by twitter.

the class TestProxyClientManager method createProxyClientManager.

private static ProxyClientManager createProxyClientManager(ProxyClient.Builder builder, HostProvider hostProvider, long periodicHandshakeIntervalMs) {
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.setPeriodicHandshakeIntervalMs(periodicHandshakeIntervalMs);
    clientConfig.setPeriodicOwnershipSyncIntervalMs(-1);
    HashedWheelTimer dlTimer = new HashedWheelTimer(new ThreadFactoryBuilder().setNameFormat("TestProxyClientManager-timer-%d").build(), clientConfig.getRedirectBackoffStartMs(), TimeUnit.MILLISECONDS);
    return new ProxyClientManager(clientConfig, builder, dlTimer, hostProvider, new ClientStats(NullStatsReceiver.get(), false, new DefaultRegionResolver()));
}
Also used : ClientStats(com.twitter.distributedlog.client.stats.ClientStats) ThreadFactoryBuilder(com.google.common.util.concurrent.ThreadFactoryBuilder) HashedWheelTimer(org.jboss.netty.util.HashedWheelTimer) DefaultRegionResolver(com.twitter.distributedlog.client.resolver.DefaultRegionResolver) ClientConfig(com.twitter.distributedlog.client.ClientConfig)

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