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 8E430107AF for ; Fri, 8 Nov 2013 03:23:26 +0000 (UTC) Received: (qmail 2655 invoked by uid 500); 8 Nov 2013 03:23:25 -0000 Delivered-To: apmail-accumulo-commits-archive@accumulo.apache.org Received: (qmail 2521 invoked by uid 500); 8 Nov 2013 03:23:25 -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 2167 invoked by uid 99); 8 Nov 2013 03:23:20 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Nov 2013 03:23:20 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id ECE86815156; Fri, 8 Nov 2013 03:23:19 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: elserj@apache.org To: commits@accumulo.apache.org Date: Fri, 08 Nov 2013 03:23:19 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/3] git commit: ACCUMULO-1833 Another instance of primitive without synchronization being used instead of AtomicBoolean with expected concurrent access. Updated Branches: refs/heads/ACCUMULO-1833-caching 3b6eade61 -> 0be6f0a79 ACCUMULO-1833 Another instance of primitive without synchronization being used instead of AtomicBoolean with expected concurrent access. Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/a5c83d6e Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/a5c83d6e Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/a5c83d6e Branch: refs/heads/ACCUMULO-1833-caching Commit: a5c83d6ef03ef506bf25fac313c65b4f906183e2 Parents: 3b6eade Author: Josh Elser Authored: Thu Nov 7 20:54:20 2013 -0500 Committer: Josh Elser Committed: Thu Nov 7 20:54:20 2013 -0500 ---------------------------------------------------------------------- .../client/impl/MultiTableBatchWriterImpl.java | 23 +++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/a5c83d6e/core/src/main/java/org/apache/accumulo/core/client/impl/MultiTableBatchWriterImpl.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/MultiTableBatchWriterImpl.java b/core/src/main/java/org/apache/accumulo/core/client/impl/MultiTableBatchWriterImpl.java index 35f7c2f..ee11277 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/impl/MultiTableBatchWriterImpl.java +++ b/core/src/main/java/org/apache/accumulo/core/client/impl/MultiTableBatchWriterImpl.java @@ -19,6 +19,7 @@ package org.apache.accumulo.core.client.impl; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; import org.apache.accumulo.core.client.AccumuloException; import org.apache.accumulo.core.client.AccumuloSecurityException; @@ -44,7 +45,7 @@ public class MultiTableBatchWriterImpl implements MultiTableBatchWriter { public static final TimeUnit DEFAULT_CACHE_TIME_UNIT = TimeUnit.SECONDS; static final Logger log = Logger.getLogger(MultiTableBatchWriterImpl.class); - private boolean closed; + private AtomicBoolean closed; private class TableBatchWriter implements BatchWriter { @@ -111,19 +112,19 @@ public class MultiTableBatchWriterImpl implements MultiTableBatchWriter { this.instance = instance; this.bw = new TabletServerBatchWriter(instance, credentials, config); tableWriters = new ConcurrentHashMap(); - this.closed = false; + this.closed = new AtomicBoolean(false); nameToIdCache = CacheBuilder.newBuilder().expireAfterWrite(cacheTime, cacheTimeUnit).concurrencyLevel(8).maximumSize(64).initialCapacity(16) .build(new TableNameToIdLoader()); } public boolean isClosed() { - return this.closed; + return this.closed.get(); } public void close() throws MutationsRejectedException { bw.close(); - this.closed = true; + this.closed.set(true); } /** @@ -131,7 +132,7 @@ public class MultiTableBatchWriterImpl implements MultiTableBatchWriter { */ @Override protected void finalize() { - if (!closed) { + if (!closed.get()) { log.warn(MultiTableBatchWriterImpl.class.getSimpleName() + " not shutdown; did you forget to call close()?"); try { close(); @@ -153,20 +154,16 @@ public class MultiTableBatchWriterImpl implements MultiTableBatchWriter { } catch (ExecutionException e) { Throwable cause = e.getCause(); + log.error("Unexpected exception when fetching table id for " + tableName); + if (null == cause) { throw new RuntimeException(e); - } - - if (cause instanceof TableNotFoundException) { + } else if (cause instanceof TableNotFoundException) { throw (TableNotFoundException) cause; - } - - if (cause instanceof TableOfflineException) { + } else if (cause instanceof TableOfflineException) { throw (TableOfflineException) cause; } - log.error("Unexpected exception when fetching table id for " + tableName); - throw new RuntimeException(e); } }