Class RDBFactory

java.lang.Object
org.yamcs.yarch.rocksdb.RDBFactory
All Implemented Interfaces:
Runnable

public class RDBFactory extends Object implements Runnable
manufacturer of RDB databases residing under a sub-directory which is normally the Tablespace.getDataDir(). It runs a thread that synchronises them from time to time and closes those that have not been used in a while
  • Field Details

    • flushOptions

      public static org.rocksdb.FlushOptions flushOptions
  • Method Details

    • getRdb

      public YRDB getRdb(String relativePath, boolean readonly) throws IOException
      Opens or create a database at a given relative path
      Parameters:
      relativePath - Relative path to the dataDir. Should be a directory.
      readonly - Open in readonly mode; if the database is open in readwrite mode, it will be returned like that
      Returns:
      the database created or opened
      Throws:
      IOException
    • getRdb

      public YRDB getRdb(boolean readonly) throws IOException
      Opens or creates a database at the root dataDir
      Throws:
      IOException
    • delete

      public void delete(String file)
    • run

      public void run()
      Specified by:
      run in interface Runnable
    • dispose

      public void dispose(YRDB rdb)
    • closeIfOpen

      public void closeIfOpen(String relativePath)
      Close the DB if open (called when dropping the table)
      Parameters:
      relativePath -
    • setRegisterShutdownHooks

      public static void setRegisterShutdownHooks(boolean registerShutdownHooks)
      Set whether shutdown hooks are registered on each created RDBFactory. By default this is enabled.
    • getOpenRdb

      public YRDB getOpenRdb()
      Get the root database if it's open, otherwise return null
    • getOpenRdb

      public YRDB getOpenRdb(String relativePath)
      Get the database which is already open or null if it is not open
      Parameters:
      relativePath - path of the database to be returned
      Returns:
      the database object
    • getOpenDbPaths

      public List<String> getOpenDbPaths()
    • getOpenDbs

      public List<YRDB> getOpenDbs(boolean updateAccessTime)
      Get the list of all open databases increasing the reference count but optionally not updating the last access time
    • close

      public void close(YRDB yrdb)
      immediately closes the database
      Parameters:
      yrdb -
    • doBackup

      public CompletableFuture<Void> doBackup(String backupDir)
      Performs backup of the root database to a given directory
      Parameters:
      backupDir -
      Returns:
      a future that can be used to know when the backup has finished and if there was any error
    • doBackup

      public CompletableFuture<Void> doBackup(String relativePath, String backupDir)
      Performs a backup of the database to the given directory
      Parameters:
      relativePath -
      backupDir -
      Returns:
      a future that can be used to know when the backup has finished and if there was any error
    • restoreBackup

      public CompletableFuture<Void> restoreBackup(String backupDir, String relativePath)
    • restoreBackup

      public CompletableFuture<Void> restoreBackup(int backupId, String backupDir, String relativePath)
    • getOpenRdbs

      public List<org.rocksdb.RocksDB> getOpenRdbs()
    • shutdownAll

      public static void shutdownAll()
      Called from Unit tests to cleanup before the next test