Search in sources :

Example 1 with BrokerRequestHandler

use of com.linkedin.pinot.broker.requesthandler.BrokerRequestHandler 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 2 with BrokerRequestHandler

use of com.linkedin.pinot.broker.requesthandler.BrokerRequestHandler in project pinot by linkedin.

the class BrokerRequestValidationTest method runQuery.

/**
   * Helper method to run the query.
   *
   * @param query
   * @return Returns exception string if any, null otherwise.
   * @throws Exception
   */
private String runQuery(String query) throws Exception {
    BrokerRequestHandler brokerRequestHandler = brokerBuilder.getBrokerRequestHandler();
    Pql2Compiler compiler = new Pql2Compiler();
    BrokerRequest brokerRequest = compiler.compileToBrokerRequest(query);
    String exceptionMessage = null;
    try {
        brokerRequestHandler.validateRequest(brokerRequest);
    } catch (Exception e) {
        exceptionMessage = e.getMessage();
    }
    return exceptionMessage;
}
Also used : Pql2Compiler(com.linkedin.pinot.pql.parsers.Pql2Compiler) BrokerRequest(com.linkedin.pinot.common.request.BrokerRequest) BrokerRequestHandler(com.linkedin.pinot.broker.requesthandler.BrokerRequestHandler)

Aggregations

BrokerRequestHandler (com.linkedin.pinot.broker.requesthandler.BrokerRequestHandler)2 BrokerMetrics (com.linkedin.pinot.common.metrics.BrokerMetrics)1 ReduceServiceRegistry (com.linkedin.pinot.common.query.ReduceServiceRegistry)1 BrokerRequest (com.linkedin.pinot.common.request.BrokerRequest)1 ServerInstance (com.linkedin.pinot.common.response.ServerInstance)1 Pql2Compiler (com.linkedin.pinot.pql.parsers.Pql2Compiler)1 CfgBasedRouting (com.linkedin.pinot.routing.CfgBasedRouting)1 TransportClientConf (com.linkedin.pinot.transport.conf.TransportClientConf)1 ConnectionPoolConfig (com.linkedin.pinot.transport.config.ConnectionPoolConfig)1 NettyClientMetrics (com.linkedin.pinot.transport.metrics.NettyClientMetrics)1 NettyClientConnection (com.linkedin.pinot.transport.netty.NettyClientConnection)1 PooledNettyClientResourceManager (com.linkedin.pinot.transport.netty.PooledNettyClientResourceManager)1 ScatterGatherImpl (com.linkedin.pinot.transport.scattergather.ScatterGatherImpl)1 MetricsRegistry (com.yammer.metrics.core.MetricsRegistry)1 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)1 HashedWheelTimer (io.netty.util.HashedWheelTimer)1 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)1 Configuration (org.apache.commons.configuration.Configuration)1