public class Replication extends java.lang.Object implements com.couchbase.lite.replicator.ReplicationInternal.ChangeListener, NetworkReachabilityListener
| Modifier and Type | Class and Description |
|---|---|
static class |
Replication.ChangeEvent
The type of event raised by a Replication when any of the following
properties change: mode, running, error, completed, total.
|
static interface |
Replication.ChangeListener
A delegate that can be used to listen for Replication changes.
|
static class |
Replication.Direction
Enum to specify which direction this replication is going (eg, push vs pull)
|
static class |
Replication.Lifecycle
Enum to specify whether this replication is oneshot or continuous.
|
static class |
Replication.ReplicationField |
static class |
Replication.ReplicationStatus
Options for what metadata to include in document bodies
|
| Modifier and Type | Field and Description |
|---|---|
protected HttpClientFactory |
clientFactory |
protected Database |
db |
static int |
DEFAULT_HEARTBEAT |
static long |
DEFAULT_MAX_TIMEOUT_FOR_SHUTDOWN |
protected Replication.Direction |
direction |
protected java.lang.Throwable |
lastError |
protected Replication.Lifecycle |
lifecycle |
protected java.net.URL |
remote |
protected com.couchbase.lite.replicator.ReplicationInternal |
replicationInternal |
static java.lang.String |
REPLICATOR_DATABASE_NAME |
| Constructor and Description |
|---|
Replication(Database db,
java.net.URL remote,
Replication.Direction direction)
Constructor
|
Replication(Database db,
java.net.URL remote,
Replication.Direction direction,
HttpClientFactory factory)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
addChangeListener(Replication.ChangeListener changeListener)
Adds a change delegate that will be called whenever the Replication changes.
|
protected java.lang.String |
buildRelativeURLString(java.lang.String relativePath) |
void |
changed(Replication.ChangeEvent event)
This is called back for changes from the ReplicationInternal.
|
boolean |
clearAuthenticationStores()
Deletes any persistent credentials (passwords, auth tokens...) associated with this
replication's CBLAuthenticator.
|
void |
deleteCookie(java.lang.String name)
Deletes an HTTP cookie for the Replication.
|
Authenticator |
getAuthenticator()
Get the Authenticator used for authenticating with the Sync Gateway
|
int |
getChangesCount()
The total number of changes to be processed, if the task is active, else 0 (observable).
|
java.util.List<java.lang.String> |
getChannels()
List of Sync Gateway channel names to filter by; a nil value means no filtering, i.e.
|
protected HttpClientFactory |
getClientFactory() |
int |
getCompletedChangesCount()
The number of completed changes processed, if the task is active, else 0 (observable).
|
java.util.List<java.lang.String> |
getDocIds()
Gets the documents to specify as part of the replication.
|
java.lang.String |
getFilter()
Name of an optional filter function to run on the source server.
|
java.util.Map<java.lang.String,java.lang.Object> |
getFilterParams()
Parameters to pass to the filter function.
|
java.util.Map<java.lang.String,java.lang.Object> |
getHeaders()
Extra HTTP headers to send in all requests to the remote server.
|
java.lang.Throwable |
getLastError()
The error status of the replication, or null if there have not been any errors since
it started.
|
Database |
getLocalDatabase()
Get the local database which is the source or target of this replication
|
java.util.Set<java.lang.String> |
getPendingDocumentIDs() |
java.net.URL |
getRemoteUrl()
Get the remote URL which is the source or target of this replication
|
java.lang.String |
getRemoteUUID()
Get the remote UUID representing the remote server.
|
java.lang.String |
getSessionID() |
Replication.ReplicationStatus |
getStatus()
The replication's current state, one of {stopped, offline, idle, active}.
|
java.lang.String |
getUsername()
The server user name that the authenticator has logged in as, if known.
|
void |
goOffline()
Tell the replication to go offline, asynchronously.
|
void |
goOnline()
Tell the replication to go online, asynchronously.
|
boolean |
isContinuous()
Is this replication continous?
|
boolean |
isDocumentPending(Document doc) |
boolean |
isPull()
Is this a pull replication? (Eg, it pulls data from Sync Gateway -> Device running CBL?)
|
boolean |
isRunning()
True while the replication is running, False if it's stopped.
|
void |
networkReachable() |
void |
networkUnreachable() |
java.lang.String |
remoteCheckpointDocID()
Following two methods for temporary methods instead of CBL_ReplicatorSettings implementation.
|
void |
removeChangeListener(Replication.ChangeListener changeListener)
Removes the specified delegate as a listener for the Replication change event.
|
void |
restart()
Restarts the replication.
|
protected boolean |
serverIsSyncGatewayVersion(java.lang.String minVersion) |
void |
setAuthenticator(Authenticator authenticator)
Set the Authenticator used for authenticating with the Sync Gateway
|
void |
setChannels(java.util.List<java.lang.String> channels)
Set the list of Sync Gateway channel names
|
protected void |
setClientFactory(HttpClientFactory factory)
Set the HTTP client factory if one was passed in, or use the default
set in the manager if available.
|
void |
setContinuous(boolean isContinous)
Set whether this replication is continous
|
void |
setCookie(java.lang.String name,
java.lang.String value,
java.lang.String path,
java.util.Date expirationDate,
boolean secure,
boolean httpOnly)
Sets an HTTP cookie for the Replication.
|
void |
setCookie(java.lang.String name,
java.lang.String value,
java.lang.String path,
long maxAge,
boolean secure,
boolean httpOnly)
Sets an HTTP cookie for the Replication.
|
void |
setCreateTarget(boolean createTarget)
Set whether the target database be created if it doesn't already exist?
|
void |
setDocIds(java.util.List<java.lang.String> docIds)
Sets the documents to specify as part of the replication.
|
void |
setFilter(java.lang.String filterName)
Set the filter to be used by this replication
|
void |
setFilterParams(java.util.Map<java.lang.String,java.lang.Object> filterParams)
Set parameters to pass to the filter function.
|
void |
setHeaders(java.util.Map<java.lang.String,java.lang.Object> requestHeadersParam)
Set Extra HTTP headers to be sent in all requests to the remote server.
|
protected void |
setLastError(java.lang.Throwable lastError)
Update the lastError
|
void |
setRemoteUUID(java.lang.String remoteUUID)
Set the remote UUID representing the remote server.
|
protected void |
setServerType(java.lang.String serverType) |
boolean |
shouldCreateTarget()
Should the target database be created if it doesn't already exist? (Defaults to NO).
|
void |
start()
Starts the replication, asynchronously.
|
void |
stop()
Stops the replication, asynchronously.
|
java.lang.String |
toString() |
public static final java.lang.String REPLICATOR_DATABASE_NAME
public static long DEFAULT_MAX_TIMEOUT_FOR_SHUTDOWN
public static int DEFAULT_HEARTBEAT
protected Database db
protected java.net.URL remote
protected HttpClientFactory clientFactory
protected com.couchbase.lite.replicator.ReplicationInternal replicationInternal
protected Replication.Lifecycle lifecycle
protected java.lang.Throwable lastError
protected Replication.Direction direction
public Replication(Database db, java.net.URL remote, Replication.Direction direction)
public Replication(Database db, java.net.URL remote, Replication.Direction direction, HttpClientFactory factory)
public void start()
public void restart()
public void goOffline()
public void goOnline()
public boolean isRunning()
public void stop()
public boolean isContinuous()
public void setContinuous(boolean isContinous)
public void setAuthenticator(Authenticator authenticator)
public Authenticator getAuthenticator()
public boolean shouldCreateTarget()
public void setCreateTarget(boolean createTarget)
public void addChangeListener(Replication.ChangeListener changeListener)
public void removeChangeListener(Replication.ChangeListener changeListener)
public Replication.ReplicationStatus getStatus()
public void changed(Replication.ChangeEvent event)
changed in interface com.couchbase.lite.replicator.ReplicationInternal.ChangeListenerpublic java.lang.Throwable getLastError()
public int getCompletedChangesCount()
public int getChangesCount()
protected void setLastError(java.lang.Throwable lastError)
public java.lang.String remoteCheckpointDocID()
public java.util.Set<java.lang.String> getPendingDocumentIDs()
public boolean isDocumentPending(Document doc)
protected void setClientFactory(HttpClientFactory factory)
factory - protected boolean serverIsSyncGatewayVersion(java.lang.String minVersion)
protected void setServerType(java.lang.String serverType)
public void setFilter(java.lang.String filterName)
public void setDocIds(java.util.List<java.lang.String> docIds)
public java.util.List<java.lang.String> getDocIds()
public void setFilterParams(java.util.Map<java.lang.String,java.lang.Object> filterParams)
public java.lang.String getUsername()
public void setCookie(java.lang.String name,
java.lang.String value,
java.lang.String path,
long maxAge,
boolean secure,
boolean httpOnly)
name - The name of the cookie.value - The value of the cookie.path - The path attribute of the cookie. If null or empty, will use remote.getPath()maxAge - The maxAge, in milliseconds, that this cookie should be valid for.secure - Whether the cookie should only be sent using a secure protocol (e.g. HTTPS).httpOnly - (ignored) Whether the cookie should only be used when transmitting HTTP,
or HTTPS, requests thus restricting access from other, non-HTTP APIs.public void setCookie(java.lang.String name,
java.lang.String value,
java.lang.String path,
java.util.Date expirationDate,
boolean secure,
boolean httpOnly)
name - The name of the cookie.value - The value of the cookie.path - The path attribute of the cookie. If null or empty, will use remote.getPath()expirationDate - The expiration date of the cookie.secure - Whether the cookie should only be sent using a secure protocol (e.g. HTTPS).httpOnly - (ignored) Whether the cookie should only be used when transmitting HTTP,
or HTTPS, requests thus restricting access from other, non-HTTP APIs.public void deleteCookie(java.lang.String name)
name - The name of the cookie.public boolean clearAuthenticationStores()
public java.lang.String getRemoteUUID()
public void setRemoteUUID(java.lang.String remoteUUID)
remoteUUID - remote unique identifierprotected HttpClientFactory getClientFactory()
protected java.lang.String buildRelativeURLString(java.lang.String relativePath)
public java.util.List<java.lang.String> getChannels()
public void setChannels(java.util.List<java.lang.String> channels)
public java.lang.String getFilter()
public java.util.Map<java.lang.String,java.lang.Object> getFilterParams()
public void setHeaders(java.util.Map<java.lang.String,java.lang.Object> requestHeadersParam)
public java.util.Map<java.lang.String,java.lang.Object> getHeaders()
public java.lang.String getSessionID()
public Database getLocalDatabase()
public java.net.URL getRemoteUrl()
public boolean isPull()
public void networkReachable()
networkReachable in interface NetworkReachabilityListenerpublic void networkUnreachable()
networkUnreachable in interface NetworkReachabilityListenerpublic java.lang.String toString()
toString in class java.lang.Object