You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by bh...@apache.org on 2014/01/14 21:48:49 UTC

[11/17] git commit: ACCUMULO-2182 Backport ACCUMULO-2104 and ACCUMULO-2106 to 1.5.x

ACCUMULO-2182 Backport ACCUMULO-2104 and ACCUMULO-2106 to 1.5.x

This commit is an adaption of the backport to 1.4.x, adapted due to files moving
between the releases.


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/a3eae058
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/a3eae058
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/a3eae058

Branch: refs/heads/1.6.0-SNAPSHOT
Commit: a3eae058d8fff13c768aa7ae1828cee617426878
Parents: 0603edb
Author: Bill Havanki <bh...@cloudera.com>
Authored: Tue Jan 14 15:43:53 2014 -0500
Committer: Bill Havanki <bh...@cloudera.com>
Committed: Tue Jan 14 15:43:53 2014 -0500

----------------------------------------------------------------------
 .../org/apache/accumulo/test/randomwalk/State.java | 13 +++++++++++++
 .../test/randomwalk/image/ImageFixture.java        | 17 ++++++++++++++++-
 .../randomwalk/multitable/MultiTableFixture.java   | 14 ++++++++++++++
 .../randomwalk/sequential/SequentialFixture.java   | 14 ++++++++++++++
 .../test/randomwalk/shard/ShardFixture.java        | 15 +++++++++++++++
 5 files changed, 72 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/a3eae058/test/src/main/java/org/apache/accumulo/test/randomwalk/State.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/State.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/State.java
index d31d88b..65d26c6 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/State.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/State.java
@@ -28,6 +28,7 @@ import org.apache.accumulo.core.client.BatchWriterConfig;
 import org.apache.accumulo.core.client.Connector;
 import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.client.MultiTableBatchWriter;
+import org.apache.accumulo.core.client.MutationsRejectedException;
 import org.apache.accumulo.core.client.ZooKeeperInstance;
 import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
 import org.apache.accumulo.core.client.security.tokens.PasswordToken;
@@ -143,6 +144,18 @@ public class State {
     return mtbw;
   }
   
