Package org.yamcs.yarch
Interface StorageEngine
- All Known Implementing Classes:
RdbStorageEngine
public interface StorageEngine
A storage engine stores the tables of the Yamcs instances.
Besides the built-in RocksDB engine, additional engines can be configured in yamcs.yaml:
storageEngines:
- rocksdb2
- name: myengine
class: org.example.MyStorageEngine
args:
...
The class needs a public constructor without arguments; the engine is then configured with
init(String, YConfiguration). Engines can also be registered programmatically with
YarchDatabase.addStorageEngine(String, StorageEngine) before the instances are loaded.-
Method Summary
Modifier and TypeMethodDescriptionvoidcreateTable(YarchDatabaseInstance ydb, TableDefinition tblDef) Create a new table based on definition.voiddropTable(YarchDatabaseInstance ydb, TableDefinition tblDef) Drop the table (removing all data)getBucketDatabase(YarchDatabaseInstance yarchDatabaseInstance) getHistogramIterator(YarchDatabaseInstance ydb, TableDefinition tblDef, String columnName, TimeInterval interval) default ParameterArchiveStoragegetParameterArchiveStorage(YarchDatabaseInstance ydb, TimePartitionSchema partitioningSchema) Returns the storage of the parameter archive of the instance.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 valuesdefault SpecgetSpec()Returns the specification of theargsof the engine configuration in yamcs.yaml.default voidinit(String name, YConfiguration args) Called once, before any instance is loaded, for the engines configured in yamcs.yaml.Loads the table definitions from the disk for all the tables belonging to the instance.default 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)newSecondaryIndexTableWalker(YarchDatabaseInstance ydb, TableDefinition tableDefinition, boolean ascending, boolean follow) newTableWalker(ExecutionContext ctx, TableDefinition tblDef, boolean ascending, boolean follow) Creates a new table iterator.newTableWriter(YarchDatabaseInstance ydb, TableDefinition tblDef, TableWriter.InsertMode insertMode) Creates a new table writerdefault CompletableFuture<Void>rebuildHistogram(YarchDatabaseInstance ydb, TableDefinition tblDef, TimeInterval interval) Rebuilds the histograms of the table from the table data, for the partitions overlapping the interval (all the partitions if the interval is unbounded).voidrenameTable(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)default voidshutdown()Called when Yamcs shuts down, after all the instances have been stopped.
-
Method Details
-
getSpec
Returns the specification of theargsof the engine configuration in yamcs.yaml. The default implementation accepts any arguments. -
init
Called once, before any instance is loaded, for the engines configured in yamcs.yaml.- Parameters:
name- the name of the engine as configured (and used increate table ... engine <name>)args- theargsof the engine configuration, validated againstgetSpec()- Throws:
ConfigurationException
-
shutdown
default void shutdown()Called when Yamcs shuts down, after all the instances have been stopped. -
loadTables
Loads the table definitions from the disk for all the tables belonging to the instance.called at startup.
- Parameters:
ydb-- Throws:
YarchException
-
createTable
Create a new table based on definition.- Parameters:
ydb-tblDef-- Throws:
YarchException
-
saveTableDefinition
void saveTableDefinition(YarchDatabaseInstance ydb, TableDefinition tblDef, List<TableColumnDefinition> keyColumns, List<TableColumnDefinition> valueColumns) throws YarchException 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.
- Parameters:
ydb-tblDef-- Throws:
YarchException
-
dropTable
Drop the table (removing all data)- Parameters:
ydb-tblDef-- Throws:
YarchException
-
newTableWriter
TableWriter newTableWriter(YarchDatabaseInstance ydb, TableDefinition tblDef, TableWriter.InsertMode insertMode) throws YarchException Creates a new table writer- Parameters:
ydb-tblDef-insertMode-- Returns:
- Throws:
YarchException
-
newTableWalker
TableWalker newTableWalker(ExecutionContext ctx, TableDefinition tblDef, boolean ascending, boolean follow) Creates a new table iterator.- Parameters:
ctx-tblDef-
-
getHistogramIterator
HistogramIterator getHistogramIterator(YarchDatabaseInstance ydb, TableDefinition tblDef, String columnName, TimeInterval interval) throws YarchException - Throws:
YarchException
-
rebuildHistogram
default CompletableFuture<Void> rebuildHistogram(YarchDatabaseInstance ydb, TableDefinition tblDef, TimeInterval interval) throws YarchException Rebuilds the histograms of the table from the table data, for the partitions overlapping the interval (all the partitions if the interval is unbounded).- Returns:
- a future completed when the rebuild is finished
- Throws:
UnsupportedOperationException- if the storage engine cannot rebuild histogramsYarchException
-
getParameterArchiveStorage
default ParameterArchiveStorage getParameterArchiveStorage(YarchDatabaseInstance ydb, TimePartitionSchema partitioningSchema) throws YarchException Returns the storage of the parameter archive of the instance.Called once by the parameter archive service when it is initialized.
- Parameters:
partitioningSchema- the time partitioning schema to be used if the parameter archive does not exist yet (null for no partitioning)- Throws:
UnsupportedOperationException- if the storage engine cannot store the parameter archiveYarchException
-
getBucketDatabase
- Throws:
YarchException
-
getProtobufDatabase
- Throws:
YarchException
-
getPartitionManager
-
migrateTableDefinition
default void migrateTableDefinition(YarchDatabaseInstance ydb, TableDefinition tblDef) throws YarchException 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
- Throws:
YarchException
-
getSequence
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.
- Parameters:
name-create-- Returns:
- Throws:
YarchException
-
newSecondaryIndexTableWalker
TableWalker newSecondaryIndexTableWalker(YarchDatabaseInstance ydb, TableDefinition tableDefinition, boolean ascending, boolean follow) -
getSequencesInfo
Gets the list of sequences togehter with their latest values -
renameTable
rename the table
-