[ 
https://issues.apache.org/jira/browse/DRILL-3640?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16057774#comment-16057774
 ] 

ASF GitHub Bot commented on DRILL-3640:
---------------------------------------

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)`


> Drill JDBC driver support Statement.setQueryTimeout(int)
> --------------------------------------------------------
>
>                 Key: DRILL-3640
>                 URL: https://issues.apache.org/jira/browse/DRILL-3640
>             Project: Apache Drill
>          Issue Type: New Feature
>          Components: Client - JDBC
>    Affects Versions: 1.2.0
>            Reporter: Chun Chang
>            Assignee: Kunal Khatua
>             Fix For: 1.11.0
>
>
> It would be nice if we have this implemented. Run away queries can be 
> automatically canceled by setting the timeout. 
> java.sql.SQLFeatureNotSupportedException: Setting network timeout is not 
> supported.
>       at 
> org.apache.drill.jdbc.impl.DrillStatementImpl.setQueryTimeout(DrillStatementImpl.java:152)



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to