Class PBAppendDataStateData
java.lang.Object
edu.stanford.slac.archiverappliance.plain.AppendDataStateData
edu.stanford.slac.archiverappliance.plain.pb.PBAppendDataStateData
Companion class to PlainStoragePlugin that handles the appending of event streams in a partition-aware fashion.
This is used both by the engine and by ETL.
- Author:
- mshankar
-
Field Summary
FieldsFields inherited from class edu.stanford.slac.archiverappliance.plain.AppendDataStateData
currentEventsYear, desc, lastKnownTimeStamp, partitionGranularity, previousFilePath, previousYear, pv2key, rootFolder -
Constructor Summary
ConstructorsConstructorDescriptionPBAppendDataStateData(PartitionGranularity partitionGranularity, String rootFolder, String desc, Instant lastKnownTimestamp, PBCompressionMode compressionMode, PVNameToKeyMapping pv2key, PathResolver pathResolver) -
Method Summary
Modifier and TypeMethodDescriptionbooleanbulkAppend(String pvName, ETLContext context, ETLBulkStream bulkStream, String extension, String extensionToCopyFrom) Append data in bulk skipping some of the per event checks.voidprotected voidcreateNewFileAndWriteAHeader(String pvName, Path pvPath, EventStream stream) In cases where we create a new file, this method is used to create an empty file and write out an header.intpartitionBoundaryAwareAppendData(BasicContext context, String pvName, EventStream stream, String extension, String extensionToCopyFrom) Append data into PB files honoring partition boundaries switching into new partitions as we cross the boundary.toString()voidupdateStateBasedOnExistingFile(String pvName, Path pvPath) If we have an existing file, then this loads a PBInfo, validates the PV name and then updates the appendDataStateMethods inherited from class edu.stanford.slac.archiverappliance.plain.AppendDataStateData
checkStream, getPathResolver, preparePartition, shouldISkipEventBasedOnTimeStamps, shouldISwitchPartitions
-
Field Details
-
BULK_BUFFER_INITIAL_CAPACITY
public static final int BULK_BUFFER_INITIAL_CAPACITY- See Also:
-
-
Constructor Details
-
PBAppendDataStateData
public PBAppendDataStateData(PartitionGranularity partitionGranularity, String rootFolder, String desc, Instant lastKnownTimestamp, PBCompressionMode compressionMode, PVNameToKeyMapping pv2key, PathResolver pathResolver) - Parameters:
partitionGranularity- partitionGranularity of the PB plugin.rootFolder- RootFolder of the PB plugindesc- Desc for logging purposeslastKnownTimestamp- This is probably the most important argument here. This is the last known timestamp in this storage. If null, we assume time(0) for the last known timestamp.compressionMode- CompressionModepv2key- PVNameToKeyMapping
-
-
Method Details
-
partitionBoundaryAwareAppendData
public int partitionBoundaryAwareAppendData(BasicContext context, String pvName, EventStream stream, String extension, String extensionToCopyFrom) throws IOException Append data into PB files honoring partition boundaries switching into new partitions as we cross the boundary.- We make sure timestamp monotonicity is maintained.
- We generate clean partitions.
- Specified by:
partitionBoundaryAwareAppendDatain classAppendDataStateData- Parameters:
context-pvName- The PV namestream-extension-extensionToCopyFrom-- Returns:
- eventsAppended
- Throws:
IOException-
-
closeStreams
public void closeStreams()- Specified by:
closeStreamsin classAppendDataStateData
-
updateStateBasedOnExistingFile
If we have an existing file, then this loads a PBInfo, validates the PV name and then updates the appendDataState- Specified by:
updateStateBasedOnExistingFilein classAppendDataStateData- Parameters:
pvName- The PV namepvPath- The PV path- Throws:
IOException-
-
createNewFileAndWriteAHeader
protected void createNewFileAndWriteAHeader(String pvName, Path pvPath, EventStream stream) throws IOException In cases where we create a new file, this method is used to create an empty file and write out an header.- Specified by:
createNewFileAndWriteAHeaderin classAppendDataStateData- Parameters:
pvName- The PV namepvPath- The PV pathstream- The Event stream- Throws:
IOException-
-
toString
-
bulkAppend
public boolean bulkAppend(String pvName, ETLContext context, ETLBulkStream bulkStream, String extension, String extensionToCopyFrom) throws IOException Append data in bulk skipping some of the per event checks.- Specified by:
bulkAppendin classAppendDataStateData- Parameters:
pvName- The PV namecontext- The ETL contextbulkStream- The ETL bulk streamextension-extensionToCopyFrom-- Returns:
- boolean
- Throws:
IOException-
-