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 TypeMethodDescriptionvoidcreateTable(YarchDatabaseInstance ydb, TableDefinition def) Create a new table based on definition.createTablespace(String tablespaceName) static final byte[]dbKey(int tbsIndex) returns a byte array containing the encoded tbsIndexvoiddropTable(YarchDatabaseInstance ydb, TableDefinition tbl) Drop the table (removing all data)voiddropTablespace(String tablespaceName) getHistogramIterator(YarchDatabaseInstance ydb, TableDefinition tblDef, String columnName, TimeInterval interval) static RdbStorageEnginegetPartitionManager(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.voidmigrateTableDefinition(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)newRdbParameterProducer(String yamcsInstance, SystemParametersService sps) returns a system parameter producer for the databases used by the yamcsInstancenewSecondaryIndexTableWalker(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 writervoidrenameTable(YarchDatabaseInstance ydb, TableDefinition tblDef, String newName) rename the tablevoidsaveTableDefinition(YarchDatabaseInstance ydb, TableDefinition tblDef, List<TableColumnDefinition> keyColumns, List<TableColumnDefinition> valueColumns) Persist the table definition to diks (called when the table definition modifies)voidsetIgnoreVersionIncompatibility(boolean b) set to ignore version incompatibility - only used from the version upgrading functions to allow loading old tables.voidshutdown()
-
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:StorageEngineDrop the table (removing all data)- Specified by:
dropTablein interfaceStorageEngine- Throws:
YarchException
-
newTableWriter
public RdbTableWriter newTableWriter(YarchDatabaseInstance ydb, TableDefinition tblDef, TableWriter.InsertMode insertMode) Description copied from interface:StorageEngineCreates a new table writer- Specified by:
newTableWriterin interfaceStorageEngine- Returns:
-
newTableWalker
public TableWalker newTableWalker(ExecutionContext ctx, TableDefinition tbl, boolean ascending, boolean follow) Description copied from interface:StorageEngineCreates a new table iterator.- Specified by:
newTableWalkerin interfaceStorageEngine
-
createTable
Description copied from interface:StorageEngineCreate a new table based on definition.- Specified by:
createTablein interfaceStorageEngine- Throws:
YarchException
-
getInstance
-
getPartitionManager
- Specified by:
getPartitionManagerin 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:
getHistogramIteratorin interfaceStorageEngine- Throws:
YarchException
-
getBucketDatabase
- Specified by:
getBucketDatabasein interfaceStorageEngine- Throws:
YarchException
-
getProtobufDatabase
- Specified by:
getProtobufDatabasein interfaceStorageEngine- Throws:
YarchException
-
getTablespace
-
dropTablespace
-
shutdown
public void shutdown() -
loadTables
Description copied from interface:StorageEngineLoads the table definitions from the disk for all the tables belonging to the instance.called at startup.
- Specified by:
loadTablesin interfaceStorageEngine- Throws:
YarchException
-
renameTable
Description copied from interface:StorageEnginerename the table- Specified by:
renameTablein interfaceStorageEngine
-
migrateTableDefinition
public void migrateTableDefinition(YarchDatabaseInstance ydb, TableDefinition tblDef) throws YarchException Description copied from interface:StorageEngineIn 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:
migrateTableDefinitionin interfaceStorageEngine- Throws:
YarchException
-
saveTableDefinition
public void saveTableDefinition(YarchDatabaseInstance ydb, TableDefinition tblDef, List<TableColumnDefinition> keyColumns, List<TableColumnDefinition> valueColumns) throws YarchException Description copied from interface:StorageEnginePersist 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:
saveTableDefinitionin interfaceStorageEngine- Throws:
YarchException
-
getSequence
public Sequence getSequence(YarchDatabaseInstance ydb, String name, boolean create) throws YarchException Description copied from interface:StorageEngineReturns 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:
getSequencein interfaceStorageEngine- Returns:
- Throws:
YarchException
-
newSecondaryIndexTableWalker
public TableWalker newSecondaryIndexTableWalker(YarchDatabaseInstance ydb, TableDefinition tableDefinition, boolean ascending, boolean follow) - Specified by:
newSecondaryIndexTableWalkerin interfaceStorageEngine
-
getSequencesInfo
Description copied from interface:StorageEngineGets the list of sequences togehter with their latest values- Specified by:
getSequencesInfoin interfaceStorageEngine
-
dbKey
public static final byte[] dbKey(int tbsIndex) returns a byte array containing the encoded tbsIndex -
newRdbParameterProducer
public RocksdbSysParamProducer newRdbParameterProducer(String yamcsInstance, SystemParametersService sps) returns a system parameter producer for the databases used by the yamcsInstancethe producer will provide statistics with the memory usage
-