Repository: hbase Updated Branches: refs/heads/branch-1 463374ecf -> 8151503fa
HBASE-14963 Remove use of Guava Stopwatch from HBase client code (Devaraj Das) Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/8151503f Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/8151503f Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/8151503f Branch: refs/heads/branch-1 Commit: 8151503fa075bb7388019770bccb28703d23935d Parents: 463374e Author: Jerry He <jerry...@apache.org> Authored: Sat Mar 19 13:21:53 2016 -0700 Committer: Jerry He <jerry...@apache.org> Committed: Sat Mar 19 13:23:05 2016 -0700 ---------------------------------------------------------------------- .../hbase/zookeeper/MetaTableLocator.java | 23 ++++++++------------ 1 file changed, 9 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/8151503f/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/MetaTableLocator.java ---------------------------------------------------------------------- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/MetaTableLocator.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/MetaTableLocator.java index 0975c14..dc25bab 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/MetaTableLocator.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/MetaTableLocator.java @@ -54,7 +54,6 @@ import org.apache.hadoop.hbase.util.Pair; import org.apache.hadoop.ipc.RemoteException; import org.apache.zookeeper.KeeperException; -import com.google.common.base.Stopwatch; import com.google.protobuf.InvalidProtocolBufferException; /** @@ -228,11 +227,11 @@ public class MetaTableLocator { * @throws InterruptedException if interrupted while waiting */ public void waitMetaRegionLocation(ZooKeeperWatcher zkw) throws InterruptedException { - Stopwatch stopwatch = new Stopwatch().start(); + long startTime = System.currentTimeMillis(); while (!stopped) { try { if (waitMetaRegionLocation(zkw, 100) != null) break; - long sleepTime = stopwatch.elapsedMillis(); + long sleepTime = System.currentTimeMillis() - startTime; // +1 in case sleepTime=0 if ((sleepTime + 1) % 10000 == 0) { LOG.warn("Have been waiting for meta to be assigned for " + sleepTime + "ms"); @@ -590,19 +589,15 @@ public class MetaTableLocator { throws InterruptedException { if (timeout < 0) throw new IllegalArgumentException(); if (zkw == null) throw new IllegalArgumentException(); - Stopwatch sw = new Stopwatch().start(); + long startTime = System.currentTimeMillis(); ServerName sn = null; - try { - while (true) { - sn = getMetaRegionLocation(zkw, replicaId); - if (sn != null || sw.elapsedMillis() - > timeout - HConstants.SOCKET_RETRY_WAIT_MS) { - break; - } - Thread.sleep(HConstants.SOCKET_RETRY_WAIT_MS); + while (true) { + sn = getMetaRegionLocation(zkw, replicaId); + if (sn != null || (System.currentTimeMillis() - startTime) + > timeout - HConstants.SOCKET_RETRY_WAIT_MS) { + break; } - } finally { - sw.stop(); + Thread.sleep(HConstants.SOCKET_RETRY_WAIT_MS); } return sn; }