org.gcube.common.core.persistence
Class GCUBERIFilePersistenceManager

java.lang.Object
  extended by org.gcube.common.core.persistence.GCUBERIPersistenceManager
      extended by org.gcube.common.core.persistence.GCUBERIFilePersistenceManager

public abstract class GCUBERIFilePersistenceManager
extends GCUBERIPersistenceManager

A GCUBERIPersistenceManager for Running Instances that persist their state on the file system.

Author:
Fabio Simeoni (University of Strathclyde)

Nested Class Summary
 
Nested classes/interfaces inherited from class org.gcube.common.core.persistence.GCUBERIPersistenceManager
GCUBERIPersistenceManager.StateChangeConsumer, GCUBERIPersistenceManager.StateNotFoundException
 
Field Summary
 
Fields inherited from class org.gcube.common.core.persistence.GCUBERIPersistenceManager
ctxt, excludes, logger, profile
 
Constructor Summary
GCUBERIFilePersistenceManager(GCUBEServiceContext ctxt, GCUBERIPersistenceManagerProfile profile)
          Creates a new instance for a given service and from a given configuration profile.
 
Method Summary
protected  void commitState()
          Invoked by GCUBERIPersistenceManager.commit() to commit the state of the running instance.
protected  List<File> getState(File dir, List<File>... files)
          Used internally to enumerate the files that comprise the state to persist (i.e.
protected  File getStateFile()
          Returns the file in which state is to be packaged.
 boolean isExclude(String name)
          Used internally to check whether a given string matches at least one of the exclude directives.
protected abstract  void loadState()
          Loads the state of the running instance from persistent storage.
protected  void packageState()
          Packages the state of the running instance in a single file.
protected  void recoverState()
          Invoked by GCUBERIPersistenceManager.recover() to recover the state of the running instance.
protected abstract  void storeState()
          Stores the state of the running instance into persistent storage.
protected  void unpackageState()
          Unpackages the state of the running instances from a single file.
 
Methods inherited from class org.gcube.common.core.persistence.GCUBERIPersistenceManager
commit, exclude, getCommit, recover, setCommit, setLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GCUBERIFilePersistenceManager

public GCUBERIFilePersistenceManager(GCUBEServiceContext ctxt,
                                     GCUBERIPersistenceManagerProfile profile)
Creates a new instance for a given service and from a given configuration profile.

Parameters:
ctxt - the context of the service.
profile - the configuration profile.
Method Detail

commitState

protected void commitState()
                    throws Exception
Invoked by GCUBERIPersistenceManager.commit() to commit the state of the running instance.

Specified by:
commitState in class GCUBERIPersistenceManager
Throws:
Exception - if the state could not be committed.

recoverState

protected void recoverState()
                     throws GCUBERIPersistenceManager.StateNotFoundException,
                            Exception
Invoked by GCUBERIPersistenceManager.recover() to recover the state of the running instance.

Specified by:
recoverState in class GCUBERIPersistenceManager
Throws:
Exception - if the state could not be recovered.
GCUBERIPersistenceManager.StateNotFoundException

getState

protected List<File> getState(File dir,
                              List<File>... files)
Used internally to enumerate the files that comprise the state to persist (i.e. filtered by excludes directives), starting from a given directory.

Parameters:
dir - the start directory.
files - (optional) the list of files to persist accumulated during recursive invocations.
Returns:
the files to persist.

isExclude

public boolean isExclude(String name)
Used internally to check whether a given string matches at least one of the exclude directives.

Parameters:
name - the name to match.
Returns:
true if the string matches, false otherwise.

getStateFile

protected File getStateFile()
                     throws IOException
Returns the file in which state is to be packaged.

Returns:
the file.
Throws:
IOException

packageState

protected void packageState()
                     throws Exception
Packages the state of the running instance in a single file.

Throws:
Exception - if the state could not be packaged.

unpackageState

protected void unpackageState()
                       throws Exception
Unpackages the state of the running instances from a single file.

Throws:
Exception - if the state could not be unpackaged.

loadState

protected abstract void loadState()
                           throws GCUBERIPersistenceManager.StateNotFoundException,
                                  Exception
Loads the state of the running instance from persistent storage.

Throws:
Exception - if the state could not be loaded.
GCUBERIPersistenceManager.StateNotFoundException

storeState

protected abstract void storeState()
                            throws Exception
Stores the state of the running instance into persistent storage.

Throws:
Exception - if the state could not be persisted.


Copyright © 2013. All Rights Reserved.