use of org.apache.druid.java.util.common.guava.SequenceWrapper in project druid by druid-io.
the class QuerySchedulerTest method testHiLoLo.
@Test
public void testHiLoLo() throws ExecutionException, InterruptedException {
TopNQuery report = makeReportQuery();
ListenableFuture<?> future = executorService.submit(() -> {
try {
Query<?> scheduledReport = scheduler.prioritizeAndLaneQuery(QueryPlus.wrap(report), ImmutableSet.of());
Assert.assertNotNull(scheduledReport);
Assert.assertEquals(HiLoQueryLaningStrategy.LOW, QueryContexts.getLane(scheduledReport));
Sequence<Integer> underlyingSequence = makeSequence(10);
underlyingSequence = Sequences.wrap(underlyingSequence, new SequenceWrapper() {
@Override
public void before() {
Assert.assertEquals(4, scheduler.getTotalAvailableCapacity());
Assert.assertEquals(1, scheduler.getLaneAvailableCapacity(HiLoQueryLaningStrategy.LOW));
}
});
Sequence<Integer> results = scheduler.run(scheduledReport, underlyingSequence);
int rowCount = consumeAndCloseSequence(results);
Assert.assertEquals(10, rowCount);
} catch (IOException ex) {
throw new RuntimeException(ex);
}
});
future.get();
assertHiLoHasAllCapacity(TEST_HI_CAPACITY, TEST_LO_CAPACITY);
Assert.assertEquals(QueryScheduler.UNAVAILABLE, scheduler.getLaneAvailableCapacity("non-existent"));
}
use of org.apache.druid.java.util.common.guava.SequenceWrapper in project druid by druid-io.
the class QuerySchedulerTest method testHiLoHi.
@Test
public void testHiLoHi() throws ExecutionException, InterruptedException {
TopNQuery interactive = makeInteractiveQuery();
ListenableFuture<?> future = executorService.submit(() -> {
try {
Query<?> scheduled = scheduler.prioritizeAndLaneQuery(QueryPlus.wrap(interactive), ImmutableSet.of());
Assert.assertNotNull(scheduled);
Sequence<Integer> underlyingSequence = makeSequence(10);
underlyingSequence = Sequences.wrap(underlyingSequence, new SequenceWrapper() {
@Override
public void before() {
Assert.assertEquals(4, scheduler.getTotalAvailableCapacity());
Assert.assertEquals(2, scheduler.getLaneAvailableCapacity(HiLoQueryLaningStrategy.LOW));
}
});
Sequence<Integer> results = scheduler.run(scheduled, underlyingSequence);
int rowCount = consumeAndCloseSequence(results);
Assert.assertEquals(10, rowCount);
} catch (IOException ex) {
throw new RuntimeException(ex);
}
});
future.get();
Assert.assertEquals(TEST_HI_CAPACITY, scheduler.getTotalAvailableCapacity());
Assert.assertEquals(QueryScheduler.UNAVAILABLE, scheduler.getLaneAvailableCapacity("non-existent"));
}
Aggregations