Class BlackholeStoragePlugin
- java.lang.Object
-
- org.epics.archiverappliance.utils.blackhole.BlackholeStoragePlugin
-
- All Implemented Interfaces:
ETLDest
,Reader
,StoragePlugin
,Writer
public class BlackholeStoragePlugin extends Object implements StoragePlugin, ETLDest
A storage plugin that deletes all data that goes into it. Use this as an ETL dest for policies that eliminate data after a certain period.- Author:
- mshankar
-
-
Constructor Summary
Constructors Constructor Description BlackholeStoragePlugin()
-
Method Summary
Modifier and Type Method Description boolean
appendData(BasicContext context, String pvName, EventStream stream)
boolean
appendToETLAppendData(String pvName, EventStream stream, ETLContext context)
This appends an EventStream to the ETL append data for a PV.boolean
commitETLAppendData(String pvName, ETLContext context)
This concatenates the ETL append data for a PV with the PV's destination data.void
convert(BasicContext context, String pvName, ConversionFunction conversionFuntion)
Sometimes, PVs change types, EGUs etc.List<Callable<EventStream>>
getDataForPV(BasicContext context, String pvName, Timestamp startTime, Timestamp endTime, PostProcessor postProcessor)
String
getDescription()
Get a string description of this plugin; one that can potentially be used in log messages and provide context.Event
getFirstKnownEvent(BasicContext context, String pvName)
Get the first event for this PV.Event
getLastKnownEvent(BasicContext context, String pvName)
Gets the last known event in this destination.String
getName()
Multiple PVs will probably use the same storage area and we identify the area using the name.PartitionGranularity
getPartitionGranularity()
String
getURLRepresentation()
void
initialize(String configURL, ConfigService configService)
Each storage plugin is registered to a URI scheme; for example, the PlainStoragePBPlugin uses pb:// as the scheme.boolean
prepareForNewPartition(String pvName, Event ev, ArchDBRTypes archDBRType, ETLContext context)
This informs the destination that we are switching to a new partition and this dest needs to execute its pre-processing for a new partition.void
renamePV(BasicContext context, String oldName, String newName)
Change the name of a PV.boolean
runPostProcessors(String pvName, ArchDBRTypes dbrtype, ETLContext context)
Run the post processors associated with this plugin if any for this pv.
-
-
-
Method Detail
-
getDataForPV
public List<Callable<EventStream>> getDataForPV(BasicContext context, String pvName, Timestamp startTime, Timestamp endTime, PostProcessor postProcessor) throws IOException
- Specified by:
getDataForPV
in interfaceReader
- Throws:
IOException
-
appendData
public boolean appendData(BasicContext context, String pvName, EventStream stream)
- Specified by:
appendData
in interfaceWriter
-
getLastKnownEvent
public Event getLastKnownEvent(BasicContext context, String pvName) throws IOException
Description copied from interface:Writer
Gets the last known event in this destination. Future events will be appended to this destination only if their timestamp is more recent than the timestamp of this event. If there is no last known event, then a null is returned.- Specified by:
getLastKnownEvent
in interfaceWriter
- Parameters:
context
-pvName
- The PV name- Returns:
- Event The last known event of pvName
- Throws:
IOException
-
-
getFirstKnownEvent
public Event getFirstKnownEvent(BasicContext context, String pvName) throws IOException
Description copied from interface:Reader
Get the first event for this PV. This call is used to optimize away calls to other readers that have older data.- Specified by:
getFirstKnownEvent
in interfaceReader
- Parameters:
context
-pvName
- The PV name- Returns:
- Event The first event of pvName
- Throws:
IOException
-
-
prepareForNewPartition
public boolean prepareForNewPartition(String pvName, Event ev, ArchDBRTypes archDBRType, ETLContext context) throws IOException
Description copied from interface:ETLDest
This informs the destination that we are switching to a new partition and this dest needs to execute its pre-processing for a new partition. For example, in a PlainPBStorage plugin, this will close the previous fileoutputstreams if any, open a new stream to the file backing the new partition writing a header if needed.- Specified by:
prepareForNewPartition
in interfaceETLDest
- Parameters:
pvName
- The name of PV.ev
- This is used to determine the partition for the new partitionarchDBRType
- ArchDBRTypescontext
- ETLContext- Returns:
- boolean True or False
- Throws:
IOException
-
-
appendToETLAppendData
public boolean appendToETLAppendData(String pvName, EventStream stream, ETLContext context)
Description copied from interface:ETLDest
This appends an EventStream to the ETL append data for a PV.- Specified by:
appendToETLAppendData
in interfaceETLDest
- Parameters:
pvName
- The name of PV.stream
- The EventStream to append to the append data for a PV.context
- ETLContext- Returns:
- boolean True or False
-
commitETLAppendData
public boolean commitETLAppendData(String pvName, ETLContext context) throws IOException
Description copied from interface:ETLDest
This concatenates the ETL append data for a PV with the PV's destination data.- Specified by:
commitETLAppendData
in interfaceETLDest
- Parameters:
pvName
- The name of PV.context
- ETLContext- Returns:
- boolean True or False
- Throws:
IOException
-
-
runPostProcessors
public boolean runPostProcessors(String pvName, ArchDBRTypes dbrtype, ETLContext context) throws IOException
Description copied from interface:ETLDest
Run the post processors associated with this plugin if any for this pv. The post processing is done after the commit and outside of the ETL transaction. This process is expected to catch up on previously missed/incomplete computation of cached post processing files. I can think of at least two usecases for this - one where we decide to go back and add a post processor for a pv and one where we change the algorithm for the post processor and want to recompute all the cached files again.- Specified by:
runPostProcessors
in interfaceETLDest
- Parameters:
pvName
- The name of PV.dbrtype
- ArchDBRTypescontext
- ETLContext- Returns:
- boolean True or False
- Throws:
IOException
-
-
getPartitionGranularity
public PartitionGranularity getPartitionGranularity()
- Specified by:
getPartitionGranularity
in interfaceETLDest
-
getDescription
public String getDescription()
Description copied from interface:StoragePlugin
Get a string description of this plugin; one that can potentially be used in log messages and provide context.- Specified by:
getDescription
in interfaceETLDest
- Specified by:
getDescription
in interfaceStoragePlugin
- Returns:
- description
-
getURLRepresentation
public String getURLRepresentation()
-
initialize
public void initialize(String configURL, ConfigService configService) throws IOException
Description copied from interface:StoragePlugin
Each storage plugin is registered to a URI scheme; for example, the PlainStoragePBPlugin uses pb:// as the scheme. Configuration for a storage plugin typically comes in as a URL like URI.- The config service identifies the storage plugin using the scheme ("pb" maps to PlainStoragePBPlugin)
- Creates an instance using the default constructor.
- Calls initialize with the complete URL.
- Specified by:
initialize
in interfaceStoragePlugin
- Parameters:
configURL
- The complete URLconfigService
-- Throws:
IOException
-- See Also:
StoragePluginURLParser
-
getName
public String getName()
Description copied from interface:StoragePlugin
Multiple PVs will probably use the same storage area and we identify the area using the name. This is principally used in capacity planning/load balancing to identify the storage area for the PV. We should make sure that storage's with similar lifetimes have the same name in all the appliances. The name is also used to identify the storage in the storage report. For example, the PlainPBStoragePlugin takes a name parameter and we should use something like STS as the identity for the short term store in all the appliances.- Specified by:
getName
in interfaceStoragePlugin
- Returns:
- name
-
renamePV
public void renamePV(BasicContext context, String oldName, String newName) throws IOException
Description copied from interface:StoragePlugin
Change the name of a PV. This happens occasionally in the EPICS world when people change the names of PVs but want to retain the data. This method is used to change the name of the PV in any of the datasets for PVoldName
. For example, in PB files, the name of the PV is encoded in the file names and is also stored in the header. In this case, we expect the plugin to move the data to new files names and change the PV name in the file header. To avoid getting into issues about data changing when renaming files, the PV can be assumed to be in a paused state.- Specified by:
renamePV
in interfaceStoragePlugin
- Parameters:
context
-oldName
- The old PV namenewName
- The new PV name- Throws:
IOException
-
-
convert
public void convert(BasicContext context, String pvName, ConversionFunction conversionFuntion) throws IOException
Description copied from interface:StoragePlugin
Sometimes, PVs change types, EGUs etc. In these cases, we are left with the problem of what to do with the already archived data. We can rename the PV to a new but related name - this keeps the existing data as is. Or, we can attempt to convert to the new type, EGU etc. This method can be used to convert the existing data using the supplied conversion function. Conversions should be all or nothing; that is, first convert all the streams into temporary chunks and then do a bulk rename once all the conversions have succeeded. Note that we'll also be using the same conversion mechanism for imports and other functions that change data. So, when/if implementing the conversion function, make sure we respect the typical expectations within the archiver - monotonically increasing timestamps and so on. To avoid getting into issues about data changing when converting, the PV can be assumed to be in a paused state.- Specified by:
convert
in interfaceStoragePlugin
- Parameters:
context
-pvName
- The PV nameconversionFuntion
-- Throws:
IOException
-
-
-