hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ser...@apache.org
Subject svn commit: r1479745 - in /hbase/branches/0.94/src: docbkx/developer.xml test/java/org/apache/hadoop/hbase/HBaseClusterManager.java
Date Tue, 07 May 2013 01:47:48 GMT
Author: sershe
Date: Tue May  7 01:47:29 2013
New Revision: 1479745

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

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=1479745&r1=1479744&r2=1479745&view=diff
==============================================================================
--- hbase/branches/0.94/src/docbkx/developer.xml (original)
+++ hbase/branches/0.94/src/docbkx/developer.xml Tue May  7 01:47:29 2013
@@ -659,8 +659,10 @@ and public client API's can be used.
 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>,

-<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").
+<code>hbase.it.clustermanager.ssh.opts</code> and <code>hbase.it.clustermanager.ssh.cmd</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").

+Finally, if you have some custom environment setup, "cmd" is the override format for the
entire tunnel (ssh) command. The default string is {<code>/usr/bin/ssh %1$s %2$s%3$s%4$s
"%5$s"</code>} and is a good starting point. This is a standard Java format string with
5 arguments that is used to execute the remote command. The argument 1 (%1$s) is SSH options
set the via opts setting or via environment variable, 2 is SSH user name, 3 is "@" if username
is set or "" otherwise, 4 is the target host name, and 5 is the logical command to execute
(that may include single quotes, so don't use them). For example, if you run the tests under
non-hbase user and want to ssh as that user and change to hbase on remote machine, you can
use {<code>/usr/bin/ssh %1$s %2$s%3$s%4$s "su hbase - -c \"%5$s\""</code>}. That
way, to kill RS (for example) integration tests may run {<code>/usr/bin/ssh some-hostname
"su hbase - -c \"ps aux | ... | kill ...\""</code>}.
+The command is logged in the test logs, so you can verify it is correct for your environment.
 </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=1479745&r1=1479744&r2=1479745&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 Tue
May  7 01:47:29 2013
@@ -40,7 +40,13 @@ import org.apache.hadoop.util.Shell;
 public class HBaseClusterManager extends ClusterManager {
   private String sshUserName;
   private String sshOptions;
-  private String sshBeforeCommand;
+
+  /**
+   * The command format that is used to execute the remote command. Arguments:
+   * 1 SSH options, 2 user name , 3 "@" if username is set, 4 host, 5 original command.
+   */
+  private static final String DEFAULT_TUNNEL_CMD = "/usr/bin/ssh %1$s %2$s%3$s%4$s \"%5$s\"";
+  private String tunnelCmd;
 
   @Override
   public void setConf(Configuration conf) {
@@ -55,10 +61,8 @@ 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 += " && ";
-    }
+    sshOptions = (sshOptions == null) ? "" : sshOptions;
+    tunnelCmd = conf.get("hbase.it.clustermanager.ssh.cmd", DEFAULT_TUNNEL_CMD);
     LOG.info("Running with SSH user [" + sshUserName + "] and options [" + sshOptions + "]");
   }
 
@@ -68,8 +72,6 @@ public class HBaseClusterManager extends
   protected class RemoteShell extends Shell.ShellCommandExecutor {
     private String hostname;
 
-    private String sshCmd = "/usr/bin/ssh";
-
     public RemoteShell(String hostname, String[] execString, File dir, Map<String, String>
env,
         long timeout) {
       super(execString, dir, env, timeout);
@@ -92,14 +94,11 @@ public class HBaseClusterManager extends
     }
 
     public String[] getExecString() {
-      String userAndHost = sshUserName.isEmpty() ? hostname : (sshUserName + "@" + hostname);
-      return new String[] {
-          "bash", "-c",
-          StringUtils.join(new String[] { sshCmd,
-              (sshOptions == null) ? "" : sshOptions,
-              userAndHost,
-              "\"" + sshBeforeCommand + StringUtils.join(super.getExecString(), " ") + "\""
-          }, " ")};
+      String at = sshUserName.isEmpty() ? "" : "@";
+      String remoteCmd = StringUtils.join(super.getExecString(), " ");
+      String cmd = String.format(tunnelCmd, sshOptions, sshUserName, at, hostname, remoteCmd);
+      LOG.info("Executing full command [" + cmd + "]");
+      return new String[] { "/usr/bin/env", "bash", "-c", cmd };
     }
 
     @Override



Mime
View raw message