Class ParameterArchive
- All Implemented Interfaces:
com.google.common.util.concurrent.Service,YamcsService
A partition covers one year/month/day and each partition has its own RocksDB database.
An interval covers 2^23 millisec (=~ 139 minutes) - so for any timestamp (Yamcs time) we know exactly in which interval it falls.
A segment covers at most maxSegmentSize samples for one parameter. The segments do not cover a fixed period of time; we use them to avoid intervals getting very large; usually (1Hz or less frequency data) there is only one segment in an interval.
Segments cannot span across intervals.
When new data has been received in the past, the whole interval has to be re-created (by doing a replay); that likely means a new split of the respective interval into segments.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface com.google.common.util.concurrent.Service
com.google.common.util.concurrent.Service.Listener, com.google.common.util.concurrent.Service.State -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final longstatic final intstatic final booleanstatic final intstatic final intversion 0 - before Yamcs 5.10Fields inherited from class org.yamcs.AbstractYamcsService
config, log, serviceName, yamcsInstance -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcompact()longdeletePartitions(long start, long stop) Delete all partitions that overlap with [start, stop) segment.voiddisableAutoCompaction(long start, long stop) protected voiddoStart()protected voiddoStop()voidenableAutoCompaction(long start, long stop) longgetCoverageEnd(long now) Computes the coverage end as the greatest timestamp of a parameter in the archive, smaller than nowstatic longgetInterval(long instant) static longduration in milliseconds of one segmentstatic longgetIntervalEnd(long instant) returns the end of the interval where the instant fitsstatic longgetIntervalStart(long instant) returns the interval (instant) where this instant could fit.org.rocksdb.RocksIteratorgetPartitions(long start, long stop, boolean ascending) a copy of the partitions from start to stop inclusivegetSpec()Returns the valid configuration options for this service.getTimeSegment(ParameterArchive.Partition p, long segmentStart, int parameterGroupId, org.rocksdb.ReadOptions opts) voidinit(String yamcsInstance, String serviceName, YConfiguration config) Initialize this service.longvoidprintKeys(PrintStream out) voidpurge()Remove all the data and metadata related to the parameter archive and initialize a new databaseFuture<?>reprocess(long start, long stop) Rebuild the parameter archive between start and stop.voidSets thecoverageEndto negative infinityvoidupdateCoverageEnd(long t) voidwriteToArchive(long interval, Collection<PGSegment> pgList) voidwriteToArchive(PGSegment pgs) Methods inherited from class org.yamcs.AbstractYamcsService
findStream, getConfig, getYamcsInstanceMethods inherited from class com.google.common.util.concurrent.AbstractService
addListener, awaitRunning, awaitRunning, awaitRunning, awaitTerminated, awaitTerminated, awaitTerminated, doCancelStart, failureCause, isRunning, notifyFailed, notifyStarted, notifyStopped, startAsync, state, stopAsync, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.google.common.util.concurrent.Service
addListener, awaitRunning, awaitRunning, awaitRunning, awaitTerminated, awaitTerminated, awaitTerminated, failureCause, isRunning, startAsync, state, stopAsync
-
Field Details
-
VERSION
public static final int VERSIONversion 0 - before Yamcs 5.10version 1 - starting with Yamcs 5.10
- uses the RocksDB merge operator
- sorts properly the timestamps
- See Also:
-
STORE_RAW_VALUES
public static final boolean STORE_RAW_VALUES- See Also:
-
NUMBITS_MASK
public static final int NUMBITS_MASK- See Also:
-
TIMESTAMP_MASK
public static final int TIMESTAMP_MASK- See Also:
-
INTERVAL_MASK
public static final long INTERVAL_MASK- See Also:
-
CF_NAME
- See Also:
-
-
Constructor Details
-
ParameterArchive
public ParameterArchive()
-
-
Method Details
-
getSpec
Description copied from interface:YamcsServiceReturns the valid configuration options for this service.- Returns:
- the argument specification, or
nullif the args should not be validated.
-
init
public void init(String yamcsInstance, String serviceName, YConfiguration config) throws InitException Description copied from interface:YamcsServiceInitialize this service. This is called before the service is started. All operations should finish fast.- Specified by:
initin interfaceYamcsService- Overrides:
initin classAbstractYamcsService- Parameters:
yamcsInstance- The yamcs instance, ornullif this is a global service.serviceName- The service name.config- The configured arguments for this service. IfYamcsService.getSpec()is implemented then this contains the arguments after being validated (including any defaults).- Throws:
InitException- When something goes wrong during the execution of this method.
-
getPartitioningSchema
-
getParameterIdDb
-
getParameterGroupIdDb
-
updateCoverageEnd
public void updateCoverageEnd(long t) -
resetCoverageEnd
public void resetCoverageEnd()Sets thecoverageEndto negative infinityThis method is used mostly in unit tests
-
writeToArchive
- Throws:
org.rocksdb.RocksDBExceptionIOException
-
writeToArchive
public void writeToArchive(long interval, Collection<PGSegment> pgList) throws org.rocksdb.RocksDBException, IOException - Throws:
org.rocksdb.RocksDBExceptionIOException
-
reprocess
Rebuild the parameter archive between start and stop. The times will be adjusted to build full intervals.Both start and stop can be left unspecified (by setting them to
TimeEncoding.INVALID_INSTANT) to start from the beginning and/or go to the end of the archive.If the realtime parameter filler is enabled, the end will be set by default to the end of the previous interval compared to the interval of the current mission time.
-
getPartitions
a copy of the partitions from start to stop inclusive- Parameters:
start-stop-- Returns:
- a sorted list of partitions
-
doStart
protected void doStart()- Specified by:
doStartin classcom.google.common.util.concurrent.AbstractService
-
doStop
protected void doStop()- Specified by:
doStopin classcom.google.common.util.concurrent.AbstractService
-
printKeys
public void printKeys(PrintStream out) throws DecodingException, org.rocksdb.RocksDBException, IOException - Throws:
DecodingExceptionorg.rocksdb.RocksDBExceptionIOException
-
deletePartitions
public List<ParameterArchive.Partition> deletePartitions(long start, long stop) throws org.rocksdb.RocksDBException Delete all partitions that overlap with [start, stop) segment.- Parameters:
start-stop-- Returns:
- all the partitions removed
- Throws:
org.rocksdb.RocksDBException
-
purge
Remove all the data and metadata related to the parameter archive and initialize a new databasePrior to Yamcs 5.9.0 the Parameter Archive was stored on the default RocksDB column family. After the purge operation, the parameter archive will be moved to its own column family
If the parameter archive is stored in the default column family this operation will remove all the records.
If the parameter archive is stored into its own column family this operation will simply drop that column family (for all time based partitions)
- Throws:
org.rocksdb.RocksDBExceptionInterruptedExceptionIOException
-
getIterator
public org.rocksdb.RocksIterator getIterator(ParameterArchive.Partition p) throws org.rocksdb.RocksDBException, IOException - Throws:
org.rocksdb.RocksDBExceptionIOException
-
getIteratorWithOptions
public RdbIteratorWithOptions getIteratorWithOptions(ParameterArchive.Partition p) throws org.rocksdb.RocksDBException, IOException - Throws:
org.rocksdb.RocksDBExceptionIOException
-
getTimeSegment
public SortedTimeSegment getTimeSegment(ParameterArchive.Partition p, long segmentStart, int parameterGroupId, org.rocksdb.ReadOptions opts) throws org.rocksdb.RocksDBException, IOException - Throws:
org.rocksdb.RocksDBExceptionIOException
-
coverageEnd
public long coverageEnd() -
getIntervalStart
public static long getIntervalStart(long instant) returns the interval (instant) where this instant could fit.- Parameters:
instant-- Returns:
-
getInterval
public static long getInterval(long instant) -
getIntervalEnd
public static long getIntervalEnd(long instant) returns the end of the interval where the instant fits- Parameters:
instant-- Returns:
-
getIntervalDuration
public static long getIntervalDuration()duration in milliseconds of one segment- Returns:
-
getTablespace
-
getRealtimeFiller
-
getBackFiller
-
disableAutoCompaction
public void disableAutoCompaction(long start, long stop) -
enableAutoCompaction
public void enableAutoCompaction(long start, long stop) -
compact
public void compact() -
maxCoverageEnd
public long maxCoverageEnd() -
getCoverageEnd
public long getCoverageEnd(long now) throws org.rocksdb.RocksDBException, IOException, DecodingException Computes the coverage end as the greatest timestamp of a parameter in the archive, smaller than nowIn order to find that, it iterates over all time segments
- Throws:
IOExceptionorg.rocksdb.RocksDBExceptionDecodingException
-
getFillerLock
-