Class TarRevisions
- java.lang.Object
-
- org.apache.jackrabbit.oak.segment.file.TarRevisions
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Revisions
public class TarRevisions extends Object implements Revisions, Closeable
This implementation ofRevisions
is backed by ajournal
file where the current head is persisted by callingtryFlush(Flusher)
.The
setHead(Function, Option...)
method supports a timeoutRevisions.Option
, which can be retrieved through factory methods of this class.Instance of this class must be
bind(SegmentStore, SegmentIdProvider, Supplier)
bound} to aSegmentStore
otherwise its method throwIllegalStateException
s.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.jackrabbit.oak.segment.Revisions
Revisions.Option
-
-
Field Summary
Fields Modifier and Type Field Description static Revisions.Option
EXPEDITE_OPTION
Option to cause set head calls to be expedited.static Revisions.Option
INFINITY
Timeout option approximating no time out (Long.MAX_VALUE
days).
-
Constructor Summary
Constructors Constructor Description TarRevisions(SegmentNodeStorePersistence persistence)
Create a new instance placing the journal log file into the passeddirectory
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close the underlying journal file.@NotNull RecordId
getHead()
Returns the record id of the head state.@NotNull RecordId
getPersistedHead()
Returns the persisted to disk record id of the head state.RecordId
setHead(@NotNull Function<RecordId,RecordId> newHead, @NotNull Revisions.Option... options)
This implementation blocks if a concurrent call is already in progress.boolean
setHead(@NotNull RecordId expected, @NotNull RecordId head, @NotNull Revisions.Option... options)
This implementation blocks if a concurrent call tosetHead(Function, Option...)
is already in progress.static Revisions.Option
timeout(long time, TimeUnit unit)
Factory method for creating a timeout option.
-
-
-
Field Detail
-
EXPEDITE_OPTION
public static final Revisions.Option EXPEDITE_OPTION
Option to cause set head calls to be expedited. That is, cause them to skip the queue of any other callers waiting to complete that don't have this option specified.
-
INFINITY
public static final Revisions.Option INFINITY
Timeout option approximating no time out (Long.MAX_VALUE
days).
-
-
Constructor Detail
-
TarRevisions
public TarRevisions(SegmentNodeStorePersistence persistence) throws IOException
Create a new instance placing the journal log file into the passeddirectory
.- Parameters:
persistence
- object representing the segment persistence- Throws:
IOException
-
-
Method Detail
-
timeout
public static Revisions.Option timeout(long time, TimeUnit unit)
Factory method for creating a timeout option.
-
getHead
@NotNull public @NotNull RecordId getHead()
Description copied from interface:Revisions
Returns the record id of the head state. The returned id is a valid id for aSegmentNodeState
.
-
getPersistedHead
@NotNull public @NotNull RecordId getPersistedHead()
Description copied from interface:Revisions
Returns the persisted to disk record id of the head state. The returned id is a valid id for aSegmentNodeState
.- Specified by:
getPersistedHead
in interfaceRevisions
- Returns:
- id of the head state
-
setHead
public boolean setHead(@NotNull @NotNull RecordId expected, @NotNull @NotNull RecordId head, @NotNull @NotNull Revisions.Option... options)
This implementation blocks if a concurrent call tosetHead(Function, Option...)
is already in progress.- Specified by:
setHead
in interfaceRevisions
- Parameters:
options
- zero or one expedite option for expediting this callexpected
- the expected head for the update to take placehead
- the new head to update to- Returns:
true
if the current head was successfully updated,false
otherwise.- Throws:
IllegalArgumentException
- on any non recognisedoption
.- See Also:
EXPEDITE_OPTION
-
setHead
public RecordId setHead(@NotNull @NotNull Function<RecordId,RecordId> newHead, @NotNull @NotNull Revisions.Option... options) throws InterruptedException
This implementation blocks if a concurrent call is already in progress.- Specified by:
setHead
in interfaceRevisions
- Parameters:
newHead
- function mapping an record id to the record id to which the current head id should be set. If it returnsnull
the head remains unchanged andsetHead
returnsfalse
.options
- zero or one timeout options specifying how long to block- Returns:
- the record id of the root node if the current head was successfully
updated,
null
otherwise. - Throws:
InterruptedException
IllegalArgumentException
- on any non recognisedoption
.- See Also:
timeout(long, TimeUnit)
,INFINITY
-
close
public void close() throws IOException
Close the underlying journal file.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
-