Class DocumentNodeStore

    • Field Detail

      • META_PROP_NAMES

        public static final List<String> META_PROP_NAMES
        List of meta properties which are created by DocumentNodeStore and which needs to be retained in any cloned copy of DocumentNodeState.
      • commitQueue

        protected final org.apache.jackrabbit.oak.plugins.document.CommitQueue commitQueue
        The commit queue to coordinate the commits.
    • Method Detail

      • isChildOrderCleanupEnabled

        public boolean isChildOrderCleanupEnabled()
      • dispose

        public void dispose()
      • getDocumentStore

        @NotNull
        public @NotNull DocumentStore getDocumentStore()
      • setAsyncDelay

        public void setAsyncDelay​(int delay)
      • getAsyncDelay

        public int getAsyncDelay()
      • setMaxBackOffMillis

        public void setMaxBackOffMillis​(int time)
      • getMaxBackOffMillis

        public int getMaxBackOffMillis()
      • getChangeSetMaxItems

        public int getChangeSetMaxItems()
      • setChangeSetMaxItems

        public void setChangeSetMaxItems​(int changeSetMaxItems)
      • getChangeSetMaxDepth

        public int getChangeSetMaxDepth()
      • setChangeSetMaxDepth

        public void setChangeSetMaxDepth​(int changeSetMaxDepth)
      • getClusterInfo

        @NotNull
        public @NotNull ClusterNodeInfo getClusterInfo()
      • getNodeCacheStats

        public CacheStats getNodeCacheStats()
      • getNodeChildrenCacheStats

        public CacheStats getNodeChildrenCacheStats()
      • getNodeCachePredicate

        public Predicate<Path> getNodeCachePredicate()
      • getPendingWriteCount

        public int getPendingWriteCount()
      • isDisableBranches

        public boolean isDisableBranches()
      • getMaxTimeDiffMillis

        public long getMaxTimeDiffMillis()
      • getNode

        @Nullable
        public @Nullable DocumentNodeState getNode​(@NotNull
                                                   @NotNull Path path,
                                                   @NotNull
                                                   @NotNull RevisionVector rev)
        Get the node for the given path and revision. The returned object might not be modified directly.
        Parameters:
        path - the path of the node.
        rev - the read revision.
        Returns:
        the node or null if the node does not exist at the given revision.
      • compare

        public boolean compare​(@NotNull
                               @NotNull AbstractDocumentNodeState node,
                               @NotNull
                               @NotNull AbstractDocumentNodeState base,
                               @NotNull
                               @NotNull NodeStateDiff diff)
        Compares the given node against the base state and reports the differences to the NodeStateDiff.
        Specified by:
        compare in interface NodeStateDiffer
        Parameters:
        node - the node to compare.
        base - the base node to compare against.
        diff - handler of node state differences
        Returns:
        true if the full diff was performed, or false if it was aborted as requested by the handler (see the NodeStateDiff contract for more details)
      • addObserver

        public Closeable addObserver​(Observer observer)
        Description copied from interface: Observable
        Register a new Observer. Clients need to call Closeable.close() to stop getting notifications on the registered observer and to free up any resources associated with the registration.
        Specified by:
        addObserver in interface Observable
        Returns:
        a Closeable instance.
      • getRoot

        @NotNull
        public @NotNull DocumentNodeState getRoot()
        Description copied from interface: NodeStore
        Returns the latest state of the tree.
        Specified by:
        getRoot in interface NodeStore
        Returns:
        root node state
      • merge

        @NotNull
        public @NotNull NodeState merge​(@NotNull
                                        @NotNull NodeBuilder builder,
                                        @NotNull
                                        @NotNull CommitHook commitHook,
                                        @NotNull
                                        @NotNull CommitInfo info)
                                 throws CommitFailedException
        Description copied from interface: NodeStore
        Merges the changes between the base and head states of the given builder to this store.
        Specified by:
        merge in interface NodeStore
        Parameters:
        builder - the builder whose changes to apply
        commitHook - the commit hook to apply while merging changes
        info - commit info associated with this merge operation
        Returns:
        the node state resulting from the merge.
        Throws:
        CommitFailedException - if the merge failed
      • rebase

        @NotNull
        public @NotNull NodeState rebase​(@NotNull
                                         @NotNull NodeBuilder builder)
        Description copied from interface: NodeStore
        Rebases the changes between the base and head states of the given builder on top of the current root state. The base state of the given builder becomes the latest root state of the repository, and the head state will contain the rebased changes.
        Specified by:
        rebase in interface NodeStore
        Parameters:
        builder - the builder to rebase
        Returns:
        the node state resulting from the rebase.
      • reset

        public NodeState reset​(@NotNull
                               @NotNull NodeBuilder builder)
        Description copied from interface: NodeStore
        Reset the passed builder by throwing away all its changes and setting its base state to the current root state.
        Specified by:
        reset in interface NodeStore
        Parameters:
        builder - the builder to reset
        Returns:
        the node state resulting from the reset.
      • createBlob

        @NotNull
        public @NotNull BlobStoreBlob createBlob​(InputStream inputStream)
                                          throws IOException
        Description copied from interface: NodeStore
        Create a Blob from the given input stream. The input stream is closed after this method returns.
        Specified by:
        createBlob in interface NodeStore
        Parameters:
        inputStream - The input stream for the Blob
        Returns:
        The Blob representing inputStream
        Throws:
        IOException - If an error occurs while reading from the stream
      • getBlob

        public Blob getBlob​(@NotNull
                            @NotNull String reference)
        Returns the Blob with the given reference. Note that this method is meant to be used with secure reference obtained from Blob#reference which is different from blobId
        Specified by:
        getBlob in interface NodeStore
        Parameters:
        reference - the reference of the blob.
        Returns:
        the blob.
        See Also:
        Blob.getReference()
      • getBlobFromBlobId

        public Blob getBlobFromBlobId​(String blobId)
        Returns the Blob with the given blobId.
        Parameters:
        blobId - the blobId of the blob.
        Returns:
        the blob.
      • checkpoint

        @NotNull
        public @NotNull String checkpoint​(long lifetime,
                                          @NotNull
                                          @NotNull Map<String,​String> properties)
        Description copied from interface: NodeStore
        Creates a new checkpoint of the latest root of the tree. The checkpoint remains valid for at least as long as requested and allows that state of the repository to be retrieved using the returned opaque string reference.

        The properties passed to this methods are associated with the checkpoint and can be retrieved through the NodeStore.checkpointInfo(String) method. Its semantics is entirely application specific.

        Specified by:
        checkpoint in interface NodeStore
        Parameters:
        lifetime - time (in milliseconds, > 0) that the checkpoint should remain available
        properties - properties to associate with the checkpoint
        Returns:
        string reference of this checkpoint
      • checkpoint

        @NotNull
        public @NotNull String checkpoint​(long lifetime)
        Description copied from interface: NodeStore
        Creates a new checkpoint of the latest root of the tree. The checkpoint remains valid for at least as long as requested and allows that state of the repository to be retrieved using the returned opaque string reference.

        This method is a shortcut for NodeStore.checkpoint(long, Map) passing an empty map for its 2nd argument.

        Specified by:
        checkpoint in interface NodeStore
        Parameters:
        lifetime - time (in milliseconds, > 0) that the checkpoint should remain available
        Returns:
        string reference of this checkpoint
      • checkpointInfo

        @NotNull
        public @NotNull Map<String,​String> checkpointInfo​(@NotNull
                                                                @NotNull String checkpoint)
        Description copied from interface: NodeStore
        Retrieve the properties associated with a checkpoint.
        Specified by:
        checkpointInfo in interface NodeStore
        Parameters:
        checkpoint - string reference of a checkpoint
        Returns:
        the properties associated with the checkpoint referenced by checkpoint or an empty map when there is no such checkpoint.
      • checkpoints

        @NotNull
        public @NotNull Iterable<String> checkpoints()
        Description copied from interface: NodeStore
        Returns all valid checkpoints. The returned Iterable provides a snapshot of valid checkpoints at the time this method is called. That is, the Iterable will not reflect checkpoints created after this method was called.

        See NodeStore.checkpoint(long, Map) for a definition of a valid checkpoint.

        Specified by:
        checkpoints in interface NodeStore
        Returns:
        valid checkpoints.
      • retrieve

        @Nullable
        public @Nullable NodeState retrieve​(@NotNull
                                            @NotNull String checkpoint)
        Description copied from interface: NodeStore
        Retrieves the root node from a previously created repository checkpoint.
        Specified by:
        retrieve in interface NodeStore
        Parameters:
        checkpoint - string reference of a checkpoint
        Returns:
        the root node of the checkpoint, or null if the checkpoint is no longer available
      • release

        public boolean release​(@NotNull
                               @NotNull String checkpoint)
        Description copied from interface: NodeStore
        Releases the provided checkpoint. If the provided checkpoint doesn't exist this method should return true.
        Specified by:
        release in interface NodeStore
        Parameters:
        checkpoint - string reference of a checkpoint
        Returns:
        true if the checkpoint was successfully removed, or if it doesn't exist
      • getBranches

        public org.apache.jackrabbit.oak.plugins.document.UnmergedBranches getBranches()
        Specified by:
        getBranches in interface RevisionContext
        Returns:
        the branches of the local DocumentMK instance, which are not yet merged.
      • getPendingModifications

        public org.apache.jackrabbit.oak.plugins.document.UnsavedModifications getPendingModifications()
        Specified by:
        getPendingModifications in interface RevisionContext
        Returns:
        the pending modifications.
      • getClusterId

        public int getClusterId()
        Specified by:
        getClusterId in interface RevisionContext
        Returns:
        the cluster id of the local DocumentMK instance.
      • newRevision

        @NotNull
        public @NotNull Revision newRevision()
        Specified by:
        newRevision in interface RevisionContext
        Returns:
        a new revision for the local document node store instance.
      • getClock

        @NotNull
        public @NotNull Clock getClock()
        Specified by:
        getClock in interface RevisionContext
        Returns:
        the clock in use when a new revision is created.
      • getCommitValue

        public String getCommitValue​(@NotNull
                                     @NotNull Revision changeRevision,
                                     @NotNull
                                     @NotNull NodeDocument doc)
        Description copied from interface: RevisionContext
        Retrieves the commit value for a given change. This method returns the following types of commit values:
        • "c" : the change revision is committed as is.
        • "c-rX-Y-Z" : the change revision is a branch commit merged in revision "rX-Y-Z".
        • "brX-Y-Z" : the change revision is a branch commit done at "rX-Y-Z" but not yet merged.
        • null : the change revision does not have an entry on the commit root document and is not committed.
        Specified by:
        getCommitValue in interface RevisionContext
        Parameters:
        changeRevision - the revision a change was made.
        doc - the document where the change was made.
        Returns:
        the commit value or null if the change does not have a commit value (yet).
      • runBackgroundOperations

        public void runBackgroundOperations()
        Used for testing only
      • createBlobGarbageCollector

        @Nullable
        public @Nullable MarkSweepGarbageCollector createBlobGarbageCollector​(long blobGcMaxAgeInSecs,
                                                                              String repositoryId,
                                                                              Whiteboard whiteboard,
                                                                              StatisticsProvider statisticsProvider)
        Creates and returns a MarkSweepGarbageCollector if the current BlobStore supports garbage collection
        Parameters:
        blobGcMaxAgeInSecs -
        repositoryId -
        whiteboard -
        statisticsProvider -
        Returns:
        garbage collector of the BlobStore supports GC otherwise null
      • getBlobStore

        public BlobStore getBlobStore()
      • getReferencedBlobsIterator

        public Iterator<ReferencedBlob> getReferencedBlobsIterator()
        Returns an iterator for all the blob present in the store.

        In some cases the iterator might implement Closeable. So callers should check for such iterator and close them.

        Returns:
        an iterator for all the blobs
      • getDiffCache

        public org.apache.jackrabbit.oak.plugins.document.DiffCache getDiffCache()
      • getCheckpoints

        public org.apache.jackrabbit.oak.plugins.document.Checkpoints getCheckpoints()
      • getInstanceId

        public String getInstanceId()
        Description copied from interface: Clusterable

        Will return a unique number per instance across the cluster. It will only make its best effort to preserve the same number across restarts but it must be unique across the cluster.

        Specified by:
        getInstanceId in interface Clusterable
        Returns:
        Cannot be null or empty.
      • getVisibilityToken

        public String getVisibilityToken()
        Description copied from interface: Clusterable

        Returns the visibility token of the underlying NodeStore. A 'visibility token' is an opaque String that can be used to verify if changes done on one NodeStore are visible on another NodeStore of the same cluster. This can be achieved by generating such a visibility token on the source NodeStore, passing it on to the target NodeStore (by whatever means) and checking for visibility on that target NodeStore.

        The visibility check returns true if the target NodeStore sees at least all the changes that the source NodeStore saw at time of visibility token generation. Once a visibility token is visible on a particular NodeStore it will always return true ever after. This also implies that the visibility check can only state whether at least all source changes are visible on the target and that it is independent of any further modifications.

        When source and target NodeStore are identical, the visibility check is expected to return true, immediately. This is based on the assumption that with a session.refresh() on that NodeStore you'll always get the latest changes applied by any other session locally.

        Visibility tokens are meant to be lightweight and are not expected to be persisted by the implementor. Nevertheless they should survive their validity in the case of crashes of the source and/or the target instance.

        Specified by:
        getVisibilityToken in interface Clusterable
      • isVisible

        public boolean isVisible​(@NotNull
                                 @NotNull String visibilityToken,
                                 long maxWaitMillis)
                          throws InterruptedException
        Description copied from interface: Clusterable

        Checks if the underlying NodeStore sees at least the changes that were visible at the time the visibility token was created on potentially another instance if in a clustered NodeStore setup.

        If the visibility token was created on the underlying NodeStore this check always returns true, immediately.

        Specified by:
        isVisible in interface Clusterable
        Parameters:
        visibilityToken - the visibility token that was created on another instance in a clustered NodeStore setup. Providing null is not supported and might throw a RuntimeException
        maxWaitMillis - if >-1 waits (at max this many milliseconds if >0, forever if ==0) until the underlying NodeStore sees at least the changes represented by the provided visibility token. if < 0 the method does not wait
        Returns:
        true if the underlying NodeStore sees at least the changes that were visible at the time the visibility token was created
        Throws:
        InterruptedException - (optionally) thrown if interrupted while waiting
      • prefetch

        public void prefetch​(Collection<String> paths,
                             NodeState rootState)
        Description copied from interface: PrefetchNodeStore
        Make an attempt to prefetch node states for the given paths and hold them in a cache.
        Specified by:
        prefetch in interface PrefetchNodeStore
        Parameters:
        paths - the paths of the node states to prefetch.
        rootState - the current root node state.