Class AgilityContext.NonAgile

java.lang.Object
com.apple.foundationdb.record.lucene.directory.AgilityContext.NonAgile
All Implemented Interfaces:
AgilityContext
Enclosing interface:
AgilityContext

public static class AgilityContext.NonAgile extends Object implements AgilityContext
A non-agile context - plainly use caller's context as context and never commit.
  • Constructor Details

  • Method Details

    • apply

      public <R> CompletableFuture<R> apply(Function<FDBRecordContext,CompletableFuture<R>> function)
      Description copied from interface: AgilityContext
      `apply` should be called when a returned value is expected. Performed under appropriate lock.
      Specified by:
      apply in interface AgilityContext
      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: AgilityContext
      This function is similar to AgilityContext.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:
      applyInRecoveryPath in interface AgilityContext
      Type Parameters:
      R - future's type
      Parameters:
      function - a function accepting context, returning a future
      Returns:
      the future of the function above
    • accept

      public void accept(Consumer<FDBRecordContext> function)
      Description copied from interface: AgilityContext
      `accept` should be called when a returned value is not expected. Performed under appropriate lock.
      Specified by:
      accept in interface AgilityContext
      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:
      set in interface AgilityContext
      Parameters:
      key - key
      value - value
    • getCallerContext

      @Nonnull public FDBRecordContext getCallerContext()
      Description copied from interface: AgilityContext
      This function returns the caller's context. If called by external entities, it should only be used for testing.
      Specified by:
      getCallerContext in interface AgilityContext
      Returns:
      caller's context
    • flush

      public void flush()
      Specified by:
      flush in interface AgilityContext
    • flushAndClose

      public void flushAndClose()
      Description copied from interface: AgilityContext
      This 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:
      flushAndClose in interface AgilityContext
    • abortAndClose

      public void abortAndClose()
      Description copied from interface: AgilityContext
      This 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 use AgilityContext.applyInRecoveryPath(Function)
      Specified by:
      abortAndClose in interface AgilityContext
    • isClosed

      public boolean isClosed()
      Specified by:
      isClosed in interface AgilityContext
    • setCommitCheck

      public void setCommitCheck(Function<FDBRecordContext,CompletableFuture<Void>> commitCheck)
      Description copied from interface: AgilityContext
      The commitCheck callback is expected to use the argument context but should never call other agility context functions as it may cause a deadlock.
      Specified by:
      setCommitCheck in interface AgilityContext
      Parameters:
      commitCheck - callback