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 8054B177D6 for ; Thu, 27 Aug 2015 21:40:50 +0000 (UTC) Received: (qmail 10847 invoked by uid 500); 27 Aug 2015 21:40:50 -0000 Delivered-To: apmail-accumulo-commits-archive@accumulo.apache.org Received: (qmail 10797 invoked by uid 500); 27 Aug 2015 21:40:50 -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 10784 invoked by uid 99); 27 Aug 2015 21:40:50 -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, 27 Aug 2015 21:40:50 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 4C181E7E7C; Thu, 27 Aug 2015 21:40:50 +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: Thu, 27 Aug 2015 21:40:50 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/3] accumulo git commit: ACCUMULO-3977 fix issue with deep copy and isolation Repository: accumulo Updated Branches: refs/heads/1.7 162acf2f2 -> d77863e04 ACCUMULO-3977 fix issue with deep copy and isolation Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/562b6ad6 Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/562b6ad6 Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/562b6ad6 Branch: refs/heads/1.7 Commit: 562b6ad606d3211a957852baf5d598237631ddde Parents: 2906895 Author: Keith Turner Authored: Thu Aug 27 16:27:29 2015 -0400 Committer: Keith Turner Committed: Thu Aug 27 16:40:27 2015 -0400 ---------------------------------------------------------------------- .../apache/accumulo/tserver/FileManager.java | 8 +- .../accumulo/test/IsolationAndDeepCopyIT.java | 85 ++++++++++++++++++++ 2 files changed, 89 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/562b6ad6/server/tserver/src/main/java/org/apache/accumulo/tserver/FileManager.java ---------------------------------------------------------------------- diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/FileManager.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/FileManager.java index 4b9664a..3a4d512 100644 --- a/server/tserver/src/main/java/org/apache/accumulo/tserver/FileManager.java +++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/FileManager.java @@ -425,9 +425,7 @@ public class FileManager { } @Override - public SortedKeyValueIterator iterator() throws IOException { - if (iflag != null) - ((InterruptibleIterator) this.iter).setInterruptFlag(iflag); + public SortedKeyValueIterator iterator() { return iter; } @@ -444,8 +442,9 @@ public class FileManager { current = false; this.iter = iter; - if (iflag != null) + if (iflag != null) { ((InterruptibleIterator) this.iter).setInterruptFlag(iflag); + } for (FileDataSource fds : deepCopies) { fds.current = false; @@ -456,6 +455,7 @@ public class FileManager { @Override public void setInterruptFlag(AtomicBoolean flag) { this.iflag = flag; + ((InterruptibleIterator) this.iter).setInterruptFlag(iflag); } } http://git-wip-us.apache.org/repos/asf/accumulo/blob/562b6ad6/test/src/test/java/org/apache/accumulo/test/IsolationAndDeepCopyIT.java ---------------------------------------------------------------------- diff --git a/test/src/test/java/org/apache/accumulo/test/IsolationAndDeepCopyIT.java b/test/src/test/java/org/apache/accumulo/test/IsolationAndDeepCopyIT.java new file mode 100644 index 0000000..6af1fdf --- /dev/null +++ b/test/src/test/java/org/apache/accumulo/test/IsolationAndDeepCopyIT.java @@ -0,0 +1,85 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.accumulo.test; + +import java.util.Iterator; +import java.util.Map.Entry; + +import org.apache.accumulo.core.client.BatchWriter; +import org.apache.accumulo.core.client.BatchWriterConfig; +import org.apache.accumulo.core.client.Connector; +import org.apache.accumulo.core.client.IteratorSetting; +import org.apache.accumulo.core.client.MutationsRejectedException; +import org.apache.accumulo.core.client.Scanner; +import org.apache.accumulo.core.data.Key; +import org.apache.accumulo.core.data.Mutation; +import org.apache.accumulo.core.data.Value; +import org.apache.accumulo.core.iterators.user.IntersectingIterator; +import org.apache.accumulo.core.security.Authorizations; +import org.apache.accumulo.harness.AccumuloClusterIT; +import org.apache.hadoop.io.Text; +import org.junit.Assert; +import org.junit.Test; + +public class IsolationAndDeepCopyIT extends AccumuloClusterIT { + + @Test + public void testBugFix() throws Exception { + // test bug fox for ACCUMULO-3977 + + String table = super.getUniqueNames(1)[0]; + Connector conn = getConnector(); + + conn.tableOperations().create(table); + + BatchWriter bw = conn.createBatchWriter(table, new BatchWriterConfig()); + + addDocument(bw, "000A", "dog", "cat", "hamster", "iguana", "the"); + addDocument(bw, "000B", "java", "perl", "C++", "pascal", "the"); + addDocument(bw, "000C", "chrome", "firefox", "safari", "opera", "the"); + addDocument(bw, "000D", "logarithmic", "quadratic", "linear", "exponential", "the"); + + bw.close(); + + // its a bug when using rfiles, so flush + conn.tableOperations().flush(table, null, null, true); + + IteratorSetting iterCfg = new IteratorSetting(30, "ayeaye", IntersectingIterator.class.getName()); + IntersectingIterator.setColumnFamilies(iterCfg, new Text[] {new Text("the"), new Text("hamster")}); + + Scanner scanner = conn.createScanner(table, Authorizations.EMPTY); + scanner.enableIsolation(); + scanner.addScanIterator(iterCfg); + + for (int i = 0; i < 100; i++) { + Iterator> iter = scanner.iterator(); + Assert.assertTrue(iter.hasNext()); + Assert.assertEquals("000A", iter.next().getKey().getColumnQualifierData().toString()); + Assert.assertFalse(iter.hasNext()); + } + } + + private void addDocument(BatchWriter bw, String docId, String... terms) throws MutationsRejectedException { + Mutation m = new Mutation(String.format("%04d", docId.hashCode() % 10)); + for (String term : terms) { + m.put(term, docId, ""); + } + + bw.addMutation(m); + } +}