Repository: accumulo Updated Branches: refs/heads/master aed37c21d -> 2ea2cd566
ACCUMULO-3534 Remove unnecessary thread for proxy start. Removes the unnecessary map that contains a single entry and replaces it with Collections.singletonMap. Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/2ea2cd56 Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/2ea2cd56 Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/2ea2cd56 Branch: refs/heads/master Commit: 2ea2cd5661194524f1c01465520409a506224a29 Parents: aed37c2 Author: Josh Elser <els...@apache.org> Authored: Mon Jan 26 17:09:04 2015 -0500 Committer: Josh Elser <els...@apache.org> Committed: Mon Jan 26 17:09:04 2015 -0500 ---------------------------------------------------------------------- .../accumulo/proxy/ProxyDurabilityIT.java | 8 ------ .../apache/accumulo/proxy/SimpleProxyBase.java | 29 +------------------- .../accumulo/proxy/TestProxyReadWrite.java | 17 +----------- .../proxy/TestProxySecurityOperations.java | 22 ++++----------- .../proxy/TestProxyTableOperations.java | 20 +++----------- 5 files changed, 11 insertions(+), 85 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/2ea2cd56/test/src/test/java/org/apache/accumulo/proxy/ProxyDurabilityIT.java ---------------------------------------------------------------------- diff --git a/test/src/test/java/org/apache/accumulo/proxy/ProxyDurabilityIT.java b/test/src/test/java/org/apache/accumulo/proxy/ProxyDurabilityIT.java index bea39bf..45799c4 100644 --- a/test/src/test/java/org/apache/accumulo/proxy/ProxyDurabilityIT.java +++ b/test/src/test/java/org/apache/accumulo/proxy/ProxyDurabilityIT.java @@ -80,13 +80,6 @@ public class ProxyDurabilityIT extends ConfigurableMacIT { int proxyPort = PortUtils.getRandomFreePort(); final TServer proxyServer = Proxy.createProxyServer(HostAndPort.fromParts("localhost", proxyPort), protocol, props).server; - Thread thread = new Thread() { - @Override - public void run() { - proxyServer.serve(); - } - }; - thread.start(); while (!proxyServer.isServing()) UtilWaitThread.sleep(100); Client client = new TestProxyClient("localhost", proxyPort, protocol).proxy(); @@ -124,7 +117,6 @@ public class ProxyDurabilityIT extends ConfigurableMacIT { assertEquals(0, count(tableName)); proxyServer.stop(); - thread.join(); } private void restartTServer() throws Exception { http://git-wip-us.apache.org/repos/asf/accumulo/blob/2ea2cd56/test/src/test/java/org/apache/accumulo/proxy/SimpleProxyBase.java ---------------------------------------------------------------------- diff --git a/test/src/test/java/org/apache/accumulo/proxy/SimpleProxyBase.java b/test/src/test/java/org/apache/accumulo/proxy/SimpleProxyBase.java index f644b7c..72ed278 100644 --- a/test/src/test/java/org/apache/accumulo/proxy/SimpleProxyBase.java +++ b/test/src/test/java/org/apache/accumulo/proxy/SimpleProxyBase.java @@ -125,31 +125,13 @@ public abstract class SimpleProxyBase { private static MiniAccumuloCluster accumulo; private static String secret = "superSecret"; private static TServer proxyServer; - private static Thread thread; private static int proxyPort; private static org.apache.accumulo.proxy.thrift.AccumuloProxy.Client client; private static String principal = "root"; - private static Map<String,String> properties = new TreeMap<String,String>() { - private static final long serialVersionUID = 1L; - - { - put("password", secret); - } - }; + private static Map<String,String> properties = Collections.singletonMap("password", secret); private static ByteBuffer creds = null; - // static TProtocolFactory getRandomProtocol() throws InstantiationException, IllegalAccessException { - // List<Class<? extends TProtocolFactory>> protocolFactories = new ArrayList<Class<? extends TProtocolFactory>>(); - // protocolFactories.add(org.apache.thrift.protocol.TJSONProtocol.Factory.class); - // protocolFactories.add(org.apache.thrift.protocol.TBinaryProtocol.Factory.class); - // protocolFactories.add(org.apache.thrift.protocol.TTupleProtocol.Factory.class); - // protocolFactories.add(org.apache.thrift.protocol.TCompactProtocol.Factory.class); - // - // Class<? extends TProtocolFactory> clz = protocolFactories.get(random.nextInt(protocolFactories.size())); - // return clz.newInstance(); - // } - private static final AtomicInteger tableCounter = new AtomicInteger(0); private static String makeTableName() { @@ -194,13 +176,6 @@ public abstract class SimpleProxyBase { proxyPort = PortUtils.getRandomFreePort(); proxyServer = Proxy.createProxyServer(HostAndPort.fromParts("localhost", proxyPort), protocol, props).server; - thread = new Thread() { - @Override - public void run() { - proxyServer.serve(); - } - }; - thread.start(); while (!proxyServer.isServing()) UtilWaitThread.sleep(100); client = new TestProxyClient("localhost", proxyPort, protocol).proxy(); @@ -211,8 +186,6 @@ public abstract class SimpleProxyBase { public static void tearDownMiniCluster() throws Exception { if (null != proxyServer) { proxyServer.stop(); - thread.interrupt(); - thread.join(5000); } accumulo.stop(); FileUtils.deleteQuietly(macTestFolder); http://git-wip-us.apache.org/repos/asf/accumulo/blob/2ea2cd56/test/src/test/java/org/apache/accumulo/proxy/TestProxyReadWrite.java ---------------------------------------------------------------------- diff --git a/test/src/test/java/org/apache/accumulo/proxy/TestProxyReadWrite.java b/test/src/test/java/org/apache/accumulo/proxy/TestProxyReadWrite.java index b005440..616917f 100644 --- a/test/src/test/java/org/apache/accumulo/proxy/TestProxyReadWrite.java +++ b/test/src/test/java/org/apache/accumulo/proxy/TestProxyReadWrite.java @@ -26,7 +26,6 @@ import java.util.List; import java.util.Map; import java.util.Properties; import java.util.Set; -import java.util.TreeMap; import org.apache.accumulo.core.client.security.tokens.PasswordToken; import org.apache.accumulo.core.iterators.user.RegExFilter; @@ -52,13 +51,11 @@ import com.google.common.net.HostAndPort; public class TestProxyReadWrite { protected static TServer proxy; - protected static Thread thread; protected static TestProxyClient tpc; protected static ByteBuffer userpass; protected static final int port = 10194; protected static final String testtable = "testtable"; - @SuppressWarnings("serial") @BeforeClass public static void setup() throws Exception { Properties prop = new Properties(); @@ -66,25 +63,13 @@ public class TestProxyReadWrite { prop.put("tokenClass", PasswordToken.class.getName()); proxy = Proxy.createProxyServer(HostAndPort.fromParts("localhost", port), new TCompactProtocol.Factory(), prop).server; - thread = new Thread() { - @Override - public void run() { - proxy.serve(); - } - }; - thread.start(); tpc = new TestProxyClient("localhost", port); - userpass = tpc.proxy().login("root", new TreeMap<String,String>() { - { - put("password", ""); - } - }); + userpass = tpc.proxy().login("root", Collections.singletonMap("password", "")); } @AfterClass public static void tearDown() throws InterruptedException { proxy.stop(); - thread.join(); } @Before http://git-wip-us.apache.org/repos/asf/accumulo/blob/2ea2cd56/test/src/test/java/org/apache/accumulo/proxy/TestProxySecurityOperations.java ---------------------------------------------------------------------- diff --git a/test/src/test/java/org/apache/accumulo/proxy/TestProxySecurityOperations.java b/test/src/test/java/org/apache/accumulo/proxy/TestProxySecurityOperations.java index 5d3b443..607b499 100644 --- a/test/src/test/java/org/apache/accumulo/proxy/TestProxySecurityOperations.java +++ b/test/src/test/java/org/apache/accumulo/proxy/TestProxySecurityOperations.java @@ -21,6 +21,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.nio.ByteBuffer; +import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -45,7 +46,6 @@ import com.google.common.net.HostAndPort; public class TestProxySecurityOperations { protected static TServer proxy; - protected static Thread thread; protected static TestProxyClient tpc; protected static ByteBuffer userpass; protected static final int port = 10196; @@ -60,28 +60,16 @@ public class TestProxySecurityOperations { prop.put("tokenClass", PasswordToken.class.getName()); proxy = Proxy.createProxyServer(HostAndPort.fromParts("localhost", port), new TCompactProtocol.Factory(), prop).server; - thread = new Thread() { - @Override - public void run() { - proxy.serve(); - } - }; - thread.start(); - + while (!proxy.isServing()) { + Thread.sleep(500); + } tpc = new TestProxyClient("localhost", port); - userpass = tpc.proxy().login("root", new TreeMap<String,String>() { - private static final long serialVersionUID = 1L; - - { - put("password", ""); - } - }); + userpass = tpc.proxy().login("root", Collections.singletonMap("password", "")); } @AfterClass public static void tearDown() throws InterruptedException { proxy.stop(); - thread.join(); } @Before http://git-wip-us.apache.org/repos/asf/accumulo/blob/2ea2cd56/test/src/test/java/org/apache/accumulo/proxy/TestProxyTableOperations.java ---------------------------------------------------------------------- diff --git a/test/src/test/java/org/apache/accumulo/proxy/TestProxyTableOperations.java b/test/src/test/java/org/apache/accumulo/proxy/TestProxyTableOperations.java index df57ba6..419810d 100644 --- a/test/src/test/java/org/apache/accumulo/proxy/TestProxyTableOperations.java +++ b/test/src/test/java/org/apache/accumulo/proxy/TestProxyTableOperations.java @@ -29,7 +29,6 @@ import java.util.List; import java.util.Map; import java.util.Properties; import java.util.Set; -import java.util.TreeMap; import org.apache.accumulo.core.client.security.tokens.PasswordToken; import org.apache.accumulo.proxy.thrift.ColumnUpdate; @@ -48,13 +47,11 @@ import com.google.common.net.HostAndPort; public class TestProxyTableOperations { protected static TServer proxy; - protected static Thread thread; protected static TestProxyClient tpc; protected static ByteBuffer userpass; protected static final int port = 10195; protected static final String testtable = "testtable"; - @SuppressWarnings("serial") @BeforeClass public static void setup() throws Exception { Properties prop = new Properties(); @@ -62,25 +59,16 @@ public class TestProxyTableOperations { prop.put("tokenClass", PasswordToken.class.getName()); proxy = Proxy.createProxyServer(HostAndPort.fromParts("localhost", port), new TCompactProtocol.Factory(), prop).server; - thread = new Thread() { - @Override - public void run() { - proxy.serve(); - } - }; - thread.start(); + while (!proxy.isServing()) { + Thread.sleep(500); + } tpc = new TestProxyClient("localhost", port); - userpass = tpc.proxy().login("root", new TreeMap<String,String>() { - { - put("password", ""); - } - }); + userpass = tpc.proxy().login("root", Collections.singletonMap("password", "")); } @AfterClass public static void tearDown() throws InterruptedException { proxy.stop(); - thread.join(); } @Before