Class XodusKVDatabase

java.lang.Object
io.permazen.kv.xodus.XodusKVDatabase
All Implemented Interfaces:
KVDatabase

@ThreadSafe public class XodusKVDatabase extends Object implements KVDatabase
KVDatabase view of an Xodus database.

A database directory is the only required configuration property. Instances may be stopped and (re)started multiple times.

Transactions implement XodusKVTransaction.readOnlySnapshot().

  • Field Details

  • Constructor Details

    • XodusKVDatabase

      public XodusKVDatabase()
  • Method Details

    • getDirectory

      public File getDirectory()
      Get the filesystem directory containing the database.
      Returns:
      database directory
    • setDirectory

      public void setDirectory(File directory)
      Configure the filesystem directory containing the database. Required property.
      Parameters:
      directory - database directory
      Throws:
      IllegalStateException - if this instance is already start()ed
    • getStoreName

      public String getStoreName()
      Get the Xodus store name to use.
      Returns:
      configured store name
    • setStoreName

      public void setStoreName(String storeName)
      Set the Xodus store name to use.

      Default value is DEFAULT_STORE_NAME.

      Parameters:
      storeName - store name
      Throws:
      IllegalStateException - if this instance is already start()ed
      IllegalArgumentException - if storeName is null
    • getEnvironmentConfig

      public jetbrains.exodus.env.EnvironmentConfig getEnvironmentConfig()
      Get the EnvironmentConfig that will be used when creating the associated Environment.
      Returns:
      environment config
    • setEnvironmentConfig

      public void setEnvironmentConfig(jetbrains.exodus.env.EnvironmentConfig config)
      Set the EnvironmentConfig to be used when creating the associated Environment.

      Default value is EnvironmentConfig.DEFAULT.

      Parameters:
      config - environment config
      Throws:
      IllegalStateException - if this instance is already start()ed
      IllegalArgumentException - if config is null
    • getEnvironment

      public jetbrains.exodus.env.Environment getEnvironment()
      Get the underlying Environment associated with this instance.
      Returns:
      the associated Environment
      Throws:
      IllegalStateException - if this instance is not start()ed
    • start

      @PostConstruct public void start()
      Description copied from interface: KVDatabase
      Start this instance. This method must be called prior to creating any transactions.

      This method is idempotent: if this instance is already started, nothing happens.

      Whether an instance that has been started and stopped can be restarted is implementation-dependent.

      Specified by:
      start in interface KVDatabase
    • stop

      @PreDestroy public void stop()
      Description copied from interface: KVDatabase
      Stop this instance.

      This method is idempotent: if this instance has not been started, or is already stopped, nothing happens.

      Specified by:
      stop in interface KVDatabase
    • createTransaction

      public XodusKVTransaction createTransaction()
      Description copied from interface: KVDatabase
      Create a new transaction.
      Specified by:
      createTransaction in interface KVDatabase
      Returns:
      newly created transaction
    • createTransaction

      public XodusKVTransaction createTransaction(Map<String,?> options)
      Description copied from interface: KVDatabase
      Create a new transaction with the specified options.
      Specified by:
      createTransaction in interface KVDatabase
      Parameters:
      options - optional transaction options; may be null
      Returns:
      newly created transaction
    • finalize

      protected void finalize() throws Throwable
      Finalize this instance. Invokes stop() to close any unclosed iterators.
      Overrides:
      finalize in class Object
      Throws:
      Throwable
    • toString

      public String toString()
      Overrides:
      toString in class Object