accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ktur...@apache.org
Subject [1/4] accumulo git commit: ACCUMULO-3977 fix issue with deep copy and isolation
Date Thu, 27 Aug 2015 21:41:13 GMT
Repository: accumulo
Updated Branches:
  refs/heads/master dd6780898 -> b38371d9a


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/master
Commit: 562b6ad606d3211a957852baf5d598237631ddde
Parents: 2906895
Author: Keith Turner <keith@deenlo.com>
Authored: Thu Aug 27 16:27:29 2015 -0400
Committer: Keith Turner <keith@deenlo.com>
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<Key,Value> iterator() throws IOException {
-      if (iflag != null)
-        ((InterruptibleIterator) this.iter).setInterruptFlag(iflag);
+    public SortedKeyValueIterator<Key,Value> 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<Entry<Key,Value>> 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);
+  }
+}


Mime
View raw message