Search in sources :

Example 26 with HashedWheelTimer

use of io.netty.util.HashedWheelTimer in project pinot by linkedin.

the class BrokerServerBuilder method buildNetwork.

public void buildNetwork() throws ConfigurationException {
    // build transport
    Configuration transportConfigs = _config.subset(TRANSPORT_CONFIG_PREFIX);
    TransportClientConf conf = new TransportClientConf();
    conf.init(transportConfigs);
    _registry = new MetricsRegistry();
    MetricsHelper.initializeMetrics(_config.subset(METRICS_CONFIG_PREFIX));
    MetricsHelper.registerMetricsRegistry(_registry);
    _brokerMetrics = new BrokerMetrics(_registry, !emitTableLevelMetrics());
    _brokerMetrics.initializeGlobalMeters();
    _state.set(State.INIT);
    _eventLoopGroup = new NioEventLoopGroup();
    /**
     * Some of the client metrics uses histogram which is doing synchronous operation.
     * These are fixed overhead per request/response.
     * TODO: Measure the overhead of this.
     */
    final NettyClientMetrics clientMetrics = new NettyClientMetrics(_registry, "client_");
    // Setup Netty Connection Pool
    _resourceManager = new PooledNettyClientResourceManager(_eventLoopGroup, new HashedWheelTimer(), clientMetrics);
    _poolTimeoutExecutor = new ScheduledThreadPoolExecutor(50);
    // _requestSenderPool = MoreExecutors.sameThreadExecutor();
    _requestSenderPool = Executors.newCachedThreadPool();
    final ConnectionPoolConfig connPoolCfg = conf.getConnPool();
    _connPool = new KeyedPoolImpl<ServerInstance, NettyClientConnection>(connPoolCfg.getMinConnectionsPerServer(), connPoolCfg.getMaxConnectionsPerServer(), connPoolCfg.getIdleTimeoutMs(), connPoolCfg.getMaxBacklogPerServer(), _resourceManager, _poolTimeoutExecutor, _requestSenderPool, _registry);
    // MoreExecutors.sameThreadExecutor(), _registry);
    _resourceManager.setPool(_connPool);
    // Setup Routing Table
    if (conf.getRoutingMode() == RoutingMode.CONFIG) {
        final CfgBasedRouting rt = new CfgBasedRouting();
        rt.init(conf.getCfgBasedRouting());
        _routingTable = rt;
    } else {
    // Helix based routing is already initialized.
    }
    // Setup ScatterGather
    _scatterGather = new ScatterGatherImpl(_connPool, _requestSenderPool);
    // Setup Broker Request Handler
    ReduceServiceRegistry reduceServiceRegistry = buildReduceServiceRegistry();
    _requestHandler = new BrokerRequestHandler(_routingTable, _timeBoundaryService, _scatterGather, reduceServiceRegistry, _brokerMetrics, _config);
    LOGGER.info("Network initialized !!");
}
Also used : MetricsRegistry(com.yammer.metrics.core.MetricsRegistry) ConnectionPoolConfig(com.linkedin.pinot.transport.config.ConnectionPoolConfig) NettyClientMetrics(com.linkedin.pinot.transport.metrics.NettyClientMetrics) Configuration(org.apache.commons.configuration.Configuration) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) PooledNettyClientResourceManager(com.linkedin.pinot.transport.netty.PooledNettyClientResourceManager) HashedWheelTimer(io.netty.util.HashedWheelTimer) NettyClientConnection(com.linkedin.pinot.transport.netty.NettyClientConnection) CfgBasedRouting(com.linkedin.pinot.routing.CfgBasedRouting) ScatterGatherImpl(com.linkedin.pinot.transport.scattergather.ScatterGatherImpl) ReduceServiceRegistry(com.linkedin.pinot.common.query.ReduceServiceRegistry) TransportClientConf(com.linkedin.pinot.transport.conf.TransportClientConf) BrokerMetrics(com.linkedin.pinot.common.metrics.BrokerMetrics) ServerInstance(com.linkedin.pinot.common.response.ServerInstance) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) BrokerRequestHandler(com.linkedin.pinot.broker.requesthandler.BrokerRequestHandler)

Example 27 with HashedWheelTimer

use of io.netty.util.HashedWheelTimer in project async-http-client by AsyncHttpClient.

the class DefaultAsyncHttpClient method newNettyTimer.

private Timer newNettyTimer() {
    HashedWheelTimer timer = new HashedWheelTimer();
    timer.start();
    return timer;
}
Also used : HashedWheelTimer(io.netty.util.HashedWheelTimer)

Example 28 with HashedWheelTimer

use of io.netty.util.HashedWheelTimer in project bookkeeper by apache.

the class TestRackawareEnsemblePlacementPolicyUsingScript method setUp.

@Before
public void setUp() throws Exception {
    conf.setProperty(REPP_DNS_RESOLVER_CLASS, ScriptBasedMapping.class.getName());
    conf.setProperty(CommonConfigurationKeys.NET_TOPOLOGY_SCRIPT_FILE_NAME_KEY, "src/test/resources/networkmappingscript.sh");
    timer = new HashedWheelTimer(new ThreadFactoryBuilder().setNameFormat("TestTimer-%d").build(), conf.getTimeoutTimerTickDurationMs(), TimeUnit.MILLISECONDS, conf.getTimeoutTimerNumTicks());
    repp = new RackawareEnsemblePlacementPolicy();
    repp.initialize(conf, Optional.<DNSToSwitchMapping>empty(), timer, DISABLE_ALL, NullStatsLogger.INSTANCE);
}
Also used : ScriptBasedMapping(org.apache.bookkeeper.net.ScriptBasedMapping) ThreadFactoryBuilder(com.google.common.util.concurrent.ThreadFactoryBuilder) HashedWheelTimer(io.netty.util.HashedWheelTimer) Before(org.junit.Before)

