use of org.apache.drill.exec.proto.UserBitShared.QueryResult.QueryState in project drill by apache.
the class QueryBuilder method produceSummary.
private QuerySummary produceSummary(BufferingQueryEventListener listener) throws Exception {
long start = System.currentTimeMillis();
int recordCount = 0;
int batchCount = 0;
QueryId queryId = null;
QueryState state = null;
loop: for (; ; ) {
QueryEvent event = listener.get();
switch(event.type) {
case BATCH:
batchCount++;
recordCount += event.batch.getHeader().getRowCount();
event.batch.release();
break;
case EOF:
state = event.state;
break loop;
case ERROR:
throw event.error;
case QUERY_ID:
queryId = event.queryId;
break;
default:
throw new IllegalStateException("Unexpected event: " + event.type);
}
}
long end = System.currentTimeMillis();
long elapsed = end - start;
return new QuerySummary(queryId, recordCount, batchCount, elapsed, state);
}
use of org.apache.drill.exec.proto.UserBitShared.QueryResult.QueryState in project drill by apache.
the class TestDrillbitResilience method passThrough.
// To test pause and resume. Test hangs and times out if resume did not happen.
@Test
public void passThrough() {
final long before = countAllocatedMemory();
final WaitUntilCompleteListener listener = new WaitUntilCompleteListener() {
@Override
public void queryIdArrived(final QueryId queryId) {
super.queryIdArrived(queryId);
final ExtendedLatch trigger = new ExtendedLatch(1);
(new ResumingThread(queryId, ex, trigger)).start();
trigger.countDown();
}
};
final String controls = Controls.newBuilder().addPause(PojoRecordReader.class, "read-next").build();
setControls(controls);
QueryTestUtil.testWithListener(drillClient, QueryType.SQL, TEST_QUERY, listener);
final Pair<QueryState, Exception> result = listener.waitForCompletion();
assertStateCompleted(result, QueryState.COMPLETED);
final long after = countAllocatedMemory();
assertEquals(String.format("We are leaking %d bytes", after - before), before, after);
}
Aggregations