Class ZooWorker

java.lang.Object
org.apache.bookkeeper.zookeeper.ZooWorker

class ZooWorker extends Object
Provide a mechanism to perform an operation on ZooKeeper that is safe on disconnections and recoverable errors.
  • Field Details

    • attempts

      int attempts
    • startTimeNanos

      long startTimeNanos
    • elapsedTimeMs

      long elapsedTimeMs
    • retryPolicy

      final RetryPolicy retryPolicy
    • statsLogger

      final OpStatsLogger statsLogger
  • Constructor Details

  • Method Details

    • allowRetry

      public boolean allowRetry(int rc)
    • nextRetryWaitTime

      public long nextRetryWaitTime()
    • isRecoverableException

      public static boolean isRecoverableException(int rc)
      Check whether the given result code is recoverable by retry.
      Parameters:
      rc - result code
      Returns:
      true if given result code is recoverable.
    • isRecoverableException

      public static boolean isRecoverableException(org.apache.zookeeper.KeeperException exception)
      Check whether the given exception is recoverable by retry.
      Parameters:
      exception - given exception
      Returns:
      true if given exception is recoverable.
    • syncCallWithRetries

      public static <T> T syncCallWithRetries(ZooKeeperClient client, ZooWorker.ZooCallable<T> proc, RetryPolicy retryPolicy, com.google.common.util.concurrent.RateLimiter rateLimiter, OpStatsLogger statsLogger) throws org.apache.zookeeper.KeeperException, InterruptedException
      Execute a sync zookeeper operation with a given retry policy.
      Parameters:
      client - ZooKeeper client.
      proc - Synchronous zookeeper operation wrapped in a Callable.
      retryPolicy - Retry policy to execute the synchronous operation.
      rateLimiter - Rate limiter for zookeeper calls
      statsLogger - Stats Logger for zookeeper client.
      Returns:
      result of the zookeeper operation
      Throws:
      org.apache.zookeeper.KeeperException - any non-recoverable exception or recoverable exception exhausted all retires.
      InterruptedException - the operation is interrupted.