public class PullerInternal extends java.lang.Object implements ChangeTrackerClient
| Modifier and Type | Class and Description |
|---|---|
static interface |
com.couchbase.lite.replicator.ReplicationInternal.ChangeListener
A delegate that can be used to listen for Replication changes.
|
protected static class |
com.couchbase.lite.replicator.ReplicationInternal.ChangeListenerNotifyStyle |
BlockingQueueListener.EventType| Modifier and Type | Field and Description |
|---|---|
protected boolean |
authenticating |
protected Authenticator |
authenticator |
protected Batcher<RevisionInternal> |
batcher |
protected java.util.List<RevisionInternal> |
bulkRevsToPull |
static java.lang.String |
BY_CHANNEL_FILTER_NAME |
protected java.lang.Boolean |
canBulkGet |
protected java.util.Map<java.util.concurrent.Future,CancellableRunnable> |
cancellables |
static int |
CHANGE_TRACKER_RESTART_DELAY_MS |
protected com.couchbase.lite.replicator.ReplicationInternal.ChangeListenerNotifyStyle |
changeListenerNotifyStyle |
protected java.util.concurrent.atomic.AtomicInteger |
changesCount |
static java.lang.String |
CHANNELS_QUERY_PARAM |
protected HttpClientFactory |
clientFactory |
protected java.util.concurrent.atomic.AtomicInteger |
completedChangesCount |
protected Database |
db |
protected java.util.List<RevisionInternal> |
deletedRevsToPull |
protected java.util.List<java.lang.String> |
documentIDs |
protected Batcher<RevisionInternal> |
downloadsToInsert |
protected java.util.concurrent.ScheduledExecutorService |
executor |
static int |
EXECUTOR_THREAD_POOL_SIZE |
protected java.lang.String |
filterName |
protected java.util.Map<java.lang.String,java.lang.Object> |
filterParams |
protected int |
httpConnectionCount |
protected static int |
INBOX_CAPACITY |
protected java.lang.String |
lastSequence |
protected Replication.Lifecycle |
lifecycle |
protected java.lang.Object |
lockWaitForPendingFutures |
static int |
MAX_NUMBER_OF_ATTS_SINCE |
static int |
MAX_PENDING_DOCS |
static int |
MAX_REVS_TO_GET_IN_BULK |
static int |
MIN_EXECUTOR_THREAD_POOL_SIZE |
protected Replication |
parentReplication |
protected java.util.concurrent.BlockingQueue<java.util.concurrent.Future> |
pendingFutures |
protected SequenceMap |
pendingSequences |
protected static int |
PROCESSOR_DELAY |
protected java.util.concurrent.atomic.AtomicLong |
queuedMemorySize |
protected java.net.URL |
remote |
protected java.util.Map<java.lang.String,java.lang.Object> |
remoteCheckpoint |
protected java.util.concurrent.ScheduledExecutorService |
remoteRequestExecutor |
protected java.util.Map<java.lang.String,java.lang.Object> |
requestHeaders |
static int |
RETRY_DELAY_SECONDS |
protected CollectionUtils.Functor<RevisionInternal,RevisionInternal> |
revisionBodyTransformationBlock |
protected java.util.List<RevisionInternal> |
revsToPull |
protected java.lang.String |
sessionID |
protected <any> |
stateMachine |
static java.lang.String |
SYNC_GATEWAY_PREFIX |
protected boolean |
waitingForPendingFutures |
| Constructor and Description |
|---|
PullerInternal(Database db,
java.net.URL remote,
HttpClientFactory clientFactory,
Replication.Lifecycle lifecycle,
Replication parentReplication) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addToChangesCount(int delta) |
protected void |
addToCompletedChangesCount(int delta) |
void |
addToInbox(RevisionInternal rev) |
protected void |
beginReplicating()
Actual work of starting the replication process.
|
protected java.lang.String |
buildRelativeURLString(java.lang.String relativePath) |
boolean |
canSendCompressedRequests()
gzip
in CBL_Replicator.m
- (BOOL) canSendCompressedRequests
|
void |
changed(BlockingQueueListener.EventType type,
java.lang.Object o,
java.util.concurrent.BlockingQueue queue)
Implementation of BlockingQueueListener.changed(EventType, Object, BlockingQueue) for Pull Replication
Note: Pull replication needs to send IDLE after PUT /{db}/_local.
|
void |
changeTrackerCaughtUp() |
void |
changeTrackerFinished(ChangeTracker tracker) |
void |
changeTrackerReceivedChange(java.util.Map<java.lang.String,java.lang.Object> change) |
void |
changeTrackerStopped(ChangeTracker tracker) |
protected void |
checkSession() |
protected void |
checkSessionAtPath(java.lang.String sessionPath) |
protected void |
close()
Close all resources associated with this replicator.
|
ReplicationFilter |
compilePushReplicationFilter()
Get replicator filter.
|
void |
deleteCookie(java.lang.String name)
For java docs, see Replication.deleteCookie()
|
protected static java.lang.String |
encodeDocumentId(java.lang.String docId)
Encodes the given document id for use in an URI.
|
void |
fetchRemoteCheckpointDoc() |
protected void |
finalize() |
protected void |
fireTrigger(com.couchbase.lite.replicator.ReplicationTrigger trigger)
Fire a trigger to the state machine
|
Authenticator |
getAuthenticator() |
java.util.concurrent.atomic.AtomicInteger |
getChangesCount() |
java.util.List<java.lang.String> |
getChannels()
For javadocs, see Replication object
|
protected HttpClientFactory |
getClientFactory() |
java.util.concurrent.atomic.AtomicInteger |
getCompletedChangesCount() |
java.util.List<java.lang.String> |
getDocIds()
Gets the documents to specify as part of the replication.
|
java.lang.String |
getFilter()
For javadocs, see Replication
|
java.util.Map<java.lang.String,java.lang.Object> |
getFilterParams()
For javadoc, see Replication
|
java.util.Map<java.lang.String,java.lang.Object> |
getHeaders()
Extra HTTP headers to send in all requests to the remote server.
|
java.lang.String |
getLastSequence() |
Replication.Lifecycle |
getLifecycle() |
protected Database |
getLocalDatabase()
Get the local database which is the source or target of this replication
|
OkHttpClient |
getOkHttpClient() |
java.lang.String |
getRemoteUUID()
Get the remoteUUID representing the remote server.
|
java.lang.String |
getSessionID() |
protected void |
goOffline()
Take the replication offline
|
protected void |
goOnline()
Put the replication back online after being offline
|
protected void |
initAuthorizer() |
protected void |
initBatcher() |
protected java.util.concurrent.ScheduledExecutorService |
initializeReplicationExecutor() |
protected void |
initializeRequestWorkers() |
protected void |
initializeStateMachine()
Initialize the state machine which defines the overall behavior of the replication
object.
|
void |
insertDownloads(java.util.List<RevisionInternal> downloads)
This will be called when _revsToInsert fills up:
|
boolean |
isContinuous()
Should the replication operate continuously, copying changes as soon as the
source database is modified? (Defaults to NO).
|
protected boolean |
isNetworkReachable() |
boolean |
isPull()
Is this a pull replication? (Eg, it pulls data from Sync Gateway -> Device running CBL?)
|
protected boolean |
isRunning() |
static java.lang.String |
joinQuotedEscaped(java.util.List<java.lang.String> strings) |
protected void |
login() |
protected void |
maybeCreateRemoteDB() |
protected void |
onBeforeScheduleRetry()
If sub-class of ReplicationInternal needs to do additional steps before scheduling retry,
you need to implement in onBeforeScheduleRetry();
https://github.com/couchbase/couchbase-lite-java-core/issues/1149
|
protected void |
pauseOrResume() |
protected void |
processChangeTrackerChange(java.util.Map<java.lang.String,java.lang.Object> change)
in CBL_Puller.m
- (void) changeTrackerReceivedSequence: (id)remoteSequenceID
docID: (NSString*)docID
revIDs: (NSArray*)revIDs
deleted: (BOOL)deleted
|
protected void |
processInbox(RevisionList inbox)
Process a bunch of remote revisions from the _changes feed at once
|
protected void |
pullBulkRevisions(java.util.List<RevisionInternal> bulkRevs) |
protected void |
pullBulkWithAllDocs(java.util.List<RevisionInternal> bulkRevs) |
void |
pullRemoteRevision(RevisionInternal rev)
Fetches the contents of a revision from the remote db, including its parent revision ID.
|
void |
pullRemoteRevisions()
Start up some HTTP GETs, within our limit on the maximum simultaneous number
The entire method is not synchronized, only the portion pulling work off the list
Important to not hold the synchronized block while we do network access
|
protected void |
queueRemoteRevision(RevisionInternal rev)
Add a revision to the appropriate queue of revs to individually GET
|
java.lang.String |
remoteCheckpointDocID()
This is the _local document ID stored on the remote server to keep track of state.
|
java.lang.String |
remoteCheckpointDocID(java.lang.String localUUID) |
protected void |
retry()
Called after a continuous replication has gone idle, but it failed to transfer some revisions
and so wants to try again in a minute.
|
protected void |
retryIfReady()
in CBL_Replicator.m
- (void) retryIfReady
|
protected void |
retryReplicationIfError()
Retry replication if previous attempt ends with error
|
void |
saveLastSequence()
in CBL_Replicator.m
- (void) saveLastSequence
|
CustomFuture |
sendAsyncMultipartDownloaderRequest(java.lang.String method,
java.lang.String relativePath,
java.util.Map<java.lang.String,java.lang.Object> body,
Database db,
RemoteRequestCompletion onCompletion) |
CustomFuture |
sendAsyncMultipartRequest(java.lang.String method,
java.lang.String relativePath,
java.util.Map<java.lang.String,java.lang.Object> body,
java.util.Map<java.lang.String,java.lang.Object> attachments,
RemoteRequestCompletion onCompletion) |
CustomFuture |
sendAsyncRequest(java.lang.String method,
java.lang.String relativePath,
boolean cancelable,
java.util.Map<java.lang.String,?> body,
boolean dontLog404,
RemoteRequestCompletion onCompletion) |
CustomFuture |
sendAsyncRequest(java.lang.String method,
java.lang.String relativePath,
boolean cancelable,
java.util.Map<java.lang.String,?> body,
RemoteRequestCompletion onCompletion) |
CustomFuture |
sendAsyncRequest(java.lang.String method,
java.lang.String relativePath,
java.util.Map<java.lang.String,?> body,
boolean dontLog404,
RemoteRequestCompletion onCompletion) |
CustomFuture |
sendAsyncRequest(java.lang.String method,
java.lang.String relativePath,
java.util.Map<java.lang.String,?> body,
RemoteRequestCompletion onCompletion) |
CustomFuture |
sendAsyncRequest(java.lang.String method,
java.net.URL url,
boolean cancelable,
java.util.Map<java.lang.String,?> body,
boolean dontLog404,
RemoteRequestCompletion onCompletion) |
protected boolean |
serverIsSyncGateway() |
protected boolean |
serverIsSyncGatewayVersion(java.lang.String minVersion) |
protected static boolean |
serverIsSyncGatewayVersion(java.lang.String serverName,
java.lang.String minVersion) |
void |
setAuthenticator(Authenticator authenticator) |
void |
setChannels(java.util.List<java.lang.String> channels)
For javadocs, see Replication object
|
void |
setCookie(Cookie cookie) |
void |
setCookie(java.lang.String name,
java.lang.String value,
java.lang.String path,
java.util.Date expirationDate,
boolean secure,
boolean httpOnly)
For java docs, see Replication.setCookie()
|
void |
setCookie(java.lang.String name,
java.lang.String value,
java.lang.String path,
long maxAge,
boolean secure,
boolean httpOnly)
For java docs, see Replication.setCookie()
|
void |
setCreateTarget(boolean createTarget) |
void |
setDocIds(java.util.List<java.lang.String> docIds)
Sets the documents to specify as part of the replication.
|
protected void |
setError(java.lang.Throwable throwable) |
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.
|
void |
setLastSequence(java.lang.String lastSequenceIn)
in CBL_Replicator.m
- (void) setLastSequence:(NSString*)lastSequence;
|
protected void |
setLastSequenceFromWorkExecutor(java.lang.String lastSequence,
java.lang.String checkpointId) |
void |
setLifecycle(Replication.Lifecycle lifecycle) |
void |
setRemoteUUID(java.lang.String remoteUUID)
Set the remoteUUID representing the remote server.
|
protected void |
setServerType(java.lang.String serverType) |
boolean |
shouldCreateTarget() |
protected void |
start()
Start the replication process.
|
protected void |
startChangeTracker() |
protected void |
startNetworkReachabilityManager() |
protected static Status |
statusFromBulkDocsResponseItem(java.util.Map<java.lang.String,java.lang.Object> item) |
protected void |
stop()
Actual work of stopping the replication process.
|
protected void |
stopNetworkReachabilityManager() |
java.lang.String |
toString() |
protected RevisionInternal |
transformRevision(RevisionInternal rev) |
void |
triggerGoOffline()
Trigger this replication to go offline (async)
|
void |
triggerGoOnline()
Trigger this replication to go online (async)
|
void |
triggerStart()
Trigger this replication to start (async)
|
void |
triggerStopGraceful()
Trigger this replication to stop (async)
|
protected void |
triggerStopImmediate()
Trigger this replication to stop immediately -- assumes pending work has
been drained, or that caller chooses to ignore any pending work.
|
protected void |
waitBatcherCompleted() |
protected static void |
waitBatcherCompleted(Batcher<RevisionInternal> b) |
protected void |
waitDownloadsToInsertBatcherCompleted() |
protected void |
waitForAllTasksCompleted() |
protected void |
waitForPendingFutures() |
protected void |
waitPendingFuturesCompleted() |
public static final int MAX_REVS_TO_GET_IN_BULK
public static final int MAX_NUMBER_OF_ATTS_SINCE
public static int CHANGE_TRACKER_RESTART_DELAY_MS
public static final int MAX_PENDING_DOCS
protected SequenceMap pendingSequences
protected java.lang.Boolean canBulkGet
protected java.util.List<RevisionInternal> revsToPull
protected java.util.List<RevisionInternal> bulkRevsToPull
protected java.util.List<RevisionInternal> deletedRevsToPull
protected int httpConnectionCount
protected Batcher<RevisionInternal> downloadsToInsert
protected java.util.concurrent.atomic.AtomicLong queuedMemorySize
public static final java.lang.String BY_CHANNEL_FILTER_NAME
public static final java.lang.String CHANNELS_QUERY_PARAM
public static final int EXECUTOR_THREAD_POOL_SIZE
public static final int MIN_EXECUTOR_THREAD_POOL_SIZE
public static final java.lang.String SYNC_GATEWAY_PREFIX
public static int RETRY_DELAY_SECONDS
protected Replication parentReplication
protected Database db
protected java.net.URL remote
protected HttpClientFactory clientFactory
protected java.lang.String lastSequence
protected Authenticator authenticator
protected boolean authenticating
protected java.lang.String filterName
protected java.util.Map<java.lang.String,java.lang.Object> filterParams
protected java.util.List<java.lang.String> documentIDs
protected java.util.Map<java.lang.String,java.lang.Object> requestHeaders
protected Batcher<RevisionInternal> batcher
protected static int PROCESSOR_DELAY
protected static int INBOX_CAPACITY
protected java.util.concurrent.ScheduledExecutorService remoteRequestExecutor
protected java.util.Map<java.lang.String,java.lang.Object> remoteCheckpoint
protected java.util.concurrent.atomic.AtomicInteger completedChangesCount
protected java.util.concurrent.atomic.AtomicInteger changesCount
protected CollectionUtils.Functor<RevisionInternal,RevisionInternal> revisionBodyTransformationBlock
protected java.lang.String sessionID
protected java.util.concurrent.BlockingQueue<java.util.concurrent.Future> pendingFutures
protected java.util.Map<java.util.concurrent.Future,CancellableRunnable> cancellables
protected java.util.concurrent.ScheduledExecutorService executor
protected <any> stateMachine
protected Replication.Lifecycle lifecycle
protected com.couchbase.lite.replicator.ReplicationInternal.ChangeListenerNotifyStyle changeListenerNotifyStyle
protected boolean waitingForPendingFutures
protected final java.lang.Object lockWaitForPendingFutures
public PullerInternal(Database db, java.net.URL remote, HttpClientFactory clientFactory, Replication.Lifecycle lifecycle, Replication parentReplication)
protected void beginReplicating()
protected void onBeforeScheduleRetry()
public boolean isPull()
protected void maybeCreateRemoteDB()
protected void startChangeTracker()
protected void processInbox(RevisionList inbox)
public void pullRemoteRevisions()
protected void pullBulkRevisions(java.util.List<RevisionInternal> bulkRevs)
protected void pullBulkWithAllDocs(java.util.List<RevisionInternal> bulkRevs)
public void insertDownloads(java.util.List<RevisionInternal> downloads)
public void pullRemoteRevision(RevisionInternal rev)
public static java.lang.String joinQuotedEscaped(java.util.List<java.lang.String> strings)
protected void queueRemoteRevision(RevisionInternal rev)
public java.lang.String getLastSequence()
public OkHttpClient getOkHttpClient()
getOkHttpClient in interface ChangeTrackerClientpublic void changeTrackerReceivedChange(java.util.Map<java.lang.String,java.lang.Object> change)
changeTrackerReceivedChange in interface ChangeTrackerClientpublic void changeTrackerStopped(ChangeTracker tracker)
changeTrackerStopped in interface ChangeTrackerClientpublic void changeTrackerFinished(ChangeTracker tracker)
changeTrackerFinished in interface ChangeTrackerClientpublic void changeTrackerCaughtUp()
changeTrackerCaughtUp in interface ChangeTrackerClientprotected void processChangeTrackerChange(java.util.Map<java.lang.String,java.lang.Object> change)
public void changed(BlockingQueueListener.EventType type, java.lang.Object o, java.util.concurrent.BlockingQueue queue)
changed in interface BlockingQueueListenerprotected void stop()
protected void waitForAllTasksCompleted()
protected void waitDownloadsToInsertBatcherCompleted()
public boolean shouldCreateTarget()
public void setCreateTarget(boolean createTarget)
protected void goOffline()
protected void pauseOrResume()
public java.lang.String toString()
toString in class java.lang.Objectprotected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwablepublic void triggerStart()
public void triggerStopGraceful()
public void triggerGoOffline()
public void triggerGoOnline()
protected void fireTrigger(com.couchbase.lite.replicator.ReplicationTrigger trigger)
protected void triggerStopImmediate()
protected void start()
protected void goOnline()
protected void close()
protected void initAuthorizer()
protected void initBatcher()
protected void startNetworkReachabilityManager()
protected void stopNetworkReachabilityManager()
protected boolean isNetworkReachable()
protected java.util.concurrent.ScheduledExecutorService initializeReplicationExecutor()
protected void initializeRequestWorkers()
protected void checkSession()
protected void checkSessionAtPath(java.lang.String sessionPath)
protected void login()
protected void setError(java.lang.Throwable throwable)
protected void addToCompletedChangesCount(int delta)
protected void addToChangesCount(int delta)
public java.util.concurrent.atomic.AtomicInteger getCompletedChangesCount()
public java.util.concurrent.atomic.AtomicInteger getChangesCount()
public CustomFuture sendAsyncRequest(java.lang.String method, java.lang.String relativePath, java.util.Map<java.lang.String,?> body, RemoteRequestCompletion onCompletion)
public CustomFuture sendAsyncRequest(java.lang.String method, java.lang.String relativePath, boolean cancelable, java.util.Map<java.lang.String,?> body, RemoteRequestCompletion onCompletion)
public CustomFuture sendAsyncRequest(java.lang.String method, java.lang.String relativePath, java.util.Map<java.lang.String,?> body, boolean dontLog404, RemoteRequestCompletion onCompletion)
public CustomFuture sendAsyncRequest(java.lang.String method, java.lang.String relativePath, boolean cancelable, java.util.Map<java.lang.String,?> body, boolean dontLog404, RemoteRequestCompletion onCompletion)
public CustomFuture sendAsyncRequest(java.lang.String method, java.net.URL url, boolean cancelable, java.util.Map<java.lang.String,?> body, boolean dontLog404, RemoteRequestCompletion onCompletion)
public CustomFuture sendAsyncMultipartRequest(java.lang.String method, java.lang.String relativePath, java.util.Map<java.lang.String,java.lang.Object> body, java.util.Map<java.lang.String,java.lang.Object> attachments, RemoteRequestCompletion onCompletion)
public CustomFuture sendAsyncMultipartDownloaderRequest(java.lang.String method, java.lang.String relativePath, java.util.Map<java.lang.String,java.lang.Object> body, Database db, RemoteRequestCompletion onCompletion)
protected Database getLocalDatabase()
public java.util.Map<java.lang.String,java.lang.Object> getHeaders()
public void setHeaders(java.util.Map<java.lang.String,java.lang.Object> requestHeadersParam)
public void saveLastSequence()
protected void setLastSequenceFromWorkExecutor(java.lang.String lastSequence,
java.lang.String checkpointId)
protected java.lang.String buildRelativeURLString(java.lang.String relativePath)
public void fetchRemoteCheckpointDoc()
public java.lang.String remoteCheckpointDocID()
public java.lang.String remoteCheckpointDocID(java.lang.String localUUID)
public java.lang.String getFilter()
public void setFilter(java.lang.String filterName)
public ReplicationFilter compilePushReplicationFilter()
public java.util.List<java.lang.String> getDocIds()
public void setDocIds(java.util.List<java.lang.String> docIds)
public boolean isContinuous()
public java.util.Map<java.lang.String,java.lang.Object> getFilterParams()
public void setFilterParams(java.util.Map<java.lang.String,java.lang.Object> filterParams)
public java.lang.String getRemoteUUID()
public void setRemoteUUID(java.lang.String remoteUUID)
public boolean canSendCompressedRequests()
protected void initializeStateMachine()
public Authenticator getAuthenticator()
public void setAuthenticator(Authenticator authenticator)
protected boolean serverIsSyncGatewayVersion(java.lang.String minVersion)
protected boolean serverIsSyncGateway()
protected static boolean serverIsSyncGatewayVersion(java.lang.String serverName,
java.lang.String minVersion)
public void addToInbox(RevisionInternal rev)
protected void retry()
protected void retryIfReady()
protected void retryReplicationIfError()
protected void setServerType(java.lang.String serverType)
public Replication.Lifecycle getLifecycle()
public void setLifecycle(Replication.Lifecycle lifecycle)
public void setLastSequence(java.lang.String lastSequenceIn)
protected RevisionInternal transformRevision(RevisionInternal rev)
protected static Status statusFromBulkDocsResponseItem(java.util.Map<java.lang.String,java.lang.Object> item)
public void setCookie(java.lang.String name,
java.lang.String value,
java.lang.String path,
long maxAge,
boolean secure,
boolean httpOnly)
public void setCookie(java.lang.String name,
java.lang.String value,
java.lang.String path,
java.util.Date expirationDate,
boolean secure,
boolean httpOnly)
public void setCookie(Cookie cookie)
public void deleteCookie(java.lang.String name)
protected HttpClientFactory getClientFactory()
public java.util.List<java.lang.String> getChannels()
public void setChannels(java.util.List<java.lang.String> channels)
public java.lang.String getSessionID()
protected static java.lang.String encodeDocumentId(java.lang.String docId)
protected boolean isRunning()
protected void waitForPendingFutures()
protected void waitBatcherCompleted()
protected static void waitBatcherCompleted(Batcher<RevisionInternal> b)
protected void waitPendingFuturesCompleted()