gr.uoa.di.madgik.commons.state.store.registry
Class StateStoreRegistryKey

java.lang.Object
  extended by gr.uoa.di.madgik.commons.state.store.registry.StateStoreRegistryKey

public class StateStoreRegistryKey
extends java.lang.Object

The StateStoreRegistryKey class holds metadata information for one entry registrered with the State repository. The metadata kept for each such entry include the key with which the entry is identified, the offset within the registry file that this metadata entry is persisted, the location of the actual data the key is associated with in the data file, whether or not the entry is to be considered active or a client has deleted it and the type of the entry data.

Author:
gpapanikos

Nested Class Summary
static class StateStoreRegistryKey.EntryType
          The type of data an entry persisted with the state repository holds
 
Constructor Summary
StateStoreRegistryKey()
          Creates a new instance
StateStoreRegistryKey(java.lang.String Key, long StartingDataOffset, long EndingDataOffset, long StartingRegistryOffset, StateStoreRegistryKey.EntryType TypeOfEntry)
          Creates a new instance with the provided values
 
Method Summary
 void Deactivate()
          Sets the entry as deactivated
 void Decode(java.io.DataInputStream stream)
          Decodes a StateStoreRegistryKey as the Encode(java.io.RandomAccessFile) wrote it in the provided file.
 void Encode(java.io.RandomAccessFile stream)
          Stores this instance in the provided file leaving the file pointer at the end of the written entry.
 long GetEndingDataOffset()
          Retrieves the ending offset in the data fale where the entry's data are stored
 java.lang.String GetKey()
          Retrieves the key with which the entry is identified
 long GetStartingDataOffset()
          Retrieves the offset in the data falie where the entry's data are stored
 long GetStartingRegistryOffset()
          Retrieves the offset in the registry file where this metadata entry is stored
 StateStoreRegistryKey.EntryType GetTypeOfEntry()
          Retrieves the type of entry
 java.lang.Boolean IsActive()
          Whether or not the entry is considered active or it has been deleted
 void SetEndingDataOffset(long Offset)
          Sets the ending offset in the data fale where the entry's data are stored
 void SetStartingDataOffset(long Offset)
          Sets the offset in the data falie where the entry's data are stored
 void SetStartingRegistryOffset(long Offset)
          Sets the offset in the registry file where this metadata entry is stored
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StateStoreRegistryKey

public StateStoreRegistryKey()
Creates a new instance


StateStoreRegistryKey

public StateStoreRegistryKey(java.lang.String Key,
                             long StartingDataOffset,
                             long EndingDataOffset,
                             long StartingRegistryOffset,
                             StateStoreRegistryKey.EntryType TypeOfEntry)
Creates a new instance with the provided values

Parameters:
Key - The key with which this entry is reachable
StartingDataOffset - The starting offset of the actual data in the data file
EndingDataOffset - The ending offset of the actual data in the data file
StartingRegistryOffset - The starting offset of this metadata record in the registry file
TypeOfEntry - The type of the actual data stored
Method Detail

IsActive

public java.lang.Boolean IsActive()
Whether or not the entry is considered active or it has been deleted

Returns:
whether or not the entry is considered active or it has been deactivated

Deactivate

public void Deactivate()
Sets the entry as deactivated


GetKey

public java.lang.String GetKey()
Retrieves the key with which the entry is identified

Returns:
The key

GetTypeOfEntry

public StateStoreRegistryKey.EntryType GetTypeOfEntry()
Retrieves the type of entry

Returns:
the type of entry

GetStartingRegistryOffset

public long GetStartingRegistryOffset()
Retrieves the offset in the registry file where this metadata entry is stored

Returns:
the offset

SetStartingRegistryOffset

public void SetStartingRegistryOffset(long Offset)
Sets the offset in the registry file where this metadata entry is stored

Parameters:
Offset - the offset

GetStartingDataOffset

public long GetStartingDataOffset()
Retrieves the offset in the data falie where the entry's data are stored

Returns:
the offset

SetStartingDataOffset

public void SetStartingDataOffset(long Offset)
Sets the offset in the data falie where the entry's data are stored

Parameters:
Offset - the offset

GetEndingDataOffset

public long GetEndingDataOffset()
Retrieves the ending offset in the data fale where the entry's data are stored

Returns:
The offset

SetEndingDataOffset

public void SetEndingDataOffset(long Offset)
Sets the ending offset in the data fale where the entry's data are stored

Parameters:
Offset - the offset

Encode

public void Encode(java.io.RandomAccessFile stream)
            throws java.lang.Exception
Stores this instance in the provided file leaving the file pointer at the end of the written entry. The method also update the position of the metadata entry it just written to point to the position of the file it started serializing its content

Parameters:
stream - the file to write the entry to
Throws:
java.lang.Exception - The encoding could not be performed

Decode

public void Decode(java.io.DataInputStream stream)
            throws java.lang.Exception
Decodes a StateStoreRegistryKey as the Encode(java.io.RandomAccessFile) wrote it in the provided file.

Parameters:
stream - The file to read the entry from
Throws:
java.lang.Exception - The decoding could not be performed