HBASE-12680 Move signal related code from ClusterManager to HBaseClusterManager and change ClusterManager to an interface
Summary: The reason of this change is to make us write implementation of ClusterManager not using ssh/unix signals. Test Plan: The compilation is OK. Reviewers: eclark, manukranthk Differential Revision: https://reviews.facebook.net/D30201 Signed-off-by: Elliott Clark <eclark@apache.org>
This commit is contained in:
parent
ae684cac87
commit
555d14ed45
|
@ -20,10 +20,8 @@ package org.apache.hadoop.hbase;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.hadoop.conf.Configurable;
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
import org.apache.hadoop.hbase.classification.InterfaceAudience;
|
import org.apache.hadoop.hbase.classification.InterfaceAudience;
|
||||||
import org.apache.hadoop.conf.Configured;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,16 +30,7 @@ import org.apache.hadoop.conf.Configured;
|
||||||
* functionality for carrying out deployment-specific tasks.
|
* functionality for carrying out deployment-specific tasks.
|
||||||
*/
|
*/
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
public abstract class ClusterManager extends Configured {
|
interface ClusterManager extends Configurable {
|
||||||
protected static final Log LOG = LogFactory.getLog(ClusterManager.class);
|
|
||||||
|
|
||||||
private static final String SIGKILL = "SIGKILL";
|
|
||||||
private static final String SIGSTOP = "SIGSTOP";
|
|
||||||
private static final String SIGCONT = "SIGCONT";
|
|
||||||
|
|
||||||
public ClusterManager() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type of the service daemon
|
* Type of the service daemon
|
||||||
*/
|
*/
|
||||||
|
@ -72,50 +61,38 @@ public abstract class ClusterManager extends Configured {
|
||||||
/**
|
/**
|
||||||
* Start the service on the given host
|
* Start the service on the given host
|
||||||
*/
|
*/
|
||||||
public abstract void start(ServiceType service, String hostname) throws IOException;
|
void start(ServiceType service, String hostname) throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop the service on the given host
|
* Stop the service on the given host
|
||||||
*/
|
*/
|
||||||
public abstract void stop(ServiceType service, String hostname) throws IOException;
|
void stop(ServiceType service, String hostname) throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restart the service on the given host
|
* Restarts the service on the given host
|
||||||
*/
|
*/
|
||||||
public abstract void restart(ServiceType service, String hostname) throws IOException;
|
void restart(ServiceType service, String hostname) throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send the given posix signal to the service
|
* Kills the service running on the given host
|
||||||
*/
|
*/
|
||||||
public abstract void signal(ServiceType service, String signal,
|
void kill(ServiceType service, String hostname) throws IOException;
|
||||||
String hostname) throws IOException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Kill the service running on given host
|
* Suspends the service running on the given host
|
||||||
*/
|
*/
|
||||||
public void kill(ServiceType service, String hostname) throws IOException {
|
void suspend(ServiceType service, String hostname) throws IOException;
|
||||||
signal(service, SIGKILL, hostname);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Suspend the service running on given host
|
* Resumes the services running on the given host
|
||||||
*/
|
*/
|
||||||
public void suspend(ServiceType service, String hostname) throws IOException {
|
void resume(ServiceType service, String hostname) throws IOException;
|
||||||
signal(service, SIGSTOP, hostname);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resume the services running on given hosts
|
|
||||||
*/
|
|
||||||
public void resume(ServiceType service, String hostname) throws IOException {
|
|
||||||
signal(service, SIGCONT, hostname);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether the service is running on the remote host. This only checks whether the
|
* Returns whether the service is running on the remote host. This only checks whether the
|
||||||
* service still has a pid.
|
* service still has a pid.
|
||||||
*/
|
*/
|
||||||
public abstract boolean isRunning(ServiceType service, String hostname) throws IOException;
|
boolean isRunning(ServiceType service, String hostname) throws IOException;
|
||||||
|
|
||||||
/* TODO: further API ideas:
|
/* TODO: further API ideas:
|
||||||
*
|
*
|
||||||
|
|
|
@ -24,7 +24,10 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.hadoop.hbase.classification.InterfaceAudience;
|
import org.apache.hadoop.hbase.classification.InterfaceAudience;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
|
import org.apache.hadoop.conf.Configured;
|
||||||
import org.apache.hadoop.hbase.HBaseClusterManager.CommandProvider.Operation;
|
import org.apache.hadoop.hbase.HBaseClusterManager.CommandProvider.Operation;
|
||||||
import org.apache.hadoop.hbase.util.Pair;
|
import org.apache.hadoop.hbase.util.Pair;
|
||||||
import org.apache.hadoop.hbase.util.RetryCounter;
|
import org.apache.hadoop.hbase.util.RetryCounter;
|
||||||
|
@ -40,7 +43,12 @@ import org.apache.hadoop.util.Shell;
|
||||||
* user the daemon is running as)
|
* user the daemon is running as)
|
||||||
*/
|
*/
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
public class HBaseClusterManager extends ClusterManager {
|
public class HBaseClusterManager extends Configured implements ClusterManager {
|
||||||
|
private static final String SIGKILL = "SIGKILL";
|
||||||
|
private static final String SIGSTOP = "SIGSTOP";
|
||||||
|
private static final String SIGCONT = "SIGCONT";
|
||||||
|
|
||||||
|
protected static final Log LOG = LogFactory.getLog(HBaseClusterManager.class);
|
||||||
private String sshUserName;
|
private String sshUserName;
|
||||||
private String sshOptions;
|
private String sshOptions;
|
||||||
|
|
||||||
|
@ -181,7 +189,6 @@ public class HBaseClusterManager extends ClusterManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public HBaseClusterManager() {
|
public HBaseClusterManager() {
|
||||||
super();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CommandProvider getCommandProvider(ServiceType service) {
|
protected CommandProvider getCommandProvider(ServiceType service) {
|
||||||
|
@ -263,7 +270,6 @@ public class HBaseClusterManager extends ClusterManager {
|
||||||
exec(hostname, service, Operation.RESTART);
|
exec(hostname, service, Operation.RESTART);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void signal(ServiceType service, String signal, String hostname) throws IOException {
|
public void signal(ServiceType service, String signal, String hostname) throws IOException {
|
||||||
execWithRetries(hostname, getCommandProvider(service).signalCommand(service, signal));
|
execWithRetries(hostname, getCommandProvider(service).signalCommand(service, signal));
|
||||||
}
|
}
|
||||||
|
@ -275,4 +281,18 @@ public class HBaseClusterManager extends ClusterManager {
|
||||||
return ret.length() > 0;
|
return ret.length() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void kill(ServiceType service, String hostname) throws IOException {
|
||||||
|
signal(service, SIGKILL, hostname);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void suspend(ServiceType service, String hostname) throws IOException {
|
||||||
|
signal(service, SIGSTOP, hostname);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void resume(ServiceType service, String hostname) throws IOException {
|
||||||
|
signal(service, SIGCONT, hostname);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue