Package org.eclipse.rdf4j.sail.helpers

## Class AbstractSail

- java.lang.Object
- - org.eclipse.rdf4j.sail.helpers.AbstractSail

- All Implemented Interfaces:
    `Sail`
  Direct Known Subclasses:
    `AbstractNotifyingSail`, `FedX`, `FedXConnection.SailBaseDefaultImpl`

      public abstract class AbstractSail
      extends Object
      implements Sail

  An abstract Sail implementation that takes care of common sail tasks, including proper closing of active connections and a grace period for active connections during shutdown of the store.
  Author:
    Herko ter Horst, jeen, Arjohn Kampman

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected long` | `connectionTimeOut` | Connection timeout on shutdown (in ms).
    `protected static long` | `DEFAULT_CONNECTION_TIMEOUT` | Default connection timeout on shutdown: 20,000 milliseconds.
    `protected static long` | `DEFAULT_ITERATION_SYNC_THRESHOLD` | default value for the Iteration item sync threshold
    `protected ReentrantReadWriteLock` | `initializationLock` | Lock used to synchronize the initialization state of a sail.

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `AbstractSail()` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `protected void` | `addSupportedIsolationLevel​(IsolationLevels level)` | Appends the provided `IsolationLevels` to the SAIL's list of supported isolation levels.
    `protected void` | `connectionClosed​(SailConnection connection)` | Signals to the store that the supplied connection has been closed; called by `AbstractSailConnection.close()`.
    `protected static boolean` | `debugEnabled()` |
    `SailConnection` | `getConnection()` | Opens a connection on the Sail which can be used to query and update data.
    `protected abstract SailConnection` | `getConnectionInternal()` | Returns a store-specific SailConnection object.
    `File` | `getDataDir()` | Gets the Sail's data directory.
    `IsolationLevel` | `getDefaultIsolationLevel()` | Retrieves the default `IsolationLevel` level on which transactions in this Sail operate.
    `long` | `getIterationCacheSyncThreshold()` | Retrieves the currently configured threshold for syncing query evaluation iteration caches to disk.
    `List<IsolationLevel>` | `getSupportedIsolationLevels()` | Retrieve the `IsolationLevel`s supported by this SAIL, ordered by increasing complexity.
    `void` | `init()` | Initializes the Sail.
    `protected void` | `initializeInternal()` | Do store-specific operations to initialize the store.
    `protected boolean` | `isInitialized()` | Checks whether the Sail has been initialized.
    `boolean` | `isTrackResultSize()` | Returns the status of the result size tracking for the query plan.
    `protected void` | `removeSupportedIsolationLevel​(IsolationLevel level)` | Removes all occurrences of the provided `IsolationLevels` in the list of supported Isolation levels.
    `void` | `setConnectionTimeOut​(long connectionTimeOut)` | Set connection timeout on shutdown (in ms).
    `void` | `setDataDir​(File dataDir)` | Sets the data directory for the Sail.
    `void` | `setDefaultIsolationLevel​(IsolationLevel defaultIsolationLevel)` | Sets the default `IsolationLevel` on which transactions in this Sail operate.
    `void` | `setIterationCacheSyncThreshold​(long iterationCacheSyncThreshold)` | Set the threshold for syncing query evaluation iteration caches to disk.
    `protected void` | `setSupportedIsolationLevels​(List<IsolationLevel> supportedIsolationLevels)` | Sets the list of supported `IsolationLevels`s for this SAIL.
    `protected void` | `setSupportedIsolationLevels​(IsolationLevel... supportedIsolationLevels)` | Sets the list of supported `IsolationLevels`s for this SAIL.
    `void` | `setTrackResultSize​(boolean trackResultSize)` | Enable or disable results size tracking for the query plan.
    `void` | `shutDown()` | Shuts down the Sail, giving it the opportunity to synchronize any stale data.
    `protected abstract void` | `shutDownInternal()` | Do store-specific operations to ensure proper shutdown of the store.
    `String` | `toString()` |

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.eclipse.rdf4j.sail.Sail

      `getValueFactory, isWritable`

- - ### Field Detail

    - #### DEFAULT_CONNECTION_TIMEOUT

          protected static final long DEFAULT_CONNECTION_TIMEOUT

      Default connection timeout on shutdown: 20,000 milliseconds.
      See Also:
        Constant Field Values

    - #### DEFAULT_ITERATION_SYNC_THRESHOLD

          protected static final long DEFAULT_ITERATION_SYNC_THRESHOLD

      default value for the Iteration item sync threshold
      See Also:
        Constant Field Values

    - #### initializationLock

          protected final ReentrantReadWriteLock initializationLock

      Lock used to synchronize the initialization state of a sail.
      - write lock: initialize(), shutDown()
      - read lock: getConnection()

    - #### connectionTimeOut

          protected volatile long connectionTimeOut

      Connection timeout on shutdown (in ms). Defaults to `DEFAULT_CONNECTION_TIMEOUT`.

  - ### Constructor Detail

    - #### AbstractSail

          public AbstractSail()

  - ### Method Detail

    - #### debugEnabled

          protected static boolean debugEnabled()

    - #### setConnectionTimeOut

          public void setConnectionTimeOut​(long connectionTimeOut)

      Set connection timeout on shutdown (in ms).
      Parameters:
        `connectionTimeOut` - timeout (in ms)

    - #### setDataDir

          public void setDataDir​(File dataDir)

      Description copied from interface: `Sail`
      Sets the data directory for the Sail. The Sail can use this directory for storage of data, parameters, etc. This directory must be set before the Sail is `initialized`.
      Specified by:
        `setDataDir` in interface `Sail`

    - #### getDataDir

          public File getDataDir()

      Description copied from interface: `Sail`
      Gets the Sail's data directory.
      Specified by:
        `getDataDir` in interface `Sail`
      See Also:
        `Sail.setDataDir(File)`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### isInitialized

          protected boolean isInitialized()

      Checks whether the Sail has been initialized. Sails are initialized from `initialization` until `shutdown`.
      Returns:
        true if the Sail has been initialized, false otherwise.

    - #### init

          public void init()
                    throws SailException

      Description copied from interface: `Sail`
      Initializes the Sail. Care should be taken that required initialization parameters have been set before this method is called. Please consult the specific Sail implementation for information about the relevant parameters.
      Specified by:
        `init` in interface `Sail`
      Throws:
        `SailException` - If the Sail could not be initialized.

    - #### initializeInternal

          protected void initializeInternal()
                                     throws SailException

      Do store-specific operations to initialize the store. The default implementation of this method does nothing.
      Throws:
        `SailException`

    - #### shutDown

          public void shutDown()
                        throws SailException

      Description copied from interface: `Sail`
      Shuts down the Sail, giving it the opportunity to synchronize any stale data. Care should be taken that all initialized Sails are being shut down before an application exits to avoid potential loss of data. Once shut down, a Sail can no longer be used until it is re-initialized.
      Specified by:
        `shutDown` in interface `Sail`
      Throws:
        `SailException` - If the Sail object encountered an error or unexpected situation internally.

    - #### shutDownInternal

          protected abstract void shutDownInternal()
                                            throws SailException

      Do store-specific operations to ensure proper shutdown of the store.
      Throws:
        `SailException`

    - #### getConnection

          public SailConnection getConnection()
                                       throws SailException

      Description copied from interface: `Sail`
      Opens a connection on the Sail which can be used to query and update data. Depending on how the implementation handles concurrent access, a call to this method might block when there is another open connection on this Sail.
      Specified by:
        `getConnection` in interface `Sail`
      Throws:
        `SailException` - If no transaction could be started, for example because the Sail is not writable.

    - #### getConnectionInternal

          protected abstract SailConnection getConnectionInternal()
                                                           throws SailException

      Returns a store-specific SailConnection object.
      Returns:
        A connection to the store.
      Throws:
        `SailException`

    - #### connectionClosed

          protected void connectionClosed​(SailConnection connection)

      Signals to the store that the supplied connection has been closed; called by `AbstractSailConnection.close()`.
      Parameters:
        `connection` - The connection that has been closed.

    - #### addSupportedIsolationLevel

          protected void addSupportedIsolationLevel​(IsolationLevels level)

      Appends the provided `IsolationLevels` to the SAIL's list of supported isolation levels.
      Parameters:
        `level` - a supported IsolationLevel.

    - #### removeSupportedIsolationLevel

          protected void removeSupportedIsolationLevel​(IsolationLevel level)

      Removes all occurrences of the provided `IsolationLevels` in the list of supported Isolation levels.
      Parameters:
        `level` - the isolation level to remove.

    - #### setSupportedIsolationLevels

          protected void setSupportedIsolationLevels​(List<IsolationLevel> supportedIsolationLevels)

      Sets the list of supported `IsolationLevels`s for this SAIL. The list is expected to be ordered in increasing complexity.
      Parameters:
        `supportedIsolationLevels` - a list of supported isolation levels.

    - #### setSupportedIsolationLevels

          protected void setSupportedIsolationLevels​(IsolationLevel... supportedIsolationLevels)

      Sets the list of supported `IsolationLevels`s for this SAIL. The list is expected to be ordered in increasing complexity.
      Parameters:
        `supportedIsolationLevels` - a list of supported isolation levels.

    - #### getSupportedIsolationLevels

          public List<IsolationLevel> getSupportedIsolationLevels()

      Description copied from interface: `Sail`
      Retrieve the `IsolationLevel`s supported by this SAIL, ordered by increasing complexity.
      Specified by:
        `getSupportedIsolationLevels` in interface `Sail`
      Returns:
        a non-empty List of supported Isolation Levels, in order of increasing complexity. Every SAIL supports at least one `IsolationLevel`.

    - #### getDefaultIsolationLevel

          public IsolationLevel getDefaultIsolationLevel()

      Description copied from interface: `Sail`
      Retrieves the default `IsolationLevel` level on which transactions in this Sail operate.
      Specified by:
        `getDefaultIsolationLevel` in interface `Sail`
      Returns:
        the `IsolationLevel` that will be used with `SailConnection.begin()`, for SAIL connections returned by `Sail.getConnection()`.

    - #### setDefaultIsolationLevel

          public void setDefaultIsolationLevel​(IsolationLevel defaultIsolationLevel)

      Sets the default `IsolationLevel` on which transactions in this Sail operate.
      Parameters:
        `defaultIsolationLevel` - The defaultIsolationLevel to set.

    - #### getIterationCacheSyncThreshold

          public long getIterationCacheSyncThreshold()

      Retrieves the currently configured threshold for syncing query evaluation iteration caches to disk.
      Returns:
        Returns the iterationCacheSyncThreshold.

    - #### setIterationCacheSyncThreshold

          public void setIterationCacheSyncThreshold​(long iterationCacheSyncThreshold)

      Set the threshold for syncing query evaluation iteration caches to disk.
      Parameters:
        `iterationCacheSyncThreshold` - The iterationCacheSyncThreshold to set.

    - #### isTrackResultSize

          public boolean isTrackResultSize()

      Returns the status of the result size tracking for the query plan. Useful to determine which parts of a query plan generated the most data.
      Returns:
        true if result size tracking is enabled.

    - #### setTrackResultSize

          public void setTrackResultSize​(boolean trackResultSize)

      Enable or disable results size tracking for the query plan. Useful to determine which parts of a query plan generated the most data.
      Parameters:
        `trackResultSize` - true to enable tracking.