Class SegmentNodeStore
- java.lang.Object
-
- org.apache.jackrabbit.oak.segment.SegmentNodeStore
-
- All Implemented Interfaces:
Observable
,NodeStore
public class SegmentNodeStore extends Object implements NodeStore, Observable
The top level class for the segment store.The root node of the JCR content tree is actually stored in the node "/root", and checkpoints are stored under "/checkpoints".
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SegmentNodeStore.SegmentNodeStoreBuilder
-
Field Summary
Fields Modifier and Type Field Description static String
CHECKPOINTS
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Closeable
addObserver(Observer observer)
Register a newObserver
.static @NotNull SegmentNodeStore.SegmentNodeStoreBuilder
builder(@NotNull Revisions revisions, @NotNull SegmentReader reader, @NotNull SegmentWriter writer, @Nullable BlobStore blobStore)
@NotNull String
checkpoint(long lifetime)
Creates a new checkpoint of the latest root of the tree.@NotNull String
checkpoint(long lifetime, @NotNull Map<String,String> properties)
Creates a new checkpoint of the latest root of the tree.@NotNull Map<String,String>
checkpointInfo(@NotNull String checkpoint)
Retrieve the properties associated with a checkpoint.@NotNull Iterable<String>
checkpoints()
Returns all valid checkpoints.@NotNull Blob
createBlob(InputStream stream)
Create aBlob
from the given input stream.Blob
getBlob(@NotNull String reference)
Get a blob by its reference.@NotNull NodeState
getRoot()
Returns the latest state of the tree.SegmentNodeStoreStats
getStats()
@NotNull NodeState
merge(@NotNull NodeBuilder builder, @NotNull CommitHook commitHook, @NotNull CommitInfo info)
@NotNull NodeState
rebase(@NotNull NodeBuilder builder)
boolean
release(@NotNull String checkpoint)
Releases the provided checkpoint.@NotNull NodeState
reset(@NotNull NodeBuilder builder)
Reset the passedbuilder
by throwing away all its changes and setting its base state to the current root state.@Nullable NodeState
retrieve(@NotNull String checkpoint)
Retrieves the root node from a previously created repository checkpoint.
-
-
-
Field Detail
-
CHECKPOINTS
public static final String CHECKPOINTS
- See Also:
- Constant Field Values
-
-
Method Detail
-
builder
@NotNull public static @NotNull SegmentNodeStore.SegmentNodeStoreBuilder builder(@NotNull @NotNull Revisions revisions, @NotNull @NotNull SegmentReader reader, @NotNull @NotNull SegmentWriter writer, @Nullable @Nullable BlobStore blobStore)
-
addObserver
public Closeable addObserver(Observer observer)
Description copied from interface:Observable
Register a newObserver
. Clients need to callCloseable.close()
to stop getting notifications on the registered observer and to free up any resources associated with the registration.- Specified by:
addObserver
in interfaceObservable
- Returns:
- a
Closeable
instance.
-
getRoot
@NotNull public @NotNull NodeState getRoot()
Description copied from interface:NodeStore
Returns the latest state of the tree.
-
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
- Specified by:
merge
in interfaceNodeStore
- Parameters:
builder
- the builder whose changes to applycommitHook
- the commit hook to apply while merging changesinfo
- 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
-
reset
@NotNull public @NotNull NodeState reset(@NotNull @NotNull NodeBuilder builder)
Description copied from interface:NodeStore
Reset the passedbuilder
by throwing away all its changes and setting its base state to the current root state.
-
createBlob
@NotNull public @NotNull Blob createBlob(InputStream stream) throws IOException
Description copied from interface:NodeStore
Create aBlob
from the given input stream. The input stream is closed after this method returns.- Specified by:
createBlob
in interfaceNodeStore
- Parameters:
stream
- The input stream for theBlob
- Returns:
- The
Blob
representinginputStream
- Throws:
IOException
- If an error occurs while reading from the stream
-
getBlob
public Blob getBlob(@NotNull @NotNull String reference)
Description copied from interface:NodeStore
Get a blob by its reference.- Specified by:
getBlob
in interfaceNodeStore
- Parameters:
reference
- reference to the blob- Returns:
- blob or
null
if the reference does not resolve to a blob. - See Also:
Blob.getReference()
-
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 theNodeStore.checkpointInfo(String)
method. Its semantics is entirely application specific.- Specified by:
checkpoint
in interfaceNodeStore
- Parameters:
lifetime
- time (in milliseconds, > 0) that the checkpoint should remain availableproperties
- 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 interfaceNodeStore
- 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 interfaceNodeStore
- 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 returnedIterable
provides a snapshot of valid checkpoints at the time this method is called. That is, theIterable
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 interfaceNodeStore
- 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.
-
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 returntrue
.
-
getStats
public SegmentNodeStoreStats getStats()
-
-