You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by arina-ielchiieva <gi...@git.apache.org> on 2017/12/04 16:06:30 UTC

[GitHub] drill pull request #1051: DRILL-5963: Query state process improvements

Github user arina-ielchiieva commented on a diff in the pull request:

    https://github.com/apache/drill/pull/1051#discussion_r154117496
  
    --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/Foreman.java ---
    @@ -873,105 +791,133 @@ public void close() throws Exception {
         }
       }
     
    -  private void moveToState(final QueryState newState, final Exception exception) {
    -    logger.debug(queryIdString + ": State change requested {} --> {}", state, newState,
    -      exception);
    +  public synchronized void moveToState(final QueryState newState, final Exception exception) {
    +    logger.debug(queryIdString + ": State change requested {} --> {}", state, newState, exception);
         switch (state) {
    -    case ENQUEUED:
    -      switch (newState) {
    -      case FAILED:
    -        Preconditions.checkNotNull(exception, "exception cannot be null when new state is failed");
    -        recordNewState(newState);
    -        foremanResult.setFailed(exception);
    -        foremanResult.close();
    -        return;
    +      case PLANNING:
    +        switch (newState) {
    +          case ENQUEUED:
    +            recordNewState(newState);
    +            enqueuedQueries.inc();
    +            return;
    +          case CANCELLATION_REQUESTED:
    +            assert exception == null;
    +            recordNewState(newState);
    +            foremanResult.setCompleted(QueryState.CANCELED);
    +            foremanResult.close();
    +            return;
    +          case FAILED:
    +            assert exception != null;
    +            recordNewState(newState);
    +            foremanResult.setFailed(exception);
    +            foremanResult.close();
    +            return;
    +        }
    +        break;
    +      case ENQUEUED:
    +        enqueuedQueries.dec();
    +        queryManager.markQueueWaitEndTime();
    +        switch (newState) {
    --- End diff --
    
    Done.


---