Class AgilityContext.Agile
java.lang.Object
com.apple.foundationdb.record.lucene.directory.AgilityContext.Agile
- All Implemented Interfaces:
AgilityContext
- Enclosing interface:
- AgilityContext
A floating window (agile) context - create sub contexts and commit them as they reach their time/size quota.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.apple.foundationdb.record.lucene.directory.AgilityContext
AgilityContext.Agile, AgilityContext.NonAgile -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAgile(FDBRecordContext callerContext, FDBRecordContextConfig.Builder contextBuilder, long timeQuotaMillis, long sizeQuotaBytes) -
Method Summary
Modifier and TypeMethodDescriptionvoidThis will abort the existing agile context (if agile) and prevent future operations.voidaccept(Consumer<FDBRecordContext> function) `accept` should be called when a returned value is not expected.<R> CompletableFuture<R>apply(Function<FDBRecordContext, CompletableFuture<R>> function) `apply` should be called when a returned value is expected.<R> CompletableFuture<R>applyInRecoveryPath(Function<FDBRecordContext, CompletableFuture<R>> function) This function is similar toAgilityContext.apply(Function), but should only be called in the recovery path.voidvoidflush()voidThis can be called to declare the object as 'closed' after flush.This function returns the caller's context.booleanisClosed()voidset(byte[] key, byte[] value) `set` should be called for writes - keeping track of write size (if needed).voidsetCommitCheck(Function<FDBRecordContext, CompletableFuture<Void>> commitCheck) ThecommitCheckcallback is expected to use the argument context but should never call other agility context functions as it may cause a deadlock.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.apple.foundationdb.record.lucene.directory.AgilityContext
asyncToSync, clear, clear, commit, get, getPropertyValue, getRange, increment, increment, instrument, instrument, recordEvent, recordSize
-
Constructor Details
-
Agile
protected Agile(FDBRecordContext callerContext, @Nullable FDBRecordContextConfig.Builder contextBuilder, long timeQuotaMillis, long sizeQuotaBytes)
-
-
Method Details
-
setCommitCheck
Description copied from interface:AgilityContextThecommitCheckcallback is expected to use the argument context but should never call other agility context functions as it may cause a deadlock.- Specified by:
setCommitCheckin interfaceAgilityContext- Parameters:
commitCheck- callback
-
getCallerContext
Description copied from interface:AgilityContextThis function returns the caller's context. If called by external entities, it should only be used for testing.- Specified by:
getCallerContextin interfaceAgilityContext- Returns:
- caller's context
-
commitNow
public void commitNow() -
apply
Description copied from interface:AgilityContext`apply` should be called when a returned value is expected. Performed under appropriate lock.- Specified by:
applyin interfaceAgilityContext- Type Parameters:
R- future's type- Parameters:
function- a function accepting context, returning a future- Returns:
- the future of the function above
-
applyInRecoveryPath
public <R> CompletableFuture<R> applyInRecoveryPath(Function<FDBRecordContext, CompletableFuture<R>> function) Description copied from interface:AgilityContextThis function is similar toAgilityContext.apply(Function), but should only be called in the recovery path. In Agile mode, it creates a new context for the function's apply to allow recovery, in non-Agile mode it's a no-op. This function may be called after agility context was closed.- Specified by:
applyInRecoveryPathin interfaceAgilityContext- Type Parameters:
R- future's type- Parameters:
function- a function accepting context, returning a future- Returns:
- the future of the function above
-
accept
Description copied from interface:AgilityContext`accept` should be called when a returned value is not expected. Performed under appropriate lock.- Specified by:
acceptin interfaceAgilityContext- Parameters:
function- a function that accepts context
-
set
public void set(byte[] key, byte[] value) Description copied from interface:AgilityContext`set` should be called for writes - keeping track of write size (if needed).- Specified by:
setin interfaceAgilityContext- Parameters:
key- keyvalue- value
-
flush
public void flush()- Specified by:
flushin interfaceAgilityContext
-
flushAndClose
public void flushAndClose()Description copied from interface:AgilityContextThis can be called to declare the object as 'closed' after flush. Future "flush" will succeed, but any attempt to perform a transaction read/write will cause an exception.- Specified by:
flushAndClosein interfaceAgilityContext
-
abortAndClose
public void abortAndClose()Description copied from interface:AgilityContextThis will abort the existing agile context (if agile) and prevent future operations. The only reason to call this function is after an exception, by a wrapper function. to clean potential locks after a failure and close, one should useAgilityContext.applyInRecoveryPath(Function)- Specified by:
abortAndClosein interfaceAgilityContext
-
isClosed
public boolean isClosed()- Specified by:
isClosedin interfaceAgilityContext
-