ACCUMULO-3823 Separate out client/server ACCUMULO_CONF_DIR Can't blindly use one if we're supporting both. Things will break when we try to use the server's conf without sudo'ing.
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/4eda9ec7 Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/4eda9ec7 Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/4eda9ec7 Branch: refs/heads/master Commit: 4eda9ec74869aabbc5f982a0cbb6770eadfcaea2 Parents: 8894000 Author: Josh Elser <els...@apache.org> Authored: Sat May 16 23:38:17 2015 -0400 Committer: Josh Elser <els...@apache.org> Committed: Sun May 17 10:15:19 2015 -0400 ---------------------------------------------------------------------- .../standalone/StandaloneAccumuloCluster.java | 21 ++++++++++++++------ .../standalone/StandaloneClusterControl.java | 17 ++++++++-------- .../StandaloneClusterControlTest.java | 6 +++--- .../accumulo/harness/AccumuloClusterIT.java | 3 ++- .../StandaloneAccumuloClusterConfiguration.java | 11 +++++++--- 5 files changed, 37 insertions(+), 21 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/4eda9ec7/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneAccumuloCluster.java ---------------------------------------------------------------------- diff --git a/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneAccumuloCluster.java b/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneAccumuloCluster.java index dc0bc18..40fcfae 100644 --- a/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneAccumuloCluster.java +++ b/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneAccumuloCluster.java @@ -49,7 +49,7 @@ public class StandaloneAccumuloCluster implements AccumuloCluster { private Instance instance; private ClientConfiguration clientConf; - private String accumuloHome, accumuloConfDir, hadoopConfDir; + private String accumuloHome, clientAccumuloConfDir, serverAccumuloConfDir, hadoopConfDir; private Path tmp; private List<ClusterUser> users; private String serverUser; @@ -74,12 +74,20 @@ public class StandaloneAccumuloCluster implements AccumuloCluster { this.accumuloHome = accumuloHome; } - public String getAccumuloConfDir() { - return accumuloConfDir; + public String getClientAccumuloConfDir() { + return clientAccumuloConfDir; } - public void setAccumuloConfDir(String accumuloConfDir) { - this.accumuloConfDir = accumuloConfDir; + public void setClientAccumuloConfDir(String accumuloConfDir) { + this.clientAccumuloConfDir = accumuloConfDir; + } + + public String getServerAccumuloConfDir() { + return serverAccumuloConfDir; + } + + public void setServerAccumuloConfDir(String accumuloConfDir) { + this.serverAccumuloConfDir = accumuloConfDir; } public String getHadoopConfDir() { @@ -119,7 +127,8 @@ public class StandaloneAccumuloCluster implements AccumuloCluster { @Override public StandaloneClusterControl getClusterControl() { return new StandaloneClusterControl(serverUser, null == accumuloHome ? System.getenv("ACCUMULO_HOME") : accumuloHome, - null == accumuloConfDir ? System.getenv("ACCUMULO_CONF_DIR") : accumuloConfDir); + null == clientAccumuloConfDir ? System.getenv("ACCUMULO_CONF_DIR") : clientAccumuloConfDir, + null == serverAccumuloConfDir ? System.getenv("ACCUMULO_CONF_DIR") : serverAccumuloConfDir); } @Override http://git-wip-us.apache.org/repos/asf/accumulo/blob/4eda9ec7/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneClusterControl.java ---------------------------------------------------------------------- diff --git a/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneClusterControl.java b/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneClusterControl.java index c652b0b..b3b1634 100644 --- a/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneClusterControl.java +++ b/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneClusterControl.java @@ -52,20 +52,21 @@ public class StandaloneClusterControl implements ClusterControl { private static final String ACCUMULO_CONF_DIR = "ACCUMULO_CONF_DIR="; protected String user; - protected String accumuloHome, accumuloConfDir; + protected String accumuloHome, clientAccumuloConfDir, serverAccumuloConfDir; protected RemoteShellOptions options; protected String startServerPath, accumuloPath, toolPath; public StandaloneClusterControl(String user) { - this(user, System.getenv("ACCUMULO_HOME"), System.getenv("ACCUMULO_CONF_DIR")); + this(user, System.getenv("ACCUMULO_HOME"), System.getenv("ACCUMULO_CONF_DIR"), System.getenv("ACCUMULO_CONF_DIR")); } - public StandaloneClusterControl(String user, String accumuloHome, String accumuloConfDir) { + public StandaloneClusterControl(String user, String accumuloHome, String clientAccumuloConfDir, String serverAccumuloConfDir) { this.user = user; this.options = new RemoteShellOptions(); this.accumuloHome = accumuloHome; - this.accumuloConfDir = accumuloConfDir; + this.clientAccumuloConfDir = clientAccumuloConfDir; + this.serverAccumuloConfDir = serverAccumuloConfDir; File bin = new File(accumuloHome, "bin"); this.startServerPath = new File(bin, START_SERVER_SCRIPT).getAbsolutePath(); @@ -100,7 +101,7 @@ public class StandaloneClusterControl implements ClusterControl { String master = getHosts(new File(confDir, "masters")).get(0); String[] cmd = new String[3 + args.length]; // Make sure we always set the right ACCUMULO_CONF_DIR - cmd[0] = ACCUMULO_CONF_DIR + confDir; + cmd[0] = ACCUMULO_CONF_DIR + clientAccumuloConfDir; cmd[1] = accumuloPath; cmd[2] = clz.getName(); // Quote the arguments to prevent shell expansion @@ -138,7 +139,7 @@ public class StandaloneClusterControl implements ClusterControl { public void adminStopAll() throws IOException { File confDir = getConfDir(); String master = getHosts(new File(confDir, "masters")).get(0); - String[] cmd = new String[] {SUDO_CMD, "-u", user, ACCUMULO_CONF_DIR + accumuloConfDir, accumuloPath, Admin.class.getName(), "stopAll"}; + String[] cmd = new String[] {SUDO_CMD, "-u", user, ACCUMULO_CONF_DIR + serverAccumuloConfDir, accumuloPath, Admin.class.getName(), "stopAll"}; // Directly invoke the RemoteShell Entry<Integer,String> pair = exec(master, cmd); if (0 != pair.getKey().intValue()) { @@ -192,7 +193,7 @@ public class StandaloneClusterControl implements ClusterControl { @Override public void start(ServerType server, String hostname) throws IOException { - String[] cmd = new String[] {SUDO_CMD, "-u", user, ACCUMULO_CONF_DIR + accumuloConfDir, startServerPath, hostname, getProcessString(server)}; + String[] cmd = new String[] {SUDO_CMD, "-u", user, ACCUMULO_CONF_DIR + serverAccumuloConfDir, startServerPath, hostname, getProcessString(server)}; Entry<Integer,String> pair = exec(hostname, cmd); if (0 != pair.getKey()) { throw new IOException("Start " + server + " on " + hostname + " failed for execute successfully"); @@ -319,7 +320,7 @@ public class StandaloneClusterControl implements ClusterControl { } protected File getConfDir() { - String confPath = null == accumuloConfDir ? System.getenv("ACCUMULO_CONF_DIR") : accumuloConfDir; + String confPath = null == clientAccumuloConfDir ? System.getenv("ACCUMULO_CONF_DIR") : clientAccumuloConfDir; File confDir; if (null == confPath) { String homePath = null == accumuloHome ? System.getenv("ACCUMULO_HOME") : accumuloHome; http://git-wip-us.apache.org/repos/asf/accumulo/blob/4eda9ec7/minicluster/src/test/java/org/apache/accumulo/cluster/standalone/StandaloneClusterControlTest.java ---------------------------------------------------------------------- diff --git a/minicluster/src/test/java/org/apache/accumulo/cluster/standalone/StandaloneClusterControlTest.java b/minicluster/src/test/java/org/apache/accumulo/cluster/standalone/StandaloneClusterControlTest.java index 2849273..22632be 100644 --- a/minicluster/src/test/java/org/apache/accumulo/cluster/standalone/StandaloneClusterControlTest.java +++ b/minicluster/src/test/java/org/apache/accumulo/cluster/standalone/StandaloneClusterControlTest.java @@ -24,12 +24,12 @@ public class StandaloneClusterControlTest { @Test public void testPaths() { - String accumuloHome = "/usr/lib/accumulo", accumuloConfDir = "/etc/accumulo/conf"; + String accumuloHome = "/usr/lib/accumulo", accumuloConfDir = "/etc/accumulo/conf", accumuloServerConfDir = "/etc/accumulo/conf/server"; - StandaloneClusterControl control = new StandaloneClusterControl("accumulo", accumuloHome, accumuloConfDir); + StandaloneClusterControl control = new StandaloneClusterControl("accumulo", accumuloHome, accumuloConfDir, accumuloServerConfDir); assertEquals(accumuloHome, control.accumuloHome); - assertEquals(accumuloConfDir, control.accumuloConfDir); + assertEquals(accumuloConfDir, control.clientAccumuloConfDir); assertEquals(accumuloHome + "/bin/accumulo", control.accumuloPath); assertEquals(accumuloHome + "/bin/start-server.sh", control.startServerPath); http://git-wip-us.apache.org/repos/asf/accumulo/blob/4eda9ec7/test/src/test/java/org/apache/accumulo/harness/AccumuloClusterIT.java ---------------------------------------------------------------------- diff --git a/test/src/test/java/org/apache/accumulo/harness/AccumuloClusterIT.java b/test/src/test/java/org/apache/accumulo/harness/AccumuloClusterIT.java index a0cca46..16460ed 100644 --- a/test/src/test/java/org/apache/accumulo/harness/AccumuloClusterIT.java +++ b/test/src/test/java/org/apache/accumulo/harness/AccumuloClusterIT.java @@ -133,7 +133,8 @@ public abstract class AccumuloClusterIT extends AccumuloIT implements MiniCluste conf.getAccumuloServerUser()); // If these are provided in the configuration, pass them into the cluster standaloneCluster.setAccumuloHome(conf.getAccumuloHome()); - standaloneCluster.setAccumuloConfDir(conf.getAccumuloConfDir()); + standaloneCluster.setClientAccumuloConfDir(conf.getClientAccumuloConfDir()); + standaloneCluster.setServerAccumuloConfDir(conf.getServerAccumuloConfDir()); standaloneCluster.setHadoopConfDir(conf.getHadoopConfDir()); // For SASL, we need to get the Hadoop configuration files as well otherwise UGI will log in as SIMPLE instead of KERBEROS http://git-wip-us.apache.org/repos/asf/accumulo/blob/4eda9ec7/test/src/test/java/org/apache/accumulo/harness/conf/StandaloneAccumuloClusterConfiguration.java ---------------------------------------------------------------------- diff --git a/test/src/test/java/org/apache/accumulo/harness/conf/StandaloneAccumuloClusterConfiguration.java b/test/src/test/java/org/apache/accumulo/harness/conf/StandaloneAccumuloClusterConfiguration.java index 53e30c2..e04c10c 100644 --- a/test/src/test/java/org/apache/accumulo/harness/conf/StandaloneAccumuloClusterConfiguration.java +++ b/test/src/test/java/org/apache/accumulo/harness/conf/StandaloneAccumuloClusterConfiguration.java @@ -68,7 +68,8 @@ public class StandaloneAccumuloClusterConfiguration extends AccumuloClusterPrope public static final String ACCUMULO_STANDALONE_USER_PASSWORDS_KEY = ACCUMULO_STANDALONE_PREFIX + "passwords."; public static final String ACCUMULO_STANDALONE_HOME = ACCUMULO_STANDALONE_PREFIX + "home"; - public static final String ACCUMULO_STANDALONE_CONF = ACCUMULO_STANDALONE_PREFIX + "conf"; + public static final String ACCUMULO_STANDALONE_CLIENT_CONF = ACCUMULO_STANDALONE_PREFIX + "client.conf"; + public static final String ACCUMULO_STANDALONE_SERVER_CONF = ACCUMULO_STANDALONE_PREFIX + "server.conf"; public static final String ACCUMULO_STANDALONE_HADOOP_CONF = ACCUMULO_STANDALONE_PREFIX + "hadoop.conf"; private Map<String,String> conf; @@ -214,8 +215,12 @@ public class StandaloneAccumuloClusterConfiguration extends AccumuloClusterPrope return conf.get(ACCUMULO_STANDALONE_HOME); } - public String getAccumuloConfDir() { - return conf.get(ACCUMULO_STANDALONE_CONF); + public String getClientAccumuloConfDir() { + return conf.get(ACCUMULO_STANDALONE_CLIENT_CONF); + } + + public String getServerAccumuloConfDir() { + return conf.get(ACCUMULO_STANDALONE_SERVER_CONF); } @Override