ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanhur...@apache.org
Subject [22/29] git commit: AMBARI-7347. Cannot view slider instance in API due to exception (srimanth)
Date Wed, 17 Sep 2014 12:34:12 GMT
AMBARI-7347. Cannot view slider instance in API due to exception (srimanth)


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

Branch: refs/heads/branch-alerts-dev
Commit: e83ab259c582cbe7ab2e9a9cf7505e6d4f364afb
Parents: fe890e9
Author: Srimanth Gunturi <sgunturi@hortonworks.com>
Authored: Tue Sep 16 15:12:50 2014 -0700
Committer: Srimanth Gunturi <sgunturi@hortonworks.com>
Committed: Tue Sep 16 15:12:57 2014 -0700

----------------------------------------------------------------------
 contrib/views/slider/pom.xml                    |  2 +-
 .../slider/SliderAppTypesResourceProvider.java  |  6 +++--
 .../slider/SliderAppsViewControllerImpl.java    | 28 +++++++++++++++-----
 .../ui/app/controllers/slider_controller.js     |  1 -
 .../src/main/resources/ui/app/helpers/ajax.js   |  6 ++++-
 5 files changed, 32 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/e83ab259/contrib/views/slider/pom.xml
----------------------------------------------------------------------
diff --git a/contrib/views/slider/pom.xml b/contrib/views/slider/pom.xml
index 82d27bb..8c33c93 100644
--- a/contrib/views/slider/pom.xml
+++ b/contrib/views/slider/pom.xml
@@ -551,7 +551,7 @@
 			</resource>
 			<resource>
 				<targetPath>WEB-INF/lib</targetPath>
-				<filtering>true</filtering>
+				<filtering>false</filtering>
 				<directory>lib</directory>
 				<includes>
 					<include>slider-agent.tar.gz</include>

http://git-wip-us.apache.org/repos/asf/ambari/blob/e83ab259/contrib/views/slider/src/main/java/org/apache/ambari/view/slider/SliderAppTypesResourceProvider.java
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/java/org/apache/ambari/view/slider/SliderAppTypesResourceProvider.java
b/contrib/views/slider/src/main/java/org/apache/ambari/view/slider/SliderAppTypesResourceProvider.java
index e696016..725c18a 100644
--- a/contrib/views/slider/src/main/java/org/apache/ambari/view/slider/SliderAppTypesResourceProvider.java
+++ b/contrib/views/slider/src/main/java/org/apache/ambari/view/slider/SliderAppTypesResourceProvider.java
@@ -75,8 +75,10 @@ public class SliderAppTypesResourceProvider implements
 		Set<SliderAppType> appSet = new HashSet<SliderAppType>();
 			List<SliderAppType> sliderAppTypes = sliderController.getSliderAppTypes(request
 			    .getPropertyIds());
-			for (SliderAppType app : sliderAppTypes)
-				appSet.add(app);
+            if (sliderAppTypes != null) {
+              for (SliderAppType app : sliderAppTypes)
+                appSet.add(app);
+            }
 		return appSet;
 	}
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/e83ab259/contrib/views/slider/src/main/java/org/apache/ambari/view/slider/SliderAppsViewControllerImpl.java
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/java/org/apache/ambari/view/slider/SliderAppsViewControllerImpl.java
b/contrib/views/slider/src/main/java/org/apache/ambari/view/slider/SliderAppsViewControllerImpl.java
index 04533ee..f3c3087 100644
--- a/contrib/views/slider/src/main/java/org/apache/ambari/view/slider/SliderAppsViewControllerImpl.java
+++ b/contrib/views/slider/src/main/java/org/apache/ambari/view/slider/SliderAppsViewControllerImpl.java
@@ -26,6 +26,8 @@ import java.io.InputStream;
 import java.lang.reflect.Field;
 import java.security.PrivilegedExceptionAction;
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -447,9 +449,20 @@ public class SliderAppsViewControllerImpl implements SliderAppsViewController
{
     return yarnConfig;
   }
 
