de.fhg.igd.atlas.core
Interface StorageDB

All Known Implementing Classes:
MemoryDB

public interface StorageDB

Provides the interface for storage databases which are used to store entries of type StorageDBEntry. These databases are needed in the context of the Location Service Protocol (LSP) as part of a Location Service Server (LSServer). Implementations of this interface should be efficient enough to keep up with the high update rates which are typical for a location service for mobile objects. An event mechanism informs registered listeners whenever the state of the database has changed due to the modification or deletion of existing entries or the initialization of a new entry.

Version:
"$Id: StorageDB.java 1913 2007-08-08 02:41:53Z jpeters $"
Author:
Jan Peters
See Also:
LSServerService, StorageDBEntry, StorageDBImmutableEntry, StorageDBEvent

Method Summary
 boolean delete(byte[] implicitName)
          Deletes an existing entry with the given implicitName.
 boolean getEventFlag()
          Returns the current state of the event flag.
 EventReflector getEventReflector()
          Returns the reference to the database's event reflector which is notified with StorageDBEvent objects incrementally describing the state of the database.
 int getSize()
          Returns the current number of entries in the database.
 long getTimeout()
          Returns the timeout of entries in the database.
 boolean init(byte[] implicitName, URL contactAddress, byte[] cookie)
          Initializes a new entry with the given implicitName, contactAddress and cookie.
 Set list(long timestamp)
          Returns the content of the database as set of entries with a timestamp newer then the given one.
 StorageDBImmutableEntry lookup(byte[] implicitName)
          Returns the result of a database lookup with the given implicitName as immutable entry.
 boolean refresh(byte[] implicitName)
          Refreshes an existing entry with the given implicitName, by updating the entries timestamp to the current time.
 void setEventFlag(boolean flag)
          Sets the event flag to enable respectively disable the generation of events.
 void setTimeout(long timeout)
          Sets the timeout of entries in the database.
 boolean update(byte[] implicitName, URL contactAddress, byte[] cookie)
          Updates an existing entry with the given implicitName.
 

Method Detail

lookup

public StorageDBImmutableEntry lookup(byte[] implicitName)
Returns the result of a database lookup with the given implicitName as immutable entry.

Parameters:
implicitName - The implicit name.
Returns:
The immutable entry corresponding to the implicitName or null if the entry was not found.

init

public boolean init(byte[] implicitName,
                    URL contactAddress,
                    byte[] cookie)
Initializes a new entry with the given implicitName, contactAddress and cookie. If an entry with the implicitName already exists, false is returned.

Parameters:
implicitName - The implicit name.
contactAddress - The contact address.
cookie - The cookie.
Returns:
true if has been created successfully; false otherwise.

update

public boolean update(byte[] implicitName,
                      URL contactAddress,
                      byte[] cookie)
Updates an existing entry with the given implicitName. If no entry with the implicitName exists, false is returned.

Parameters:
implicitName - The implicit name.
contactAddress - The contact address.
cookie - The cookie.
Returns:
true if has been updated successfully; false otherwise.

delete

public boolean delete(byte[] implicitName)
Deletes an existing entry with the given implicitName. If no entry with the implicitName exists, false is returned.

Parameters:
implicitName - The implicit name.
Returns:
true if has been deleted successfully; false otherwise.

refresh

public boolean refresh(byte[] implicitName)
Refreshes an existing entry with the given implicitName, by updating the entries timestamp to the current time. If no entry with the implicitName exists, false is returned.

Parameters:
implicitName - The implicit name.
Returns:
true if has been deleted refreshed; false otherwise.

list

public Set list(long timestamp)
Returns the content of the database as set of entries with a timestamp newer then the given one.

Parameters:
timestamp - The timestamp in milliseconds since January 1, 1970, 00:00:00 GMT
Returns:
The set of database entries of type StorageDBEntry.

getSize

public int getSize()
Returns the current number of entries in the database.

Returns:
The current database size as number of entries; or Integer.MAX_VALUE, iff the number of entries is larger than Integer.MAX_VALUE.

getTimeout

public long getTimeout()
Returns the timeout of entries in the database.

Returns:
The timeout in milli seconds.

setTimeout

public void setTimeout(long timeout)
Sets the timeout of entries in the database.

Parameters:
timeout - The timeout in milli seconds.

getEventReflector

public EventReflector getEventReflector()
Returns the reference to the database's event reflector which is notified with StorageDBEvent objects incrementally describing the state of the database. These envents are triggered every time the content of the database has changed, iff the event flag is set.

Returns:
The server's event reflector.

setEventFlag

public void setEventFlag(boolean flag)
Sets the event flag to enable respectively disable the generation of events.

Parameters:
flag - The event flag to be set.

getEventFlag

public boolean getEventFlag()
Returns the current state of the event flag.

Returns:
The event flag.


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.