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
This commit is contained in:
sershe 2013-04-25 01:36:29 +00:00
parent 026779686f
commit d122093473
2 changed files with 9 additions and 5 deletions

View File

@ -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(), " ") + "\""
}, " ")};
}

View File

@ -674,9 +674,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">