From d12209347305273b83e1036dc084ea348cd99724 Mon Sep 17 00:00:00 2001 From: sershe Date: Thu, 25 Apr 2013 01:36:29 +0000 Subject: [PATCH] HBASE-8405 Add more custom options to how ClusterManager runs commands git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1471804 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/hadoop/hbase/HBaseClusterManager.java | 8 ++++++-- src/main/docbkx/developer.xml | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/hbase-it/src/test/java/org/apache/hadoop/hbase/HBaseClusterManager.java b/hbase-it/src/test/java/org/apache/hadoop/hbase/HBaseClusterManager.java index 5bd529cce05..3ddff047a61 100644 --- a/hbase-it/src/test/java/org/apache/hadoop/hbase/HBaseClusterManager.java +++ b/hbase-it/src/test/java/org/apache/hadoop/hbase/HBaseClusterManager.java @@ -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 ClusterManager { 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 ClusterManager { * Executes commands over SSH */ protected class RemoteShell extends Shell.ShellCommandExecutor { - private String hostname; private String sshCmd = "/usr/bin/ssh"; @@ -95,7 +99,7 @@ public class HBaseClusterManager extends ClusterManager { StringUtils.join(new String[] { sshCmd, (sshOptions == null) ? "" : sshOptions, userAndHost, - "\"" + StringUtils.join(super.getExecString(), " ") + "\"" + "\"" + sshBeforeCommand + StringUtils.join(super.getExecString(), " ") + "\"" }, " ")}; } diff --git a/src/main/docbkx/developer.xml b/src/main/docbkx/developer.xml index 154c284c812..521b242156f 100644 --- a/src/main/docbkx/developer.xml +++ b/src/main/docbkx/developer.xml @@ -674,9 +674,9 @@ 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, hbase.it.clustermanager.ssh.user and -hbase.it.clustermanager.ssh.opts 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, hbase.it.clustermanager.ssh.user, +hbase.it.clustermanager.ssh.opts and hbase.it.clustermanager.ssh.beforeCommand 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").