Class SqlJetDefaultBusyHandler

java.lang.Object
org.tmatesoft.sqljet.core.table.SqlJetDefaultBusyHandler
All Implemented Interfaces:
ISqlJetBusyHandler

public class SqlJetDefaultBusyHandler extends Object implements ISqlJetBusyHandler

Implementation of SQLJet busy handlers. Used by default in SqlJetDb.

Performs some number of retries (by default 10 or SQLJET_BUSY_RETRIES system property value) per every time interval (by default 100 milliseconds or SQLJET_BUSY_SLEEP system property value in milliseconds).

Author:
TMate Software Ltd., Sergey Scherbina (sergey.scherbina@gmail.com)
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Name of system property which defines retries count by default.
    static final String
    Name of system property which defines time wait by default.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates busy handler with default parameters.
    SqlJetDefaultBusyHandler(int retries, int sleep)
    Creates busy handler with custom parameters.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    call(int number)
    Callback which implements busy handler.
    int
    Returns number of attempts to make to lock database.
    int
    Returns sleep time interval in milliseconds between retries to lock database.
    boolean
    Check is busy handler to cancel.
    void
    setCancel(boolean cancel)
    Allow cancel urgently busy retries.
    void
    setRetries(int retries)
    Sets number of attempts to make to lock database.
    void
    setSleep(int sleep)
    Sets sleep time interval in milliseconds between retries to lock database.

    Methods inherited from class java.lang.Object

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

    • SQLJET_BUSY_RETRIES_PROPERTY

      public static final String SQLJET_BUSY_RETRIES_PROPERTY
      Name of system property which defines retries count by default.
      See Also:
    • SQLJET_BUSY_SLEEP_PROPERTY

      public static final String SQLJET_BUSY_SLEEP_PROPERTY
      Name of system property which defines time wait by default.
      See Also:
  • Constructor Details

    • SqlJetDefaultBusyHandler

      public SqlJetDefaultBusyHandler()
      Creates busy handler with default parameters.
    • SqlJetDefaultBusyHandler

      public SqlJetDefaultBusyHandler(int retries, int sleep)
      Creates busy handler with custom parameters.
      Parameters:
      retries - number of retries to perform
      sleep - sleep time interval in milliseconds between retries to lock database.
  • Method Details

    • getRetries

      public int getRetries()
      Returns number of attempts to make to lock database.
      Returns:
      number of attempts.
    • setRetries

      public void setRetries(int retries)
      Sets number of attempts to make to lock database.
      Parameters:
      retries - number of attempts.
    • getSleep

      public int getSleep()
      Returns sleep time interval in milliseconds between retries to lock database.
      Returns:
      sleep interval time in milliseconds.
    • setSleep

      public void setSleep(int sleep)
      Sets sleep time interval in milliseconds between retries to lock database.
      Parameters:
      sleep - interval time in milliseconds.
    • setCancel

      public void setCancel(boolean cancel)
      Allow cancel urgently busy retries. To cancel set it to true - in this case busy handler will not wait in next retry.
      Parameters:
      cancel - if true then busy handler will not wait.
    • isCancel

      public boolean isCancel()
      Check is busy handler to cancel.
      Returns:
      true if lock attempts should be cancelled.
    • call

      public boolean call(int number)
      Description copied from interface: ISqlJetBusyHandler

      Callback which implements busy handler.

      To method call() is passed number of retry to obtain database lock. If call() returns true then retries to locking still continue. If call() returns false then will be thrown SqlJetException with SqlJetErrorCode.BUSY.

      Specified by:
      call in interface ISqlJetBusyHandler
      Parameters:
      number - number of retry to obtain lock on database.
      Returns:
      true if retries will continue or false if retries will stop.