Search in sources :

Example 16 with HashedWheelTimer

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

the class ScatterGatherPerfClient method setup.

private void setup() {
    MetricsRegistry registry = new MetricsRegistry();
    _timedExecutor = new ScheduledThreadPoolExecutor(1);
    _service = new ThreadPoolExecutor(10, 10, 10, TimeUnit.DAYS, new LinkedBlockingDeque<Runnable>());
    _eventLoopGroup = new NioEventLoopGroup(10);
    _timer = new HashedWheelTimer();
    NettyClientMetrics clientMetrics = new NettyClientMetrics(registry, "client_");
    PooledNettyClientResourceManager rm = new PooledNettyClientResourceManager(_eventLoopGroup, _timer, clientMetrics);
    _pool = new KeyedPoolImpl<ServerInstance, NettyClientConnection>(1, _maxActiveConnections, 300000, 10, rm, _timedExecutor, MoreExecutors.sameThreadExecutor(), registry);
    rm.setPool(_pool);
    _scatterGather = new ScatterGatherImpl(_pool, _service);
    for (AsyncReader r : _readerThreads) {
        r.start();
    }
}
Also used : MetricsRegistry(com.yammer.metrics.core.MetricsRegistry) LinkedBlockingDeque(java.util.concurrent.LinkedBlockingDeque) NettyClientMetrics(com.linkedin.pinot.transport.metrics.NettyClientMetrics) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) PooledNettyClientResourceManager(com.linkedin.pinot.transport.netty.PooledNettyClientResourceManager) HashedWheelTimer(io.netty.util.HashedWheelTimer) NettyClientConnection(com.linkedin.pinot.transport.netty.NettyClientConnection) ScatterGatherImpl(com.linkedin.pinot.transport.scattergather.ScatterGatherImpl) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) ServerInstance(com.linkedin.pinot.common.response.ServerInstance) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup)

Example 17 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 18 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)

Aggregations

HashedWheelTimer (io.netty.util.HashedWheelTimer)18 NettyClientMetrics (com.linkedin.pinot.transport.metrics.NettyClientMetrics)16 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)16 EventLoopGroup (io.netty.channel.EventLoopGroup)14 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 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)8 AsyncResponseFuture (com.linkedin.pinot.transport.common.AsyncResponseFuture)7 NettyClientConnection (com.linkedin.pinot.transport.netty.NettyClientConnection)6 PooledNettyClientResourceManager (com.linkedin.pinot.transport.netty.PooledNettyClientResourceManager)6 ExecutorService (java.util.concurrent.ExecutorService)6 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)6 BrokerMetrics (com.linkedin.pinot.common.metrics.BrokerMetrics)5 KeyedPoolImpl (com.linkedin.pinot.transport.pool.KeyedPoolImpl)5 Timer (io.netty.util.Timer)5 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)5 SegmentId (com.linkedin.pinot.transport.common.SegmentId)4