equip.data
Interface IDataStore

All Known Implementing Classes:
CustomTableDataStore, MemoryDataStore

public interface IDataStore

The interface to a data item store, used internally by a DataDelegate to implement state storage within a dataspace replica.

Author:
Chris Greenhalgh, 2003-10-27

Method Summary
 boolean checkAdd(AddEvent add)
          check if store would like to/be prepared to handle this AddEvent.
 void flush()
          Flush any pending persistent records
 java.util.Enumeration getCandidateItemBindings(ItemData[] itemTemplates)
          get the ItemBinding maintained by this store which should be considered when pattern matching the associated itemTemplates for an add/delete while present pattern.
 java.util.Enumeration getExpiredGUIDs(Time now)
          returns GUIDs of all leased items expiring at or before time 'now'.
 Time getFirstExpireTime()
          returns lowest (soonest, or furthest in past) expire time of any leased item in this store.
 ItemBinding getItemBinding(GUID id)
          get the ItemBinding for the given id iff it is maintained by this store, else null.
 java.util.Enumeration getRemoveResponsibleGUIDs(RemoveResponsible remove)
          get GUIDs of data items in this store which are process bound to the given responsible ID as per the RemoveResponsible event (or not, according to inverse flag).
 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.
 boolean holdsGUID(GUID id)
          check if store is maintaining state for the given GUID.
 void terminate()
          terminate - tidy up.
 void truncateExpireTimes(GUID responsible, Time expire)
          reduce lease on all leased items with given responsible id to expire at 'expire time'.
 

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.

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

checkAdd

public boolean checkAdd(AddEvent add)
check if store would like to/be prepared to handle this AddEvent.

Parameters:
add - The AddEvent to be handled.
Returns:
true iff this store would be happy/able to handle it.

holdsGUID

public boolean holdsGUID(GUID id)
check if store is maintaining state for the given GUID.

Parameters:
id - The GUID of the data item in question.
Returns:
true iff the store currently has state for this item.

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).

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.

Returns:
true iff the delete has been handled (and necessarily the item's state was maintained by this store).

getRemoveResponsibleGUIDs

public java.util.Enumeration getRemoveResponsibleGUIDs(RemoveResponsible remove)
get GUIDs of data items in this store which are process bound to the given responsible ID as per the RemoveResponsible event (or not, according to inverse flag).

Parameters:
remove - the RemoveResponsible event.
Returns:
an Enumeration of the GUIDs of locally maintained data items that should now be deleted.

getItemBinding

public ItemBinding getItemBinding(GUID id)
get the ItemBinding for the given id iff it is maintained by this store, else null.

Parameters:
id - the id of the data item being requested.
Returns:
the ItemBinding for that item, else null iff unknown to this store.

getCandidateItemBindings

public java.util.Enumeration getCandidateItemBindings(ItemData[] itemTemplates)
get the ItemBinding maintained by this store which should be considered when pattern matching the associated itemTemplates for an add/delete while present pattern.

Parameters:
itemTemplates - array of template data items, else null or zero length list for a wild-card (any item).
Returns:
Enumeration of ItemBindings that should be considered (guaranteed to be a superset of possible matches).

getFirstExpireTime

public Time getFirstExpireTime()
returns lowest (soonest, or furthest in past) expire time of any leased item in this store.

Returns:
lowest (soonest, or furthest in past) expire time, else null (no leased items).

getExpiredGUIDs

public java.util.Enumeration getExpiredGUIDs(Time now)
returns GUIDs of all leased items expiring at or before time 'now'.

Parameters:
now - The current time of the expiration clock.
Returns:
Enumeration of GUIDs of now expiring data items which the call might now reasonably issue delete events for).

truncateExpireTimes

public void truncateExpireTimes(GUID responsible,
                                Time expire)
reduce lease on all leased items with given responsible id to expire at 'expire time'.

Parameters:
responsible - required item responsible id
expire - the new expire time for matched items
Returns:
none.

terminate

public void terminate()
terminate - tidy up.


flush

public void flush()
Flush any pending persistent records