Search in sources :

Example 1 with QueryScheduler

use of com.linkedin.pinot.core.query.scheduler.QueryScheduler in project pinot by linkedin.

the class ScheduledRequestHandlerTest method setupTestMethod.

@BeforeTest
public void setupTestMethod() {
    serverMetrics = new ServerMetrics(new MetricsRegistry());
    channelHandlerContext = mock(ChannelHandlerContext.class, RETURNS_DEEP_STUBS);
    when(channelHandlerContext.channel().remoteAddress()).thenAnswer(new Answer<InetSocketAddress>() {

        @Override
        public InetSocketAddress answer(InvocationOnMock invocationOnMock) throws Throwable {
            return new InetSocketAddress("localhost", 60000);
        }
    });
    queryScheduler = mock(QueryScheduler.class);
    queryExecutor = new ServerQueryExecutorV1Impl();
}
Also used : MetricsRegistry(com.yammer.metrics.core.MetricsRegistry) QueryScheduler(com.linkedin.pinot.core.query.scheduler.QueryScheduler) InetSocketAddress(java.net.InetSocketAddress) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ServerQueryExecutorV1Impl(com.linkedin.pinot.core.query.executor.ServerQueryExecutorV1Impl) ServerMetrics(com.linkedin.pinot.common.metrics.ServerMetrics) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) BeforeTest(org.testng.annotations.BeforeTest)

Example 2 with QueryScheduler

use of com.linkedin.pinot.core.query.scheduler.QueryScheduler in project pinot by linkedin.

the class ScheduledRequestHandlerTest method testQueryProcessingException.

@Test
public void testQueryProcessingException() throws Exception {
    ScheduledRequestHandler handler = new ScheduledRequestHandler(new QueryScheduler(queryExecutor) {

        @Override
        public ListenableFuture<DataTable> submit(QueryRequest queryRequest) {
            return queryWorkers.submit(new Callable<DataTable>() {

                @Override
                public DataTable call() throws Exception {
                    throw new RuntimeException("query processing error");
                }
            });
        }
    }, serverMetrics);
    ByteBuf requestBuf = getSerializedInstanceRequest(getInstanceRequest());
    ListenableFuture<byte[]> responseFuture = handler.processRequest(channelHandlerContext, requestBuf);
    byte[] bytes = responseFuture.get(2, TimeUnit.SECONDS);
    // we get DataTable with exception information in case of query processing exception
    Assert.assertTrue(bytes.length > 0);
    DataTable expectedDT = new DataTableImplV2();
    expectedDT.addException(QueryException.INTERNAL_ERROR);
    Assert.assertEquals(bytes, expectedDT.toBytes());
}
Also used : DataTable(com.linkedin.pinot.common.utils.DataTable) QueryScheduler(com.linkedin.pinot.core.query.scheduler.QueryScheduler) QueryRequest(com.linkedin.pinot.common.query.QueryRequest) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) DataTableImplV2(com.linkedin.pinot.core.common.datatable.DataTableImplV2) ByteBuf(io.netty.buffer.ByteBuf) Callable(java.util.concurrent.Callable) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 3 with QueryScheduler

use of com.linkedin.pinot.core.query.scheduler.QueryScheduler in project pinot by linkedin.

the class ScheduledRequestHandlerTest method testValidQueryResponse.

