|
@@ -24,6 +24,7 @@ import java.util.Map;
|
|
|
|
|
|
import org.apache.hadoop.classification.InterfaceAudience;
|
|
|
import org.apache.hadoop.conf.Configured;
|
|
|
+import org.apache.hadoop.ha.HAServiceProtocol.HAServiceState;
|
|
|
import org.apache.hadoop.ipc.RPC;
|
|
|
import org.apache.hadoop.net.NetUtils;
|
|
|
import org.apache.hadoop.util.Tool;
|
|
@@ -44,7 +45,9 @@ public class HAAdmin extends Configured implements Tool {
|
|
|
.put("-transitionToActive",
|
|
|
new UsageInfo("<host:port>", "Transitions the daemon into Active state"))
|
|
|
.put("-transitionToStandby",
|
|
|
- new UsageInfo("<host:port>", "Transitions the daemon into Passive state"))
|
|
|
+ new UsageInfo("<host:port>", "Transitions the daemon into Standby state"))
|
|
|
+ .put("-getServiceState",
|
|
|
+ new UsageInfo("<host:port>", "Returns the state of the daemon"))
|
|
|
.put("-checkHealth",
|
|
|
new UsageInfo("<host:port>",
|
|
|
"Requests that the daemon perform a health check.\n" +
|
|
@@ -123,6 +126,19 @@ public class HAAdmin extends Configured implements Tool {
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+ private int getServiceState(final String[] argv)
|
|
|
+ throws IOException, ServiceFailedException {
|
|
|
+ if (argv.length != 2) {
|
|
|
+ errOut.println("getServiceState: incorrect number of arguments");
|
|
|
+ printUsage(errOut, "-getServiceState");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ HAServiceProtocol proto = getProtocol(argv[1]);
|
|
|
+ out.println(proto.getServiceState());
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Return a proxy to the specified target host:port.
|
|
|
*/
|
|
@@ -155,6 +171,8 @@ public class HAAdmin extends Configured implements Tool {
|
|
|
return transitionToActive(argv);
|
|
|
} else if ("-transitionToStandby".equals(cmd)) {
|
|
|
return transitionToStandby(argv);
|
|
|
+ } else if ("-getServiceState".equals(cmd)) {
|
|
|
+ return getServiceState(argv);
|
|
|
} else if ("-checkHealth".equals(cmd)) {
|
|
|
return checkHealth(argv);
|
|
|
} else if ("-help".equals(cmd)) {
|
|
@@ -182,7 +200,7 @@ public class HAAdmin extends Configured implements Tool {
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
- errOut .println(cmd + " [" + usageInfo.args + "]: " + usageInfo.help);
|
|
|
+ errOut.println(cmd + " [" + usageInfo.args + "]: " + usageInfo.help);
|
|
|
return 1;
|
|
|
}
|
|
|
|