Interface AgilityContext

All Known Implementing Classes:
AgilityContext.Agile, AgilityContext.NonAgile

public interface AgilityContext
Create floating sub contexts from a caller context and commit when they reach time/write quota.
  • Method Details

    • nonAgile

      static AgilityContext nonAgile(FDBRecordContext callerContext)
    • agile

      static AgilityContext agile(FDBRecordContext callerContext, @Nullable FDBRecordContextConfig.Builder contextBuilder, long timeQuotaMillis, long sizeQuotaBytes)
    • agile

      static AgilityContext agile(FDBRecordContext callerContext, long timeQuotaMillis, long sizeQuotaBytes)
    • apply

      `apply` should be called when a returned value is expected. Performed under appropriate lock.
      Type Parameters:
      R - future's type
      Parameters:
      function - a function accepting context, returning a future
      Returns:
      the future of the function above
    • applyInRecoveryPath

      <R> CompletableFuture<R> applyInRecoveryPath(Function<FDBRecordContext,CompletableFuture<R>> function)
      This function is similar to 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.
      Type Parameters:
      R - future's type
      Parameters:
      function - a function accepting context, returning a future
      Returns:
      the future of the function above
    • accept

      void accept(Consumer<FDBRecordContext> function)
      `accept` should be called when a returned value is not expected. Performed under appropriate lock.
      Parameters:
      function - a function that accepts context
    • set

      void set(byte[] key, byte[] value)
      `set` should be called for writes - keeping track of write size (if needed).
      Parameters:
      key - key
      value - value
    • flush

      void flush()
    • flushAndClose

      void flushAndClose()
      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.
    • abortAndClose

      void abortAndClose()
      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 applyInRecoveryPath(Function)
    • isClosed

      boolean isClosed()
    • get

      default CompletableFuture<byte[]> get(byte[] key)
    • clear

      default void clear(byte[] key)
    • clear

      default void clear(Range range)
    • getRange

      default CompletableFuture<List<KeyValue>> getRange(byte[] begin, byte[] end)
    • getCallerContext

      @Nonnull FDBRecordContext getCallerContext()
      This function returns the caller's context. If called by external entities, it should only be used for testing.
      Returns:
      caller's context
    • instrument

      default <T> CompletableFuture<T> instrument(StoreTimer.Event event, CompletableFuture<T> future)
    • instrument

      default <T> CompletableFuture<T> instrument(StoreTimer.Event event, CompletableFuture<T> future, long start)
    • increment

      default void increment(@Nonnull StoreTimer.Count count)
    • increment

      default void increment(@Nonnull StoreTimer.Count count, int size)
    • recordEvent

      default void recordEvent(@Nonnull StoreTimer.Event event, long timeDelta)
    • recordSize

      default void recordSize(@Nonnull StoreTimer.SizeEvent sizeEvent, long size)
    • asyncToSync

      @Nullable default <T> T asyncToSync(StoreTimer.Wait event, @Nonnull CompletableFuture<T> async)
    • getPropertyValue

      @Nullable default <T> T getPropertyValue(@Nonnull com.apple.foundationdb.record.provider.foundationdb.properties.RecordLayerPropertyKey<T> propertyKey)
    • setCommitCheck

      void setCommitCheck(Function<FDBRecordContext,CompletableFuture<Void>> commitCheck)
      The commitCheck callback is expected to use the argument context but should never call other agility context functions as it may cause a deadlock.
      Parameters:
      commitCheck - callback
    • commit

      default void commit(@Nonnull FDBRecordContext context)