hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omal...@apache.org
Subject svn commit: r1077558 - in /hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/test/system: ./ process/
Date Fri, 04 Mar 2011 04:28:59 GMT
Author: omalley
Date: Fri Mar  4 04:28:58 2011
New Revision: 1077558

URL: http://svn.apache.org/viewvc?rev=1077558&view=rev
Log:
commit 8809b8d5778498385164128a90b733ccd61b953f
Author: Balaji Rajagopalan <balajirg@yahoo-inc.com>
Date:   Wed Jul 21 18:11:25 2010 -0700

    MAPREDUCE-1889 from https://issues.apache.org/jira/secure/attachment/12449067/restartDaemon_y20.patch

Modified:
    hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/test/system/AbstractDaemonCluster.java
    hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/test/system/process/ClusterProcessManager.java
    hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/test/system/process/HadoopDaemonRemoteCluster.java
    hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/test/system/process/RemoteProcess.java

Modified: hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/test/system/AbstractDaemonCluster.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/test/system/AbstractDaemonCluster.java?rev=1077558&r1=1077557&r2=1077558&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/test/system/AbstractDaemonCluster.java
(original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/test/system/AbstractDaemonCluster.java
Fri Mar  4 04:28:58 2011
@@ -48,6 +48,7 @@ public abstract class AbstractDaemonClus
   private Map<Enum<?>, List<AbstractDaemonClient>> daemons = 
     new LinkedHashMap<Enum<?>, List<AbstractDaemonClient>>();
   private String newConfDir = null;  
+  File localFolderObj = null;
   private static final  String CONF_HADOOP_LOCAL_DIR =
       "test.system.hdrc.hadoop.local.confdir"; 
   private static final  String CONF_HADOOP_MULTI_USER_LIST =
@@ -349,12 +350,8 @@ public abstract class AbstractDaemonClus
    */
   public void restartClusterWithNewConfig(Hashtable<String,?> props, 
       String configFile) throws IOException {
-
     String mapredConf = null;
-    String localDirPath = null;
-    File localFolderObj = null;
-    File xmlFileObj = null;
-    String confXMLFile = null;
+    String localDirPath = null; 
     Configuration initConf = new Configuration(getConf());
     Enumeration<String> e = props.keys();
     while (e.hasMoreElements()) {
@@ -362,15 +359,8 @@ public abstract class AbstractDaemonClus
       Object propValue = props.get(propKey);
       initConf.set(propKey,propValue.toString());
     }
-
-    localDirPath = getHadoopLocalConfDir();
-    localFolderObj = new File(localDirPath);
-    if (!localFolderObj.exists()) {
-      localFolderObj.mkdir();
-    }
-    confXMLFile = localDirPath + File.separator + configFile;
-    xmlFileObj = new File(confXMLFile);
-    initConf.writeXml(new FileOutputStream(xmlFileObj));
+    localDirPath = getHadoopLocalConfDir(); 
+    writeConfToFile(configFile,localDirPath,initConf);
     newConfDir = clusterManager.pushConfig(localDirPath);
     stop();
     waitForClusterToStop();
@@ -380,6 +370,42 @@ public abstract class AbstractDaemonClus
   }
   
   /**
+   * The method is used to only restart one daemon with new config
+   * and this gives a great flexibility in choosing which daemon the
+   * test wants to restarting instead of changing the config in all the 
+   * daemons. 
+   * @param client points to the daemon that will restarted.
+   * @param configFile the name of the config file
+   * @param conf the Configuration object
+   * @param role of remote process such as JT,TT,NN,DN
+   * @throws IOException thrown in case of any error 
+   */
+  public void restartDaemonWithNewConfig(AbstractDaemonClient client, 
+      String configFile, Configuration conf, Enum<?> role) throws IOException {   

+    String localDirPath = getHadoopLocalConfDir();
+    writeConfToFile(configFile,localDirPath,conf);
+    RemoteProcess daemon=clusterManager.getDaemonProcess(client.getHostName(), 
+        role);    
+    newConfDir = daemon.pushConfig(localDirPath);
+    daemon.kill();
+    waitForDaemonToStop(client);
+    daemon.start(newConfDir);
+    waitForDaemonToStart(client);    
+    localFolderObj.delete();
+  }
+  
+  private void writeConfToFile(String configFile, String localDirPath,
+      Configuration conf) throws IOException{      
+    localFolderObj = new File(localDirPath);
+    if (!localFolderObj.exists()) {
+      localFolderObj.mkdir();
+    }
+    String confXMLFile = localDirPath + File.separator + configFile;
+    File xmlFileObj = new File(confXMLFile);
+    conf.writeXml(new FileOutputStream(xmlFileObj));
+  }
+  
+  /**
    * It uses to restart the cluster with default configuration.<br/>
    * @throws IOException if an I/O error occurs.
    */
@@ -392,6 +418,21 @@ public abstract class AbstractDaemonClus
   }
   
   /**
+   * Restart only one daemon as opposed to all the daemons
+   * @param client points to the daemon that will restarted. 
+   * @param role  of remote process such as JT,TT,NN,DN 
+   * @throws IOException is thrown when restart fails
+   */
+  public void restart(AbstractDaemonClient client,Enum<?> role) throws IOException
{
+    RemoteProcess daemon=clusterManager.getDaemonProcess(client.getHostName(), 
+        role);
+    daemon.kill();
+    waitForDaemonToStop(client);
+    daemon.start();
+    waitForDaemonToStart(client);
+  }
+  
+  /**
    * It uses to wait until the cluster is stopped.<br/>
    * @throws IOException if an I/O error occurs.
    */
