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 B6F0A18A3B for ; Fri, 24 Apr 2015 23:50:21 +0000 (UTC) Received: (qmail 89510 invoked by uid 500); 24 Apr 2015 23:50:16 -0000 Delivered-To: apmail-accumulo-commits-archive@accumulo.apache.org Received: (qmail 89471 invoked by uid 500); 24 Apr 2015 23:50:16 -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 89451 invoked by uid 99); 24 Apr 2015 23:50:16 -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; Fri, 24 Apr 2015 23:50:16 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 719B4E0942; Fri, 24 Apr 2015 23:50:16 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: kturner@apache.org To: commits@accumulo.apache.org Date: Fri, 24 Apr 2015 23:50:16 -0000 Message-Id: <52096fedb4284d82839f8f4d0bf20a5b@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/4] accumulo git commit: ACCUMULO-3745 simplify locking and added comments Repository: accumulo Updated Branches: refs/heads/master 51f39d292 -> 488f441f7 ACCUMULO-3745 simplify locking and added comments changes from [~elserj] CR on issue Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/5ac1b52e Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/5ac1b52e Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/5ac1b52e Branch: refs/heads/master Commit: 5ac1b52efcd94b939773ef88f9f4f0bfa4fccaa2 Parents: 95e234c Author: Keith Turner Authored: Thu Apr 23 12:00:36 2015 -0400 Committer: Keith Turner Committed: Fri Apr 24 19:09:37 2015 -0400 ---------------------------------------------------------------------- .../system/SourceSwitchingIterator.java | 58 +++++++++++--------- 1 file changed, 33 insertions(+), 25 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/5ac1b52e/core/src/main/java/org/apache/accumulo/core/iterators/system/SourceSwitchingIterator.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/system/SourceSwitchingIterator.java b/core/src/main/java/org/apache/accumulo/core/iterators/system/SourceSwitchingIterator.java index 7684352..ec73c27 100644 --- a/core/src/main/java/org/apache/accumulo/core/iterators/system/SourceSwitchingIterator.java +++ b/core/src/main/java/org/apache/accumulo/core/iterators/system/SourceSwitchingIterator.java @@ -19,7 +19,6 @@ package org.apache.accumulo.core.iterators.system; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; @@ -63,17 +62,28 @@ public class SourceSwitchingIterator implements SortedKeyValueIterator copies; private SourceSwitchingIterator(DataSource source, boolean onlySwitchAfterRow, List copies) { this.source = source; this.onlySwitchAfterRow = onlySwitchAfterRow; this.copies = copies; + copies.add(this); } public SourceSwitchingIterator(DataSource source, boolean onlySwitchAfterRow) { - this(source, onlySwitchAfterRow, Collections.synchronizedList(new ArrayList())); - copies.add(this); + this(source, onlySwitchAfterRow, new ArrayList()); } public SourceSwitchingIterator(DataSource source) { @@ -83,11 +93,7 @@ public class SourceSwitchingIterator implements SortedKeyValueIterator deepCopy(IteratorEnvironment env) { synchronized (copies) { - synchronized(this){ - SourceSwitchingIterator ssi = new SourceSwitchingIterator(source.getDeepCopyDataSource(env), onlySwitchAfterRow, copies); - copies.add(ssi); - return ssi; - } + return new SourceSwitchingIterator(source.getDeepCopyDataSource(env), onlySwitchAfterRow, copies); } } @@ -113,10 +119,12 @@ public class SourceSwitchingIterator implements SortedKeyValueIterator columnFamilies, boolean inclusive) throws IOException { - this.range = range; - this.inclusive = inclusive; - this.columnFamilies = columnFamilies; + public void seek(Range range, Collection columnFamilies, boolean inclusive) throws IOException { + synchronized (copies) { + this.range = range; + this.inclusive = inclusive; + this.columnFamilies = columnFamilies; - if (iter == null) - iter = source.iterator(); + if (iter == null) + iter = source.iterator(); - readNext(true); + readNext(true); + } } - private synchronized void _switchNow() throws IOException { + private void _switchNow() throws IOException { if (onlySwitchAfterRow) throw new IllegalStateException("Can only switch on row boundries"); @@ -194,15 +204,13 @@ public class SourceSwitchingIterator implements SortedKeyValueIterator