Return-Path: X-Original-To: apmail-hbase-commits-archive@www.apache.org Delivered-To: apmail-hbase-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5C44D19B5E for ; Sat, 19 Mar 2016 20:22:23 +0000 (UTC) Received: (qmail 42303 invoked by uid 500); 19 Mar 2016 20:22:23 -0000 Delivered-To: apmail-hbase-commits-archive@hbase.apache.org Received: (qmail 42262 invoked by uid 500); 19 Mar 2016 20:22:23 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 42253 invoked by uid 99); 19 Mar 2016 20:22:23 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 19 Mar 2016 20:22:23 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 03990DFC4F; Sat, 19 Mar 2016 20:22:23 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jerryjch@apache.org To: commits@hbase.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: hbase git commit: HBASE-14963 Remove use of Guava Stopwatch from HBase client code (Devaraj Das) Date: Sat, 19 Mar 2016 20:22:23 +0000 (UTC) Repository: hbase Updated Branches: refs/heads/branch-1.3 ce00fc1bc -> c2cd23fee 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/c2cd23fe Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/c2cd23fe Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/c2cd23fe Branch: refs/heads/branch-1.3 Commit: c2cd23fee98f34b846b4c43a9141f9bab598ae6a Parents: ce00fc1 Author: Jerry He Authored: Sat Mar 19 13:21:53 2016 -0700 Committer: Jerry He Committed: Sat Mar 19 13:21:53 2016 -0700 ---------------------------------------------------------------------- .../hbase/zookeeper/MetaTableLocator.java | 23 ++++++++------------ 1 file changed, 9 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/c2cd23fe/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; }