Package org.yamcs.parameterarchive
Class ParameterArchive
- java.lang.Object
-
- com.google.common.util.concurrent.AbstractService
-
- org.yamcs.AbstractYamcsService
-
- org.yamcs.parameterarchive.ParameterArchive
-
- All Implemented Interfaces:
com.google.common.util.concurrent.Service,YamcsService
public class ParameterArchive extends AbstractYamcsService
The parameter archive stores data in partitions -> intervals -> segments. A partition covers one year and each partition has its own RocksDB database An interval covers 2^23 millisec =~ 139 minutes An segment covers at most maxSegmentSize values for one parameter
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classParameterArchive.Partition
-
Field Summary
Fields Modifier and Type Field Description static longINTERVAL_MASKstatic intNUMBITS_MASKstatic booleanSTORE_RAW_VALUESstatic intTIMESTAMP_MASK-
Fields inherited from class org.yamcs.AbstractYamcsService
config, log, yamcsInstance
-
-
Constructor Summary
Constructors Constructor Description ParameterArchive()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ParameterArchive.PartitioncreateAndGetPartition(long segStart)get partition for segment, creating it if it doesn't existList<ParameterArchive.Partition>deletePartitions(long start, long stop)Delete all partitions that overlap with [start, stop) segment.protected voiddoStart()protected voiddoStop()static longgetIntervalDuration()duration in milliseconds of one segmentstatic longgetIntervalEnd(long instant)returns the end of the interval where the instant fitsstatic longgetIntervalStart(long instant)returns the intervalStart where this instant could fit.org.rocksdb.RocksIteratorgetIterator(ParameterArchive.Partition p)ParameterGroupIdDbgetParameterGroupIdDb()ParameterIdDbgetParameterIdDb()TimePartitionSchemagetPartitioningSchema()List<ParameterArchive.Partition>getPartitions(long start, long stop, boolean ascending)a copy of the partitions from start to stop inclusiveSpecgetSpec()Returns the valid configuration options for this service.TablespacegetTablespace()SortedTimeSegmentgetTimeSegment(ParameterArchive.Partition p, long segmentStart, int parameterGroupId)voidinit(String yamcsInstance, YConfiguration config)Initialize this service.voidprintKeys(PrintStream out)Future<?>reprocess(long start, long stop)voidwriteToArchive(long segStart, Collection<PGSegment> pgList)voidwriteToArchive(PGSegment pgs)-
Methods inherited from class org.yamcs.AbstractYamcsService
getConfig, getYamcsInstance
-
Methods inherited from class com.google.common.util.concurrent.AbstractService
addListener, awaitRunning, awaitRunning, awaitTerminated, awaitTerminated, failureCause, isRunning, notifyFailed, notifyStarted, notifyStopped, startAsync, state, stopAsync, toString
-
-
-
-
Field Detail
-
STORE_RAW_VALUES
public static final boolean STORE_RAW_VALUES
- See Also:
- Constant Field Values
-
NUMBITS_MASK
public static final int NUMBITS_MASK
- See Also:
- Constant Field Values
-
TIMESTAMP_MASK
public static final int TIMESTAMP_MASK
- See Also:
- Constant Field Values
-
INTERVAL_MASK
public static final long INTERVAL_MASK
- See Also:
- Constant Field Values
-
-
Method Detail
-
getSpec
public Spec getSpec()
Description copied from interface:YamcsServiceReturns the valid configuration options for this service.- Returns:
- the argument specification, or null if the args should not be validated.
-
init
public void init(String yamcsInstance, 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, or null if this is a global service.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
public TimePartitionSchema getPartitioningSchema()
-
getParameterIdDb
public ParameterIdDb getParameterIdDb()
-
getParameterGroupIdDb
public ParameterGroupIdDb getParameterGroupIdDb()
-
writeToArchive
public void writeToArchive(PGSegment pgs) throws org.rocksdb.RocksDBException, IOException
- Throws:
org.rocksdb.RocksDBExceptionIOException
-
writeToArchive
public void writeToArchive(long segStart, Collection<PGSegment> pgList) throws org.rocksdb.RocksDBException, IOException- Throws:
org.rocksdb.RocksDBExceptionIOException
-
createAndGetPartition
public ParameterArchive.Partition createAndGetPartition(long segStart) throws org.rocksdb.RocksDBException
get partition for segment, creating it if it doesn't exist- Parameters:
segStart-- Throws:
org.rocksdb.RocksDBException
-
reprocess
public Future<?> reprocess(long start, long stop)
-
getPartitions
public List<ParameterArchive.Partition> getPartitions(long start, long stop, boolean ascending)
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
-
getIterator
public org.rocksdb.RocksIterator getIterator(ParameterArchive.Partition p) throws org.rocksdb.RocksDBException, IOException
- Throws:
org.rocksdb.RocksDBExceptionIOException
-
getTimeSegment
public SortedTimeSegment getTimeSegment(ParameterArchive.Partition p, long segmentStart, int parameterGroupId) throws org.rocksdb.RocksDBException, IOException
- Throws:
org.rocksdb.RocksDBExceptionIOException
-
getIntervalStart
public static long getIntervalStart(long instant)
returns the intervalStart where this instant could fit.- Parameters:
instant-- Returns:
-
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
public Tablespace getTablespace()
-
-