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
Modifier and TypeClassDescription(package private) static class
Provides command strings for services to be executed by Shell.(package private) static class
CommandProvider to manage the service using sbin/hadoop-* scripts.(package private) static class
CommandProvider to manage the service using bin/hbase-* scriptsprotected class
Executes commands over SSHprotected class
Executes commands over SSHprotected static enum
(package private) static class
CommandProvider to manage the service using bin/zk* scripts.Nested classes/interfaces inherited from interface org.apache.hadoop.hbase.ClusterManager
ClusterManager.ServiceType
-
Field Summary
Modifier and TypeFieldDescription(package private) static final int
(package private) static final int
private static final String
The command format that is used to execute the remote command.private static final String
The 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 String
protected org.apache.hadoop.hbase.util.RetryCounterFactory
private String
private String
private String
private String
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionexec
(String hostname, ClusterManager.ServiceType service, String... cmd) Execute the given command on the host using SSHprivate void
exec
(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.CommandProvider
protected String
getServiceUser
(ClusterManager.ServiceType service) boolean
isRunning
(ClusterManager.ServiceType service, String hostname, int port) Returns whether the service is running on the remote host.void
kill
(ClusterManager.ServiceType service, String hostname, int port) Kills the service running on the given hostvoid
restart
(ClusterManager.ServiceType service, String hostname, int port) Restart the service on the given hostvoid
resume
(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) void
setConf
(org.apache.hadoop.conf.Configuration conf) void
signal
(ClusterManager.ServiceType service, HBaseClusterManager.Signal signal, String hostname) void
start
(ClusterManager.ServiceType service, String hostname, int port) Start the service on the given hostvoid
stop
(ClusterManager.ServiceType service, String hostname, int port) Stop the service on the given hostvoid
suspend
(ClusterManager.ServiceType service, String hostname, int port) Suspends the service running on the given hostMethods inherited from class org.apache.hadoop.conf.Configured
getConf
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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:
setConf
in interfaceorg.apache.hadoop.conf.Configurable
- Overrides:
setConf
in 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:ClusterManager
Start the service on the given host- Specified by:
start
in interfaceClusterManager
- Throws:
IOException
-
stop
Description copied from interface:ClusterManager
Stop the service on the given host- Specified by:
stop
in interfaceClusterManager
- Throws:
IOException
-
restart
public void restart(ClusterManager.ServiceType service, String hostname, int port) throws IOException Description copied from interface:ClusterManager
Restart the service on the given host- Specified by:
restart
in 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:ClusterManager
Returns whether the service is running on the remote host. This only checks whether the service still has a pid.- Specified by:
isRunning
in interfaceClusterManager
- Throws:
IOException
-
kill
Description copied from interface:ClusterManager
Kills the service running on the given host- Specified by:
kill
in interfaceClusterManager
- Throws:
IOException
-
suspend
public void suspend(ClusterManager.ServiceType service, String hostname, int port) throws IOException Description copied from interface:ClusterManager
Suspends the service running on the given host- Specified by:
suspend
in interfaceClusterManager
- Throws:
IOException
-
resume
public void resume(ClusterManager.ServiceType service, String hostname, int port) throws IOException Description copied from interface:ClusterManager
Resumes the services running on the given host- Specified by:
resume
in interfaceClusterManager
- Throws:
IOException
-