@Test
public void testValidQueryResponse() throws InterruptedException, ExecutionException, TimeoutException, IOException {
    ScheduledRequestHandler handler = new ScheduledRequestHandler(new QueryScheduler(queryExecutor) {

        @Override
        public ListenableFuture<DataTable> submit(QueryRequest queryRequest) {
            return queryRunners.submit(new Callable<DataTable>() {

                @Override
                public DataTable call() throws Exception {
                    String[] columns = new String[] { "foo", "bar" };
                    FieldSpec.DataType[] columnTypes = new FieldSpec.DataType[] { FieldSpec.DataType.STRING, FieldSpec.DataType.INT };
                    DataSchema dataSchema = new DataSchema(columns, columnTypes);
                    DataTableBuilder dtBuilder = new DataTableBuilder(dataSchema);
                    dtBuilder.startRow();
                    dtBuilder.setColumn(0, "mars");
                    dtBuilder.setColumn(1, 10);
                    dtBuilder.finishRow();
                    dtBuilder.startRow();
                    dtBuilder.setColumn(0, "jupiter");
                    dtBuilder.setColumn(1, 100);
                    dtBuilder.finishRow();
                    return dtBuilder.build();
                }
            });
        }
    }, serverMetrics);
    ByteBuf requestBuf = getSerializedInstanceRequest(getInstanceRequest());
    ListenableFuture<byte[]> responseFuture = handler.processRequest(channelHandlerContext, requestBuf);
    byte[] responseBytes = responseFuture.get(2, TimeUnit.SECONDS);
    DataTable responseDT = DataTableFactory.getDataTable(responseBytes);
    Assert.assertEquals(responseDT.getNumberOfRows(), 2);
    Assert.assertEquals(responseDT.getString(0, 0), "mars");
    Assert.assertEquals(responseDT.getInt(0, 1), 10);
    Assert.assertEquals(responseDT.getString(1, 0), "jupiter");
    Assert.assertEquals(responseDT.getInt(1, 1), 100);
}
Also used : DataTable(com.linkedin.pinot.common.utils.DataTable) QueryScheduler(com.linkedin.pinot.core.query.scheduler.QueryScheduler) QueryRequest(com.linkedin.pinot.common.query.QueryRequest) ByteBuf(io.netty.buffer.ByteBuf) Callable(java.util.concurrent.Callable) DataSchema(com.linkedin.pinot.common.utils.DataSchema) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) DataTableBuilder(com.linkedin.pinot.core.common.datatable.DataTableBuilder) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 4 with QueryScheduler

use of com.linkedin.pinot.core.query.scheduler.QueryScheduler in project pinot by linkedin.

the class FileBasedServer method main.

public static void main(String[] args) throws Exception {
    //Process Command Line to get config and port
    processCommandLineArgs(args);
    LOGGER.info("Trying to build server config");
    MetricsRegistry metricsRegistry = new MetricsRegistry();
    ServerBuilder serverBuilder = new ServerBuilder(new File(_serverConfigPath), metricsRegistry);
    LOGGER.info("Trying to build InstanceDataManager");
    final DataManager instanceDataManager = serverBuilder.buildInstanceDataManager();
    LOGGER.info("Trying to start InstanceDataManager");
    instanceDataManager.start();
    //    bootstrapSegments(instanceDataManager);
    LOGGER.info("Trying to build QueryExecutor");
    final QueryExecutor queryExecutor = serverBuilder.buildQueryExecutor(instanceDataManager);
    final QueryScheduler queryScheduler = serverBuilder.buildQueryScheduler(queryExecutor);
    LOGGER.info("Trying to build RequestHandlerFactory");
    RequestHandlerFactory simpleRequestHandlerFactory = serverBuilder.buildRequestHandlerFactory(queryScheduler);
    LOGGER.info("Trying to build NettyServer");
    NettyServer nettyServer = new NettyTCPServer(_serverPort, simpleRequestHandlerFactory, null);
    Thread serverThread = new Thread(nettyServer);
    ShutdownHook shutdownHook = new ShutdownHook(nettyServer);
    serverThread.start();
    Runtime.getRuntime().addShutdownHook(shutdownHook);
}
Also used : MetricsRegistry(com.yammer.metrics.core.MetricsRegistry) QueryScheduler(com.linkedin.pinot.core.query.scheduler.QueryScheduler) QueryExecutor(com.linkedin.pinot.common.query.QueryExecutor) RequestHandlerFactory(com.linkedin.pinot.transport.netty.NettyServer.RequestHandlerFactory) DataManager(com.linkedin.pinot.common.data.DataManager) NettyTCPServer(com.linkedin.pinot.transport.netty.NettyTCPServer) File(java.io.File) NettyServer(com.linkedin.pinot.transport.netty.NettyServer)

