|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgr.uoa.di.madgik.commons.state.StateManager
public class StateManager
The StateManager
class is a utility class serving as the entry point to the State Store Repository utility.
Its purpose is to interface between clients and a persistency key-value system to enable clients to stroe state they may
need in case of restarts or simply as lognterm or temporary storage without needing to directly interact with the filesystem
or other data stores. The utility uses two files in the local filesystem to persist information it needs. One file is used to
store metadata on the entries that are stored and the other tha actual payload of the provided entries. The files that are used
are retrived through the ConfigurationManager
where the StateManager
expects to find under the
StateManager.StateStoreInfo
key an instnace of the StateStoreInfo
class holding the files to use. The
StateStoreData
instnace also expects to find some information in the ConfigurationManager
.
The actual markup that needs to be stored in the configuration file is shown below
<param name="EncodingCharset" type="String" generated="false" internal="false">UTF-8</param>
<param name="StateManager.CleanUpOnInit" type="BooleanPrimitive" generated="false" internal="false">CleanUp data and registry files on initialization</param>
<param name="StateManager.EntryRegistryPathName" type="String" generated="false" internal="true">path to registry file to use</param>
<param name="StateManager.EntryRegistryFile" type="Object" generated="false" internal="false" shared="false">
<class value="java.io.File" />
<constructor>
<arguments>
<arg order="1" name="pathname" param="StateManager.EntryRegistryPathName"/>
</arguments>
</constructor>
</param>
<param name="StateManager.EntryDataPathName" type="String" generated="false" internal="true">path to data file to use</param>
<param name="StateManager.EntryDataFile" type="Object" generated="false" internal="false" shared="false">
<class value="java.io.File" />
<constructor>
<arguments>
<arg order="1" name="pathname" param="StateManager.EntryDataPathName"/>
</arguments>
</constructor>
</param>
<param name="StateManager.StateStoreInfo" type="Object" generated="false" internal="false" shared="false">
<class value="gr.uoa.di.madgik.state.store.StateStoreInfo" />
<constructor>
<arguments>
<arg order="1" name="EntryRegistryFile" param="StateManager.EntryRegistryFile"/>
<arg order="2" name="EntryDataFile" param="StateManager.EntryDataFile"/>
</arguments>
</constructor>
</param>
Different types of entries can be stored to the State Store Repository whose values will be retrieved and storerd with different
ways. These types are the ones depicted by the StateStoreRegistryKey.EntryType
enumeration.
The StateManager
provides serialized access to its resources.
TODO Add functionality to compress data before storing them
TODO More sophisticated CleanUp initiation policy
Constructor Summary | |
---|---|
StateManager()
|
Method Summary | |
---|---|
static void |
Compact()
In case of deletes and updates in the registry and data file, there will be data kept in the files that are no longer needed but simply remain increrasing the size of the repository files. |
static java.lang.Boolean |
Contains(java.lang.String key)
Checks if the provided key is contained in the State Store Repository. |
static StateStoreRegistryKey.EntryType |
ContainsType(java.lang.String key)
If the provided key is associated in the State Store as the Contains(java.lang.String)
dictates, this method returns the type of data the entry stores |
static boolean |
Delete(java.lang.String Key)
If the priovided key is available in the State Store as dictated by Contains(java.lang.String)
the StateStoreRegistry.Delete(java.lang.String, gr.uoa.di.madgik.commons.state.store.StateStoreInfo) method is called
and its return value returned. |
static java.lang.String |
GetAlphanumeric(java.lang.String Key)
Retrieves the payload associated with the provided key as an alphanumeric string |
static byte[] |
GetByteArray(java.lang.String Key)
Retrieves the payload associated with the provided key as a byte array |
static java.io.File |
GetFile(java.lang.String Key)
Retrieves the payload associated with the provided key as a file whose content is teh stored data |
static ISerializable |
GetISerializable(java.lang.String Key)
Retrieves the payload associated with the provided key as an object |
static java.io.Serializable |
GetSerializable(java.lang.String Key)
Retrieves the payload associated with the provided key as an object |
static java.lang.String |
GetStateStoreInfo()
Retrieves a string representation of the StateStoreInfo |
static java.lang.Boolean |
Put(java.lang.String key,
byte[] bytearray)
Adds or updates the StateStoreRegistryKey referenced by the providede key. |
static java.lang.Boolean |
Put(java.lang.String key,
java.io.File file)
Adds or updates the StateStoreRegistryKey referenced by the providede key. |
static java.lang.Boolean |
Put(java.lang.String key,
ISerializable obj)
Adds or updates the StateStoreRegistryKey referenced by the providede key. |
static java.lang.Boolean |
Put(java.lang.String key,
java.io.Serializable obj)
Adds or updates the StateStoreRegistryKey referenced by the providede key. |
static java.lang.Boolean |
Put(java.lang.String key,
java.lang.String Alphanumeric)
Adds or updates the StateStoreRegistryKey referenced by the providede key. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StateManager()
Method Detail |
---|
public static java.lang.String GetStateStoreInfo()
StateStoreInfo
StateStoreInfo
public static boolean Delete(java.lang.String Key) throws java.lang.Exception
Contains(java.lang.String)
the StateStoreRegistry.Delete(java.lang.String, gr.uoa.di.madgik.commons.state.store.StateStoreInfo)
method is called
and its return value returned. Otherwise, false
is returned
Key
- The key whose entry should be marked as inactive
false
if the key is not assciated with an entry, otherwise the return value of
StateStoreRegistry.Delete(java.lang.String, gr.uoa.di.madgik.commons.state.store.StateStoreInfo)
java.lang.Exception
- The delete could not be performedpublic static java.lang.Boolean Contains(java.lang.String key)
StateStoreRegistryKey
is active.
key
- The key to check for
true
if thekey is associated with an existing and active entry,false
otherwisepublic static StateStoreRegistryKey.EntryType ContainsType(java.lang.String key) throws java.lang.Exception
Contains(java.lang.String)
dictates, this method returns the type of data the entry stores
key
- The key to check if it is associtated with an entry
StateStoreRegistryKey.GetTypeOfEntry()
java.lang.Exception
- The key was not foundpublic static java.lang.String GetAlphanumeric(java.lang.String Key) throws java.lang.Exception
Key
- The key whose value to retrieve
java.lang.Exception
- The retrieval could not be accomplishedpublic static java.io.File GetFile(java.lang.String Key) throws java.lang.Exception
Key
- The key whose value to retrieve
java.lang.Exception
- The retrieval could not be accomplishedpublic static byte[] GetByteArray(java.lang.String Key) throws java.lang.Exception
Key
- The key whose value to retrieve
java.lang.Exception
- The retrieval could not be accomplishedpublic static java.io.Serializable GetSerializable(java.lang.String Key) throws java.lang.Exception
Key
- The key whose value to retrieve
java.lang.Exception
- The retrieval could not be accomplishedpublic static ISerializable GetISerializable(java.lang.String Key) throws java.lang.Exception
Key
- The key whose value to retrieve
java.lang.Exception
- The retrieval could not be accomplishedpublic static java.lang.Boolean Put(java.lang.String key, java.lang.String Alphanumeric) throws java.lang.Exception
StateStoreRegistryKey
referenced by the providede key. Uses
StateStoreRegistry.Put(gr.uoa.di.madgik.commons.state.store.registry.StateStoreRegistryKey, gr.uoa.di.madgik.commons.state.store.StateStoreInfo)
and StateStoreData.Put(gr.uoa.di.madgik.commons.state.store.registry.StateStoreRegistryKey, java.lang.String)
to
update its internal structures. The value returend is the returned by the
StateStoreRegistry.Put(gr.uoa.di.madgik.commons.state.store.registry.StateStoreRegistryKey, gr.uoa.di.madgik.commons.state.store.StateStoreInfo)
call
key
- The key to associate the provided payload withAlphanumeric
- The payload to store
StateStoreRegistry.Put(gr.uoa.di.madgik.commons.state.store.registry.StateStoreRegistryKey, gr.uoa.di.madgik.commons.state.store.StateStoreInfo)
java.lang.Exception
- The addition could not be performedpublic static java.lang.Boolean Put(java.lang.String key, byte[] bytearray) throws java.lang.Exception
StateStoreRegistryKey
referenced by the providede key. Uses
StateStoreRegistry.Put(gr.uoa.di.madgik.commons.state.store.registry.StateStoreRegistryKey, gr.uoa.di.madgik.commons.state.store.StateStoreInfo)
and StateStoreData.Put(gr.uoa.di.madgik.commons.state.store.registry.StateStoreRegistryKey, byte[])
to
update its internal structures. The value returend is the returned by the
StateStoreRegistry.Put(gr.uoa.di.madgik.commons.state.store.registry.StateStoreRegistryKey, gr.uoa.di.madgik.commons.state.store.StateStoreInfo)
call
key
- The key to associate the provided payload withbytearray
- The payload to store
StateStoreRegistry.Put(gr.uoa.di.madgik.commons.state.store.registry.StateStoreRegistryKey, gr.uoa.di.madgik.commons.state.store.StateStoreInfo)
java.lang.Exception
- The addition could not be performedpublic static java.lang.Boolean Put(java.lang.String key, ISerializable obj) throws java.lang.Exception
StateStoreRegistryKey
referenced by the providede key. Uses
StateStoreRegistry.Put(gr.uoa.di.madgik.commons.state.store.registry.StateStoreRegistryKey, gr.uoa.di.madgik.commons.state.store.StateStoreInfo)
and StateStoreData.Put(gr.uoa.di.madgik.commons.state.store.registry.StateStoreRegistryKey, gr.uoa.di.madgik.commons.state.store.data.ISerializable)
to
update its internal structures. The value returend is the returned by the
StateStoreRegistry.Put(gr.uoa.di.madgik.commons.state.store.registry.StateStoreRegistryKey, gr.uoa.di.madgik.commons.state.store.StateStoreInfo)
call
key
- The key to associate the provided payload withobj
- The object to store
StateStoreRegistry.Put(gr.uoa.di.madgik.commons.state.store.registry.StateStoreRegistryKey, gr.uoa.di.madgik.commons.state.store.StateStoreInfo)
java.lang.Exception
- The addition could not be performedpublic static java.lang.Boolean Put(java.lang.String key, java.io.Serializable obj) throws java.lang.Exception
StateStoreRegistryKey
referenced by the providede key. Uses
StateStoreRegistry.Put(gr.uoa.di.madgik.commons.state.store.registry.StateStoreRegistryKey, gr.uoa.di.madgik.commons.state.store.StateStoreInfo)
and StateStoreData.Put(gr.uoa.di.madgik.commons.state.store.registry.StateStoreRegistryKey, java.io.Serializable)
to
update its internal structures. The value returend is the returned by the
StateStoreRegistry.Put(gr.uoa.di.madgik.commons.state.store.registry.StateStoreRegistryKey, gr.uoa.di.madgik.commons.state.store.StateStoreInfo)
call
key
- The key to associate the provided payload withobj
- The object to store
StateStoreRegistry.Put(gr.uoa.di.madgik.commons.state.store.registry.StateStoreRegistryKey, gr.uoa.di.madgik.commons.state.store.StateStoreInfo)
java.lang.Exception
- The addition could not be performedpublic static java.lang.Boolean Put(java.lang.String key, java.io.File file) throws java.lang.Exception
StateStoreRegistryKey
referenced by the providede key. Uses
StateStoreRegistry.Put(gr.uoa.di.madgik.commons.state.store.registry.StateStoreRegistryKey, gr.uoa.di.madgik.commons.state.store.StateStoreInfo)
and StateStoreData.Put(gr.uoa.di.madgik.commons.state.store.registry.StateStoreRegistryKey, java.io.File)
to
update its internal structures. The value returend is the returned by the
StateStoreRegistry.Put(gr.uoa.di.madgik.commons.state.store.registry.StateStoreRegistryKey, gr.uoa.di.madgik.commons.state.store.StateStoreInfo)
call
key
- The key to associate the provided payload withfile
- The file whose payload to store
StateStoreRegistry.Put(gr.uoa.di.madgik.commons.state.store.registry.StateStoreRegistryKey, gr.uoa.di.madgik.commons.state.store.StateStoreInfo)
java.lang.Exception
- The addition could not be performedpublic static void Compact() throws java.lang.Exception
StateStoreRegistry.MoveToClean()
and StateStoreData.MoveToClean(java.util.Map)
methods, updates the StateStoreRegistryKey
entries in the registry file, removes the old
repository files, and renames the new clean ones to the ones dictated by StateStoreInfo
java.lang.Exception
- The cleanup could not be perofrmed
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |