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 ofRevisionsis backed by ajournalfile 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 aSegmentStoreotherwise its method throwIllegalStateExceptions.
-
-
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.OptionEXPEDITE_OPTIONOption to cause set head calls to be expedited.static Revisions.OptionINFINITYTimeout option approximating no time out (Long.MAX_VALUEdays).
-
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 voidclose()Close the underlying journal file.@NotNull RecordIdgetHead()Returns the record id of the head state.@NotNull RecordIdgetPersistedHead()Returns the persisted to disk record id of the head state.RecordIdsetHead(@NotNull Function<RecordId,RecordId> newHead, @NotNull Revisions.Option... options)This implementation blocks if a concurrent call is already in progress.booleansetHead(@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.Optiontimeout(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_VALUEdays).
-
-
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:RevisionsReturns 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:RevisionsReturns the persisted to disk record id of the head state. The returned id is a valid id for aSegmentNodeState.- Specified by:
getPersistedHeadin 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:
setHeadin 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:
trueif the current head was successfully updated,falseotherwise.- 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:
setHeadin interfaceRevisions- Parameters:
newHead- function mapping an record id to the record id to which the current head id should be set. If it returnsnullthe head remains unchanged andsetHeadreturnsfalse.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,
nullotherwise. - Throws:
InterruptedExceptionIllegalArgumentException- on any non recognisedoption.- See Also:
timeout(long, TimeUnit),INFINITY
-
close
public void close() throws IOExceptionClose the underlying journal file.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
-