Class MemoryNodeStore
java.lang.Object
org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore
- All Implemented Interfaces:
Observable
,NodeStore
Basic in-memory node store implementation. Useful as a base class for
more complex functionality.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddObserver
(Observer observer) Register a newObserver
.@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.checkpointInfo
(@NotNull String checkpoint) Retrieve the properties associated with a checkpoint.Returns all valid checkpoints.createBlob
(InputStream inputStream) Create aBlob
from the given input stream.Get a blob by its reference.getRoot()
Returns the latest state of the tree.test purpose only!merge
(@NotNull NodeBuilder builder, @NotNull CommitHook commitHook, @NotNull CommitInfo info) This implementation is equal to first rebasing the builder and then applying it to a new branch and immediately merging it back.rebase
(@NotNull NodeBuilder builder) This implementation is equal to applying the differences between the builders base state and its head state to a fresh builder on the stores root state usingConflictAnnotatingRebaseDiff
for resolving conflicts.boolean
Releases the provided checkpoint.reset
(@NotNull NodeBuilder builder) This implementation is equal resetting the builder to the root of the store and returning the resulting node state from the builder.@Nullable NodeState
Retrieves the root node from a previously created repository checkpoint.toString()
Returns a string representation the head state of this node store.
-
Constructor Details
-
MemoryNodeStore
-
MemoryNodeStore
public MemoryNodeStore()
-
-
Method Details
-
toString
Returns a string representation the head state of this node store. -
addObserver
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
Description copied from interface:NodeStore
Returns the latest state of the tree. -
merge
public NodeState merge(@NotNull @NotNull NodeBuilder builder, @NotNull @NotNull CommitHook commitHook, @NotNull @NotNull CommitInfo info) throws CommitFailedException This implementation is equal to first rebasing the builder and then applying it to a new branch and immediately merging it back.- 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
IllegalArgumentException
- if the builder is not acquired from a root state of this store
-
rebase
This implementation is equal to applying the differences between the builders base state and its head state to a fresh builder on the stores root state usingConflictAnnotatingRebaseDiff
for resolving conflicts.- Specified by:
rebase
in interfaceNodeStore
- Parameters:
builder
- the builder to rebase- Returns:
- the node state resulting from the rebase.
- Throws:
IllegalArgumentException
- if the builder is not acquired from a root state of this store
-
reset
This implementation is equal resetting the builder to the root of the store and returning the resulting node state from the builder.- Specified by:
reset
in interfaceNodeStore
- Parameters:
builder
- the builder to reset- Returns:
- the node state resulting from the reset.
- Throws:
IllegalArgumentException
- if the builder is not acquired from a root state of this store
-
createBlob
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:
inputStream
- The input stream for theBlob
- Returns:
- An instance of
ArrayBasedBlob
. - Throws:
IOException
- If an error occurs while reading from the stream
-
getBlob
Description copied from interface:NodeStore
Get a blob by its reference. -
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
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
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
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
Description copied from interface:NodeStore
Retrieves the root node from a previously created repository checkpoint. -
release
Description copied from interface:NodeStore
Releases the provided checkpoint. If the provided checkpoint doesn't exist this method should returntrue
. -
listCheckpoints
test purpose only!
-