+  public boolean isMultiTableBatchWriterInitialized() {
+    return mtbw != null;
+  }
+
+  public void resetMultiTableBatchWriter() {
+    if (!mtbw.isClosed()) {
+      log.warn("Setting non-closed MultiTableBatchWriter to null (leaking resources)");
+    }
+
+    mtbw = null;
+  }
+
   public String getMapReduceJars() {
     
     String acuHome = System.getenv("ACCUMULO_HOME");

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a3eae058/test/src/main/java/org/apache/accumulo/test/randomwalk/image/ImageFixture.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/image/ImageFixture.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/image/ImageFixture.java
index 5dc8928..86df45d 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/image/ImageFixture.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/image/ImageFixture.java
@@ -27,6 +27,8 @@ import java.util.TreeSet;
 
 import org.apache.accumulo.core.client.Connector;
 import org.apache.accumulo.core.client.Instance;
+import org.apache.accumulo.core.client.MultiTableBatchWriter;
+import org.apache.accumulo.core.client.MutationsRejectedException;
 import org.apache.accumulo.core.client.TableExistsException;
 import org.apache.accumulo.core.client.impl.Tables;
 import org.apache.accumulo.test.randomwalk.Fixture;
@@ -105,7 +107,20 @@ public class ImageFixture extends Fixture {
   
   @Override
   public void tearDown(State state) throws Exception {
-    
+    // We have resources we need to clean up
+    if (state.isMultiTableBatchWriterInitialized()) {
+      MultiTableBatchWriter mtbw = state.getMultiTableBatchWriter();
+      try {
+        mtbw.close();
+      } catch (MutationsRejectedException e) {
+        log.error("Ignoring mutations that weren't flushed", e);
+      }
+
+      // Reset the MTBW on the state to null
+      state.resetMultiTableBatchWriter();
+    }
+
+    // Now we can safely delete the tables
     log.debug("Dropping tables: " + imageTableName + " " + indexTableName);
     
     Connector conn = state.getConnector();

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a3eae058/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/MultiTableFixture.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/MultiTableFixture.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/MultiTableFixture.java
index 01ebdd7..ee0fff6 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/MultiTableFixture.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/MultiTableFixture.java
@@ -20,6 +20,8 @@ import java.net.InetAddress;
 import java.util.ArrayList;
 
 import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.client.MultiTableBatchWriter;
+import org.apache.accumulo.core.client.MutationsRejectedException;
 import org.apache.accumulo.core.client.TableNotFoundException;
 import org.apache.accumulo.test.randomwalk.Fixture;
 import org.apache.accumulo.test.randomwalk.State;
@@ -40,6 +42,18 @@ public class MultiTableFixture extends Fixture {
   
   @Override
   public void tearDown(State state) throws Exception {
+    // We have resources we need to clean up
+    if (state.isMultiTableBatchWriterInitialized()) {
+      MultiTableBatchWriter mtbw = state.getMultiTableBatchWriter();
+      try {
+        mtbw.close();
+      } catch (MutationsRejectedException e) {
+        log.error("Ignoring mutations that weren't flushed", e);
+      }
+
+      // Reset the MTBW on the state to null
+      state.resetMultiTableBatchWriter();
+    }
     
     Connector conn = state.getConnector();
     

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a3eae058/test/src/main/java/org/apache/accumulo/test/randomwalk/sequential/SequentialFixture.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/sequential/SequentialFixture.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/sequential/SequentialFixture.java
index 2b89264..b7377b7 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/sequential/SequentialFixture.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/sequential/SequentialFixture.java
@@ -20,6 +20,8 @@ import java.net.InetAddress;
 
 import org.apache.accumulo.core.client.Connector;
 import org.apache.accumulo.core.client.Instance;
+import org.apache.accumulo.core.client.MultiTableBatchWriter;
+import org.apache.accumulo.core.client.MutationsRejectedException;
 import org.apache.accumulo.core.client.TableExistsException;
 import org.apache.accumulo.core.client.impl.Tables;
 import org.apache.accumulo.test.randomwalk.Fixture;
@@ -55,6 +57,18 @@ public class SequentialFixture extends Fixture {
   
   @Override
   public void tearDown(State state) throws Exception {
+    // We have resources we need to clean up
+    if (state.isMultiTableBatchWriterInitialized()) {
+      MultiTableBatchWriter mtbw = state.getMultiTableBatchWriter();
+      try {
+        mtbw.close();
+      } catch (MutationsRejectedException e) {
+        log.error("Ignoring mutations that weren't flushed", e);
+      }
+
+      // Reset the MTBW on the state to null
+      state.resetMultiTableBatchWriter();
+    }
     
     log.debug("Dropping tables: " + seqTableName);
     

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a3eae058/test/src/main/java/org/apache/accumulo/test/randomwalk/shard/ShardFixture.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/shard/ShardFixture.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/shard/ShardFixture.java
index 8de30ae..97e33b4 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/shard/ShardFixture.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/shard/ShardFixture.java
@@ -22,6 +22,8 @@ import java.util.SortedSet;
 import java.util.TreeSet;
 
 import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.client.MultiTableBatchWriter;
+import org.apache.accumulo.core.client.MutationsRejectedException;
 import org.apache.accumulo.core.conf.Property;
 import org.apache.accumulo.test.randomwalk.Fixture;
 import org.apache.accumulo.test.randomwalk.State;
@@ -94,6 +96,19 @@ public class ShardFixture extends Fixture {
   
   @Override
   public void tearDown(State state) throws Exception {
+    // We have resources we need to clean up
+    if (state.isMultiTableBatchWriterInitialized()) {
+      MultiTableBatchWriter mtbw = state.getMultiTableBatchWriter();
+      try {
+        mtbw.close();
+      } catch (MutationsRejectedException e) {
+        log.error("Ignoring mutations that weren't flushed", e);
+      }
+
+      // Reset the MTBW on the state to null
+      state.resetMultiTableBatchWriter();
+    }
+
     Connector conn = state.getConnector();
     
     conn.tableOperations().delete((String) state.get("indexTableName"));