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/03/07 17:27:45 UTC
[1/3] git commit: ACCUMULO-2429 Add shell shutdown for thread cleanup
Repository: accumulo
Updated Branches:
refs/heads/1.6.0-SNAPSHOT a4e562602 -> 8acdf534c
refs/heads/master ff605865d -> 4edc82eb3
ACCUMULO-2429 Add shell shutdown for thread cleanup
The JLine 2 ConsoleReader used by Shell spawns a thread which should be cleaned up when
done with the Shell. Otherwise, the thread leaks, taking up resources when the shell is
used programmatically. This commit adds a shutdown() method to Shell for cleaning up the
thread. This enables ShellServerIT to pass reliably and not flood the OS with leaked
threads.
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/8acdf534
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/8acdf534
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/8acdf534
Branch: refs/heads/1.6.0-SNAPSHOT
Commit: 8acdf534ceb92627075a1417e61c5e14790ee9d8
Parents: a4e5626
Author: Bill Havanki <bh...@cloudera.com>
Authored: Wed Mar 5 11:23:32 2014 -0500
Committer: Bill Havanki <bh...@cloudera.com>
Committed: Fri Mar 7 11:26:11 2014 -0500
----------------------------------------------------------------------
.../org/apache/accumulo/core/util/shell/Shell.java | 14 ++++++++++++--
.../accumulo/core/util/shell/ShellConfigTest.java | 1 +
.../core/util/shell/ShellSetInstanceTest.java | 1 +
.../apache/accumulo/core/util/shell/ShellTest.java | 6 ++++++
.../java/org/apache/accumulo/test/ShellServerIT.java | 10 +++++-----
5 files changed, 25 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/8acdf534/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java b/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java
index 850816c..420d465 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java
@@ -458,9 +458,13 @@ public class Shell extends ShellOptions {
public static void main(String args[]) throws IOException {
Shell shell = new Shell();
- shell.config(args);
+ try {
+ shell.config(args);
- System.exit(shell.start());
+ System.exit(shell.start());
+ } finally {
+ shell.shutdown();
+ }
}
public int start() throws IOException {
@@ -555,6 +559,12 @@ public class Shell extends ShellOptions {
}
}
+ public void shutdown() {
+ if (reader != null) {
+ reader.shutdown();
+ }
+ }
+
public void printInfo() throws IOException {
reader.print("\n" + SHELL_DESCRIPTION + "\n" + "- \n" + "- version: " + Constants.VERSION + "\n" + "- instance name: "
+ connector.getInstance().getInstanceName() + "\n" + "- instance id: " + connector.getInstance().getInstanceID() + "\n" + "- \n"
http://git-wip-us.apache.org/repos/asf/accumulo/blob/8acdf534/core/src/test/java/org/apache/accumulo/core/util/shell/ShellConfigTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/util/shell/ShellConfigTest.java b/core/src/test/java/org/apache/accumulo/core/util/shell/ShellConfigTest.java
index df4d817..c9914da 100644
--- a/core/src/test/java/org/apache/accumulo/core/util/shell/ShellConfigTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/util/shell/ShellConfigTest.java
@@ -53,6 +53,7 @@ public class ShellConfigTest {
@After
public void teardown() throws Exception {
+ shell.shutdown();
output.clear();
System.setOut(out);
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/8acdf534/core/src/test/java/org/apache/accumulo/core/util/shell/ShellSetInstanceTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/util/shell/ShellSetInstanceTest.java b/core/src/test/java/org/apache/accumulo/core/util/shell/ShellSetInstanceTest.java
index 5a6cc8a..2929b04 100644
--- a/core/src/test/java/org/apache/accumulo/core/util/shell/ShellSetInstanceTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/util/shell/ShellSetInstanceTest.java
@@ -99,6 +99,7 @@ public class ShellSetInstanceTest {
}
@After
public void tearDown() {
+ shell.shutdown();
SiteConfiguration.clearInstance();
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/8acdf534/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java b/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java
index bf203f7..4771f2c 100644
--- a/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java
@@ -30,6 +30,7 @@ import jline.console.ConsoleReader;
import org.apache.accumulo.core.util.format.DateStringFormatter;
import org.apache.log4j.Level;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -108,6 +109,11 @@ public class ShellTest {
shell.config("--fake", "-u", "test", "-p", "secret");
}
+ @After
+ public void teardown() {
+ shell.shutdown();
+ }
+
void assertGoodExit(String s, boolean stringPresent) {
Shell.log.debug(output.get());
assertEquals(shell.getExitCode(), 0);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/8acdf534/test/src/test/java/org/apache/accumulo/test/ShellServerIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/ShellServerIT.java b/test/src/test/java/org/apache/accumulo/test/ShellServerIT.java
index da094e8..7a1121f 100644
--- a/test/src/test/java/org/apache/accumulo/test/ShellServerIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/ShellServerIT.java
@@ -185,11 +185,6 @@ public class ShellServerIT extends SimpleMacIT {
exec("quit", true);
shell.start();
shell.setExit(false);
-
- traceProcess = getStaticCluster().exec(TraceServer.class);
-
- // give the tracer some time to start
- UtilWaitThread.sleep(1000);
}
@AfterClass
@@ -210,6 +205,11 @@ public class ShellServerIT extends SimpleMacIT {
}
}
+ @After
+ public void tearDownShell() {
+ shell.shutdown();
+ }
+
@Test(timeout = 60000)
public void exporttableImporttable() throws Exception {
final String table = name.getMethodName(), table2 = table + "2";
[2/3] git commit: ACCUMULO-2429 Add shell shutdown for thread cleanup
Posted by bh...@apache.org.
ACCUMULO-2429 Add shell shutdown for thread cleanup
The JLine 2 ConsoleReader used by Shell spawns a thread which should be cleaned up when
done with the Shell. Otherwise, the thread leaks, taking up resources when the shell is
used programmatically. This commit adds a shutdown() method to Shell for cleaning up the
thread. This enables ShellServerIT to pass reliably and not flood the OS with leaked
threads.
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/8acdf534
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/8acdf534
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/8acdf534
Branch: refs/heads/master
Commit: 8acdf534ceb92627075a1417e61c5e14790ee9d8
Parents: a4e5626
Author: Bill Havanki <bh...@cloudera.com>
Authored: Wed Mar 5 11:23:32 2014 -0500
Committer: Bill Havanki <bh...@cloudera.com>
Committed: Fri Mar 7 11:26:11 2014 -0500
----------------------------------------------------------------------
.../org/apache/accumulo/core/util/shell/Shell.java | 14 ++++++++++++--
.../accumulo/core/util/shell/ShellConfigTest.java | 1 +
.../core/util/shell/ShellSetInstanceTest.java | 1 +
.../apache/accumulo/core/util/shell/ShellTest.java | 6 ++++++
.../java/org/apache/accumulo/test/ShellServerIT.java | 10 +++++-----
5 files changed, 25 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/8acdf534/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java b/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java
index 850816c..420d465 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java
@@ -458,9 +458,13 @@ public class Shell extends ShellOptions {
public static void main(String args[]) throws IOException {
Shell shell = new Shell();
- shell.config(args);
+ try {
+ shell.config(args);
- System.exit(shell.start());
+ System.exit(shell.start());
+ } finally {
+ shell.shutdown();
+ }
}
public int start() throws IOException {
@@ -555,6 +559,12 @@ public class Shell extends ShellOptions {
}
}
+ public void shutdown() {
+ if (reader != null) {
+ reader.shutdown();
+ }
+ }
+
public void printInfo() throws IOException {
reader.print("\n" + SHELL_DESCRIPTION + "\n" + "- \n" + "- version: " + Constants.VERSION + "\n" + "- instance name: "
+ connector.getInstance().getInstanceName() + "\n" + "- instance id: " + connector.getInstance().getInstanceID() + "\n" + "- \n"
http://git-wip-us.apache.org/repos/asf/accumulo/blob/8acdf534/core/src/test/java/org/apache/accumulo/core/util/shell/ShellConfigTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/util/shell/ShellConfigTest.java b/core/src/test/java/org/apache/accumulo/core/util/shell/ShellConfigTest.java
index df4d817..c9914da 100644
--- a/core/src/test/java/org/apache/accumulo/core/util/shell/ShellConfigTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/util/shell/ShellConfigTest.java
@@ -53,6 +53,7 @@ public class ShellConfigTest {
@After
public void teardown() throws Exception {
+ shell.shutdown();
output.clear();
System.setOut(out);
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/8acdf534/core/src/test/java/org/apache/accumulo/core/util/shell/ShellSetInstanceTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/util/shell/ShellSetInstanceTest.java b/core/src/test/java/org/apache/accumulo/core/util/shell/ShellSetInstanceTest.java
index 5a6cc8a..2929b04 100644
--- a/core/src/test/java/org/apache/accumulo/core/util/shell/ShellSetInstanceTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/util/shell/ShellSetInstanceTest.java
@@ -99,6 +99,7 @@ public class ShellSetInstanceTest {
}
@After
public void tearDown() {
+ shell.shutdown();
SiteConfiguration.clearInstance();
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/8acdf534/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java b/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java
index bf203f7..4771f2c 100644
--- a/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java
@@ -30,6 +30,7 @@ import jline.console.ConsoleReader;
import org.apache.accumulo.core.util.format.DateStringFormatter;
import org.apache.log4j.Level;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -108,6 +109,11 @@ public class ShellTest {
shell.config("--fake", "-u", "test", "-p", "secret");
}
+ @After
+ public void teardown() {
+ shell.shutdown();
+ }
+
void assertGoodExit(String s, boolean stringPresent) {
Shell.log.debug(output.get());
assertEquals(shell.getExitCode(), 0);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/8acdf534/test/src/test/java/org/apache/accumulo/test/ShellServerIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/ShellServerIT.java b/test/src/test/java/org/apache/accumulo/test/ShellServerIT.java
index da094e8..7a1121f 100644
--- a/test/src/test/java/org/apache/accumulo/test/ShellServerIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/ShellServerIT.java
@@ -185,11 +185,6 @@ public class ShellServerIT extends SimpleMacIT {
exec("quit", true);
shell.start();
shell.setExit(false);
-
- traceProcess = getStaticCluster().exec(TraceServer.class);
-
- // give the tracer some time to start
- UtilWaitThread.sleep(1000);
}
@AfterClass
@@ -210,6 +205,11 @@ public class ShellServerIT extends SimpleMacIT {
}
}
+ @After
+ public void tearDownShell() {
+ shell.shutdown();
+ }
+
@Test(timeout = 60000)
public void exporttableImporttable() throws Exception {
final String table = name.getMethodName(), table2 = table + "2";
[3/3] git commit: Merge branch '1.6.0-SNAPSHOT'
Posted by bh...@apache.org.
Merge branch '1.6.0-SNAPSHOT'
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/4edc82eb
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/4edc82eb
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/4edc82eb
Branch: refs/heads/master
Commit: 4edc82eb3f3a1c2c2e1f1052f74af6942bd96efe
Parents: ff60586 8acdf53
Author: Bill Havanki <bh...@cloudera.com>
Authored: Fri Mar 7 11:27:03 2014 -0500
Committer: Bill Havanki <bh...@cloudera.com>
Committed: Fri Mar 7 11:27:03 2014 -0500
----------------------------------------------------------------------
.../org/apache/accumulo/core/util/shell/Shell.java | 14 ++++++++++++--
.../accumulo/core/util/shell/ShellConfigTest.java | 1 +
.../core/util/shell/ShellSetInstanceTest.java | 1 +
.../apache/accumulo/core/util/shell/ShellTest.java | 6 ++++++
.../java/org/apache/accumulo/test/ShellServerIT.java | 10 +++++-----
5 files changed, 25 insertions(+), 7 deletions(-)
----------------------------------------------------------------------