Interface CoreSync<DocumentT>

  • Type Parameters:
    DocumentT - the type of document we are syncing on
    All Known Implementing Classes:
    CoreSyncImpl

    public interface CoreSync<DocumentT>
    A set of synchronization related operations for a collection.
    • Method Detail

      • configure

        void configure​(@Nonnull
                       SyncConfiguration syncConfig)
        Set the conflict resolver and and change event listener on this collection.
        Parameters:
        syncConfig - the SyncConfiguration that contains relevant options
      • updateSyncFrequency

        void updateSyncFrequency​(@Nonnull
                                 SyncFrequency syncFrequency)
        Set the SyncFrequency on this collection.
        Parameters:
        syncFrequency - the SyncFrequency that contains relevant options
      • syncOne

        void syncOne​(BsonValue id)
        Requests that the given document _id be synchronized.
        Parameters:
        id - the document _id to synchronize.
      • syncMany

        void syncMany​(BsonValue... ids)
        Requests that the given document _ids be synchronized.
        Parameters:
        ids - the document _ids to synchronize.
      • desyncOne

        void desyncOne​(BsonValue id)
        Stops synchronizing the given document _id. Any uncommitted writes will be lost.
        Parameters:
        id - the _id of the document to desynchronize.
      • desyncMany

        void desyncMany​(BsonValue... ids)
        Stops synchronizing the given document _ids. Any uncommitted writes will be lost.
        Parameters:
        ids - the _ids of the documents to desynchronize.
      • getSyncedIds

        Set<BsonValue> getSyncedIds()
        Returns the set of synchronized document ids in a namespace.
        Returns:
        the set of synchronized document ids in a namespace.
      • getPausedDocumentIds

        Set<BsonValue> getPausedDocumentIds()
        Return the set of synchronized document _ids in a namespace that have been paused due to an irrecoverable error.
        Returns:
        the set of paused document _ids in a namespace
      • resumeSyncForDocument

        boolean resumeSyncForDocument​(BsonValue documentId)
        A document that is paused no longer has remote updates applied to it. Any local updates to this document cause it to be resumed. An example of pausing a document is when a conflict is being resolved for that document and the handler throws an exception.
        Parameters:
        documentId - the id of the document to resume syncing
        Returns:
        true if successfully resumed, false if the document could not be found or there was an error resuming
      • count

        long count()
        Counts the number of documents in the collection that have been synchronized with the remote.
        Returns:
        the number of documents in the collection
      • count

        long count​(Bson filter)
        Counts the number of documents in the collection that have been synchronized with the remote according to the given options.
        Parameters:
        filter - the query filter
        Returns:
        the number of documents in the collection
      • count

        long count​(Bson filter,
                   SyncCountOptions options)
        Counts the number of documents in the collection that have been synchronized with the remote according to the given options.
        Parameters:
        filter - the query filter
        options - the options describing the count
        Returns:
        the number of documents in the collection
      • findOne

        DocumentT findOne()
        Finds a document in the collection.
        Returns:
        the resulting document
      • findOne

        <ResultT> ResultT findOne​(Class<ResultT> resultClass)
        Finds a document in the collection.
        Type Parameters:
        ResultT - the target document type
        Parameters:
        resultClass - the class to decode each document into
        Returns:
        the resulting document
      • findOne

        DocumentT findOne​(Bson filter)
        Finds a document in the collection.
        Parameters:
        filter - the query filter
        Returns:
        the resulting document
      • findOne

        <ResultT> ResultT findOne​(Bson filter,
                                  Class<ResultT> resultClass)
        Finds a document in the collection.
        Type Parameters:
        ResultT - the target document type of the iterable.
        Parameters:
        filter - the query filter
        resultClass - the class to decode each document into
        Returns:
        the resulting document
      • findOne

        DocumentT findOne​(Bson filter,
                          RemoteFindOptions options)
        Finds a document in the collection.
        Parameters:
        filter - the query filter
        options - A RemoteFindOptions struct
        Returns:
        the resulting document
      • findOne

        <ResultT> ResultT findOne​(Bson filter,
                                  RemoteFindOptions options,
                                  Class<ResultT> resultClass)
        Finds a document in the collection.
        Type Parameters:
        ResultT - the target document type of the iterable.
        Parameters:
        filter - the query filter
        options - A RemoteFindOptions struct
        resultClass - the class to decode each document into
        Returns:
        the resulting document
      • find

        CoreSyncFindIterable<DocumentT> find()
        Finds all documents in the collection that have been synchronized with the remote.
        Returns:
        the find iterable interface
      • find

        <ResultT> CoreSyncFindIterable<ResultT> find​(Class<ResultT> resultClass)
        Finds all documents in the collection that have been synchronized with the remote.
        Type Parameters:
        ResultT - the target document type of the iterable.
        Parameters:
        resultClass - the class to decode each document into
        Returns:
        the find iterable interface
      • find

        CoreSyncFindIterable<DocumentT> find​(Bson filter)
        Finds all documents in the collection that have been synchronized with the remote.
        Parameters:
        filter - the query filter
        Returns:
        the find iterable interface
      • find

        <ResultT> CoreSyncFindIterable<ResultT> find​(Bson filter,
                                                     Class<ResultT> resultClass)
        Finds all documents in the collection that have been synchronized with the remote.
        Type Parameters:
        ResultT - the target document type of the iterable.
        Parameters:
        filter - the query filter
        resultClass - the class to decode each document into
        Returns:
        the find iterable interface
      • aggregate

        CoreSyncAggregateIterable<DocumentT> aggregate​(List<? extends Bson> pipeline)
        Aggregates documents that have been synchronized with the remote according to the specified aggregation pipeline.
        Parameters:
        pipeline - the aggregation pipeline
        Returns:
        an iterable containing the result of the aggregation operation
      • aggregate

        <ResultT> CoreSyncAggregateIterable<ResultT> aggregate​(List<? extends Bson> pipeline,
                                                               Class<ResultT> resultClass)
        Aggregates documents that have been synchronized with the remote according to the specified aggregation pipeline.
        Type Parameters:
        ResultT - the target document type of the iterable.
        Parameters:
        pipeline - the aggregation pipeline
        resultClass - the class to decode each document into
        Returns:
        an iterable containing the result of the aggregation operation
      • insertOne

        SyncInsertOneResult insertOne​(DocumentT document)
        Inserts the provided document. If the document is missing an identifier, the client should generate one. Syncs the newly inserted document against the remote.
        Parameters:
        document - the document to insert
        Returns:
        the result of the insert one operation
      • insertMany

        SyncInsertManyResult insertMany​(List<DocumentT> documents)
        Inserts one or more documents. Syncs the newly inserted documents against the remote.
        Parameters:
        documents - the documents to insert
        Returns:
        the result of the insert many operation
      • deleteOne

        SyncDeleteResult deleteOne​(Bson filter)
        Removes at most one document from the collection that has been synchronized with the remote that matches the given filter. If no documents match, the collection is not modified.
        Parameters:
        filter - the query filter to apply the the delete operation
        Returns:
        the result of the remove one operation
      • deleteMany

        SyncDeleteResult deleteMany​(Bson filter)
        Removes all documents from the collection that have been synchronized with the remote that match the given query filter. If no documents match, the collection is not modified.
        Parameters:
        filter - the query filter to apply the the delete operation
        Returns:
        the result of the remove many operation
      • updateOne

        SyncUpdateResult updateOne​(Bson filter,
                                   Bson update)
        Update a single document in the collection that have been synchronized with the remote according to the specified arguments. If the update results in an upsert, the newly upserted document will automatically become synchronized.
        Parameters:
        filter - a document describing the query filter, which may not be null.
        update - a document describing the update, which may not be null. The update to apply must include only update operators.
        Returns:
        the result of the update one operation
      • updateOne

        SyncUpdateResult updateOne​(Bson filter,
                                   Bson update,
                                   SyncUpdateOptions updateOptions)
        Update a single document in the collection that has been synchronized with the remote according to the specified arguments. If the update results in an upsert, the newly upserted document will automatically become synchronized.
        Parameters:
        filter - a document describing the query filter, which may not be null.
        update - a document describing the update, which may not be null. The update to apply must include only update operators.
        updateOptions - the options to apply to the update operation
        Returns:
        the result of the update one operation
      • updateMany

        SyncUpdateResult updateMany​(Bson filter,
                                    Bson update)
        Update all documents in the collection that have been synchronized with the remote according to the specified arguments. If the update results in an upsert, the newly upserted document will automatically become synchronized.
        Parameters:
        filter - a document describing the query filter, which may not be null.
        update - a document describing the update, which may not be null. The update to apply must include only update operators.
        Returns:
        the result of the update many operation
      • updateMany

        SyncUpdateResult updateMany​(Bson filter,
                                    Bson update,
                                    SyncUpdateOptions updateOptions)
        Update all documents in the collection that have been synchronized with the remote according to the specified arguments. If the update results in an upsert, the newly upserted document will automatically become synchronized.
        Parameters:
        filter - a document describing the query filter, which may not be null.
        update - a document describing the update, which may not be null. The update to apply must include only update operators.
        updateOptions - the options to apply to the update operation
        Returns:
        the result of the update many operation