Search in sources :

Example 16 with RetryCounter

use of org.apache.hadoop.hbase.util.RetryCounter in project hbase by apache.

the class RecoverableZooKeeper method createSequential.

private String createSequential(String path, byte[] data, List<ACL> acl, CreateMode createMode) throws KeeperException, InterruptedException {
    RetryCounter retryCounter = retryCounterFactory.create();
    boolean first = true;
    String newPath = path + this.identifier;
    while (true) {
        try {
            if (!first) {
                // Check if we succeeded on a previous attempt
                String previousResult = findPreviousSequentialNode(newPath);
                if (previousResult != null) {
                    return previousResult;
                }
            }
            first = false;
            return checkZk().create(newPath, data, acl, createMode);
        } catch (KeeperException e) {
            switch(e.code()) {
                case CONNECTIONLOSS:
                case OPERATIONTIMEOUT:
                    retryOrThrow(retryCounter, e, "create");
                    break;
                default:
                    throw e;
            }
        }
        retryCounter.sleepUntilNextRetry();
    }
}
Also used : RetryCounter(org.apache.hadoop.hbase.util.RetryCounter) KeeperException(org.apache.zookeeper.KeeperException)

Aggregations

RetryCounter (org.apache.hadoop.hbase.util.RetryCounter)16 KeeperException (org.apache.zookeeper.KeeperException)13 TraceScope (org.apache.htrace.TraceScope)11 IOException (java.io.IOException)2 InterruptedIOException (java.io.InterruptedIOException)1 TableNotFoundException (org.apache.hadoop.hbase.TableNotFoundException)1 FlushRegionCallable (org.apache.hadoop.hbase.client.FlushRegionCallable)1 HBaseRpcController (org.apache.hadoop.hbase.ipc.HBaseRpcController)1 AdminService (org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.AdminService)1 FlushRegionResponse (org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.FlushRegionResponse)1 ServerInfo (org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.ServerInfo)1 RetryCounterFactory (org.apache.hadoop.hbase.util.RetryCounterFactory)1 Op (org.apache.zookeeper.Op)1 Stat (org.apache.zookeeper.data.Stat)1