public interface SyncService
database is hierarchical and the hierarchy is specified by
the strings in SyncServiceNodePath in order. i.e., At the root of
the hierarchy is a node identified by the first string in
SyncServiceNodePath and root's child node is identified by the next
string and so on.
To access the data in the database, user must first obtain
SyncServiceNode either by creating a new node or accessing an existing
node. Read/write/delete operations can be performed on the nodes using
SyncServiceNode
Some successful API calls can leave watches on the data nodes. Other calls
can trigger those watches. Once a watch is triggered, an event will be
delivered to the user which left the watch via SyncServiceUser.
Each watch is triggered only once. Thus, up to one event will be delivered
to a user for every watch it leaves.
Watches of two types can be set on nodes. First type is a watch that is
triggered on creation or deletion of node or changing node's data.
The second type is triggered on changes to node's children or the node is
deleted.
All API calls described below, internally use a TCP session established with the distributed database. In case of unrecoverable errors such as session expiration or authentication failure the session is terminated and all associated ephemeral nodes see createNode are deleted
| Modifier and Type | Method and Description |
|---|---|
SyncServiceNode |
createNode(SyncServiceNodePath nodePath,
byte[] data,
SyncServiceCreateMode createMode)
Create a new data node on distributed in memory database
|
SyncServiceNode |
getNode(SyncServiceNodePath nodePath)
Get existing data node from distributed in memory database
|
Boolean |
isSyncServiceUp() |
List<SyncServiceMultiOpResult> |
multi(List<SyncServiceMultiOp> opList)
Execute a batch of sync services operations.
|
boolean |
nodeExists(SyncServiceNodePath nodePath)
Check for node existence
|
boolean |
nodeExists(SyncServiceNodePath nodePath,
SyncServiceUser watcher)
Check for node existence and register watch on the node that is triggered
when the node is created, deleted or node's data is changed
|
void |
registerListener(SyncServiceUser watcher) |
void |
unregisterListener(SyncServiceUser watcher) |
void registerListener(SyncServiceUser watcher) throws IllegalArgumentException, DuplicateDataException
void unregisterListener(SyncServiceUser watcher) throws IllegalArgumentException, NotFoundException
Boolean isSyncServiceUp()
SyncServiceNode getNode(SyncServiceNodePath nodePath) throws ServiceNotAvailableException, SyncServiceException.NodeNotFoundException, InterruptedException
nodePath - Name of the node to be createdServiceNotAvailableException - Sync service is not UPSyncServiceException.NodeNotFoundException - Node not found exceptionInterruptedException - Operation interrupted exceptionSyncServiceNode createNode(SyncServiceNodePath nodePath, byte[] data, SyncServiceCreateMode createMode) throws ServiceNotAvailableException, SyncServiceException.NodeExistsException, SyncServiceException.NodeNotFoundException, InterruptedException, SyncServiceException.NoChildrenForEphemeralException
nodePath - Name of the node to be createddata - Data of the node to be createdcreateMode - Mode of the created node (PERSISTENT, EPHEMERAL, ...)
Persistent Nodes - These nodes exists till they are deleted
Ephemeral Nodes - These nodes exists as long as the session that created
is active. When the session ends the node is deleted. ephemeral nodes
are not allowed to have children.
Sequence Nodes - When creating a node you can also request to append a
monotonically increasing counter to the end of path. This counter is
unique to the parent node. The counter has a format of %010d --
that is 10 digits with 0 (zero) padding. i.e. "ServiceNotAvailableException - Sync service is not UPSyncServiceException.NodeExistsException - Node exists exceptionSyncServiceException.NodeNotFoundException - Node not found exceptionInterruptedException - Operation interrupted exceptionSyncServiceException.NoChildrenForEphemeralException - Children not allowed for
ephemeral nodesboolean nodeExists(SyncServiceNodePath nodePath) throws ServiceNotAvailableException, InterruptedException
nodePath - Node path to check if a node existsServiceNotAvailableException - Sync service is not UPInterruptedException - Operation interrupted exceptionboolean nodeExists(SyncServiceNodePath nodePath, SyncServiceUser watcher) throws ServiceNotAvailableException, InterruptedException
nodePath - Node path to check if a node exists and watch to be setwatcher - Watcher object passed by the userServiceNotAvailableException - Sync service is not UPInterruptedException - Operation interrupted exceptionList<SyncServiceMultiOpResult> multi(List<SyncServiceMultiOp> opList) throws ServiceNotAvailableException, InterruptedException, SyncServiceException.NodeExistsException, SyncServiceException.NodeNotFoundException, SyncServiceException.NodeHasChildrenException
opList - List of sync service multi operation objectsInterruptedException - Operation interrupted exceptionServiceNotAvailableException - Sync service is not UPSyncServiceException.NodeHasChildrenException - Node has childrenSyncServiceException.NodeNotFoundException - Node not foundSyncServiceException.NodeExistsException - Node existsCopyright © 2014. All Rights Reserved.