Github user laurentgo commented on a diff in the pull request: https://github.com/apache/drill/pull/858#discussion_r123294533 --- Diff: exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillStatementImpl.java --- @@ -497,14 +594,64 @@ public boolean isPoolable() throws SQLException { @Override public void closeOnCompletion() throws SQLException { - throwIfClosed(); + throwIfTimedOutOrClosed(); super.closeOnCompletion(); } @Override public boolean isCloseOnCompletion() throws SQLException { - throwIfClosed(); + throwIfTimedOutOrClosed(); return super.isCloseOnCompletion(); } } + +/** + * Timeout Trigger required for canceling of running queries + */ +class TimeoutTrigger implements Callable<Boolean> { + private int timeoutInSeconds; + + /** + * Get Timeout period in seconds + */ + public int getTimeoutInSeconds() { + return timeoutInSeconds; + } + + private DrillStatementImpl statementHandle; + + //Default Constructor is Invalid + @SuppressWarnings("unused") + private TimeoutTrigger() {} + + /** + * Timeout Constructor + * @param stmtContext Statement Handle + * @param timeoutInSec Timeout defined in seconds + */ + TimeoutTrigger(DrillStatementImpl stmtContext, int timeoutInSec) { + timeoutInSeconds = timeoutInSec; + statementHandle = stmtContext; + } + + @Override + public Boolean call() throws Exception { + try { + Thread.sleep(timeoutInSeconds*1000L); --- End diff -- `TimeUnit.SECONDS.sleep(timeoutInSeconds)`
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---