Repository: incubator-slider
Updated Branches:
  refs/heads/develop 586acb62e -> fdaae7eed


SLIDER-568 Refactor slider diagnostic options (Thomas Liu)


Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/a133d12e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/a133d12e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/a133d12e

Branch: refs/heads/develop
Commit: a133d12efaa23e1b225bd9f5e9dfefbdb311a9d9
Parents: c288cdd
Author: tedyu <[email protected]>
Authored: Sun Oct 26 08:47:43 2014 -0700
Committer: tedyu <[email protected]>
Committed: Sun Oct 26 08:47:43 2014 -0700

----------------------------------------------------------------------
 .../org/apache/slider/client/SliderClient.java  | 38 +++++++++++---------
 .../common/params/ActionDiagnosticArgs.java     | 24 ++++++-------
 2 files changed, 34 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/a133d12e/slider-core/src/main/java/org/apache/slider/client/SliderClient.java
----------------------------------------------------------------------
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 @@ public class SliderClient extends 
AbstractSliderLaunchedService implements RunSe
     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 @@ public class SliderClient extends 
AbstractSliderLaunchedService implements RunSe
     // 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 @@ public class SliderClient extends 
AbstractSliderLaunchedService implements RunSe
       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 @@ public class SliderClient extends 
AbstractSliderLaunchedService implements RunSe
   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 @@ public class SliderClient extends 
AbstractSliderLaunchedService implements RunSe
     // 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 @@ public class SliderClient extends 
AbstractSliderLaunchedService implements RunSe
       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 @@ public class SliderClient extends 
AbstractSliderLaunchedService implements RunSe
     // 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 {

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/a133d12e/slider-core/src/main/java/org/apache/slider/common/params/ActionDiagnosticArgs.java
----------------------------------------------------------------------
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 @@ import com.beust.jcommander.Parameters;
   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 @@ public class ActionDiagnosticArgs extends 
AbstractActionArgs {
        
          @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

Reply via email to