Class HedgeLayer

java.lang.Object
org.apache.opendal.Layer
org.apache.opendal.layer.HedgeLayer

public class HedgeLayer extends Layer
Starts duplicate attempts for slow stat calls and reads. By default, both operations can launch one additional attempt per request after five seconds. Each additional attempt waits a full delay after the previous launch. The builder's delay sets the shared delay, and statDelay and readDelay override it per operation. Set maxHedges to zero to disable hedging, or set hedgeStat or hedgeRead to false to disable hedging for that operation.

The first success or non-temporary error ends the race. A temporary error prevents further launches and lets any attempts already in flight finish. If every attempt fails temporarily, the layer returns the last observed error. On reads, the layer races range requests, including opening a stream. The caller consumes the winning stream without hedging individual chunks. When the race ends, the layer cancels outstanding attempts on the client. The service may still process requests it already received.

Add this layer before TimeoutLayer and RetryLayer so that a timeout covers the entire race and retries can handle temporary errors from the race.

See Also:
  • Method Details

    • layer

      protected long layer(long nativeOp)
      Specified by:
      layer in class Layer