/** * Utility method to return display name for query state * @param queryState query state * @return display string for query state */ public static String getQueryStateDisplayName(QueryState queryState) { String displayName = queryStateDisplayMap.get(queryState); if (displayName == null) { displayName = queryState.name(); } return displayName; } }
private void checkCommonStates(final QueryState newState, final Exception exception) { switch (newState) { case FAILED: assert exception != null; recordNewState(QueryState.FAILED); queryManager.cancelExecutingFragments(drillbitContext); foremanResult.setFailed(exception); foremanResult.close(); return; } throw new IllegalStateException(String.format("Failure trying to change states: %s --> %s", state.name(), newState.name())); }
@Nullable @Override public ProfileInfo apply(@Nullable Entry<String, UserBitShared.QueryProfile> input) { if (input == null || input.getValue() == null) { return ProfileInfo.getDefault(); } //Constructing ProfileInfo final String queryID = input.getKey(); final QueryProfile profile = input.getValue(); //For cases where query was never queued final long assumedQueueEndTime = profile.getQueueWaitEnd()> 0 ? profile.getQueueWaitEnd() : profile.getPlanEnd(); return new ProfileInfo( queryID, new Timestamp(profile.getStart()), profile.getForeman().getAddress(), profile.getTotalFragments(), profile.getUser(), profile.getQueueName(), computeDuration(profile.getStart(), profile.getPlanEnd()), computeDuration(profile.getPlanEnd(), assumedQueueEndTime), computeDuration(assumedQueueEndTime, profile.getEnd()), profile.getState().name(), profile.getQuery() ); } });
private void cancellationRequested(final QueryState newState, final Exception exception) { switch (newState) { case FAILED: if (drillbitContext.getConfig().getBoolean(ExecConstants.RETURN_ERROR_FOR_FAILURE_IN_CANCELLED_FRAGMENTS)) { assert exception != null; recordNewState(QueryState.FAILED); foremanResult.setForceFailure(exception); } // proceed case CANCELED: case COMPLETED: /* * These amount to a completion of the cancellation requests' cleanup; * now we can clean up and send the result. */ foremanResult.close(); return; } throw new IllegalStateException(String.format("Failure trying to change states: %s --> %s", state.name(), newState.name())); }