Procházet zdrojové kódy

commit 80f87df12b0591e2969406c3a582612f4f7106b1
Author: Konstantin Boudnik <cos@goodenter-lm.local>
Date: Mon Feb 22 19:18:13 2010 -0800

from


git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.20-security-patches@1077179 13f79535-47bb-0310-9956-ffa450edef68

Owen O'Malley před 14 roky
rodič
revize
03bdf057b9

+ 13 - 0
src/test/system/java/org/apache/hadoop/test/system/process/ClusterProcessManager.java

@@ -68,4 +68,17 @@ public interface ClusterProcessManager {
    */
   void stop() throws IOException;
 
+  /**
+   * Method cleans the remote hosts' directories used by a deployed cluster
+   * @throws IOException is thrown if cleaning process fails or terminates with
+   * non-zero exit code
+   */
+  void cleanDirs() throws Exception;
+
+  /**
+   * Method (re)reploys cluster bits to the remote hosts
+   * @throws IOException is thrown if cleaning process fails or terminates with
+   * non-zero exit code
+  */
+  void deploy() throws IOException;
 }

+ 43 - 0
src/test/system/java/org/apache/hadoop/test/system/process/HadoopDaemonRemoteCluster.java

@@ -53,6 +53,13 @@ public class HadoopDaemonRemoteCluster implements ClusterProcessManager {
   public final static String CONF_DEPLOYED_HADOOPCONFDIR =
     "test.system.hdrc.deployed.hadoopconfdir";
 
+  /**
+   * Key is used to configure the location of deployment control directory
+   * where additional helper scripts might reside
+   */
+  public final static String CONF_STAGED_HADOOP_CONTROLDIR =
+    "test.system.hdrc.staged.controldir";
+
   private String hadoopHome;
   private String hadoopConfDir;
   private String deployed_hadoopConfDir;
@@ -176,6 +183,32 @@ public class HadoopDaemonRemoteCluster implements ClusterProcessManager {
     }
   }
 
+  @Override
+  public void cleanDirs() throws Exception {
+    File controlDir = getControlDirectory();
+    if (controlDir == null) {
+      LOG.warn("External tools for cluster control aren't available");
+      return;
+    }
+    String [] cmd = new String[]{"clusterCleanupFs.sh"};
+    ShellCommandExecutor cleanScript =
+      new ShellCommandExecutor(cmd, controlDir);
+    cleanScript.execute();
+  }
+
+  @Override
+  public void deploy() throws IOException {
+    File controlDir = getControlDirectory();
+    if (controlDir == null) {
+      LOG.warn("External tools for cluster control aren't available");
+      return;
+    }
+    String [] cmd = new String[]{"clusterInstall.sh"};
+    ShellCommandExecutor installScript =
+      new ShellCommandExecutor(cmd, controlDir);
+    installScript.execute();
+  }
+
   private void populateDaemons(String confLocation) throws IOException {
     File mastersFile = new File(confLocation, MASTERS_FILE);
     File slavesFile = new File(confLocation, SLAVES_FILE);
@@ -220,6 +253,16 @@ public class HadoopDaemonRemoteCluster implements ClusterProcessManager {
     }
   }
 
+  private static File getControlDirectory () {
+    String controlDirLocation = System.getProperty(CONF_STAGED_HADOOP_CONTROLDIR);
+    if (controlDirLocation != null) {
+      File controlDir = new File(controlDirLocation);
+      if (!controlDir.exists())
+        return controlDir;
+    }
+    return null;
+  }
+
   /**
    * The core daemon class which actually implements the remote process
    * management of actual daemon processes in the cluster.