Class AbstractReplicator

  • All Implemented Interfaces:
    java.lang.AutoCloseable
    Direct Known Subclasses:
    Replicator

    public abstract class AbstractReplicator
    extends com.couchbase.lite.internal.core.BaseReplicator
    A replicator for replicating document changes between a local database and a target database. The replicator can be bidirectional or either push or pull. The replicator can also be one-shot or continuous. The replicator runs asynchronously, so observe the status to be notified of progress.
    • Method Detail

      • start

        public void start()
        Start the replicator.
      • start

        public void start​(boolean resetCheckpoint)
        Start the replicator. This method does not wait for the replicator to start. The replicator runs asynchronously and reports its progress through replicator change notifications.
      • stop

        public void stop()
        Stop a running replicator. This method does not wait for the replicator to stop. When it does actually stop it will a new state, STOPPED, to change listeners.
      • getConfig

        @NonNull
        public ReplicatorConfiguration getConfig()
        The replicator's configuration.
        Returns:
        this replicator's configuration
      • getStatus

        @NonNull
        public ReplicatorStatus getStatus()
        The replicator's current status: its activity level and progress. Observable.
        Returns:
        this replicator's status
      • getServerCertificates

        @Nullable
        public java.util.List<java.security.cert.Certificate> getServerCertificates()
        The server certificates received from the server during the TLS handshake.
        Returns:
        this replicator's server certificates.
      • getPendingDocumentIds

        @NonNull
        public java.util.Set<java.lang.String> getPendingDocumentIds()
                                                              throws CouchbaseLiteException
        Get a best effort list of documents still pending replication.
        Returns:
        a set of ids for documents still awaiting replication.
        Throws:
        CouchbaseLiteException
      • isDocumentPending

        public boolean isDocumentPending​(@NonNull
                                         java.lang.String docId)
                                  throws CouchbaseLiteException
        Best effort check to see if the document whose ID is passed is still pending replication.
        Parameters:
        docId - Document id
        Returns:
        true if the document is pending
        Throws:
        CouchbaseLiteException
      • addChangeListener

        @NonNull
        public ListenerToken addChangeListener​(@NonNull
                                               ReplicatorChangeListener listener)
        Adds a change listener for the changes in the replication status and progress.

        The changes will be delivered on the UI thread for the Android platform On other Java platforms, the callback will occur on an arbitrary thread.

        When developing a Java Desktop application using Swing or JavaFX that needs to update the UI after receiving the changes, make sure to schedule the UI update on the UI thread by using SwingUtilities.invokeLater(Runnable) or Platform.runLater(Runnable) respectively.

        Parameters:
        listener - callback
      • addChangeListener

        @NonNull
        public ListenerToken addChangeListener​(@Nullable
                                               java.util.concurrent.Executor executor,
                                               @NonNull
                                               ReplicatorChangeListener listener)
        Adds a change listener for the changes in the replication status and progress with an executor on which the changes will be posted to the listener. If the executor is not specified, the changes will be delivered on the UI thread on Android platform and on an arbitrary thread on other Java platform.
        Parameters:
        executor - executor on which events will be delivered
        listener - callback
      • addDocumentReplicationListener

        @NonNull
        public ListenerToken addDocumentReplicationListener​(@NonNull
                                                            DocumentReplicationListener listener)
        Adds a listener for receiving the replication status of the specified document. The status will be delivered on the UI thread for the Android platform and on an arbitrary thread for the Java platform. When developing a Java Desktop application using Swing or JavaFX that needs to update the UI after receiving the status, make sure to schedule the UI update on the UI thread by using SwingUtilities.invokeLater(Runnable) or Platform.runLater(Runnable) respectively.
        Parameters:
        listener - callback
        Returns:
        A ListenerToken that can be used to remove the handler in the future.
      • addDocumentReplicationListener

        @NonNull
        public ListenerToken addDocumentReplicationListener​(@Nullable
                                                            java.util.concurrent.Executor executor,
                                                            @NonNull
                                                            DocumentReplicationListener listener)
        Adds a listener for receiving the replication status of the specified document with an executor on which the status will be posted to the listener. If the executor is not specified, the status will be delivered on the UI thread for the Android platform and on an arbitrary thread for the Java platform.
        Parameters:
        executor - executor on which events will be delivered
        listener - callback
      • removeChangeListener

        public void removeChangeListener​(@NonNull
                                         ListenerToken token)
        Remove the given ReplicatorChangeListener or DocumentReplicationListener from the this replicator.
        Parameters:
        token - returned by a previous call to addChangeListener or addDocumentListener.
      • toString

        @NonNull
        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object