SLIDER-568 Refactor slider diagnostic options (Thomas Liu)
diff --git a/slider-core/src/main/java/org/apache/slider/client/SliderClient.java b/slider-core/src/main/java/org/apache/slider/client/SliderClient.java
index 0a985ed..706a34b 100644
--- a/slider-core/src/main/java/org/apache/slider/client/SliderClient.java
+++ b/slider-core/src/main/java/org/apache/slider/client/SliderClient.java
@@ -2627,17 +2627,15 @@
try {
if (diagnosticArgs.client) {
actionDiagnosticClient(diagnosticArgs);
- } else if (SliderUtils.isSet(diagnosticArgs.application)) {
+ } else if (diagnosticArgs.application) {
actionDiagnosticApplication(diagnosticArgs);
- } else if (SliderUtils.isSet(diagnosticArgs.slider)) {
- actionDiagnosticSlider(diagnosticArgs);
} else if (diagnosticArgs.yarn) {
actionDiagnosticYarn(diagnosticArgs);
} else if (diagnosticArgs.credentials) {
actionDiagnosticCredentials();
- } else if (SliderUtils.isSet(diagnosticArgs.all)) {
+ } else if (diagnosticArgs.all) {
actionDiagnosticAll(diagnosticArgs);
- } else if (SliderUtils.isSet(diagnosticArgs.level)) {
+ } else if (diagnosticArgs.level) {
actionDiagnosticIntelligent(diagnosticArgs);
} else {
// it's an unknown option
@@ -2656,8 +2654,11 @@
// not using member variable clustername because we want to place
// application name after --application option and member variable
// cluster name has to be put behind action
- String clusterName = diagnosticArgs.level;
-
+ String clusterName = diagnosticArgs.name;
+ if(SliderUtils.isUnset(clusterName)){
+ throw new BadCommandArgumentsException("application name must be provided with --name option");
+ }
+
try {
SliderUtils.validateClientConfigFile();
log.info("Slider-client.xml is accessible");
@@ -2684,18 +2685,19 @@
if (imagePath == null) {
ApplicationReport appReport = findInstance(clusterName);
Path path1 = sliderFileSystem.getTempPathForCluster(clusterName);
+
Path subPath = new Path(path1, appReport.getApplicationId().toString()
- + "/am");
+ + "/agent");
imagePath = subPath.toString();
}
try {
- SliderUtils.validateHDFSFile(sliderFileSystem, imagePath);
+ SliderUtils.validateHDFSFile(sliderFileSystem, imagePath + "/" + AGENT_TAR);
log.info("Slider agent package is properly installed");
} catch (FileNotFoundException e) {
- log.error("can not find agent package: {}", e);
+ log.error("can not find agent package: " + e.toString());
return;
} catch (IOException e) {
- log.error("can not open agent package: {}", e, e);
+ log.error("can not open agent package: " + e.toString());
return;
}
String pkgTarballPath = instanceDefinition.getAppConfOperations()
@@ -2716,8 +2718,6 @@
private void actionDiagnosticAll(ActionDiagnosticArgs diagnosticArgs)
throws IOException, YarnException {
// assign application name from param to each sub diagnostic function
- diagnosticArgs.application = diagnosticArgs.all;
- diagnosticArgs.slider = diagnosticArgs.all;
actionDiagnosticClient(diagnosticArgs);
actionDiagnosticApplication(diagnosticArgs);
actionDiagnosticSlider(diagnosticArgs);
@@ -2792,7 +2792,10 @@
// not using member variable clustername because we want to place
// application name after --application option and member variable
// cluster name has to be put behind action
- String clusterName = diagnosticArgs.slider;
+ String clusterName = diagnosticArgs.name;
+ if(SliderUtils.isUnset(clusterName)){
+ throw new BadCommandArgumentsException("application name must be provided with --name option");
+ }
SliderClusterOperations clusterOperations;
AggregateConf instanceDefinition = null;
try {
@@ -2814,7 +2817,7 @@
ApplicationReport appReport = findInstance(clusterName);
Path path1 = sliderFileSystem.getTempPathForCluster(clusterName);
Path subPath = new Path(path1, appReport.getApplicationId().toString()
- + "/am");
+ + "/agent");
imagePath = subPath.toString();
}
log.info("The path of slider agent tarball on HDFS is: " + imagePath);
@@ -2825,7 +2828,10 @@
// not using member variable clustername because we want to place
// application name after --application option and member variable
// cluster name has to be put behind action
- String clusterName = diagnosticArgs.application;
+ String clusterName = diagnosticArgs.name;
+ if(SliderUtils.isUnset(clusterName)){
+ throw new BadCommandArgumentsException("application name must be provided with --name option");
+ }
SliderClusterOperations clusterOperations;
AggregateConf instanceDefinition = null;
try {
diff --git a/slider-core/src/main/java/org/apache/slider/common/params/ActionDiagnosticArgs.java b/slider-core/src/main/java/org/apache/slider/common/params/ActionDiagnosticArgs.java
index d54aa8e..9feeea4 100644
--- a/slider-core/src/main/java/org/apache/slider/common/params/ActionDiagnosticArgs.java
+++ b/slider-core/src/main/java/org/apache/slider/common/params/ActionDiagnosticArgs.java
@@ -8,22 +8,22 @@
commandDescription = SliderActions.DESCRIBE_ACTION_DIAGNOSTIC)
public class ActionDiagnosticArgs extends AbstractActionArgs {
- @Override
- public String getActionName() {
- return SliderActions.ACTION_DIAGNOSTICS;
- }
-
+ @Override
+ public String getActionName() {
+ return SliderActions.ACTION_DIAGNOSTICS;
+ }
+
+ @Parameter(names = {ARG_NAME},
+ description = "the name of the running application")
+ public String name;
+
@Parameter(names = {ARG_CLIENT},
description = "print configuration of the slider client")
public boolean client = false;
- @Parameter(names = {ARG_SLIDER},
- description = "print configuration of the running slider app master")
- public String slider;
-
@Parameter(names = {ARG_APPLICATION},
description = "print configuration of the running application")
- public String application;
+ public boolean application;
@Parameter(names = {ARG_VERBOSE},
description = "print out information in details")
@@ -39,11 +39,11 @@
@Parameter(names = {ARG_ALL},
description = "print all of the information above")
- public String all;
+ public boolean all;
@Parameter(names = {ARG_LEVEL},
description = "diagnose each slider configuration one by one")
- public String level;
+ public boolean level;
/**
* Get the min #of params expected