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();
}
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());
}
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);
}
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);
}
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");
}
Aggregations