public class TarRevisions extends Object implements Revisions, Closeable
Revisions is backed by a
journal file where the current head is persisted
by calling flush(Callable).
The Revisions.setHead(Function, Option...) method supports a timeout
Option, which can be retrieved through factory methods of this class.
Instance of this class must be bound to
a SegmentStore otherwise its method throw IllegalStateExceptions.
Revisions.Option| Modifier and Type | Field and 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). |
static String |
JOURNAL_FILE_NAME |
| Constructor and Description |
|---|
TarRevisions(File directory)
Create a new instance placing the journal log file into the passed
directory. |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the underlying journal file.
|
void |
flush(Callable<Void> persisted)
Flush the id of the current head to the journal after a call to
persisted. |
RecordId |
getHead()
Returns the record id of the head state.
|
boolean |
setHead(com.google.common.base.Function<RecordId,RecordId> newHead,
Revisions.Option... options)
This implementation blocks if a concurrent call is already in progress.
|
boolean |
setHead(RecordId expected,
RecordId head,
Revisions.Option... options)
This implementation blocks if a concurrent call to
Revisions.setHead(Function, Option...) is already in
progress. |
static Revisions.Option |
timeout(long time,
TimeUnit unit)
Factory method for creating a timeout option.
|
public static final String JOURNAL_FILE_NAME
public static final Revisions.Option EXPEDITE_OPTION
public static final Revisions.Option INFINITY
Long.MAX_VALUE days).public TarRevisions(@Nonnull File directory) throws IOException
directory.directory - directory of the journal fileIOExceptionpublic static Revisions.Option timeout(long time, TimeUnit unit)
public void flush(@Nonnull Callable<Void> persisted) throws IOException
persisted. This method does nothing and returns immediately if
called concurrently and a call is already in progress.persisted - call back for upstream dependencies to ensure
the current head state is actually persisted before
its id is written to the head state.IOException@Nonnull public RecordId getHead()
RevisionsSegmentNodeState.public boolean setHead(@Nonnull RecordId expected, @Nonnull RecordId head, @Nonnull Revisions.Option... options)
Revisions.setHead(Function, Option...) is already in
progress.setHead in interface Revisionsoptions - zero or one expedite option for expediting this callexpected - the expected head for the update to take placehead - the new head to update totrue if the current head was successfully
updated, false otherwise.IllegalArgumentException - on any non recognised option.EXPEDITE_OPTIONpublic boolean setHead(@Nonnull com.google.common.base.Function<RecordId,RecordId> newHead, @Nonnull Revisions.Option... options) throws InterruptedException
setHead in interface RevisionsnewHead - function mapping an record id to the record id to which
the current head id should be set. If it returns
null the head remains unchanged and setHead
returns false.options - zero or one timeout options specifying how long to blocktrue if the current head was successfully
updated, false otherwise.InterruptedExceptionIllegalArgumentException - on any non recognised option.timeout(long, TimeUnit),
INFINITYpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionCopyright © 2012-2017 The Apache Software Foundation. All Rights Reserved.