Search in sources :

Example 1 with RetryCounter

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

the class RecoverableZooKeeper method getAcl.

/**
   * getAcl is an idempotent operation. Retry before throwing exception
   * @return list of ACLs
   */
public List<ACL> getAcl(String path, Stat stat) throws KeeperException, InterruptedException {
    TraceScope traceScope = null;
    try {
        traceScope = Trace.startSpan("RecoverableZookeeper.getAcl");
        RetryCounter retryCounter = retryCounterFactory.create();
        while (true) {
            try {
                return checkZk().getACL(path, stat);
            } catch (KeeperException e) {
                switch(e.code()) {
                    case CONNECTIONLOSS:
                    case OPERATIONTIMEOUT:
                        retryOrThrow(retryCounter, e, "getAcl");
                        break;
                    default:
                        throw e;
                }
            }
            retryCounter.sleepUntilNextRetry();
        }
    } finally {
        if (traceScope != null)
            traceScope.close();
    }
}
Also used : RetryCounter(org.apache.hadoop.hbase.util.RetryCounter) TraceScope(org.apache.htrace.TraceScope) KeeperException(org.apache.zookeeper.KeeperException)

Example 2 with RetryCounter

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

the class RecoverableZooKeeper method exists.

/**
   * exists is an idempotent operation. Retry before throwing exception
   * @return A Stat instance
   */
public Stat exists(String path, boolean watch) throws KeeperException, InterruptedException {
    TraceScope traceScope = null;
    try {
        traceScope = Trace.startSpan("RecoverableZookeeper.exists");
        RetryCounter retryCounter = retryCounterFactory.create();
        while (true) {
            try {
                return checkZk().exists(path, watch);
            } catch (KeeperException e) {
                switch(e.code()) {
                    case CONNECTIONLOSS:
                    case OPERATIONTIMEOUT:
                        retryOrThrow(retryCounter, e, "exists");
                        break;
                    default:
                        throw e;
                }
            }
            retryCounter.sleepUntilNextRetry();
        }
    } finally {
        if (traceScope != null)
            traceScope.close();
    }
}
Also used : RetryCounter(org.apache.hadoop.hbase.util.RetryCounter) TraceScope(org.apache.htrace.TraceScope) KeeperException(org.apache.zookeeper.KeeperException)

Example 3 with RetryCounter

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

the class RecoverableZooKeeper method getChildren.

/**
   * getChildren is an idempotent operation. Retry before throwing exception
   * @return List of children znodes
   */
public List<String> getChildren(String path, boolean watch) throws KeeperException, InterruptedException {
    TraceScope traceScope = null;
    try {
        traceScope = Trace.startSpan("RecoverableZookeeper.getChildren");
        RetryCounter retryCounter = retryCounterFactory.create();
        while (true) {
            try {
                return checkZk().getChildren(path, watch);
            } catch (KeeperException e) {
                switch(e.code()) {
                    case CONNECTIONLOSS:
                    case OPERATIONTIMEOUT:
                        retryOrThrow(retryCounter, e, "getChildren");
                        break;
                    default:
                        throw e;
                }
            }
            retryCounter.sleepUntilNextRetry();
        }
    } finally {
        if (traceScope != null)
            traceScope.close();
    }
}
Also used : RetryCounter(org.apache.hadoop.hbase.util.RetryCounter) TraceScope(org.apache.htrace.TraceScope) KeeperException(org.apache.zookeeper.KeeperException)

Example 4 with RetryCounter

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

the class RecoverableZooKeeper method getChildren.

/**
   * getChildren is an idempotent operation. Retry before throwing exception
   * @return List of children znodes
   */
public List<String> getChildren(String path, Watcher watcher) throws KeeperException, InterruptedException {
    TraceScope traceScope = null;
    try {
        traceScope = Trace.startSpan("RecoverableZookeeper.getChildren");
        RetryCounter retryCounter = retryCounterFactory.create();
        while (true) {
            try {
                return checkZk().getChildren(path, watcher);
            } catch (KeeperException e) {
                switch(e.code()) {
                    case CONNECTIONLOSS:
                    case OPERATIONTIMEOUT:
                        retryOrThrow(retryCounter, e, "getChildren");
                        break;
                    default:
                        throw e;
                }
            }
            retryCounter.sleepUntilNextRetry();
        }
    } finally {
        if (traceScope != null)
            traceScope.close();
    }
}
Also used : RetryCounter(org.apache.hadoop.hbase.util.RetryCounter) TraceScope(org.apache.htrace.TraceScope) KeeperException(org.apache.zookeeper.KeeperException)

Example 5 with RetryCounter

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

the class RecoverableZooKeeper method getData.

/**
   * getData is an idempotent operation. Retry before throwing exception
   * @return Data
   */
public byte[] getData(String path, Watcher watcher, Stat stat) throws KeeperException, InterruptedException {
    TraceScope traceScope = null;
    try {
        traceScope = Trace.startSpan("RecoverableZookeeper.getData");
        RetryCounter retryCounter = retryCounterFactory.create();
        while (true) {
            try {
                byte[] revData = checkZk().getData(path, watcher, stat);
                return removeMetaData(revData);
            } catch (KeeperException e) {
                switch(e.code()) {
                    case CONNECTIONLOSS:
                    case OPERATIONTIMEOUT:
                        retryOrThrow(retryCounter, e, "getData");
                        break;
                    default:
                        throw e;
                }
            }
            retryCounter.sleepUntilNextRetry();
        }
    } finally {
        if (traceScope != null)
            traceScope.close();
    }
}
Also used : RetryCounter(org.apache.hadoop.hbase.util.RetryCounter) TraceScope(org.apache.htrace.TraceScope) KeeperException(org.apache.zookeeper.KeeperException)

Aggregations

RetryCounter (org.apache.hadoop.hbase.util.RetryCounter)23 KeeperException (org.apache.zookeeper.KeeperException)16 TraceScope (org.apache.htrace.TraceScope)8 IOException (java.io.IOException)7 ArrayList (java.util.ArrayList)4 Arrays (java.util.Arrays)4 Collections (java.util.Collections)4 List (java.util.List)4 TimeUnit (java.util.concurrent.TimeUnit)4 Bytes (org.apache.hadoop.hbase.util.Bytes)4 Threads (org.apache.hadoop.hbase.util.Threads)4 Closeables (org.apache.hbase.thirdparty.com.google.common.io.Closeables)4 InetAddress (java.net.InetAddress)3 UnknownHostException (java.net.UnknownHostException)3 Collection (java.util.Collection)3 Iterator (java.util.Iterator)3 Map (java.util.Map)3 Random (java.util.Random)3 Set (java.util.Set)3 Configuration (org.apache.hadoop.conf.Configuration)3