diff options
author | Salim Achouche <sachouche2@gmail.com> | 2018-07-02 19:13:26 -0700 |
---|---|---|
committer | Sorabh Hamirwasia <sorabh@apache.org> | 2018-07-12 13:40:53 -0700 |
commit | cfe61eb9b6ed4d636a26c76dbd12df26f38ba672 (patch) | |
tree | ab3700d85bf5914306ecda824960548908fea16c /common | |
parent | c64436774387e80fd9b0ff6e9cd7d42c9aa7a961 (diff) |
DRILL-6578: Handle query cancellation in Parquet reader
closes #1360
Diffstat (limited to 'common')
-rw-r--r-- | common/src/main/java/org/apache/drill/common/exceptions/DrillRuntimeException.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/common/src/main/java/org/apache/drill/common/exceptions/DrillRuntimeException.java b/common/src/main/java/org/apache/drill/common/exceptions/DrillRuntimeException.java index 98b1a9d03..b6ced84d0 100644 --- a/common/src/main/java/org/apache/drill/common/exceptions/DrillRuntimeException.java +++ b/common/src/main/java/org/apache/drill/common/exceptions/DrillRuntimeException.java @@ -48,4 +48,22 @@ public class DrillRuntimeException extends RuntimeException { public static void format(Throwable cause, String format, Object...args) { throw new DrillRuntimeException(String.format(format, args), cause); } + + /** + * This method can be called within loops to check whether the current thread has been + * interrupted; it ensures that operator implementation can respond to query cancellation + * in a timely manner. + * + * <p>Calling this method will result in the following behavior: + * <ul> + * <li>Throws a runtime exception if current thread interrupt flag has been set + * <li>Clears current thread interrupt flag + * </ul> + */ + public static void checkInterrupted() { + if (Thread.interrupted()) { + // This exception will ensure the control layer will immediately get back control + throw new DrillRuntimeException("Interrupt received; aborting current operation"); + } + } } |