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 DataGateClient
collection
- the remote collection namepublic ChangeFeed changedSince(FeedOptions feedOptions)
SyncTemplate
Downloads the list of changes from the server.
changedSince
in interface SyncTemplate
feedOptions
- options to fetch the change feedpublic boolean change(ChangeFeed changeFeed)
SyncTemplate
Uploads the local changes to the server.
change
in interface SyncTemplate
changeFeed
- the list of changes to uploadtrue
if the operation is successful; false
otherwise.public java.util.List<Document> fetch(int offset, int limit)
SyncTemplate
Fetches all documents from remote.
fetch
in interface SyncTemplate
offset
- pagination offsetlimit
- pagination limitpublic long size()
SyncTemplate
Gets the size of the remote collection.
size
in interface SyncTemplate
public void clear()
SyncTemplate
Clears the remote collection.
clear
in interface SyncTemplate
public boolean isOnline()
SyncTemplate
Checks if the server is online and reachable.
isOnline
in interface SyncTemplate
true
if online; false
otherwise.public java.lang.String getCollectionName()
SyncTemplate
Gets the name of the remote collection.
getCollectionName
in interface SyncTemplate
public boolean trySyncLock(TimeSpan expiryDelay, java.lang.String issuer)
SyncTemplate
Tries 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 SyncTemplate
expiryDelay
- the expiry delayissuer
- originator of the change feedpublic void releaseLock(java.lang.String issuer)
SyncTemplate
Releases the synchronization lock on the remote collection.
releaseLock
in interface SyncTemplate