Package org.apache.hadoop.hbase
Class HBaseClusterManager
java.lang.Object
org.apache.hadoop.conf.Configured
org.apache.hadoop.hbase.HBaseClusterManager
- All Implemented Interfaces:
org.apache.hadoop.conf.Configurable,ClusterManager
- Direct Known Subclasses:
CoprocClusterManager
@Private
public class HBaseClusterManager
extends org.apache.hadoop.conf.Configured
implements ClusterManager
A default cluster manager for HBase. Uses SSH, and hbase shell scripts to manage the cluster.
Assumes Unix-like commands are available like 'ps', 'kill', etc. Also assumes the user running
the test has enough "power" to start & stop servers on the remote machines (for example, the test
user could be the same user as the user the daemon is running as)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classProvides command strings for services to be executed by Shell.(package private) static classCommandProvider to manage the service using sbin/hadoop-* scripts.(package private) static classCommandProvider to manage the service using bin/hbase-* scriptsprotected classExecutes commands over SSHprotected classExecutes commands over SSHprotected static enum(package private) static classCommandProvider to manage the service using bin/zk* scripts.Nested classes/interfaces inherited from interface org.apache.hadoop.hbase.ClusterManager
ClusterManager.ServiceType -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final int(package private) static final intprivate static final StringThe command format that is used to execute the remote command.private static final StringThe command format that is used to execute the remote command with sudo.protected static final org.slf4j.Logger(package private) static final String(package private) static final Stringprotected org.apache.hadoop.hbase.util.RetryCounterFactoryprivate Stringprivate Stringprivate Stringprivate String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionexec(String hostname, ClusterManager.ServiceType service, String... cmd) Execute the given command on the host using SSHprivate voidexec(String hostname, ClusterManager.ServiceType service, HBaseClusterManager.CommandProvider.Operation op) Execute the given command on the host using SSHexecSudoWithRetries(String hostname, long timeout, String... cmd) execWithRetries(String hostname, ClusterManager.ServiceType service, String... cmd) protected HBaseClusterManager.CommandProviderprotected StringgetServiceUser(ClusterManager.ServiceType service) booleanisRunning(ClusterManager.ServiceType service, String hostname, int port) Returns whether the service is running on the remote host.voidkill(ClusterManager.ServiceType service, String hostname, int port) Kills the service running on the given hostvoidrestart(ClusterManager.ServiceType service, String hostname, int port) Restart the service on the given hostvoidresume(ClusterManager.ServiceType service, String hostname, int port) Resumes the services running on the given hostprivate <E extends Exception>
voidretryOrThrow(org.apache.hadoop.hbase.util.RetryCounter retryCounter, E ex, String hostname, String[] cmd) voidsetConf(org.apache.hadoop.conf.Configuration conf) voidsignal(ClusterManager.ServiceType service, HBaseClusterManager.Signal signal, String hostname) voidstart(ClusterManager.ServiceType service, String hostname, int port) Start the service on the given hostvoidstop(ClusterManager.ServiceType service, String hostname, int port) Stop the service on the given hostvoidsuspend(ClusterManager.ServiceType service, String hostname, int port) Suspends the service running on the given hostMethods inherited from class org.apache.hadoop.conf.Configured
getConfMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.hadoop.conf.Configurable
getConf
-
Field Details
-
LOG
-
sshUserName
-
sshOptions
-
DEFAULT_TUNNEL_CMD
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, 6 service user.- See Also:
-
tunnelCmd
-
DEFAULT_TUNNEL_SUDO_CMD
The command format that is used to execute the remote command with sudo. Arguments: 1 SSH options, 2 user name , 3 "@" if username is set, 4 host, 5 original command, 6 timeout.- See Also:
-
tunnelSudoCmd
-
RETRY_ATTEMPTS_KEY
- See Also:
-
DEFAULT_RETRY_ATTEMPTS
- See Also:
-
RETRY_SLEEP_INTERVAL_KEY
- See Also:
-
DEFAULT_RETRY_SLEEP_INTERVAL
- See Also:
-
retryCounterFactory
-
-
Constructor Details
-
HBaseClusterManager
public HBaseClusterManager()
-
-
Method Details
-
setConf
- Specified by:
setConfin interfaceorg.apache.hadoop.conf.Configurable- Overrides:
setConfin classorg.apache.hadoop.conf.Configured
-
getServiceUser
-
getCommandProvider
protected HBaseClusterManager.CommandProvider getCommandProvider(ClusterManager.ServiceType service) throws IOException - Throws:
IOException
-
exec
protected org.apache.hadoop.hbase.util.Pair<Integer,String> exec(String hostname, ClusterManager.ServiceType service, String... cmd) throws IOException Execute the given command on the host using SSH- Returns:
- pair of exit code and command output
- Throws:
IOException- if something goes wrong.
-
execWithRetries
private org.apache.hadoop.hbase.util.Pair<Integer,String> execWithRetries(String hostname, ClusterManager.ServiceType service, String... cmd) throws IOException - Throws:
IOException
-
execSudo
public org.apache.hadoop.hbase.util.Pair<Integer,String> execSudo(String hostname, long timeout, String... cmd) throws IOException Execute the given command on the host using SSH- Returns:
- pair of exit code and command output
- Throws:
IOException- if something goes wrong.
-
execSudoWithRetries
public org.apache.hadoop.hbase.util.Pair<Integer,String> execSudoWithRetries(String hostname, long timeout, String... cmd) throws IOException - Throws:
IOException
-
retryOrThrow
private <E extends Exception> void retryOrThrow(org.apache.hadoop.hbase.util.RetryCounter retryCounter, E ex, String hostname, String[] cmd) throws E - Throws:
E extends Exception
-
exec
private void exec(String hostname, ClusterManager.ServiceType service, HBaseClusterManager.CommandProvider.Operation op) throws IOException - Throws:
IOException
-
start
Description copied from interface:ClusterManagerStart the service on the given host- Specified by:
startin interfaceClusterManager- Throws:
IOException
-
stop
Description copied from interface:ClusterManagerStop the service on the given host- Specified by:
stopin interfaceClusterManager- Throws:
IOException
-
restart
public void restart(ClusterManager.ServiceType service, String hostname, int port) throws IOException Description copied from interface:ClusterManagerRestart the service on the given host- Specified by:
restartin interfaceClusterManager- Throws:
IOException
-
signal
public void signal(ClusterManager.ServiceType service, HBaseClusterManager.Signal signal, String hostname) throws IOException - Throws:
IOException
-
isRunning
public boolean isRunning(ClusterManager.ServiceType service, String hostname, int port) throws IOException Description copied from interface:ClusterManagerReturns whether the service is running on the remote host. This only checks whether the service still has a pid.- Specified by:
isRunningin interfaceClusterManager- Throws:
IOException
-
kill
Description copied from interface:ClusterManagerKills the service running on the given host- Specified by:
killin interfaceClusterManager- Throws:
IOException
-
suspend
public void suspend(ClusterManager.ServiceType service, String hostname, int port) throws IOException Description copied from interface:ClusterManagerSuspends the service running on the given host- Specified by:
suspendin interfaceClusterManager- Throws:
IOException
-
resume
public void resume(ClusterManager.ServiceType service, String hostname, int port) throws IOException Description copied from interface:ClusterManagerResumes the services running on the given host- Specified by:
resumein interfaceClusterManager- Throws:
IOException
-