P-Grid v2.0a2 API Specification

p2p.storage
Interface Storage


public interface Storage

Defines the operations that the storage layer supports. It includes standard data (search, insert, delete, update) operations and registration of callbacks associated with them.

Version:
1.0.0
Author:
@author Roman Schmidt

Method Summary
 void addStorageListener(StorageListener listener, Type type)
          Register a listener of events related to data items.
 void delete(Collection items)
          Remove the data items with given Ds.
 Collection getLocalDataItems()
          Get collection of the local data items.
 void insert(Collection items)
          Store the data items into the network
 void search(Query query, SearchListener listener)
          Search the network for matching items.
 void shutdown()
          Shutdowns the storage service.
 void update(Collection items)
          Inserts the dataitems int the network, if the items with such ID's already exist, they will be rewritten
 

Method Detail

addStorageListener

void addStorageListener(StorageListener listener,
                        Type type)
Register a listener of events related to data items. Such listeners are notified when operations on items on the the current node are requested.

Parameters:
listener - the listener to register
type - the type of data items that the listener is interested in

delete

void delete(Collection items)
Remove the data items with given Ds.

Parameters:
items - data items to be removed

insert

void insert(Collection items)
Store the data items into the network

Parameters:
items - the DataItems to insert

getLocalDataItems

Collection getLocalDataItems()
Get collection of the local data items.

Returns:
the local data items.

search

void search(Query query,
            SearchListener listener)
            throws NoSuchTypeException,
                   NoRouteToKeyException
Search the network for matching items. Implemented as an asynchronous operation, because search might take some time. Callback is notified for each new result.

Parameters:
query - the query used to specify the search
listener - an object to notify when results arrive
Throws:
NoSuchTypeException - if the provided Type is unknown.
NoRouteToKeyException - if the query cannot be routed to a responsible peer.

update

void update(Collection items)
Inserts the dataitems int the network, if the items with such ID's already exist, they will be rewritten

Parameters:
items - the collection of data items

shutdown

void shutdown()
Shutdowns the storage service.


P-Grid v2.0a2 API Specification

This is open source software distributed under the terms of the GNU General Public License, a copy of which is included in the file LICENSE. If not you can find the GPL at http://www.gnu.org/copyleft/gpl.txt