Package org.yamcs.yarch.rocksdb
Class RdbStorageEngine
java.lang.Object
org.yamcs.yarch.rocksdb.RdbStorageEngine
- All Implemented Interfaces:
StorageEngine
Storage Engine based on RocksDB. Data is stored in multiple
Tablespace
.
Each table has associated a tablespace, if not set at creation of the table, it is the tablespace associated to the instance.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoid
createTable
(YarchDatabaseInstance ydb, TableDefinition def) Create a new table based on definition.createTablespace
(String tablespaceName) void
dropTable
(YarchDatabaseInstance ydb, TableDefinition tbl) Drop the table (removing all data)void
dropTablespace
(String tablespaceName) getHistogramIterator
(YarchDatabaseInstance ydb, TableDefinition tblDef, String columnName, TimeInterval interval) static RdbStorageEngine
getPartitionManager
(YarchDatabaseInstance ydb, TableDefinition tblDef) getSequence
(YarchDatabaseInstance ydb, String name, boolean create) Returns a sequence with the given name if it exists or first create it and returns it if create is true.Gets the list of sequences togehter with their latest valuesgetTablespace
(String tablespaceName) Create and/or get the tablespace for the yarch database instance.Loads the table definitions from the disk for all the tables belonging to the instance.void
migrateTableDefinition
(YarchDatabaseInstance ydb, TableDefinition tblDef) In Yamcs version 4 the table definitions were stored in yaml serialized format (in the /storage/yamcs-data/<instance-name>/<table-name>.def)newSecondaryIndexTableWalker
(YarchDatabaseInstance ydb, TableDefinition tableDefinition, boolean ascending, boolean follow) newTableWalker
(ExecutionContext ctx, TableDefinition tbl, boolean ascending, boolean follow) Creates a new table iterator.newTableWriter
(YarchDatabaseInstance ydb, TableDefinition tblDef, TableWriter.InsertMode insertMode) Creates a new table writervoid
renameTable
(YarchDatabaseInstance ydb, TableDefinition tblDef, String newName) rename the tablevoid
saveTableDefinition
(YarchDatabaseInstance ydb, TableDefinition tblDef, List<TableColumnDefinition> keyColumns, List<TableColumnDefinition> valueColumns) Persist the table definition to diks (called when the table definition modifies)void
setIgnoreVersionIncompatibility
(boolean b) set to ignore version incompatibility - only used from the version upgrading functions to allow loading old tables.void
shutdown()
-
Field Details
-
TBS_INDEX_SIZE
public static final int TBS_INDEX_SIZE- See Also:
-
ZERO_BYTES
public static final byte[] ZERO_BYTES
-
-
Method Details
-
dropTable
Description copied from interface:StorageEngine
Drop the table (removing all data)- Specified by:
dropTable
in interfaceStorageEngine
- Throws:
YarchException
-
newTableWriter
public RdbTableWriter newTableWriter(YarchDatabaseInstance ydb, TableDefinition tblDef, TableWriter.InsertMode insertMode) Description copied from interface:StorageEngine
Creates a new table writer- Specified by:
newTableWriter
in interfaceStorageEngine
- Returns:
-
newTableWalker
public TableWalker newTableWalker(ExecutionContext ctx, TableDefinition tbl, boolean ascending, boolean follow) Description copied from interface:StorageEngine
Creates a new table iterator.- Specified by:
newTableWalker
in interfaceStorageEngine
-
createTable
Description copied from interface:StorageEngine
Create a new table based on definition.- Specified by:
createTable
in interfaceStorageEngine
- Throws:
YarchException
-
getInstance
-
getPartitionManager
- Specified by:
getPartitionManager
in interfaceStorageEngine
-
getTablespace
Create and/or get the tablespace for the yarch database instance.- Parameters:
ydb
-- Returns:
-
getTablespaces
-
createTablespace
-
setIgnoreVersionIncompatibility
public void setIgnoreVersionIncompatibility(boolean b) set to ignore version incompatibility - only used from the version upgrading functions to allow loading old tables.- Parameters:
b
-
-
getHistogramIterator
public HistogramIterator getHistogramIterator(YarchDatabaseInstance ydb, TableDefinition tblDef, String columnName, TimeInterval interval) throws YarchException - Specified by:
getHistogramIterator
in interfaceStorageEngine
- Throws:
YarchException
-
getBucketDatabase
- Specified by:
getBucketDatabase
in interfaceStorageEngine
- Throws:
YarchException
-
getProtobufDatabase
- Specified by:
getProtobufDatabase
in interfaceStorageEngine
- Throws:
YarchException
-
getTablespace
-
dropTablespace
-
shutdown
public void shutdown() -
loadTables
Description copied from interface:StorageEngine
Loads the table definitions from the disk for all the tables belonging to the instance.called at startup.
- Specified by:
loadTables
in interfaceStorageEngine
- Throws:
YarchException
-
renameTable
Description copied from interface:StorageEngine
rename the table- Specified by:
renameTable
in interfaceStorageEngine
-
migrateTableDefinition
public void migrateTableDefinition(YarchDatabaseInstance ydb, TableDefinition tblDef) throws YarchException Description copied from interface:StorageEngine
In Yamcs version 4 the table definitions were stored in yaml serialized format (in the /storage/yamcs-data/<instance-name>/<table-name>.def)This function is called to migrate them inside the storage engine where they are stored starting with Yamcs 5
- Specified by:
migrateTableDefinition
in interfaceStorageEngine
- Throws:
YarchException
-
saveTableDefinition
public void saveTableDefinition(YarchDatabaseInstance ydb, TableDefinition tblDef, List<TableColumnDefinition> keyColumns, List<TableColumnDefinition> valueColumns) throws YarchException Description copied from interface:StorageEngine
Persist the table definition to diks (called when the table definition modifies)The general table properties should be read from the tblDef argument but the column properties should be read from the extra arguments This is because the method is called with modified column content which is not reflected in the table definition until the data is saved in the database.
- Specified by:
saveTableDefinition
in interfaceStorageEngine
- Throws:
YarchException
-
getSequence
public Sequence getSequence(YarchDatabaseInstance ydb, String name, boolean create) throws YarchException Description copied from interface:StorageEngine
Returns a sequence with the given name if it exists or first create it and returns it if create is true.If create is false and the sequence does not exist, returns null.
- Specified by:
getSequence
in interfaceStorageEngine
- Returns:
- Throws:
YarchException
-
newSecondaryIndexTableWalker
public TableWalker newSecondaryIndexTableWalker(YarchDatabaseInstance ydb, TableDefinition tableDefinition, boolean ascending, boolean follow) - Specified by:
newSecondaryIndexTableWalker
in interfaceStorageEngine
-
getSequencesInfo
Description copied from interface:StorageEngine
Gets the list of sequences togehter with their latest values- Specified by:
getSequencesInfo
in interfaceStorageEngine
-