Example 29 with HashedWheelTimer

use of io.netty.util.HashedWheelTimer in project bookkeeper by apache.

the class TestRegionAwareEnsemblePlacementPolicy method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    StaticDNSResolver.reset();
    updateMyRack(NetworkTopology.DEFAULT_REGION_AND_RACK);
    LOG.info("Set up static DNS Resolver.");
    conf.setProperty(REPP_DNS_RESOLVER_CLASS, StaticDNSResolver.class.getName());
    addr1 = new BookieSocketAddress("127.0.0.2", 3181);
    addr2 = new BookieSocketAddress("127.0.0.3", 3181);
    addr3 = new BookieSocketAddress("127.0.0.4", 3181);
    addr4 = new BookieSocketAddress("127.0.0.5", 3181);
    // update dns mapping
    StaticDNSResolver.addNodeToRack(addr1.getHostName(), "/r1/rack1");
    StaticDNSResolver.addNodeToRack(addr2.getHostName(), NetworkTopology.DEFAULT_REGION_AND_RACK);
    StaticDNSResolver.addNodeToRack(addr3.getHostName(), NetworkTopology.DEFAULT_REGION_AND_RACK);
    StaticDNSResolver.addNodeToRack(addr4.getHostName(), "/r1/rack2");
    ensemble.add(addr1);
    ensemble.add(addr2);
    ensemble.add(addr3);
    ensemble.add(addr4);
    writeSet = writeSetFromValues(0, 1, 2, 3);
    timer = new HashedWheelTimer(new ThreadFactoryBuilder().setNameFormat("TestTimer-%d").build(), conf.getTimeoutTimerTickDurationMs(), TimeUnit.MILLISECONDS, conf.getTimeoutTimerNumTicks());
    repp = new RegionAwareEnsemblePlacementPolicy();
    repp.initialize(conf, Optional.<DNSToSwitchMapping>empty(), timer, DISABLE_ALL, NullStatsLogger.INSTANCE);
}
Also used : StaticDNSResolver(org.apache.bookkeeper.util.StaticDNSResolver) BookieSocketAddress(org.apache.bookkeeper.net.BookieSocketAddress) ThreadFactoryBuilder(com.google.common.util.concurrent.ThreadFactoryBuilder) HashedWheelTimer(io.netty.util.HashedWheelTimer)

Example 30 with HashedWheelTimer

use of io.netty.util.HashedWheelTimer in project bookkeeper by apache.

the class TestRackawarePolicyNotificationUpdates method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    conf.setProperty(REPP_DNS_RESOLVER_CLASS, StaticDNSResolver.class.getName());
    StaticDNSResolver.reset();
    StaticDNSResolver.addNodeToRack(InetAddress.getLocalHost().getHostAddress(), NetworkTopology.DEFAULT_REGION_AND_RACK);
    StaticDNSResolver.addNodeToRack("127.0.0.1", NetworkTopology.DEFAULT_REGION_AND_RACK);
    StaticDNSResolver.addNodeToRack("localhost", NetworkTopology.DEFAULT_REGION_AND_RACK);
    LOG.info("Set up static DNS Resolver.");
    timer = new HashedWheelTimer(new ThreadFactoryBuilder().setNameFormat("TestTimer-%d").build(), conf.getTimeoutTimerTickDurationMs(), TimeUnit.MILLISECONDS, conf.getTimeoutTimerNumTicks());
    repp = new RackawareEnsemblePlacementPolicy();
    repp.initialize(conf, Optional.<DNSToSwitchMapping>empty(), timer, DISABLE_ALL, NullStatsLogger.INSTANCE);
    repp.withDefaultRack(NetworkTopology.DEFAULT_REGION_AND_RACK);
}
Also used : StaticDNSResolver(org.apache.bookkeeper.util.StaticDNSResolver) ThreadFactoryBuilder(com.google.common.util.concurrent.ThreadFactoryBuilder) HashedWheelTimer(io.netty.util.HashedWheelTimer)

Aggregations

HashedWheelTimer (io.netty.util.HashedWheelTimer)32 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)17 NettyClientMetrics (com.linkedin.pinot.transport.metrics.NettyClientMetrics)16 EventLoopGroup (io.netty.channel.EventLoopGroup)15 Test (org.testng.annotations.Test)13 ByteBuf (io.netty.buffer.ByteBuf)12 ServerInstance (com.linkedin.pinot.common.response.ServerInstance)10 ResponseFuture (com.linkedin.pinot.transport.netty.NettyClientConnection.ResponseFuture)8 MetricsRegistry (com.yammer.metrics.core.MetricsRegistry)8 ExecutorService (java.util.concurrent.ExecutorService)8 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)8 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)7 AsyncResponseFuture (com.linkedin.pinot.transport.common.AsyncResponseFuture)7 NettyClientConnection (com.linkedin.pinot.transport.netty.NettyClientConnection)6 PooledNettyClientResourceManager (com.linkedin.pinot.transport.netty.PooledNettyClientResourceManager)6 Timer (io.netty.util.Timer)6 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)6 BrokerMetrics (com.linkedin.pinot.common.metrics.BrokerMetrics)5 KeyedPoolImpl (com.linkedin.pinot.transport.pool.KeyedPoolImpl)5 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)5