Class Foreman.ForemanResult

java.lang.Object
org.apache.drill.exec.work.foreman.Foreman.ForemanResult
All Implemented Interfaces:
AutoCloseable
Enclosing class:
Foreman

public class Foreman.ForemanResult extends Object implements AutoCloseable
Manages the end-state processing for Foreman. End-state processing is tricky, because even if a query appears to succeed, but we then encounter a problem during cleanup, we still want to mark the query as failed. So we have to construct the successful result we would send, and then clean up before we send that result, possibly changing that result if we encounter a problem during cleanup. We only send the result when there is nothing left to do, so it will account for any possible problems. The idea here is to make close()ing the ForemanResult do the final cleanup and sending. Closing the result must be the last thing that is done by Foreman.
  • Constructor Details

    • ForemanResult

      public ForemanResult()
  • Method Details

    • setCompleted

      public void setCompleted(UserBitShared.QueryResult.QueryState queryState)
      Set up the result for a COMPLETED or CANCELED state.

      Note that before sending this result, we execute cleanup steps that could result in this result still being changed to a FAILED state.

      Parameters:
      queryState - one of COMPLETED or CANCELED
    • setFailed

      public void setFailed(Exception exception)
      Set up the result for a FAILED state.

      Failures that occur during cleanup processing will be added as suppressed exceptions.

      Parameters:
      exception - the exception that led to the FAILED state
    • setForceFailure

      public void setForceFailure(Exception exception)
      Ignore the current status and force the given failure as current status. NOTE: Used only for testing purposes. Shouldn't be used in production.
    • getException

      public Exception getException()
      Expose the current exception (if it exists). This is useful for secondary reporting to the query profile.
      Returns:
      the current Foreman result exception or null.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable