public class DataGateSyncTemplate extends java.lang.Object implements SyncTemplate
Represents a template for DataGate sync operations.
| Constructor and Description |
|---|
DataGateSyncTemplate(DataGateClient dataGateClient,
java.lang.String collection)
Instantiates a new
DataGateSyncTemplate. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
change(ChangeFeed changeFeed)
Uploads the local changes to the server.
|
ChangeFeed |
changedSince(FeedOptions feedOptions)
Downloads the list of changes from the server.
|
void |
clear()
Clears the remote collection.
|
java.util.List<Document> |
fetch(int offset,
int limit)
Fetches all documents from remote.
|
java.lang.String |
getCollectionName()
Gets the name of the remote collection.
|
boolean |
isOnline()
Checks if the server is online and reachable.
|
void |
releaseLock(java.lang.String issuer)
Releases the synchronization lock on the remote collection.
|
long |
size()
Gets the size of the remote collection.
|
boolean |
trySyncLock(TimeSpan expiryDelay,
java.lang.String issuer)
Tries to acquire a synchronization lock on the remote collection.
|
public DataGateSyncTemplate(DataGateClient dataGateClient, java.lang.String collection)
Instantiates a new DataGateSyncTemplate.
dataGateClient - the DataGateClientcollection - the remote collection namepublic ChangeFeed changedSince(FeedOptions feedOptions)
SyncTemplateDownloads the list of changes from the server.
changedSince in interface SyncTemplatefeedOptions - options to fetch the change feedpublic boolean change(ChangeFeed changeFeed)
SyncTemplateUploads the local changes to the server.
change in interface SyncTemplatechangeFeed - the list of changes to uploadtrue if the operation is successful; false otherwise.public java.util.List<Document> fetch(int offset, int limit)
SyncTemplateFetches all documents from remote.
fetch in interface SyncTemplateoffset - pagination offsetlimit - pagination limitpublic long size()
SyncTemplateGets the size of the remote collection.
size in interface SyncTemplatepublic void clear()
SyncTemplateClears the remote collection.
clear in interface SyncTemplatepublic boolean isOnline()
SyncTemplateChecks if the server is online and reachable.
isOnline in interface SyncTemplatetrue if online; false otherwise.public java.lang.String getCollectionName()
SyncTemplateGets the name of the remote collection.
getCollectionName in interface SyncTemplatepublic boolean trySyncLock(TimeSpan expiryDelay, java.lang.String issuer)
SyncTemplateTries to acquire a synchronization lock on the remote collection. Before start of replication, a sync lock must be acquired on remote collection. If the acquisition is unsuccessful, replication will not occur and it will be retried in next iteration.
If the expiryDelay is expired, then a new lock will be acquired overwriting previous lock information.
|
Lock information should be maintain as a metadata in the remote database in a separate collection/table than the remote collection. |
trySyncLock in interface SyncTemplateexpiryDelay - the expiry delayissuer - originator of the change feedpublic void releaseLock(java.lang.String issuer)
SyncTemplateReleases the synchronization lock on the remote collection.
releaseLock in interface SyncTemplate