Package org.yamcs.yarch.rocksdb
Class RDBFactory
java.lang.Object
org.yamcs.yarch.rocksdb.RDBFactory
- All Implemented Interfaces:
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
immediately closes the databasevoid
closeIfOpen
(String relativePath) Close the DB if open (called when dropping the table)void
void
Performs backup of the root database to a given directoryPerforms a backup of the database to the given directorygetOpenDbs
(boolean updateAccessTime) Get the list of all open databases increasing the reference count but optionally not updating the last access timeGet the root database if it's open, otherwise return nullgetOpenRdb
(String relativePath) Get the database which is already open or null if it is not openList<org.rocksdb.RocksDB>
getRdb
(boolean readonly) Opens or creates a database at the root dataDirOpens or create a database at a given relative pathrestoreBackup
(int backupId, String backupDir, String relativePath) restoreBackup
(String backupDir, String relativePath) void
run()
static void
setRegisterShutdownHooks
(boolean registerShutdownHooks) Set whether shutdown hooks are registered on each createdRDBFactory
.static void
Called from Unit tests to cleanup before the next test
-
Field Details
-
flushOptions
public static org.rocksdb.FlushOptions flushOptions
-
-
Method Details
-
getRdb
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
Opens or creates a database at the root dataDir- Throws:
IOException
-
delete
-
run
public void run() -
dispose
-
closeIfOpen
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 createdRDBFactory
. By default this is enabled. -
getOpenRdb
Get the root database if it's open, otherwise return null -
getOpenRdb
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
-
getOpenDbs
Get the list of all open databases increasing the reference count but optionally not updating the last access time -
close
immediately closes the database- Parameters:
yrdb
-
-
doBackup
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
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
-
restoreBackup
-
getOpenRdbs
-
shutdownAll
public static void shutdownAll()Called from Unit tests to cleanup before the next test
-