Package org.lsst.ccs
Class PersistencyService
java.lang.Object
org.lsst.ccs.PersistencyService
- All Implemented Interfaces:
HasLifecycle,ServiceLifecycle
This objects is responsible for keeping track of fields annotated with
Persist and to write them into a
local file at subsystem shutdown or at regular time intervals.- Author:
- LSST CCS Team
-
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanTells whether a local persistence file exists on the local filesystem for that agent.booleanload()Reads the persisted data local file and applies the contained value to thePersistannotated fields.booleanPersists the annotated fields values in a local file.voidvoidpreStart()Called from the enclosingSubsystemwhenorg.lsst.ccs.Subsystem#start()has been called.voidsetAutomatic(boolean loadAtStartup, boolean persistAtShutdown) Customize the behavior of the local persistence service.voidsetPersistencyFileName(String fileName) voidshutdown()Called from the enclosingSubsystemwhenorg.lsst.ccs.Subsystem#shutdown()has been called.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.lsst.ccs.framework.HasLifecycle
build, init, postBuild, postInit, postShutdown, postStart, startMethods inherited from interface org.lsst.ccs.ServiceLifecycle
afterBuild, afterStart, preBuild, preInit
-
Method Details
-
afterInit
public void afterInit()- Specified by:
afterInitin interfaceServiceLifecycle
-
setPersistencyFileName
-
preStart
public void preStart()Description copied from interface:ServiceLifecycleCalled from the enclosingSubsystemwhenorg.lsst.ccs.Subsystem#start()has been called.The preceding lifecycle step is
HasLifecycle.postInit()The following lifecycle step is
HasLifecycle.start()At the time it is called :-
the
PhaseStateisINITIALIZINGconnection with the messaging layer is effective, the enclosing subsystem has startedStatusHeartBeatpublication- Specified by:
preStartin interfaceServiceLifecycle
-
preShutdown
public void preShutdown()- Specified by:
preShutdownin interfaceServiceLifecycle
-
shutdown
public void shutdown()Description copied from interface:HasLifecycleCalled from the enclosingSubsystemwhenorg.lsst.ccs.Subsystem#shutdown()has been called. At the time it is calledPhaseStateisCLOSING. It should be overridden to free non hardware related resources.- Specified by:
shutdownin interfaceHasLifecycle
-
setAutomatic
public void setAutomatic(boolean loadAtStartup, boolean persistAtShutdown) Customize the behavior of the local persistence service. This method can only when the Agent is initializing, otherwise it throws an exception.- Parameters:
loadAtStartup- true if the persistence file should be loaded automatically at startuppersistAtShutdown- true if the persistence file should be written autmatically at shutdown
-
persistNow
@Command(description="writes persistent data in local file", category=SYSTEM) public boolean persistNow()Persists the annotated fields values in a local file. REVIEW : how do we make sure that modifications made to the fields are visible ? Does it matter ?- Returns:
- true if the persistence was successful, false otherwise.
-
load
@Command(description="loads persistent data from local file", category=SYSTEM) public boolean load()Reads the persisted data local file and applies the contained value to thePersistannotated fields. Inconsistent data are silently ignored- Returns:
- true if the local persistent file has been set correctly, false otherwise.
-
isLocalPersistenceFilePresent
@Command(description="returns true if a local persistence file is present, false otherwise.", category=SYSTEM) public boolean isLocalPersistenceFilePresent()Tells whether a local persistence file exists on the local filesystem for that agent.- Returns:
- true if such a file exists, false otherwise.
-