accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [03/50] [abbrv] accumulo git commit: ACCUMULO-3167 Number of fixes from Keith on reviewboard
Date Wed, 26 Nov 2014 04:23:19 GMT
ACCUMULO-3167 Number of fixes from Keith on reviewboard

Simplify AccumuloStandaloneCluster.stop/start to use ClusterControl
instead. Create some more constants.


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

Branch: refs/heads/master
Commit: 7583946d81fa4bf7b0a792bda1fd6da6e83a08c3
Parents: 1a57895
Author: Josh Elser <elserj@apache.org>
Authored: Fri Nov 21 15:21:36 2014 -0500
Committer: Josh Elser <elserj@apache.org>
Committed: Mon Nov 24 18:08:48 2014 -0500

----------------------------------------------------------------------
 .../standalone/StandaloneAccumuloCluster.java   | 44 +++-----------------
 .../standalone/StandaloneClusterControl.java    | 33 ++++++++++-----
 .../accumulo/harness/MiniClusterHarness.java    |  9 ++--
 3 files changed, 34 insertions(+), 52 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/7583946d/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 0202194..4abb046 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
@@ -16,8 +16,8 @@
  */
 package org.apache.accumulo.cluster.standalone;
 
-import java.io.File;
 import java.io.IOException;
+import java.util.Arrays;
 
 import org.apache.accumulo.cluster.AccumuloCluster;
 import org.apache.accumulo.core.client.AccumuloException;
