Class ArchiveChannel
- java.lang.Object
-
- org.epics.archiverappliance.engine.model.ArchiveChannel
-
- Direct Known Subclasses:
DeltaArchiveChannel
,MonitoredArchiveChannel
,ScannedArchiveChannel
public abstract class ArchiveChannel extends Object
Base for archived channels. An ArchiveChannel has- A main PV; in the typical case, this would be the PV for the .VAL. The record processing timestamp from this PV constitutes identity.
- A optional collection of metadata/field PVs. Data from these PV's is stored as part of the mainPV.
- A SampleBuffer where the data from the main PV is stored.
- A Writer, typically the STS, where the data in the SampleBuffer is periodically flushed.
- Version:
- Initial version:CSS, 4-Jun-2012, Luofeng Li:added codes to support for the new archiver
- Author:
- Kay Kasemir
-
-
Field Summary
Fields Modifier and Type Field Description protected DBRTimeEvent
lastDBRTimeEvent
The last DBRTimeEvent written to the archive.protected DBRTimeEvent
latestDBRTimeEvent
The latest DBRTimeEvent received from the control systemprotected PVMetrics
pvMetrics
pvMetrics for this channel.
-
Constructor Summary
Constructors Constructor Description ArchiveChannel(String name, Writer writer, Enablement enablement, int buffer_capacity, Timestamp last_archived_timestamp, ConfigService configservice, ArchDBRTypes archdbrtype, String controlPVname, int commandThreadID, boolean usePVAccess)
create archive channel
-
Method Summary
Modifier and Type Method Description protected boolean
addValueToBuffer(DBRTimeEvent timeevent)
Add given sample to buffer, performing a back-in-time check, updating the sample buffer error state.int
getConnectedMetaChannelCount()
Get the number of connected field channelsString
getControlPVname()
if this channel is started or stopped archiving by a another pv, return the pv's nameDBRTimeEvent
getCurrentArchivedValue()
HashMap<String,String>
getCurrentCopyOfMetaFields()
Get the current value of all the meta fields.Enablement
getEnablement()
String
getHostName()
int
getJCACommandThreadID()
DBRTimeEvent
getLastArchivedValue()
HashMap<String,String>
getLatestMetadata()
Combine the metadata from various sources and return the latest copy.void
getLowLevelChannelStateInfo(List<Map<String,String>> statuses)
abstract String
getMechanism()
int
getMetaChannelCount()
Number of field names for which we have established channels.Set<String>
getMetaPVNames()
Get the field names for which we have established channels.String
getName()
ArrayListEventStream
getPVData()
get the combined ArrayListEventStream of prevouse and currentPVMetrics
getPVMetrics()
get pv metrics for this channellong
getReceivedValues()
SampleBuffer
getSampleBuffer()
long
getSecondsElapsedSinceSearchRequest()
Return the amount of time (in seconds) since we asked CAJ/JCA to connect to this channel.Writer
getWriter()
get the writer for this channelprotected void
handleDisconnected()
Handle a disconnect event.protected boolean
handleNewValue(DBRTimeEvent timeevent)
Called for each value received from PV.void
initializeMetaFieldPVS(String[] metaFields, ConfigService configservice, boolean usePVAccess, boolean useDBEProperties)
boolean
isConnected()
boolean
isEnabled()
boolean
isMetaPVConnected(String metaFieldName)
Get the archive channel for a particular metachannel.boolean
metaChannelsNeedStartingUp()
Do any of the meta channels in this PV need starting up?void
reset()
Reset countersvoid
setJCACommandThreadID(int jCACommandThreadID)
void
setlastRotateLogsEpochSeconds(long lastRotateLogsEpochSecond)
set the time stamp of the last value is stored in short term storagevoid
shutdownMetaChannels()
void
start()
Start archiving this channel.void
startUpMetaChannels()
Start the metachannelsvoid
stop()
Stop archiving this channelString
toString()
void
updateMetadataOnceADay(EngineContext context)
Use this method to do a caget on the metadata..
-
-
-
Field Detail
-
latestDBRTimeEvent
protected DBRTimeEvent latestDBRTimeEvent
The latest DBRTimeEvent received from the control system
-
lastDBRTimeEvent
protected DBRTimeEvent lastDBRTimeEvent
The last DBRTimeEvent written to the archive.
-
pvMetrics
protected final PVMetrics pvMetrics
pvMetrics for this channel. Ideally, we should move all metrics to this class.
-
-
Constructor Detail
-
ArchiveChannel
public ArchiveChannel(String name, Writer writer, Enablement enablement, int buffer_capacity, Timestamp last_archived_timestamp, ConfigService configservice, ArchDBRTypes archdbrtype, String controlPVname, int commandThreadID, boolean usePVAccess) throws Exception
create archive channel- Parameters:
name
- pv's namewriter
- the writer for this pvenablement
- start or stop archiving this pv when channel is createdbuffer_capacity
- the sample buffer's capacity for this pvlast_archived_timestamp
- the last time stamp when this pv was archivedconfigservice
- the configservice of new archiverarchdbrtype
- the archiving dbr typecontrolPVname
- the pv's name who control this pv to start archiving or stop archivingcommandThreadID
- - this is the index into the array of JCA command threads that processes this context.usePVAccess
- - Should we use PVAccess to connect to this PV.- Throws:
Exception
- error when creating archive channel for this pv
-
-
Method Detail
-
getControlPVname
public String getControlPVname()
if this channel is started or stopped archiving by a another pv, return the pv's name- Returns:
- the pv's name who control this channel archiving
-
setlastRotateLogsEpochSeconds
public void setlastRotateLogsEpochSeconds(long lastRotateLogsEpochSecond)
set the time stamp of the last value is stored in short term storage- Parameters:
lastRotateLogsEpochSecond
- the time stamp of last value and it is the number of milliseconds since 1970/01/01
-
getWriter
public Writer getWriter()
get the writer for this channel- Returns:
- the writer for this channel
-
getPVMetrics
public PVMetrics getPVMetrics()
get pv metrics for this channel- Returns:
- PVMetrics
-
initializeMetaFieldPVS
public void initializeMetaFieldPVS(String[] metaFields, ConfigService configservice, boolean usePVAccess, boolean useDBEProperties) throws IOException
- Throws:
IOException
-
getPVData
public ArrayListEventStream getPVData()
get the combined ArrayListEventStream of prevouse and current- Returns:
- ArrayListEventStream
-
getName
public final String getName()
- Returns:
- Name of channel
-
getEnablement
public final Enablement getEnablement()
- Returns:
- How channel affects its groups
-
isEnabled
public final boolean isEnabled()
- Returns:
true
if channel is currently enabled
-
getMechanism
public abstract String getMechanism()
- Returns:
- Short description of sample mechanism
-
isConnected
public final boolean isConnected()
- Returns:
true
if connected
-
getCurrentArchivedValue
public final DBRTimeEvent getCurrentArchivedValue()
- Returns:
- Most recent value of the channel's PV
-
getReceivedValues
public long getReceivedValues()
- Returns:
- Count of received values
-
getLastArchivedValue
public final DBRTimeEvent getLastArchivedValue()
- Returns:
- Last value written to archive
-
getSampleBuffer
public final SampleBuffer getSampleBuffer()
- Returns:
- Sample buffer
-
reset
public void reset()
Reset counters
-
handleNewValue
protected boolean handleNewValue(DBRTimeEvent timeevent) throws Exception
Called for each value received from PV.Base class remembers the
most_recent_value
, and asserts that one 'first' sample is archived. Derived class must callsuper()
.- Parameters:
timeevent
- DBRTimeEvent- Returns:
- true if the value was already written because it's the first value after startup or error, so there's no need to write that sample again.
- Throws:
Exception
-
-
startUpMetaChannels
public void startUpMetaChannels() throws Exception
Start the metachannels- Throws:
Exception
-
-
handleDisconnected
protected void handleDisconnected() throws Exception
Handle a disconnect event.Base class clears the
most_recent_value
and adds a 'disconnected' info sample. Subclasses may override, but must callsuper()
.- Throws:
Exception
-
-
addValueToBuffer
protected final boolean addValueToBuffer(DBRTimeEvent timeevent) throws Exception
Add given sample to buffer, performing a back-in-time check, updating the sample buffer error state.- Parameters:
timeevent
- DBRTimeEvent- Returns:
false
if value failed back-in-time or future check,true
if value was added.- Throws:
Exception
-
-
getCurrentCopyOfMetaFields
public HashMap<String,String> getCurrentCopyOfMetaFields()
Get the current value of all the meta fields.- Returns:
- - Can return null if this PV has no meta fields.
-
getHostName
public String getHostName()
-
getLowLevelChannelStateInfo
public void getLowLevelChannelStateInfo(List<Map<String,String>> statuses)
-
isMetaPVConnected
public boolean isMetaPVConnected(String metaFieldName)
Get the archive channel for a particular metachannel.- Parameters:
metaFieldName
-- Returns:
- boolean True or False
-
getMetaPVNames
public Set<String> getMetaPVNames()
Get the field names for which we have established channels.- Returns:
- String the Meta PV names
-
getMetaChannelCount
public int getMetaChannelCount()
Number of field names for which we have established channels.- Returns:
- int
-
getConnectedMetaChannelCount
public int getConnectedMetaChannelCount()
Get the number of connected field channels- Returns:
- int
-
metaChannelsNeedStartingUp
public boolean metaChannelsNeedStartingUp()
Do any of the meta channels in this PV need starting up?- Returns:
- boolean True or False
-
getSecondsElapsedSinceSearchRequest
public long getSecondsElapsedSinceSearchRequest()
Return the amount of time (in seconds) since we asked CAJ/JCA to connect to this channel.- Returns:
- long
-
getJCACommandThreadID
public int getJCACommandThreadID()
- Returns:
- int the jCACommandThreadID
-
setJCACommandThreadID
public void setJCACommandThreadID(int jCACommandThreadID)
- Parameters:
jCACommandThreadID
- the jCACommandThreadID to set
-
updateMetadataOnceADay
public void updateMetadataOnceADay(EngineContext context)
Use this method to do a caget on the metadata..- Parameters:
context
- EngineContext
-
-