@Test public void testRequestMaxActive() throws Exception { agds.latch = new CountDownLatch(3); int toRun = 2; CountDownLatch submitted = new CountDownLatch(toRun); ExecutorService es = Executors.newCachedThreadPool(); final DQPWorkContext context = DQPWorkContext.getWorkContext(); final AtomicInteger counter = new AtomicInteger(); es.invokeAll(Collections.nCopies(toRun, new Callable<Void>() { @Override public Void call() throws Exception { DQPWorkContext.setWorkContext(context); RequestMessage reqMsg = exampleRequestMessage("select * FROM BQT1.SmallA"); DQPWorkContext.getWorkContext().getSession().setSessionId("1"); DQPWorkContext.getWorkContext().getSession().setUserName("a"); Future<ResultsMessage> message = null; try { message = core.executeRequest(counter.getAndIncrement(), reqMsg); } finally { submitted.countDown(); } assertNotNull(core.getClientState("1", false)); submitted.await(); //after this, both will be submitted agds.latch.countDown(); //allow the execution to proceed message.get(500000, TimeUnit.MILLISECONDS); return null; } })); assertEquals(1, this.core.getMaxWaitingPlanWatermark()); }
public static EngineStatisticsMetadata createEngineStats( int activeSessionsCount, BufferServiceImpl bufferService, DQPCore dqp) { EngineStatisticsMetadata stats = new EngineStatisticsMetadata(); stats.setSessionCount(activeSessionsCount); stats.setTotalMemoryUsedInKB(bufferService.getHeapBufferInUseKb()); stats.setMemoryUsedByActivePlansInKB(bufferService.getMemoryReservedByActivePlansKb()); stats.setDiskWriteCount(bufferService.getDiskWriteCount()); stats.setDiskReadCount(bufferService.getDiskReadCount()); stats.setCacheReadCount(bufferService.getStorageReadCount()); stats.setCacheWriteCount(bufferService.getStorageWriteCount()); stats.setDiskSpaceUsedInMB(bufferService.getUsedDiskBufferSpaceMb()); stats.setActivePlanCount(dqp.getActivePlanCount()); stats.setWaitPlanCount(dqp.getWaitingPlanCount()); stats.setMaxWaitPlanWaterMark(dqp.getMaxWaitingPlanWatermark()); return stats; }