示例#1
0
    private void finalizeQuery(Query query, QueryCompletedEvent event) {
      MasterPlan masterPlan = query.getPlan();

      ExecutionBlock terminal = query.getPlan().getTerminalBlock();
      DataChannel finalChannel =
          masterPlan.getChannel(event.getExecutionBlockId(), terminal.getId());
      Path finalOutputDir = commitOutputData(query);

      QueryHookExecutor hookExecutor = new QueryHookExecutor(query.context.getQueryMasterContext());
      try {
        hookExecutor.execute(
            query.context.getQueryContext(), query, event.getExecutionBlockId(), finalOutputDir);
      } catch (Exception e) {
        query.eventHandler.handle(
            new QueryDiagnosticsUpdateEvent(query.id, ExceptionUtils.getStackTrace(e)));
      }
    }
示例#2
0
 @Override
 public QueryState transition(Query query, QueryEvent queryEvent) {
   QueryCompletedEvent subQueryEvent = (QueryCompletedEvent) queryEvent;
   QueryState finalState;
   if (subQueryEvent.getState() == SubQueryState.SUCCEEDED) {
     finalizeQuery(query, subQueryEvent);
     finalState = QueryState.QUERY_SUCCEEDED;
   } else if (subQueryEvent.getState() == SubQueryState.FAILED) {
     finalState = QueryState.QUERY_FAILED;
   } else if (subQueryEvent.getState() == SubQueryState.KILLED) {
     finalState = QueryState.QUERY_KILLED;
   } else {
     finalState = QueryState.QUERY_ERROR;
   }
   query.eventHandler.handle(new QueryMasterQueryCompletedEvent(query.getId()));
   query.setFinishTime();
   return finalState;
 }