+  private boolean areViewParametersSet() {
+    String hdfsPath = viewContext.getProperties().get(PROPERTY_HDFS_ADDRESS);
+    String rmAddress = viewContext.getProperties().get(PROPERTY_YARN_RM_ADDRESS);
+    String rmSchedulerAddress = viewContext.getProperties().get(PROPERTY_YARN_RM_SCHEDULER_ADDRESS);
+    String zkQuorum = viewContext.getProperties().get(PROPERTY_ZK_QUOROM);
+    return hdfsPath!=null && rmAddress!=null && rmSchedulerAddress!=null
&& zkQuorum!=null;
+  }
+
   @Override
   public List<SliderApp> getSliderApps(final Set<String> properties)
       throws YarnException, IOException, InterruptedException {
+    if (!areViewParametersSet()) {
+      return Collections.emptyList();
+    }
     return invokeSliderClientRunnable(new SliderClientContextRunnable<List<SliderApp>>()
{
       @Override
       public List<SliderApp> run(SliderClient sliderClient)
@@ -514,6 +527,9 @@ public class SliderAppsViewControllerImpl implements SliderAppsViewController
{
   @Override
   public List<SliderAppType> getSliderAppTypes(Set<String> properties) {
     if (appTypes == null) {
+      if (!areViewParametersSet()) {
+        return Collections.emptyList();
+      }
       appTypes = loadAppTypes();
     }
     return appTypes;
@@ -637,7 +653,8 @@ public class SliderAppsViewControllerImpl implements SliderAppsViewController
{
   public String createSliderApp(JsonObject json) throws IOException,
       YarnException, InterruptedException {
     if (json.has("name") && json.has("typeConfigs")
-        && json.has("typeComponents")) {
+        && json.has("typeComponents") && json.has("typeName")) {
+      final String appType = json.get("typeName").getAsString();
       final String appName = json.get("name").getAsString();
       JsonObject configs = json.get("typeConfigs").getAsJsonObject();
       JsonArray componentsArray = json.get("typeComponents").getAsJsonArray();
@@ -672,16 +689,15 @@ public class SliderAppsViewControllerImpl implements SliderAppsViewController
{
       saveAppConfigs(configs, componentsArray, appConfigJsonFile);
       saveAppResources(componentsArray, resourcesJsonFile);
 
-      String hdfsLocation = viewContext.getProperties().get(PROPERTY_HDFS_ADDRESS);
       final ActionCreateArgs createArgs = new ActionCreateArgs();
       createArgs.template = appConfigJsonFile;
       createArgs.resources = resourcesJsonFile;
-      createArgs.image = new Path(hdfsLocation
-          + "/user/yarn/agent/slider-agent.tar.gz");
       
       final ActionInstallPackageArgs installArgs = new ActionInstallPackageArgs();
-      installArgs.name = appName;
-      installArgs.packageURI = getAppsFolderPath() + "/" + configs.get("application.def").getAsString();
+      SliderAppType sliderAppType = getSliderAppType(appType, null);
+      String localAppPackageFileName = sliderAppType.getTypePackageFileName();
+      installArgs.name = appType;
+      installArgs.packageURI = getAppsFolderPath() + "/" + localAppPackageFileName;
       installArgs.replacePkg = true;
 
       return invokeSliderClientRunnable(new SliderClientContextRunnable<String>() {

http://git-wip-us.apache.org/repos/asf/ambari/blob/e83ab259/contrib/views/slider/src/main/resources/ui/app/controllers/slider_controller.js
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/app/controllers/slider_controller.js
b/contrib/views/slider/src/main/resources/ui/app/controllers/slider_controller.js
index a5eec96..51fd057 100644
--- a/contrib/views/slider/src/main/resources/ui/app/controllers/slider_controller.js
+++ b/contrib/views/slider/src/main/resources/ui/app/controllers/slider_controller.js
@@ -152,7 +152,6 @@ App.SliderController = Ember.Controller.extend(App.RunPeriodically, {
   getClusterNameSuccessCallback: function (data, opt, params) {
     var clusterName = Em.get(data.items[0], 'Clusters.cluster_name');
     App.set('clusterName', clusterName);
-    App.ApplicationStatusMapper.loop('load');
     this.loadComponentHost({componentName: "GANGLIA_SERVER", callback: "loadGangliaHostSuccessCallback"});
     this.loadComponentHost({componentName: "NAGIOS_SERVER", callback: "loadNagiosHostSuccessCallback"});
     this.loadComponentHost({componentName: "ZOOKEEPER_SERVER", callback: "setZookeeperQuorum"});

http://git-wip-us.apache.org/repos/asf/ambari/blob/e83ab259/contrib/views/slider/src/main/resources/ui/app/helpers/ajax.js
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/app/helpers/ajax.js b/contrib/views/slider/src/main/resources/ui/app/helpers/ajax.js
index 3da0624..0a14842 100644
--- a/contrib/views/slider/src/main/resources/ui/app/helpers/ajax.js
+++ b/contrib/views/slider/src/main/resources/ui/app/helpers/ajax.js
@@ -32,7 +32,11 @@ var urls = {
 
   'slider.getViewParams': {
     real: '',
-    mock: '/data/resource/slider-properties.json'
+    mock: '/data/resource/slider-properties.json',
+    headers: {
+      Accept: "text/plain; charset=utf-8",
+      "Content-Type": "text/plain; charset=utf-8"
+    }
   },
 
   'mapper.applicationTypes': {


Mime
View raw message