gov.sns.tools.pvlogger
Class SimpleStateStore

java.lang.Object
  |
  +--gov.sns.tools.pvlogger.SimpleStateStore
All Implemented Interfaces:
StateStore

public class SimpleStateStore
extends java.lang.Object
implements StateStore

SimpleStateStore is an implementation of StateStore for testing purposes only. An instance of SimpleStateStore publishes snapshot to the console. It does not provide persistent storage.


Field Summary
protected static java.lang.String SNAPSHOT_TYPE
           
 
Constructor Summary
SimpleStateStore()
           
 
Method Summary
 ChannelGroup fetchGroup(java.lang.String type)
          Fetch a channel group for the specified logger type
 MachineSnapshot fetchMachineSnapshot(long id)
          Fetch the machine snapshot with the specified id.
 MachineSnapshot[] fetchMachineSnapshotsInRange(java.lang.String type, java.util.Date startTime, java.util.Date endTime)
          Fetch the machine snapshots within the specified time range.
 java.lang.String[] fetchTypes()
          Fetch an array of valid logger types
protected static java.lang.String[] getPVsToLog()
          Get the array of pvs to log.
 MachineSnapshot loadChannelSnapshotsInto(MachineSnapshot machineSnapshot)
          Fetch the channel snapshots from the data source and populate the machine snapshot
 void publish(ChannelSnapshot snapshot, long machineId)
          Publish the channel snapshot by displaying its description to a console.
 void publish(MachineSnapshot machineSnapshot)
          Publish the machine snapshot by displaying its description to a console.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SNAPSHOT_TYPE

protected static final java.lang.String SNAPSHOT_TYPE
See Also:
Constant Field Values
Constructor Detail

SimpleStateStore

public SimpleStateStore()
Method Detail

publish

public void publish(ChannelSnapshot snapshot,
                    long machineId)
Publish the channel snapshot by displaying its description to a console.

Specified by:
publish in interface StateStore
Parameters:
snapshot - The snapshot to publish
machineId - The id of the channel snapshot's associated machine snapshot

publish

public void publish(MachineSnapshot machineSnapshot)
Publish the machine snapshot by displaying its description to a console.

Specified by:
publish in interface StateStore
Parameters:
machineSnapshot - The machine snapshot to publish

fetchTypes

public java.lang.String[] fetchTypes()
Fetch an array of valid logger types

Specified by:
fetchTypes in interface StateStore
Returns:
an array of available logger types

fetchGroup

public ChannelGroup fetchGroup(java.lang.String type)
Fetch a channel group for the specified logger type

Specified by:
fetchGroup in interface StateStore
Parameters:
type - the logger type
Returns:
a channel group for the logger type which includes the type, description and the pvs to log

fetchMachineSnapshot

public MachineSnapshot fetchMachineSnapshot(long id)
Fetch the machine snapshot with the specified id.

Specified by:
fetchMachineSnapshot in interface StateStore
Parameters:
id - The id which identifies the machine snapshot we wish to fetch.
Returns:
The machine snapshot with the specified id or nul if none could be found.

loadChannelSnapshotsInto

public MachineSnapshot loadChannelSnapshotsInto(MachineSnapshot machineSnapshot)
Fetch the channel snapshots from the data source and populate the machine snapshot

Specified by:
loadChannelSnapshotsInto in interface StateStore
Parameters:
machineSnapshot - The machine snapshot for which to fetch the channel snapshots and load them
Returns:
the machineSnapshot which is the same as the parameter returned for convenience

fetchMachineSnapshotsInRange

public MachineSnapshot[] fetchMachineSnapshotsInRange(java.lang.String type,
                                                      java.util.Date startTime,
                                                      java.util.Date endTime)
Fetch the machine snapshots within the specified time range. If the type is not null, then restrict the machine snapshots to those of the specified type. The machine snapshots do not include the channel snapshots. A complete snapshot can be obtained using the fetchMachineSnapshot(id) method.

Specified by:
fetchMachineSnapshotsInRange in interface StateStore
Parameters:
type - The type of machine snapshots to fetch or null for no restriction
startTime - The start time of the time range
endTime - The end time of the time range
Returns:
An array of machine snapshots meeting the specified criteria

getPVsToLog

protected static java.lang.String[] getPVsToLog()
Get the array of pvs to log.

Returns:
the array of pvs to log.