You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by se...@apache.org on 2013/04/25 04:20:53 UTC

svn commit: r1471813 - in /hbase/branches/0.94/src: docbkx/developer.xml test/java/org/apache/hadoop/hbase/HBaseClusterManager.java

Author: sershe
Date: Thu Apr 25 02:20:53 2013
New Revision: 1471813

URL: http://svn.apache.org/r1471813
Log:
HBASE-8405 Add more custom options to how ClusterManager runs commands

Modified:
    hbase/branches/0.94/src/docbkx/developer.xml
    hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/HBaseClusterManager.java

Modified: hbase/branches/0.94/src/docbkx/developer.xml
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/docbkx/developer.xml?rev=1471813&r1=1471812&r2=1471813&view=diff
==============================================================================
--- hbase/branches/0.94/src/docbkx/developer.xml (original)
+++ hbase/branches/0.94/src/docbkx/developer.xml Thu Apr 25 02:20:53 2013
@@ -658,9 +658,9 @@ and public client API's can be used.
 <para>
 On a distributed cluster, integration tests that use ChaosMonkey or otherwise manipulate services thru cluster manager (e.g. restart regionservers) use SSH to do it.
 To run these, test process should be able to run commands on remote end, so ssh should be configured accordingly (for example, if HBase runs under hbase
-user in your cluster, you can set up passwordless ssh for that user and run the test also under it). To facilitate that, <code>hbase.it.clustermanager.ssh.user</code> and
-<code>hbase.it.clustermanager.ssh.opts</code> configuration settings can be used. The former is the remote user that cluster manager should use to perform ssh commands.
-The latter contains additional options that are passed to SSH (for example, "-i /tmp/my-key").
+user in your cluster, you can set up passwordless ssh for that user and run the test also under it). To facilitate that, <code>hbase.it.clustermanager.ssh.user</code>, 
+<code>hbase.it.clustermanager.ssh.opts</code> and <code>hbase.it.clustermanager.ssh.beforeCommand</code> configuration settings can be used. "User" is the remote user that cluster manager should use to perform ssh commands.
+"Opts" contains additional options that are passed to SSH (for example, "-i /tmp/my-key"). "BeforeCommand" is the command that will be run immediately after SSH-ing to the server, before the actual command (for example, "su hbase").
 </para>
 
 <section xml:id="maven.build.commands.integration.tests.mini">

Modified: hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/HBaseClusterManager.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/HBaseClusterManager.java?rev=1471813&r1=1471812&r2=1471813&view=diff
==============================================================================
--- hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/HBaseClusterManager.java (original)
+++ hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/HBaseClusterManager.java Thu Apr 25 02:20:53 2013
@@ -40,6 +40,7 @@ import org.apache.hadoop.util.Shell;
 public class HBaseClusterManager extends ClusterManager {
   private String sshUserName;
   private String sshOptions;
+  private String sshBeforeCommand;
 
   @Override
   public void setConf(Configuration conf) {
@@ -54,6 +55,10 @@ public class HBaseClusterManager extends
     if (!extraSshOptions.isEmpty()) {
       sshOptions = StringUtils.join(new Object[] { sshOptions, extraSshOptions }, " ");
     }
+    sshBeforeCommand =  conf.get("hbase.it.clustermanager.ssh.beforeCommand", "");
+    if (!sshBeforeCommand.isEmpty()) {
+      sshBeforeCommand += " && ";
+    }
     LOG.info("Running with SSH user [" + sshUserName + "] and options [" + sshOptions + "]");
   }
 
@@ -61,7 +66,6 @@ public class HBaseClusterManager extends
    * Executes commands over SSH
    */
   protected class RemoteShell extends Shell.ShellCommandExecutor {
-
     private String hostname;
 
     private String sshCmd = "/usr/bin/ssh";
@@ -94,7 +98,7 @@ public class HBaseClusterManager extends
           StringUtils.join(new String[] { sshCmd,
               (sshOptions == null) ? "" : sshOptions,
               userAndHost,
-              "\"" + StringUtils.join(super.getExecString(), " ") + "\""
+              "\"" + sshBeforeCommand + StringUtils.join(super.getExecString(), " ") + "\""
           }, " ")};
     }