equip.data
Class FileBackedMemoryDataStore

java.lang.Object
  extended byequip.data.MemoryDataStore
      extended byequip.data.FileBackedMemoryDataStore
All Implemented Interfaces:
IDataStore

public class FileBackedMemoryDataStore
extends MemoryDataStore

Like MemoryDataStore, but attempts to persist dataspace contents through use of checkpoint and event log files.

See notes for DataDelegate for configuring a dataspace to make use of a custom data store such as this. Note that you should probably also fix the responsible ID for the DataDelegate.

Configuration:

 STOREID.path: DIRECTORYPATH [default "." - will use/create STOREID subdirectory]
 STOREID.checkpointEventCount: EVENTS-BETWEEN-CHECKPOINTS [default 1000]
 STOREID.maxFlushIntervalS: MAX-TIME-BETWEE-EVENTS-FLUSH [default 10, 0 to flush every event]
 STOREID.writeProcessBound: T/F [default T]
 STOREID.writePureEvents: T/F [default T]
 STOREID.restoreProcessBound: T/F [default F - don't enable this unless you are really sure :-)]
 

Files/formats. All files are in the STOREID subdirectory of the STOREID.path.


Nested Class Summary
 
Nested classes inherited from class equip.data.MemoryDataStore
MemoryDataStore.LeasedItem
 
Field Summary
static java.lang.String CHECKPOINT_HEADER
           
static java.lang.String CHECKPOINT_PREFIX
           
static java.lang.String CHECKPOINT_SUFFIX
           
static int CHECKPOINT_VERSION
           
static java.lang.String EVENTS_HEADER
           
static java.lang.String EVENTS_PREFIX
           
static java.lang.String EVENTS_SUFFIX
           
static int EVENTS_VERSION
           
static int MIN_CHECKPOINT_VERSION
           
static int MIN_EVENTS_VERSION
           
static java.lang.String TEMP_SUFFIX
           
 
Fields inherited from class equip.data.MemoryDataStore
idMap, leasedItems, parentMultimap
 
Constructor Summary
FileBackedMemoryDataStore(java.lang.String storeId, GUID responsible)
           
 
Method Summary
 void flush()
          Flush any pending persistent records
 boolean handleAdd(AddEvent add)
          request that store handle the Add event, adding to itself accordingly.
 boolean handleDelete(DeleteEvent del)
          request that store handles the given delete, which it must iff it is currently maintaining state for the corresponding data item.
 boolean handleUpdate(UpdateEvent upd)
          request that store handles the given update, which it must iff it is currently maintaining state for it.
 void terminate()
          terminate - tidy up.
 
Methods inherited from class equip.data.MemoryDataStore
checkAdd, getCandidateItemBindings, getExpiredGUIDs, getFirstExpireTime, getItemBinding, getRemoveResponsibleGUIDs, holdsGUID, removeParent, truncateExpireTimes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHECKPOINT_PREFIX

public static final java.lang.String CHECKPOINT_PREFIX
See Also:
Constant Field Values

CHECKPOINT_SUFFIX

public static final java.lang.String CHECKPOINT_SUFFIX
See Also:
Constant Field Values

TEMP_SUFFIX

public static final java.lang.String TEMP_SUFFIX
See Also:
Constant Field Values

EVENTS_PREFIX

public static final java.lang.String EVENTS_PREFIX
See Also:
Constant Field Values

EVENTS_SUFFIX

public static final java.lang.String EVENTS_SUFFIX
See Also:
Constant Field Values

CHECKPOINT_HEADER

public static final java.lang.String CHECKPOINT_HEADER
See Also:
Constant Field Values

CHECKPOINT_VERSION

public static final int CHECKPOINT_VERSION
See Also:
Constant Field Values

MIN_CHECKPOINT_VERSION

public static final int MIN_CHECKPOINT_VERSION
See Also:
Constant Field Values

EVENTS_HEADER

public static final java.lang.String EVENTS_HEADER
See Also:
Constant Field Values

EVENTS_VERSION

public static final int EVENTS_VERSION
See Also:
Constant Field Values

MIN_EVENTS_VERSION

public static final int MIN_EVENTS_VERSION
See Also:
Constant Field Values
Constructor Detail

FileBackedMemoryDataStore

public FileBackedMemoryDataStore(java.lang.String storeId,
                                 GUID responsible)
                          throws DataStoreConfigurationException
Method Detail

handleAdd

public boolean handleAdd(AddEvent add)
request that store handle the Add event, adding to itself accordingly. Note: also has to handle lease updates.

Specified by:
handleAdd in interface IDataStore
Overrides:
handleAdd in class MemoryDataStore
Parameters:
add - The AddEvent to be handled.
Returns:
true iff this store has handled the add event; false if declined. (normally as indicated by a call to IDataStore.checkAdd

handleUpdate

public boolean handleUpdate(UpdateEvent upd)
request that store handles the given update, which it must iff it is currently maintaining state for it. Note: implies currently no migration of item state between store(s).

Specified by:
handleUpdate in interface IDataStore
Overrides:
handleUpdate in class MemoryDataStore
Parameters:
upd - the UpdateEvent to be handled.
Returns:
true iff the update has been handled (and necessarily the item's state is maintained by this store).

handleDelete

public boolean handleDelete(DeleteEvent del)
request that store handles the given delete, which it must iff it is currently maintaining state for the corresponding data item.

Specified by:
handleDelete in interface IDataStore
Overrides:
handleDelete in class MemoryDataStore
Returns:
true iff the delete has been handled (and necessarily the item's state was maintained by this store).

terminate

public void terminate()
terminate - tidy up.

Specified by:
terminate in interface IDataStore
Overrides:
terminate in class MemoryDataStore

flush

public void flush()
Flush any pending persistent records

Specified by:
flush in interface IDataStore
Overrides:
flush in class MemoryDataStore