public final class DocumentNodeStore extends java.lang.Object implements NodeStore, RevisionContext, Observable, Clusterable, NodeStateDiffer
DocumentStore
.Modifier and Type | Field and Description |
---|---|
protected org.apache.jackrabbit.oak.plugins.document.CommitQueue |
commitQueue
The commit queue to coordinate the commits.
|
static java.util.List<java.lang.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.
|
static java.lang.String |
SYS_PROP_DISABLE_JOURNAL |
static java.lang.String |
SYS_PROP_DISABLE_SWEEP2 |
static FormatVersion |
VERSION |
DEFAULT_DIFFER
Constructor and Description |
---|
DocumentNodeStore(DocumentNodeStoreBuilder<?> builder) |
Modifier and Type | Method and Description |
---|---|
java.io.Closeable |
addObserver(Observer observer)
Register a new
Observer . |
@NotNull java.lang.String |
checkpoint(long lifetime)
Creates a new checkpoint of the latest root of the tree.
|
@NotNull java.lang.String |
checkpoint(long lifetime,
@NotNull java.util.Map<java.lang.String,java.lang.String> properties)
Creates a new checkpoint of the latest root of the tree.
|
@NotNull java.util.Map<java.lang.String,java.lang.String> |
checkpointInfo(@NotNull java.lang.String checkpoint)
Retrieve the properties associated with a checkpoint.
|
@NotNull java.lang.Iterable<java.lang.String> |
checkpoints()
Returns all valid checkpoints.
|
boolean |
compare(@NotNull AbstractDocumentNodeState node,
@NotNull AbstractDocumentNodeState base,
@NotNull NodeStateDiff diff)
|
@NotNull BlobStoreBlob |
createBlob(java.io.InputStream inputStream)
Create a
Blob from the given input stream. |
@Nullable MarkSweepGarbageCollector |
createBlobGarbageCollector(long blobGcMaxAgeInSecs,
java.lang.String repositoryId,
Whiteboard whiteboard,
StatisticsProvider statisticsProvider)
Creates and returns a MarkSweepGarbageCollector if the current BlobStore
supports garbage collection
|
@NotNull PropertyState |
createPropertyState(java.lang.String name,
java.lang.String value) |
void |
dispose() |
int |
getAsyncDelay() |
Blob |
getBlob(@NotNull java.lang.String reference)
Returns the
Blob with the given reference. |
Blob |
getBlobFromBlobId(java.lang.String blobId)
Returns the
Blob with the given blobId. |
BlobStore |
getBlobStore() |
org.apache.jackrabbit.oak.plugins.document.UnmergedBranches |
getBranches() |
BundlingConfigHandler |
getBundlingConfigHandler() |
int |
getChangeSetMaxDepth() |
int |
getChangeSetMaxItems() |
org.apache.jackrabbit.oak.plugins.document.Checkpoints |
getCheckpoints() |
@NotNull Clock |
getClock() |
int |
getClusterId() |
@NotNull ClusterNodeInfo |
getClusterInfo() |
java.lang.String |
getCommitValue(@NotNull Revision changeRevision,
@NotNull NodeDocument doc)
Retrieves the commit value for a given change.
|
org.apache.jackrabbit.oak.plugins.document.DiffCache |
getDiffCache() |
@NotNull java.lang.Iterable<CacheStats> |
getDiffCacheStats() |
@NotNull DocumentStore |
getDocumentStore() |
@NotNull RevisionVector |
getHeadRevision() |
java.lang.String |
getInstanceId()
Will return a unique number per instance across the cluster.
|
@NotNull JournalGarbageCollector |
getJournalGarbageCollector() |
JournalPropertyHandlerFactory |
getJournalPropertyHandlerFactory() |
@NotNull LastRevRecoveryAgent |
getLastRevRecoveryAgent() |
int |
getMaxBackOffMillis() |
long |
getMaxTimeDiffMillis() |
DocumentNodeStoreMBean |
getMBean() |
@Nullable DocumentNodeState |
getNode(@NotNull Path path,
@NotNull RevisionVector rev)
Get the node for the given path and revision.
|
Cache<PathRev,DocumentNodeState> |
getNodeCache() |
Predicate<Path> |
getNodeCachePredicate() |
CacheStats |
getNodeCacheStats() |
Cache<NamePathRev,DocumentNodeState.Children> |
getNodeChildrenCache() |
CacheStats |
getNodeChildrenCacheStats() |
DocumentNodeStateCache |
getNodeStateCache() |
org.apache.jackrabbit.oak.plugins.document.UnsavedModifications |
getPendingModifications() |
int |
getPendingWriteCount() |
java.util.Iterator<ReferencedBlob> |
getReferencedBlobsIterator()
Returns an iterator for all the blob present in the store.
|
@NotNull DocumentNodeState |
getRoot()
Returns the latest state of the tree.
|
DocumentNodeStoreStatsCollector |
getStatsCollector() |
@NotNull VersionGarbageCollector |
getVersionGarbageCollector() |
java.lang.String |
getVisibilityToken()
Returns the visibility token of the underlying NodeStore.
|
boolean |
isDisableBranches() |
boolean |
isVisible(@NotNull java.lang.String visibilityToken,
long maxWaitMillis)
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.
|
@NotNull NodeState |
merge(@NotNull NodeBuilder builder,
@NotNull CommitHook commitHook,
@NotNull CommitInfo info)
|
@NotNull Revision |
newRevision() |
@NotNull NodeState |
rebase(@NotNull NodeBuilder builder)
|
boolean |
release(@NotNull java.lang.String checkpoint)
Releases the provided checkpoint.
|
NodeState |
reset(@NotNull NodeBuilder builder)
Reset the passed
builder by throwing away all its changes and
setting its base state to the current root state. |
@Nullable NodeState |
retrieve(@NotNull java.lang.String checkpoint)
Retrieves the root node from a previously created repository checkpoint.
|
void |
runBackgroundOperations()
Used for testing only
|
void |
setAsyncDelay(int delay) |
void |
setChangeSetMaxDepth(int changeSetMaxDepth) |
void |
setChangeSetMaxItems(int changeSetMaxItems) |
void |
setMaxBackOffMillis(int time) |
void |
setNodeStateCache(DocumentNodeStateCache nodeStateCache) |
public static final FormatVersion VERSION
public static final java.util.List<java.lang.String> META_PROP_NAMES
public static final java.lang.String SYS_PROP_DISABLE_JOURNAL
public static final java.lang.String SYS_PROP_DISABLE_SWEEP2
protected final org.apache.jackrabbit.oak.plugins.document.CommitQueue commitQueue
public DocumentNodeStore(DocumentNodeStoreBuilder<?> builder)
public void dispose()
@NotNull public @NotNull DocumentStore getDocumentStore()
public void setAsyncDelay(int delay)
public int getAsyncDelay()
public void setMaxBackOffMillis(int time)
public int getMaxBackOffMillis()
public int getChangeSetMaxItems()
public void setChangeSetMaxItems(int changeSetMaxItems)
public int getChangeSetMaxDepth()
public void setChangeSetMaxDepth(int changeSetMaxDepth)
@NotNull public @NotNull ClusterNodeInfo getClusterInfo()
public CacheStats getNodeCacheStats()
public CacheStats getNodeChildrenCacheStats()
@NotNull public @NotNull java.lang.Iterable<CacheStats> getDiffCacheStats()
public Cache<PathRev,DocumentNodeState> getNodeCache()
public Cache<NamePathRev,DocumentNodeState.Children> getNodeChildrenCache()
public int getPendingWriteCount()
public boolean isDisableBranches()
public long getMaxTimeDiffMillis()
@NotNull public @NotNull PropertyState createPropertyState(java.lang.String name, java.lang.String value)
@Nullable public @Nullable DocumentNodeState getNode(@NotNull @NotNull Path path, @NotNull @NotNull RevisionVector rev)
path
- the path of the node.rev
- the read revision.null
if the node does not exist at the
given revision.public BundlingConfigHandler getBundlingConfigHandler()
public boolean compare(@NotNull @NotNull AbstractDocumentNodeState node, @NotNull @NotNull AbstractDocumentNodeState base, @NotNull @NotNull NodeStateDiff diff)
compare
in interface NodeStateDiffer
node
- the node to compare.base
- the base node to compare against.diff
- handler of node state differencestrue
if the full diff was performed, or
false
if it was aborted as requested by the handler
(see the NodeStateDiff
contract for more details)public java.io.Closeable addObserver(Observer observer)
Observable
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.addObserver
in interface Observable
Closeable
instance.@NotNull public @NotNull DocumentNodeState getRoot()
NodeStore
@NotNull public @NotNull NodeState merge(@NotNull @NotNull NodeBuilder builder, @NotNull @NotNull CommitHook commitHook, @NotNull @NotNull CommitInfo info) throws CommitFailedException
NodeStore
merge
in interface NodeStore
builder
- the builder whose changes to applycommitHook
- the commit hook to apply while merging changesinfo
- commit info associated with this merge operationCommitFailedException
- if the merge failed@NotNull public @NotNull NodeState rebase(@NotNull @NotNull NodeBuilder builder)
NodeStore
public NodeState reset(@NotNull @NotNull NodeBuilder builder)
NodeStore
builder
by throwing away all its changes and
setting its base state to the current root state.@NotNull public @NotNull BlobStoreBlob createBlob(java.io.InputStream inputStream) throws java.io.IOException
NodeStore
Blob
from the given input stream. The input stream
is closed after this method returns.createBlob
in interface NodeStore
inputStream
- The input stream for the Blob
Blob
representing inputStream
java.io.IOException
- If an error occurs while reading from the streampublic Blob getBlob(@NotNull @NotNull java.lang.String reference)
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 blobIdgetBlob
in interface NodeStore
reference
- the reference of the blob.Blob.getReference()
public Blob getBlobFromBlobId(java.lang.String blobId)
Blob
with the given blobId.blobId
- the blobId of the blob.@NotNull public @NotNull java.lang.String checkpoint(long lifetime, @NotNull @NotNull java.util.Map<java.lang.String,java.lang.String> properties)
NodeStore
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.
checkpoint
in interface NodeStore
lifetime
- time (in milliseconds, > 0) that the checkpoint
should remain availableproperties
- properties to associate with the checkpoint@NotNull public @NotNull java.lang.String checkpoint(long lifetime)
NodeStore
This method is a shortcut for NodeStore.checkpoint(long, Map)
passing
an empty map for its 2nd argument.
checkpoint
in interface NodeStore
lifetime
- time (in milliseconds, > 0) that the checkpoint
should remain available@NotNull public @NotNull java.util.Map<java.lang.String,java.lang.String> checkpointInfo(@NotNull @NotNull java.lang.String checkpoint)
NodeStore
checkpointInfo
in interface NodeStore
checkpoint
- string reference of a checkpointcheckpoint
or an empty map when there is no such
checkpoint.@NotNull public @NotNull java.lang.Iterable<java.lang.String> checkpoints()
NodeStore
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.
checkpoints
in interface NodeStore
@Nullable public @Nullable NodeState retrieve(@NotNull @NotNull java.lang.String checkpoint)
NodeStore
public boolean release(@NotNull @NotNull java.lang.String checkpoint)
NodeStore
true
.public org.apache.jackrabbit.oak.plugins.document.UnmergedBranches getBranches()
getBranches
in interface RevisionContext
public org.apache.jackrabbit.oak.plugins.document.UnsavedModifications getPendingModifications()
getPendingModifications
in interface RevisionContext
public int getClusterId()
getClusterId
in interface RevisionContext
@NotNull public @NotNull RevisionVector getHeadRevision()
getHeadRevision
in interface RevisionContext
@NotNull public @NotNull Revision newRevision()
newRevision
in interface RevisionContext
@NotNull public @NotNull Clock getClock()
getClock
in interface RevisionContext
public java.lang.String getCommitValue(@NotNull @NotNull Revision changeRevision, @NotNull @NotNull NodeDocument doc)
RevisionContext
null
: the change revision does not have an entry on
the commit root document and is not committed.getCommitValue
in interface RevisionContext
changeRevision
- the revision a change was made.doc
- the document where the change was made.null
if the change does not
have a commit value (yet).public void runBackgroundOperations()
@Nullable public @Nullable MarkSweepGarbageCollector createBlobGarbageCollector(long blobGcMaxAgeInSecs, java.lang.String repositoryId, Whiteboard whiteboard, StatisticsProvider statisticsProvider)
blobGcMaxAgeInSecs
- repositoryId
- whiteboard
- statisticsProvider
- public DocumentNodeStoreMBean getMBean()
public BlobStore getBlobStore()
public java.util.Iterator<ReferencedBlob> getReferencedBlobsIterator()
In some cases the iterator might implement Closeable
. So
callers should check for such iterator and close them.
public org.apache.jackrabbit.oak.plugins.document.DiffCache getDiffCache()
public org.apache.jackrabbit.oak.plugins.document.Checkpoints getCheckpoints()
@NotNull public @NotNull VersionGarbageCollector getVersionGarbageCollector()
@NotNull public @NotNull JournalGarbageCollector getJournalGarbageCollector()
@NotNull public @NotNull LastRevRecoveryAgent getLastRevRecoveryAgent()
public java.lang.String getInstanceId()
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.
getInstanceId
in interface Clusterable
public java.lang.String getVisibilityToken()
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.
getVisibilityToken
in interface Clusterable
public boolean isVisible(@NotNull @NotNull java.lang.String visibilityToken, long maxWaitMillis) throws java.lang.InterruptedException
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.
isVisible
in interface Clusterable
visibilityToken
- the visibility token that was created on another instance in a
clustered NodeStore setup. Providing null is not supported and
might throw a RuntimeExceptionmaxWaitMillis
- 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 waitjava.lang.InterruptedException
- (optionally) thrown if interrupted while waitingpublic DocumentNodeStoreStatsCollector getStatsCollector()
public DocumentNodeStateCache getNodeStateCache()
public void setNodeStateCache(DocumentNodeStateCache nodeStateCache)
public JournalPropertyHandlerFactory getJournalPropertyHandlerFactory()
Copyright © 2012–2022 The Apache Software Foundation. All rights reserved.