Return-Path: X-Original-To: apmail-accumulo-commits-archive@www.apache.org Delivered-To: apmail-accumulo-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 1AF1A1094B for ; Thu, 12 Dec 2013 16:25:40 +0000 (UTC) Received: (qmail 99643 invoked by uid 500); 12 Dec 2013 16:25:26 -0000 Delivered-To: apmail-accumulo-commits-archive@accumulo.apache.org Received: (qmail 99395 invoked by uid 500); 12 Dec 2013 16:25:24 -0000 Mailing-List: contact commits-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@accumulo.apache.org Delivered-To: mailing list commits@accumulo.apache.org Received: (qmail 99238 invoked by uid 99); 12 Dec 2013 16:25:23 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Dec 2013 16:25:23 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 6264389FB68; Thu, 12 Dec 2013 16:25:23 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ecn@apache.org To: commits@accumulo.apache.org Date: Thu, 12 Dec 2013 16:25:29 -0000 Message-Id: <1995848517304c7289beaf72c3b4fd80@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [07/16] git commit: ACCUMULO-1984 Rework interruption for instance implementations. ACCUMULO-1984 Rework interruption for instance implementations. This change removes the throwing of InterruptedException from several classes, simplifying the API. Some of the affected classes now also implement java.io.Closeable. Signed-off-by: Eric Newton Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/0d0bc464 Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/0d0bc464 Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/0d0bc464 Branch: refs/heads/1.6.0-SNAPSHOT Commit: 0d0bc4643a8680593e2cf5f828b7566c30fcb345 Parents: cc68925 Author: Bill Havanki Authored: Wed Dec 11 13:06:47 2013 -0500 Committer: Eric Newton Committed: Thu Dec 12 11:23:52 2013 -0500 ---------------------------------------------------------------------- .../org/apache/accumulo/core/client/Instance.java | 7 ++++--- .../accumulo/core/client/ZooKeeperInstance.java | 6 +++--- .../accumulo/core/client/mock/MockInstance.java | 2 +- .../org/apache/accumulo/core/zookeeper/ZooCache.java | 6 ++++-- .../apache/accumulo/core/zookeeper/ZooReader.java | 15 ++++++++++++--- .../core/client/impl/TabletLocatorImplTest.java | 2 +- .../accumulo/server/client/HdfsZooInstance.java | 8 ++------ 7 files changed, 27 insertions(+), 19 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/0d0bc464/src/core/src/main/java/org/apache/accumulo/core/client/Instance.java ---------------------------------------------------------------------- diff --git a/src/core/src/main/java/org/apache/accumulo/core/client/Instance.java b/src/core/src/main/java/org/apache/accumulo/core/client/Instance.java index 1820e7a..3b2af18 100644 --- a/src/core/src/main/java/org/apache/accumulo/core/client/Instance.java +++ b/src/core/src/main/java/org/apache/accumulo/core/client/Instance.java @@ -16,6 +16,7 @@ */ package org.apache.accumulo.core.client; +import java.io.Closeable; import java.nio.ByteBuffer; import java.util.List; @@ -26,7 +27,7 @@ import org.apache.accumulo.core.security.thrift.AuthInfo; * This class represents the information a client needs to know to connect to an instance of accumulo. * */ -public interface Instance { +public interface Instance extends Closeable { /** * Returns the location of the tablet server that is serving the root tablet. * @@ -130,9 +131,9 @@ public interface Instance { /** * Closes up the instance to free up all associated resources. You should try to reuse an Instance as much as you can because there is some location caching * stored which will enhance performance. - * @throws AccumuloException */ - public abstract void close() throws AccumuloException; + @Override + public abstract void close(); /** * Returns the AccumuloConfiguration to use when interacting with this instance. http://git-wip-us.apache.org/repos/asf/accumulo/blob/0d0bc464/src/core/src/main/java/org/apache/accumulo/core/client/ZooKeeperInstance.java ---------------------------------------------------------------------- diff --git a/src/core/src/main/java/org/apache/accumulo/core/client/ZooKeeperInstance.java b/src/core/src/main/java/org/apache/accumulo/core/client/ZooKeeperInstance.java index fcf8f55..4cd4972 100644 --- a/src/core/src/main/java/org/apache/accumulo/core/client/ZooKeeperInstance.java +++ b/src/core/src/main/java/org/apache/accumulo/core/client/ZooKeeperInstance.java @@ -303,14 +303,14 @@ public class ZooKeeperInstance implements Instance { static private final AtomicInteger clientInstances = new AtomicInteger(0); @Override - public synchronized void close() throws AccumuloException { + public synchronized void close() { if (!closed && clientInstances.decrementAndGet() == 0) { try { zooCache.close(); ThriftUtil.close(); - } catch (InterruptedException e) { + } catch (RuntimeException e) { clientInstances.incrementAndGet(); - throw new AccumuloException("Issues closing ZooKeeper."); + throw e; } } closed = true; http://git-wip-us.apache.org/repos/asf/accumulo/blob/0d0bc464/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstance.java ---------------------------------------------------------------------- diff --git a/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstance.java b/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstance.java index d8a15e0..b9778a7 100644 --- a/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstance.java +++ b/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstance.java @@ -142,7 +142,7 @@ public class MockInstance implements Instance { } @Override - public void close() throws AccumuloException { + public void close() { // NOOP } } http://git-wip-us.apache.org/repos/asf/accumulo/blob/0d0bc464/src/core/src/main/java/org/apache/accumulo/core/zookeeper/ZooCache.java ---------------------------------------------------------------------- diff --git a/src/core/src/main/java/org/apache/accumulo/core/zookeeper/ZooCache.java b/src/core/src/main/java/org/apache/accumulo/core/zookeeper/ZooCache.java index 0a36923..1d55f6c 100644 --- a/src/core/src/main/java/org/apache/accumulo/core/zookeeper/ZooCache.java +++ b/src/core/src/main/java/org/apache/accumulo/core/zookeeper/ZooCache.java @@ -18,6 +18,7 @@ package org.apache.accumulo.core.zookeeper; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.io.Closeable; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; @@ -40,7 +41,7 @@ import org.apache.zookeeper.data.Stat; * Caches values stored in zookeeper and keeps them up to date as they change in zookeeper. * */ -public class ZooCache { +public class ZooCache implements Closeable { private static final Logger log = Logger.getLogger(ZooCache.class); private ZCacheWatcher watcher = new ZCacheWatcher(); @@ -308,7 +309,8 @@ public class ZooCache { return zc; } - public void close() throws InterruptedException { + @Override + public void close() { cache.clear(); statCache.clear(); childrenCache.clear(); http://git-wip-us.apache.org/repos/asf/accumulo/blob/0d0bc464/src/core/src/main/java/org/apache/accumulo/core/zookeeper/ZooReader.java ---------------------------------------------------------------------- diff --git a/src/core/src/main/java/org/apache/accumulo/core/zookeeper/ZooReader.java b/src/core/src/main/java/org/apache/accumulo/core/zookeeper/ZooReader.java index 1bcd22b..ab02034 100644 --- a/src/core/src/main/java/org/apache/accumulo/core/zookeeper/ZooReader.java +++ b/src/core/src/main/java/org/apache/accumulo/core/zookeeper/ZooReader.java @@ -16,6 +16,7 @@ */ package org.apache.accumulo.core.zookeeper; +import java.io.Closeable; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; @@ -28,7 +29,7 @@ import org.apache.zookeeper.AsyncCallback.VoidCallback; import org.apache.zookeeper.KeeperException.Code; import org.apache.zookeeper.data.Stat; -public class ZooReader implements IZooReader { +public class ZooReader implements IZooReader, Closeable { protected String keepers; protected int timeout; @@ -108,7 +109,15 @@ public class ZooReader implements IZooReader { this(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut()); } - public void close() throws InterruptedException { - getZooKeeper().close(); + /** + * Closes this reader. If closure of the underlying session is interrupted, + * this method sets the calling thread's interrupt status. + */ + public void close() { + try { + getZooKeeper().close(); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } } } http://git-wip-us.apache.org/repos/asf/accumulo/blob/0d0bc464/src/core/src/test/java/org/apache/accumulo/core/client/impl/TabletLocatorImplTest.java ---------------------------------------------------------------------- diff --git a/src/core/src/test/java/org/apache/accumulo/core/client/impl/TabletLocatorImplTest.java b/src/core/src/test/java/org/apache/accumulo/core/client/impl/TabletLocatorImplTest.java index 624a824..e0ae60e 100644 --- a/src/core/src/test/java/org/apache/accumulo/core/client/impl/TabletLocatorImplTest.java +++ b/src/core/src/test/java/org/apache/accumulo/core/client/impl/TabletLocatorImplTest.java @@ -450,7 +450,7 @@ public class TabletLocatorImplTest extends TestCase { } @Override - public void close() throws AccumuloException { + public void close() { // NOOP } } http://git-wip-us.apache.org/repos/asf/accumulo/blob/0d0bc464/src/server/src/main/java/org/apache/accumulo/server/client/HdfsZooInstance.java ---------------------------------------------------------------------- diff --git a/src/server/src/main/java/org/apache/accumulo/server/client/HdfsZooInstance.java b/src/server/src/main/java/org/apache/accumulo/server/client/HdfsZooInstance.java index d68449d..2dd1db6 100644 --- a/src/server/src/main/java/org/apache/accumulo/server/client/HdfsZooInstance.java +++ b/src/server/src/main/java/org/apache/accumulo/server/client/HdfsZooInstance.java @@ -179,12 +179,8 @@ public class HdfsZooInstance implements Instance { } @Override - public void close() throws AccumuloException { - try { - zooCache.close(); - } catch (InterruptedException e) { - throw new AccumuloException("Issues closing ZooKeeper, try again"); - } + public void close() { + zooCache.close(); } @Override