Class GenericStatementContext.CancelQueryTask

  • All Implemented Interfaces:
    java.lang.Runnable
    Enclosing class:
    GenericStatementContext

    private static class GenericStatementContext.CancelQueryTask
    extends java.util.TimerTask
    This is a TimerTask that is responsible for timing out statements, typically when an application has called Statement.setQueryTimeout(). When the application invokes execute() on a statement object, or fetches data on a ResultSet, a StatementContext object is allocated for the duration of the execution in the engine (until control is returned to the application). When the StatementContext object is assigned with setInUse(), a CancelQueryTask is scheduled if a timeout > 0 has been set.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private StatementContext statementContext
      Reference to the StatementContext for the executing statement which might time out.
    • Constructor Summary

      Constructors 
      Constructor Description
      CancelQueryTask​(StatementContext ctx)
      Initializes a new task for timing out a statement's execution.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void forgetContext()
      Stops this task and prevents it from cancelling a statement.
      void run()
      Invoked by a Timer class to cancel an executing statement.
      • Methods inherited from class java.util.TimerTask

        cancel, scheduledExecutionTime
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • statementContext

        private StatementContext statementContext
        Reference to the StatementContext for the executing statement which might time out.
    • Constructor Detail

      • CancelQueryTask

        public CancelQueryTask​(StatementContext ctx)
        Initializes a new task for timing out a statement's execution. This does not schedule it for execution, the caller is responsible for calling Timer.schedule() with this object as parameter.
    • Method Detail

      • run

        public void run()
        Invoked by a Timer class to cancel an executing statement. This method just sets a volatile flag in the associated StatementContext object by calling StatementContext.cancel(); it is the responsibility of the thread executing the statement to check this flag regularly.
        Specified by:
        run in interface java.lang.Runnable
        Specified by:
        run in class java.util.TimerTask
      • forgetContext

        public void forgetContext()
        Stops this task and prevents it from cancelling a statement. Guarantees that after this method returns, the associated StatementContext object will not be tampered with by this task. Thus, the StatementContext object may safely be allocated to other executing statements.