}else{
this.lease = smallSemaphore.acquire(this.queueTimeout, TimeUnit.MILLISECONDS);
}
}
QueryWorkUnit work = parallelizer.getFragments(context.getOptions().getSessionOptionList(), context.getCurrentEndpoint(),
queryId, context.getActiveEndpoints(), context.getPlanReader(), rootFragment, planningSet);
this.context.getWorkBus().setFragmentStatusListener(work.getRootFragment().getHandle().getQueryId(), fragmentManager);
List<PlanFragment> leafFragments = Lists.newArrayList();
List<PlanFragment> intermediateFragments = Lists.newArrayList();
// store fragments in distributed grid.
logger.debug("Storing fragments");
List<Future<PlanFragment>> queue = new LinkedList<>();
for (PlanFragment f : work.getFragments()) {
// store all fragments in grid since they are part of handshake.
queue.add(context.getCache().getMap(FRAGMENT_CACHE).put(f.getHandle(), f));
if (f.getLeafFragment()) {
leafFragments.add(f);
} else {
intermediateFragments.add(f);
}
}
for (Future<PlanFragment> f : queue) {
try {
f.get(10, TimeUnit.SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
throw new ExecutionSetupException("failure while storing plan fragments", e);
}
}
int totalFragments = 1 + intermediateFragments.size() + leafFragments.size();
fragmentManager.getStatus().setTotalFragments(totalFragments);
fragmentManager.getStatus().updateCache();
logger.debug("Fragments stored.");
logger.debug("Submitting fragments to run.");
fragmentManager.runFragments(bee, work.getRootFragment(), work.getRootOperator(), initiatingClient, leafFragments, intermediateFragments);
logger.debug("Fragments running.");
state.updateState(QueryState.PENDING, QueryState.RUNNING);
} catch (Exception e) {