Package org.yamcs.yarch.rocksdb
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 theTablespace.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
Fields Modifier and Type Field Description static org.rocksdb.FlushOptions
flushOptions
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close(YRDB yrdb)
immediately closes the databasevoid
closeIfOpen(String relativePath)
Close the DB if open (called when dropping the table)void
delete(String file)
void
dispose(YRDB rdb)
CompletableFuture<Void>
doBackup(String backupDir)
Performs backup of the root database to a given directoryCompletableFuture<Void>
doBackup(String relativePath, String backupDir)
Performs a backup of the database to the given directoryList<String>
getOpenDbPaths()
YRDB
getOpenRdb()
Get the root database if it's open, otherwise return nullYRDB
getOpenRdb(String relativePath)
Get the database which is already open or null if it is not openYRDB
getRdb(boolean readonly)
Opens or creates a database at the root dataDirYRDB
getRdb(String relativePath, boolean readonly)
Opens or create a database at a given relative pathCompletableFuture<Void>
restoreBackup(int backupId, String backupDir, String relativePath)
CompletableFuture<Void>
restoreBackup(String backupDir, String relativePath)
void
run()
static void
setRegisterShutdownHooks(boolean registerShutdownHooks)
Set whether shutdown hooks are registered on each createdRDBFactory
.static void
shutdownAll()
Called from Unit tests to cleanup before the next test
-
-
-
Method Detail
-
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 directoryreadonly
- - 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)
-
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 createdRDBFactory
. 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
-
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)
-
shutdownAll
public static void shutdownAll()
Called from Unit tests to cleanup before the next test
-
-