@@ -405,7 +446,7 @@ public abstract class AbstractDaemonClus
         dmStop.start();
       }
     }
-
+    
     for (Thread daemonThread : chkDaemonStop){
       try {
         daemonThread.join();
@@ -438,6 +479,44 @@ public abstract class AbstractDaemonClus
       }
     }
   }
+  /**
+   * This will provide synchronization for the daemon to stop
+   * @param client identifies the daemon
+   * @throws IOException thrown if daemon does not stop 
+   */
+  public void waitForDaemonToStop(AbstractDaemonClient client) 
+      throws IOException {
+    while (true) {
+      try {
+        client.ping();
+        LOG.debug(client.getHostName() +" is waiting state to stop.");
+        waitFor(5000);
+      } catch (Exception exp) {
+        LOG.info("Daemon is : " + client.getHostName() + " stopped...");
+        break;
+      } 
+    }   
+  }
+  
+  /**
+   * This will provide synchronization for the daemon to start
+   * @param client identifies the daemon
+   * @throws IOException thrown if the daemon does not start
+   */
+  public void waitForDaemonToStart(AbstractDaemonClient client) 
+      throws IOException {
+    
+    while (true) {
+      try {
+        client.ping();
+        LOG.info("Daemon is : " + client.getHostName() + " pinging...");
+        break;
+      } catch (Exception exp) {
+        LOG.debug(client.getHostName() + " is waiting to come up.");
+        waitFor(5000);
+      }
+    }    
+  }
 
   /**
    * It waits for specified amount of time.

Modified: hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/test/system/process/ClusterProcessManager.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/test/system/process/ClusterProcessManager.java?rev=1077558&r1=1077557&r2=1077558&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/test/system/process/ClusterProcessManager.java
(original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/test/system/process/ClusterProcessManager.java
Fri Mar  4 04:28:58 2011
@@ -46,6 +46,13 @@ public interface ClusterProcessManager {
    * Get the list of RemoteProcess handles of all the remote processes.
    */
   List<RemoteProcess> getAllProcesses();
+  
+  /**
+   * Get a RemoteProcess given the hostname
+   * @param The hostname for which the object instance needs to be obtained.
+   * @param The role of process example are JT,TT,DN,NN
+   */
+  RemoteProcess getDaemonProcess(String hostname, Enum<?> role);
 
   /**
    * Get all the roles this cluster's daemon processes have.

Modified: hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/test/system/process/HadoopDaemonRemoteCluster.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/test/system/process/HadoopDaemonRemoteCluster.java?rev=1077558&r1=1077557&r2=1077558&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/test/system/process/HadoopDaemonRemoteCluster.java
(original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/test/system/process/HadoopDaemonRemoteCluster.java
Fri Mar  4 04:28:58 2011
@@ -141,6 +141,18 @@ public abstract class HadoopDaemonRemote
     }
     return hadoopNewConfDir;
   }
+  
+  @Override
+  public RemoteProcess getDaemonProcess(String hostname,Enum<?> role) {
+    RemoteProcess daemon=null;
+    for (RemoteProcess p : processes) {      
+      if(p.getHostName().equals(hostname) && p.getRole() == role){
+        daemon =p;
+        break;
+      }     
+    }
+    return daemon;
+  }
 
   public HadoopDaemonRemoteCluster(List<HadoopDaemonInfo> daemonInfos) {
     this.daemonInfos = daemonInfos;
@@ -324,9 +336,10 @@ public abstract class HadoopDaemonRemote
     }
 
     @Override
-    public void pushConfig(String localDir) throws IOException {
+    public String pushConfig(String localDir) throws IOException {
       createNewConfDir().execute();
       buildPushConfig(localDir, hadoopNewConfDir).execute();
+      return hadoopNewConfDir;
     }
 
     private ShellCommandExecutor buildCommandExecutor(String command,

Modified: hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/test/system/process/RemoteProcess.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/test/system/process/RemoteProcess.java?rev=1077558&r1=1077557&r2=1077558&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/test/system/process/RemoteProcess.java
(original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/test/system/process/RemoteProcess.java
Fri Mar  4 04:28:58 2011
@@ -70,6 +70,7 @@ public interface RemoteProcess {
    * @param localDir The local directory which has config files that will be 
    * pushed to the remote location
    * @throws IOException is thrown if the pushConfig results in a error. 
+   * @return The newconfdir location will be returned
    */
-  void pushConfig(String localDir) throws IOException;
+  String pushConfig(String localDir) throws IOException;
 }



Mime
View raw message