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 935C018165 for ; Thu, 12 Nov 2015 20:59:09 +0000 (UTC) Received: (qmail 21752 invoked by uid 500); 12 Nov 2015 20:59:09 -0000 Delivered-To: apmail-hbase-commits-archive@hbase.apache.org Received: (qmail 21711 invoked by uid 500); 12 Nov 2015 20:59:09 -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 21702 invoked by uid 99); 12 Nov 2015 20:59:09 -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; Thu, 12 Nov 2015 20:59:09 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 44443E5E31; Thu, 12 Nov 2015 20:59:09 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: tedyu@apache.org To: commits@hbase.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: hbase git commit: HBASE-14498 Revert for on-going review Date: Thu, 12 Nov 2015 20:59:09 +0000 (UTC) Repository: hbase Updated Branches: refs/heads/branch-1.2 c0ebcff30 -> 1db8abf70 HBASE-14498 Revert for on-going review Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/1db8abf7 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/1db8abf7 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/1db8abf7 Branch: refs/heads/branch-1.2 Commit: 1db8abf707b760f588932a9ca137c4d9d96e3ab1 Parents: c0ebcff Author: tedyu Authored: Thu Nov 12 12:59:03 2015 -0800 Committer: tedyu Committed: Thu Nov 12 12:59:03 2015 -0800 ---------------------------------------------------------------------- .../hbase/zookeeper/ZooKeeperWatcher.java | 42 +---------------- .../hbase/zookeeper/TestZooKeeperWatcher.java | 49 +------------------- 2 files changed, 3 insertions(+), 88 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/1db8abf7/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java ---------------------------------------------------------------------- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java index bfd51ee..9401a62 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java @@ -26,7 +26,6 @@ import java.util.List; import java.util.Map; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CountDownLatch; -import java.util.concurrent.atomic.AtomicBoolean; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -39,7 +38,6 @@ import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.ZooKeeperConnectionException; import org.apache.hadoop.hbase.classification.InterfaceAudience; import org.apache.hadoop.hbase.security.Superusers; -import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; import org.apache.hadoop.security.UserGroupInformation; import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.WatchedEvent; @@ -78,7 +76,7 @@ public class ZooKeeperWatcher implements Watcher, Abortable, Closeable { private RecoverableZooKeeper recoverableZooKeeper; // abortable in case of zk failure - protected final Abortable abortable; + protected Abortable abortable; // Used if abortable is null private boolean aborted = false; @@ -89,10 +87,6 @@ public class ZooKeeperWatcher implements Watcher, Abortable, Closeable { // Used by ZKUtil:waitForZKConnectionIfAuthenticating to wait for SASL // negotiation to complete public CountDownLatch saslLatch = new CountDownLatch(1); - - // Connection timeout on disconnect event - private long connWaitTimeOut; - private AtomicBoolean isConnected = new AtomicBoolean(false); // node names @@ -183,9 +177,6 @@ public class ZooKeeperWatcher implements Watcher, Abortable, Closeable { this.identifier = identifier + "0x0"; this.abortable = abortable; setNodeNames(conf); - // On Disconnected event a thread will wait for sometime (2/3 of zookeeper.session.timeout), - // it will abort the process if no SyncConnected event reported by the time. - connWaitTimeOut = this.conf.getLong("zookeeper.session.timeout", 90000) * 2 / 3; this.recoverableZooKeeper = ZKUtil.connect(conf, quorum, this, identifier); if (canCreateBaseZNode) { createBaseZNodes(); @@ -620,7 +611,6 @@ public class ZooKeeperWatcher implements Watcher, Abortable, Closeable { private void connectionEvent(WatchedEvent event) { switch(event.getState()) { case SyncConnected: - isConnected.set(true); // Now, this callback can be invoked before the this.zookeeper is set. // Wait a little while. long finished = System.currentTimeMillis() + @@ -650,35 +640,7 @@ public class ZooKeeperWatcher implements Watcher, Abortable, Closeable { // Abort the server if Disconnected or Expired case Disconnected: - LOG.debug("Received Disconnected from ZooKeeper."); - isConnected.set(false); - - Thread t = new Thread() { - public void run() { - long startTime = EnvironmentEdgeManager.currentTime(); - while (EnvironmentEdgeManager.currentTime() - startTime < connWaitTimeOut) { - if (isConnected.get()) { - LOG.debug("Client got reconnected to zookeeper."); - return; - } - try { - Thread.sleep(100); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - break; - } - } - - if (!isConnected.get() && abortable != null) { - String msg = - prefix("Couldn't connect to ZooKeeper after waiting " + connWaitTimeOut - + " ms, aborting"); - abortable.abort(msg, new KeeperException.ConnectionLossException()); - } - }; - }; - t.setDaemon(true); - t.start(); + LOG.debug(prefix("Received Disconnected from ZooKeeper, ignoring")); break; case Expired: http://git-wip-us.apache.org/repos/asf/hbase/blob/1db8abf7/hbase-client/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZooKeeperWatcher.java ---------------------------------------------------------------------- diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZooKeeperWatcher.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZooKeeperWatcher.java index 8071b03..10a3816 100644 --- a/hbase-client/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZooKeeperWatcher.java +++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZooKeeperWatcher.java @@ -22,23 +22,15 @@ import static org.junit.Assert.*; import java.io.IOException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hbase.Abortable; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.ZooKeeperConnectionException; import org.apache.hadoop.hbase.testclassification.SmallTests; -import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; -import org.apache.zookeeper.WatchedEvent; -import org.apache.zookeeper.Watcher; import org.junit.Test; import org.junit.experimental.categories.Category; @Category({SmallTests.class}) public class TestZooKeeperWatcher { - private final static Log LOG = LogFactory.getLog(TestZooKeeperWatcher.class); - + @Test public void testIsClientReadable() throws ZooKeeperConnectionException, IOException { ZooKeeperWatcher watcher = new ZooKeeperWatcher(HBaseConfiguration.create(), @@ -64,44 +56,5 @@ public class TestZooKeeperWatcher { watcher.close(); } - - @Test - public void testConnectionEvent() throws ZooKeeperConnectionException, IOException { - long zkSessionTimeout = 15000l; - Configuration conf = HBaseConfiguration.create(); - conf.set("zookeeper.session.timeout", "15000"); - - Abortable abortable = new Abortable() { - boolean aborted = false; - - @Override - public void abort(String why, Throwable e) { - aborted = true; - LOG.error(why, e); - } - - @Override - public boolean isAborted() { - return aborted; - } - }; - ZooKeeperWatcher watcher = new ZooKeeperWatcher(conf, "testConnectionEvent", abortable, false); - WatchedEvent event = - new WatchedEvent(Watcher.Event.EventType.None, Watcher.Event.KeeperState.Disconnected, null); - - long startTime = EnvironmentEdgeManager.currentTime(); - while (!abortable.isAborted() - && (EnvironmentEdgeManager.currentTime() - startTime < zkSessionTimeout)) { - watcher.process(event); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - } - } - - assertTrue(abortable.isAborted()); - watcher.close(); - } }