Example 5 with QueryScheduler

use of com.linkedin.pinot.core.query.scheduler.QueryScheduler in project pinot by linkedin.

the class InstanceServerStarter method main.

public static void main(String[] args) throws Exception {
    File confDir = new File(InstanceServerStarter.class.getClassLoader().getResource("conf").toURI());
    LOGGER.info("Trying to build server config");
    MetricsRegistry metricsRegistry = new MetricsRegistry();
    ServerBuilder serverBuilder = new ServerBuilder(confDir.getAbsolutePath(), metricsRegistry);
    LOGGER.info("Trying to build InstanceDataManager");
    final DataManager instanceDataManager = serverBuilder.buildInstanceDataManager();
    LOGGER.info("Trying to start InstanceDataManager");
    instanceDataManager.start();
    //    bootstrapSegments(instanceDataManager);
    LOGGER.info("Trying to build QueryExecutor");
    final QueryExecutor queryExecutor = serverBuilder.buildQueryExecutor(instanceDataManager);
    QueryScheduler queryScheduler = serverBuilder.buildQueryScheduler(queryExecutor);
    RequestHandlerFactory simpleRequestHandlerFactory = serverBuilder.buildRequestHandlerFactory(queryScheduler);
    LOGGER.info("Trying to build NettyServer");
    System.out.println(getMaxQuery());
    String queryJson = "";
    System.out.println(getCountQuery().toString());
    sendQueryToQueryExecutor(getCountQuery(), queryExecutor, queryScheduler, serverBuilder.getServerMetrics());
    sendQueryToQueryExecutor(getSumQuery(), queryExecutor, queryScheduler, serverBuilder.getServerMetrics());
    sendQueryToQueryExecutor(getMaxQuery(), queryExecutor, queryScheduler, serverBuilder.getServerMetrics());
    sendQueryToQueryExecutor(getMinQuery(), queryExecutor, queryScheduler, serverBuilder.getServerMetrics());
    LOGGER.info("Trying to build RequestHandlerFactory");
}
Also used : MetricsRegistry(com.yammer.metrics.core.MetricsRegistry) QueryScheduler(com.linkedin.pinot.core.query.scheduler.QueryScheduler) QueryExecutor(com.linkedin.pinot.common.query.QueryExecutor) RequestHandlerFactory(com.linkedin.pinot.transport.netty.NettyServer.RequestHandlerFactory) DataManager(com.linkedin.pinot.common.data.DataManager) File(java.io.File) ServerBuilder(com.linkedin.pinot.server.starter.ServerBuilder)

Aggregations

QueryScheduler (com.linkedin.pinot.core.query.scheduler.QueryScheduler)5 MetricsRegistry (com.yammer.metrics.core.MetricsRegistry)3 BeforeTest (org.testng.annotations.BeforeTest)3 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)2 DataManager (com.linkedin.pinot.common.data.DataManager)2 QueryExecutor (com.linkedin.pinot.common.query.QueryExecutor)2 QueryRequest (com.linkedin.pinot.common.query.QueryRequest)2 DataTable (com.linkedin.pinot.common.utils.DataTable)2 RequestHandlerFactory (com.linkedin.pinot.transport.netty.NettyServer.RequestHandlerFactory)2 ByteBuf (io.netty.buffer.ByteBuf)2 File (java.io.File)2 Callable (java.util.concurrent.Callable)2 Test (org.testng.annotations.Test)2 ServerMetrics (com.linkedin.pinot.common.metrics.ServerMetrics)1 DataSchema (com.linkedin.pinot.common.utils.DataSchema)1 DataTableBuilder (com.linkedin.pinot.core.common.datatable.DataTableBuilder)1 DataTableImplV2 (com.linkedin.pinot.core.common.datatable.DataTableImplV2)1 ServerQueryExecutorV1Impl (com.linkedin.pinot.core.query.executor.ServerQueryExecutorV1Impl)1 ServerBuilder (com.linkedin.pinot.server.starter.ServerBuilder)1 NettyServer (com.linkedin.pinot.transport.netty.NettyServer)1