@@ -95,58 +95,24 @@ public class StandaloneAccumuloCluster implements AccumuloCluster {
   @Override
   public void start() throws IOException {
     StandaloneClusterControl control = getClusterControl();
-    File confDir = control.getConfDir();
 
     // TODO We can check the hosts files, but that requires us to be on a host with the installation.
Limitation at the moment.
 
     control.exec(SetGoalState.class, new String[] {"NORMAL"});
 
-    for (String master : control.getHosts(new File(confDir, "masters"))) {
-      control.start(ServerType.MASTER, master);
-    }
-
-    for (String tserver : control.getHosts(new File(confDir, "slaves"))) {
-      control.start(ServerType.TABLET_SERVER, tserver);
-    }
-
-    for (String tracer : control.getHosts(new File(confDir, "tracers"))) {
-      control.start(ServerType.TRACER, tracer);
-    }
-
-    for (String gc : control.getHosts(new File(confDir, "gc"))) {
-      control.start(ServerType.GARBAGE_COLLECTOR, gc);
-    }
-
-    for (String monitor : control.getHosts(new File(confDir, "monitor"))) {
-      control.start(ServerType.MONITOR, monitor);
+    for (ServerType type : Arrays.asList(ServerType.MASTER, ServerType.TABLET_SERVER, ServerType.TRACER,
ServerType.GARBAGE_COLLECTOR, ServerType.MONITOR)) {
+      control.startAllServers(type);
     }
   }
 
   @Override
   public void stop() throws IOException {
     StandaloneClusterControl control = getClusterControl();
-    File confDir = control.getConfDir();
 
     // TODO We can check the hosts files, but that requires us to be on a host with the installation.
Limitation at the moment.
 
-    for (String master : control.getHosts(new File(confDir, "masters"))) {
-      control.stop(ServerType.MASTER, master);
-    }
-
-    for (String tserver : control.getHosts(new File(confDir, "slaves"))) {
-      control.stop(ServerType.TABLET_SERVER, tserver);
-    }
-
-    for (String tracer : control.getHosts(new File(confDir, "tracers"))) {
-      control.stop(ServerType.TRACER, tracer);
-    }
-
-    for (String gc : control.getHosts(new File(confDir, "gc"))) {
-      control.stop(ServerType.GARBAGE_COLLECTOR, gc);
-    }
-
-    for (String monitor : control.getHosts(new File(confDir, "monitor"))) {
-      control.stop(ServerType.MONITOR, monitor);
+    for (ServerType type : Arrays.asList(ServerType.MASTER, ServerType.TABLET_SERVER, ServerType.TRACER,
ServerType.GARBAGE_COLLECTOR, ServerType.MONITOR)) {
+      control.stopAllServers(type);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/accumulo/blob/7583946d/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 f3f311c..c9f395d 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
@@ -21,6 +21,7 @@ import java.io.File;
 import java.io.FileReader;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 import java.util.Map.Entry;
 
@@ -42,6 +43,10 @@ import com.google.common.collect.Maps;
 public class StandaloneClusterControl implements ClusterControl {
   private static final Logger log = LoggerFactory.getLogger(StandaloneClusterControl.class);
 
+  private static final String START_SERVER_SCRIPT = "start-server.sh", ACCUMULO_SCRIPT =
"accumulo";
+  private static final String MASTER_HOSTS_FILE = "masters", GC_HOSTS_FILE = "gc", TSERVER_HOSTS_FILE
= "slaves", TRACER_HOSTS_FILE = "tracers",
+      MONITOR_HOSTS_FILE = "monitor";
+
   protected String accumuloHome, accumuloConfDir;
   protected RemoteShellOptions options;
 
@@ -105,27 +110,35 @@ public class StandaloneClusterControl implements ClusterControl {
 
     switch (server) {
       case TABLET_SERVER:
-        for (String tserver : getHosts(new File(confDir, "slaves"))) {
+        for (String tserver : getHosts(new File(confDir, TSERVER_HOSTS_FILE))) {
           start(server, tserver);
         }
         break;
       case MASTER:
-        for (String master : getHosts(new File(confDir, "masters"))) {
+        for (String master : getHosts(new File(confDir, MASTER_HOSTS_FILE))) {
           start(server, master);
         }
         break;
       case GARBAGE_COLLECTOR:
-        for (String gc : getHosts(new File(confDir, "gc"))) {
+        List<String> hosts = getHosts(new File(confDir, GC_HOSTS_FILE));
+        if (hosts.isEmpty()) {
+          hosts = getHosts(new File(confDir, MASTER_HOSTS_FILE));
+          if (hosts.isEmpty()) {
+            throw new IOException("Found hosts to run garbage collector on");
+          }
+          hosts = Collections.singletonList(hosts.get(0));
+        }
+        for (String gc : hosts) {
           start(server, gc);
         }
         break;
       case TRACER:
-        for (String tracer : getHosts(new File(confDir, "tracers"))) {
+        for (String tracer : getHosts(new File(confDir, TRACER_HOSTS_FILE))) {
           start(server, tracer);
         }
         break;
       case MONITOR:
-        for (String monitor : getHosts(new File(confDir, "monitor"))) {
+        for (String monitor : getHosts(new File(confDir, MONITOR_HOSTS_FILE))) {
           start(server, monitor);
         }
         break;
@@ -147,27 +160,27 @@ public class StandaloneClusterControl implements ClusterControl {
 
     switch (server) {
       case TABLET_SERVER:
-        for (String tserver : getHosts(new File(confDir, "slaves"))) {
+        for (String tserver : getHosts(new File(confDir, TSERVER_HOSTS_FILE))) {
           stop(server, tserver);
         }
         break;
       case MASTER:
-        for (String master : getHosts(new File(confDir, "masters"))) {
+        for (String master : getHosts(new File(confDir, MASTER_HOSTS_FILE))) {
           stop(server, master);
         }
         break;
       case GARBAGE_COLLECTOR:
-        for (String gc : getHosts(new File(confDir, "gc"))) {
+        for (String gc : getHosts(new File(confDir, GC_HOSTS_FILE))) {
           stop(server, gc);
         }
         break;
       case TRACER:
-        for (String tracer : getHosts(new File(confDir, "tracers"))) {
+        for (String tracer : getHosts(new File(confDir, TRACER_HOSTS_FILE))) {
           stop(server, tracer);
         }
         break;
       case MONITOR:
-        for (String monitor : getHosts(new File(confDir, "monitor"))) {
+        for (String monitor : getHosts(new File(confDir, MONITOR_HOSTS_FILE))) {
           stop(server, monitor);
         }
         break;

http://git-wip-us.apache.org/repos/asf/accumulo/blob/7583946d/test/src/test/java/org/apache/accumulo/harness/MiniClusterHarness.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/harness/MiniClusterHarness.java b/test/src/test/java/org/apache/accumulo/harness/MiniClusterHarness.java
index f4712b3..9f2ee5f 100644
--- a/test/src/test/java/org/apache/accumulo/harness/MiniClusterHarness.java
+++ b/test/src/test/java/org/apache/accumulo/harness/MiniClusterHarness.java
@@ -42,6 +42,9 @@ public class MiniClusterHarness {
 
   private static final AtomicLong COUNTER = new AtomicLong(0);
 
+  public static final String USE_SSL_FOR_IT_OPTION = "org.apache.accumulo.test.functional.useSslForIT",
+      USE_CRED_PROVIDER_FOR_IT_OPTION = "org.apache.accumulo.test.functional.useCredProviderForIT",
TRUE = Boolean.toString(true);
+
   /**
    * Create a MiniAccumuloCluster using the given Token as the credentials for the root user.
    *
@@ -102,17 +105,17 @@ public class MiniClusterHarness {
   }
 
   protected void configureForEnvironment(MiniAccumuloConfigImpl cfg, Class<?> testClass,
File folder) {
-    if ("true".equals(System.getProperty("org.apache.accumulo.test.functional.useSslForIT")))
{
+    if (TRUE.equals(System.getProperty(USE_SSL_FOR_IT_OPTION))) {
       configureForSsl(cfg, folder);
     }
-    if ("true".equals(System.getProperty("org.apache.accumulo.test.functional.useCredProviderForIT")))
{
+    if (TRUE.equals(System.getProperty(USE_CRED_PROVIDER_FOR_IT_OPTION))) {
       cfg.setUseCredentialProvider(true);
     }
   }
 
   protected void configureForSsl(MiniAccumuloConfigImpl cfg, File folder) {
     Map<String,String> siteConfig = cfg.getSiteConfig();
-    if ("true".equals(siteConfig.get(Property.INSTANCE_RPC_SSL_ENABLED.getKey()))) {
+    if (TRUE.equals(siteConfig.get(Property.INSTANCE_RPC_SSL_ENABLED.getKey()))) {
       // already enabled; don't mess with it
       return;
     }


Mime
View raw message