You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by al...@apache.org on 2014/05/26 14:23:06 UTC
git commit: AMBARI-5892. Create mapper for apps endpoint of Slider
apps view (alexantonenko)
Repository: ambari
Updated Branches:
refs/heads/trunk 572e2a3c1 -> 0bbf2f32a
AMBARI-5892. Create mapper for apps endpoint of Slider apps view (alexantonenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/0bbf2f32
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/0bbf2f32
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/0bbf2f32
Branch: refs/heads/trunk
Commit: 0bbf2f32ababbc20790da60fa672d82a2e0e8740
Parents: 572e2a3
Author: Alex Antonenko <hi...@gmail.com>
Authored: Mon May 26 15:20:45 2014 +0300
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Mon May 26 15:20:45 2014 +0300
----------------------------------------------------------------------
.../resources/ui/app/assets/data/apps/apps.json | 43 +++++++
.../src/main/resources/ui/app/initialize.js | 1 +
.../ui/app/mappers/slider_apps_mapper.js | 88 ++++++++++++++
.../main/resources/ui/app/models/slider_app.js | 120 ++-----------------
.../ui/app/models/slider_app_component.js | 33 +----
.../resources/ui/app/models/slider_app_type.js | 53 +-------
.../ui/app/models/slider_app_type_component.js | 48 +-------
.../ui/app/models/slider_quick_link.js | 33 +----
.../resources/ui/app/models/typed_property.js | 33 +----
.../src/main/resources/ui/app/routes/main.js | 4 +-
.../resources/ui/app/templates/slider_apps.hbs | 2 +-
.../resources/ui/app/views/slider_apps_view.js | 9 +-
12 files changed, 158 insertions(+), 309 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/0bbf2f32/contrib/views/slider/src/main/resources/ui/app/assets/data/apps/apps.json
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/app/assets/data/apps/apps.json b/contrib/views/slider/src/main/resources/ui/app/assets/data/apps/apps.json
new file mode 100644
index 0000000..920cf51
--- /dev/null
+++ b/contrib/views/slider/src/main/resources/ui/app/assets/data/apps/apps.json
@@ -0,0 +1,43 @@
+{
+ "href" : "http://162.216.149.12:8080/api/v1/views/SLIDER/versions/1.0.0/instances/SLIDER_1/apps?fields=*",
+ "items" : [
+ {
+ "href" : "http://162.216.149.12:8080/api/v1/views/SLIDER/versions/1.0.0/instances/SLIDER_1/apps/1400598543383_1",
+ "components" : null,
+ "configs" : null,
+ "diagnostics" : "",
+ "endTime" : 1400598813404,
+ "id" : "1400598543383_1",
+ "instance_name" : "SLIDER_1",
+ "jmx" : null,
+ "name" : "PigLatin:pigSmoke.sh",
+ "startTime" : 1400598788691,
+ "state" : "FINISHED",
+ "type" : "MAPREDUCE",
+ "urls" : null,
+ "user" : "ambari-qa",
+ "version" : "1.0.0",
+ "view_name" : "SLIDER",
+ "yarnId" : "application_1400598543383_0001"
+ },
+ {
+ "href" : "http://162.216.149.12:8080/api/v1/views/SLIDER/versions/1.0.0/instances/SLIDER_1/apps/1400598543383_2",
+ "components" : null,
+ "configs" : null,
+ "diagnostics" : "",
+ "endTime" : 1400598890254,
+ "id" : "1400598543383_2",
+ "instance_name" : "SLIDER_1",
+ "jmx" : null,
+ "name" : "word count",
+ "startTime" : 1400598861646,
+ "state" : "FINISHED",
+ "type" : "MAPREDUCE",
+ "urls" : null,
+ "user" : "ambari-qa",
+ "version" : "1.0.0",
+ "view_name" : "SLIDER",
+ "yarnId" : "application_1400598543383_0002"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/0bbf2f32/contrib/views/slider/src/main/resources/ui/app/initialize.js
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/app/initialize.js b/contrib/views/slider/src/main/resources/ui/app/initialize.js
index f0a25de..6da6267 100755
--- a/contrib/views/slider/src/main/resources/ui/app/initialize.js
+++ b/contrib/views/slider/src/main/resources/ui/app/initialize.js
@@ -86,6 +86,7 @@ App.initializer({
});
application.ApplicationStatusMapper.loop('load');
+ application.SliderAppsMapper.loop('load');
}
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/0bbf2f32/contrib/views/slider/src/main/resources/ui/app/mappers/slider_apps_mapper.js
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/app/mappers/slider_apps_mapper.js b/contrib/views/slider/src/main/resources/ui/app/mappers/slider_apps_mapper.js
new file mode 100644
index 0000000..48925fc
--- /dev/null
+++ b/contrib/views/slider/src/main/resources/ui/app/mappers/slider_apps_mapper.js
@@ -0,0 +1,88 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Mapper for SLIDER_1 status
+ * Save mapped data to App properties
+ * @type {App.Mapper}
+ */
+App.SliderAppsMapper = App.Mapper.createWithMixins(App.RunPeriodically, {
+
+ /**
+ * Url suffix
+ * Used with <code>App.urlPrefix</code>
+ * @type {string}
+ */
+ urlSuffix: 'apps/?fields=*',
+
+ /**
+ * Load data from <code>App.urlPrefix + this.urlSuffix</code> one time
+ * @method load
+ * @return {$.ajax}
+ */
+ load: function() {
+ var self = this,
+ url = App.get('testMode') ? '/data/apps/apps.json' : App.get('urlPrefix') + this.get('urlSuffix');
+
+ return $.ajax({
+ url: url,
+ dataType: 'json',
+ async: true,
+ success: function(data) {self.parse(data);}
+ });
+ },
+
+ /**
+ * Parse loaded data according to <code>map</code>
+ * Set <code>App</code> properties
+ * @param {object} data received from server data
+ * @method parse
+ */
+ parse: function(data) {
+ var apps = [];
+ var quickLinks = [];
+ quickLinks.push(
+ Ember.Object.create({
+ id: 'YARN application',
+ label: 'YARN application',
+ url: "http://"+window.location.hostname+":8088"
+ })
+ );
+ data.items.forEach(function(app) {
+ apps.push(
+ Ember.Object.create({
+ id: app.id,
+ index: app.id,
+ yarnId: app.yarnId,
+ name: app.name,
+ status: app.state,
+ user: app.user,
+ started: app.startTime,
+ ended: app.endTime,
+ appType: app.type,
+ diagnostics: app.diagnostics,
+ components: app.components,
+ quickLinks: ["YARN application"],
+ runtimeProperties: app.configs
+ })
+ );
+ });
+ App.SliderApp.store.pushMany('quickLink', quickLinks);
+ App.SliderApp.store.pushMany('sliderApp', apps);
+ }
+});
http://git-wip-us.apache.org/repos/asf/ambari/blob/0bbf2f32/contrib/views/slider/src/main/resources/ui/app/models/slider_app.js
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/app/models/slider_app.js b/contrib/views/slider/src/main/resources/ui/app/models/slider_app.js
index 133df38..e7ca7f3 100644
--- a/contrib/views/slider/src/main/resources/ui/app/models/slider_app.js
+++ b/contrib/views/slider/src/main/resources/ui/app/models/slider_app.js
@@ -54,9 +54,9 @@ App.SliderApp = DS.Model.extend({
ended: DS.attr('number'),
/**
- * @type {App.SliderAppType}
+ * @type {string}
*/
- appType: DS.belongsTo('sliderAppType'),
+ appType: DS.attr('string'),
/**
* @type {string}
@@ -145,113 +145,15 @@ App.SliderApp = DS.Model.extend({
});
-App.SliderApp.FIXTURES = [
- {
- id: 1,
- index: 'indx1',
- yarnId: 'y1',
- name: 'name1',
- status: 'FROZEN',
- user: 'u1',
- started: 1400132912,
- ended: 1400152912,
- appType: 1,
- diagnostics: 'd1',
- components: [3, 4, 5],
- quickLinks: [1, 2, 6],
- runtimeProperties: [1, 2, 3],
- configs: {
- global: {
- config1: 'value1',
- config2: 'value2',
- config3: 'value3',
- config4: 'value4'
- },
- 'hbase-site': {
- config1: 'value1',
- config2: 'value2',
- config3: 'value3',
- config4: 'value4',
- config5: 'value5'
- },
- another: {
- config6: 'value6',
- config7: 'value7',
- config8: 'value8',
- config9: 'value9'
- },
- another2: {
- config10: 'value10',
- config11: 'value11',
- config12: 'value12',
- config13: 'value13'
- }
- }
- },
- {
- id: 2,
- index: 'indx2',
- yarnId: 'y2',
- name: 'name2',
- status: 'RUNNING',
- user: 'u2',
- started: 1400132912,
- ended: 1400152912,
- appType: 2,
- diagnostics: 'd2',
- components: [1, 3],
- quickLinks: [4, 5, 6],
- runtimeProperties: [3, 4]
- },
- {
- id: 3,
- index: 'indx3',
- yarnId: 'y3',
- name: 'name3',
- status: 'Running',
- user: 'u3',
- started: 1400132912,
- ended: 1400152912,
- appType: 3,
- diagnostics: 'd3',
- components: [1],
- quickLinks: [1, 2, 4, 5, 6],
- runtimeProperties: [2, 3]
- },
- {
- id: 4,
- index: 'indx4',
- yarnId: 'y4',
- name: 'name4',
- status: 'Running',
- user: 'u4',
- started: 1400132912,
- ended: 1400152912,
- appType: 4,
- diagnostics: 'd4',
- components: [1, 2, 3, 4, 5],
- quickLinks: [4, 6],
- runtimeProperties: [1, 2, 3, 4, 5]
- },
- {
- id: 5,
- index: 'indx5',
- yarnId: 'y5',
- name: 'name5',
- status: 'Running',
- user: 'u5',
- started: 1400132912,
- ended: 1400152912,
- appType: 5,
- diagnostics: 'd5',
- components: [2, 5],
- quickLinks: [3, 4, 6],
- runtimeProperties: [1, 2, 3]
- }
-];
+App.SliderApp.FIXTURES = [];
App.SliderApp.Status = {
- running: "Running",
- frozen: "Frozen",
- destroyed: "Destroyed"
+ accepted: "ACCEPTED",
+ failed: "FAILED",
+ finished: "FINISHED",
+ killed: "KILLED",
+ new: "NEW",
+ new_saving: "NEW_SAVING",
+ running: "RUNNING" ,
+ submitted:"SUBMITTED"
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/0bbf2f32/contrib/views/slider/src/main/resources/ui/app/models/slider_app_component.js
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/app/models/slider_app_component.js b/contrib/views/slider/src/main/resources/ui/app/models/slider_app_component.js
index 2d70a13..6f759f7 100644
--- a/contrib/views/slider/src/main/resources/ui/app/models/slider_app_component.js
+++ b/contrib/views/slider/src/main/resources/ui/app/models/slider_app_component.js
@@ -36,35 +36,4 @@ App.SliderAppComponent = DS.Model.extend({
});
-App.SliderAppComponent.FIXTURES = [
- {
- id: 1,
- index: 'indx1',
- status: 'st1',
- host: 1
- },
- {
- id: 2,
- index: 'indx2',
- status: 'st1',
- host: 2
- },
- {
- id: 3,
- index: 'indx3',
- status: 'st3',
- host: 3
- },
- {
- id: 4,
- index: 'indx4',
- status: 'st4',
- host: 4
- },
- {
- id: 5,
- index: 'indx5',
- status: 'st5',
- host: 1
- }
-];
\ No newline at end of file
+App.SliderAppComponent.FIXTURES = [];
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/0bbf2f32/contrib/views/slider/src/main/resources/ui/app/models/slider_app_type.js
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/app/models/slider_app_type.js b/contrib/views/slider/src/main/resources/ui/app/models/slider_app_type.js
index eac4ae3..e3bf522 100644
--- a/contrib/views/slider/src/main/resources/ui/app/models/slider_app_type.js
+++ b/contrib/views/slider/src/main/resources/ui/app/models/slider_app_type.js
@@ -40,55 +40,4 @@ App.SliderAppType = DS.Model.extend({
});
-App.SliderAppType.FIXTURES = [
- {
- id: 1,
- index: 'indx1',
- displayName: 'Index 1',
- components: [1, 2],
- configs: {
- c1: 'v1',
- c2: 'b1'
- }
- },
- {
- id: 2,
- index: 'indx2',
- displayName: 'Index 2',
- components: [2, 4, 5],
- configs: {
- c1: 'v2',
- c2: 'b2'
- }
- },
- {
- id: 3,
- index: 'indx3',
- displayName: 'Index 3',
- components: [1, 2, 4],
- configs: {
- c1: 'v3',
- c2: 'b3'
- }
- },
- {
- id: 4,
- index: 'indx4',
- displayName: 'Index 4',
- components: [5],
- configs: {
- c1: 'v4',
- c2: 'b4'
- }
- },
- {
- id: 5,
- index: 'indx5',
- displayName: 'Index 5',
- components: [1, 2, 3, 4, 5],
- configs: {
- c1: 'v5',
- c2: 'b5'
- }
- }
-];
\ No newline at end of file
+App.SliderAppType.FIXTURES = [];
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/0bbf2f32/contrib/views/slider/src/main/resources/ui/app/models/slider_app_type_component.js
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/app/models/slider_app_type_component.js b/contrib/views/slider/src/main/resources/ui/app/models/slider_app_type_component.js
index 162e80f..4676d2c 100644
--- a/contrib/views/slider/src/main/resources/ui/app/models/slider_app_type_component.js
+++ b/contrib/views/slider/src/main/resources/ui/app/models/slider_app_type_component.js
@@ -50,50 +50,4 @@ App.SliderAppTypeComponent = DS.Model.extend({
});
-App.SliderAppTypeComponent.FIXTURES = [
- {
- id: 1,
- index: 'indx1',
- name: 'name1',
- displayName: 'Name 1',
- defaultNumInstances: 10,
- defaultYARNMemory: 1000,
- defaultYARNCPU: 2
- },
- {
- id: 2,
- index: 'indx2',
- name: 'name2',
- displayName: 'Name 2',
- defaultNumInstances: 10,
- defaultYARNMemory: 1000,
- defaultYARNCPU: 2
- },
- {
- id: 3,
- index: 'indx3',
- name: 'name3',
- displayName: 'Name 3',
- defaultNumInstances: 10,
- defaultYARNMemory: 1000,
- defaultYARNCPU: 2
- },
- {
- id: 4,
- index: 'indx4',
- name: 'name4',
- displayName: 'Name 4',
- defaultNumInstances: 10,
- defaultYARNMemory: 1000,
- defaultYARNCPU: 2
- },
- {
- id: 5,
- index: 'indx5',
- name: 'name5',
- displayName: 'Name 5',
- defaultNumInstances: 10,
- defaultYARNMemory: 1000,
- defaultYARNCPU: 2
- }
-];
\ No newline at end of file
+App.SliderAppTypeComponent.FIXTURES = [];
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/0bbf2f32/contrib/views/slider/src/main/resources/ui/app/models/slider_quick_link.js
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/app/models/slider_quick_link.js b/contrib/views/slider/src/main/resources/ui/app/models/slider_quick_link.js
index 2988125..d526ee7 100644
--- a/contrib/views/slider/src/main/resources/ui/app/models/slider_quick_link.js
+++ b/contrib/views/slider/src/main/resources/ui/app/models/slider_quick_link.js
@@ -30,35 +30,4 @@ App.QuickLink = DS.Model.extend({
});
-App.QuickLink.FIXTURES = [
- {
- id: 1,
- label: 'link1',
- url: 'url1'
- },
- {
- id: 2,
- label: 'link2',
- url: 'url2'
- },
- {
- id: 3,
- label: 'link3',
- url: 'url3'
- },
- {
- id: 4,
- label: 'link4',
- url: 'url4'
- },
- {
- id: 5,
- label: 'link5',
- url: 'url5'
- },
- {
- id: 6,
- label: 'YARN application',
- url: 'http://yarn_application_url'
- }
-];
\ No newline at end of file
+App.QuickLink.FIXTURES = [];
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/0bbf2f32/contrib/views/slider/src/main/resources/ui/app/models/typed_property.js
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/app/models/typed_property.js b/contrib/views/slider/src/main/resources/ui/app/models/typed_property.js
index 86c611d..3c7e919 100644
--- a/contrib/views/slider/src/main/resources/ui/app/models/typed_property.js
+++ b/contrib/views/slider/src/main/resources/ui/app/models/typed_property.js
@@ -35,35 +35,4 @@ App.TypedProperty = DS.Model.extend({
});
-App.TypedProperty.FIXTURES = [
- {
- id: 1,
- key: 'k1',
- value: 'v1',
- type: 'host'
- },
- {
- id: 2,
- key: 'k2',
- value: 'v2',
- type: 'host'
- },
- {
- id: 3,
- key: 'k3',
- value: 'v3',
- type: 'date'
- },
- {
- id: 4,
- key: 'k4',
- value: 'v4',
- type: 'date'
- },
- {
- id: 5,
- key: 'k5',
- value: 'v5',
- type: 'host'
- }
-];
\ No newline at end of file
+App.TypedProperty.FIXTURES = [];
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/0bbf2f32/contrib/views/slider/src/main/resources/ui/app/routes/main.js
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/app/routes/main.js b/contrib/views/slider/src/main/resources/ui/app/routes/main.js
index bef8692..07babda 100644
--- a/contrib/views/slider/src/main/resources/ui/app/routes/main.js
+++ b/contrib/views/slider/src/main/resources/ui/app/routes/main.js
@@ -31,7 +31,7 @@ App.IndexRoute = Ember.Route.extend({
App.SliderAppsRoute = Ember.Route.extend({
model: function () {
- return this.store.find('sliderApp');
+ return this.store.all('sliderApp');
},
actions: {
@@ -44,7 +44,7 @@ App.SliderAppsRoute = Ember.Route.extend({
App.SliderAppRoute = Ember.Route.extend({
model: function(params) {
- return this.store.find('sliderApp', params.slider_app_id);
+ return this.store.all('sliderApp', params.slider_app_id);
}
});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/0bbf2f32/contrib/views/slider/src/main/resources/ui/app/templates/slider_apps.hbs
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/app/templates/slider_apps.hbs b/contrib/views/slider/src/main/resources/ui/app/templates/slider_apps.hbs
index 024e638..2f16df1 100644
--- a/contrib/views/slider/src/main/resources/ui/app/templates/slider_apps.hbs
+++ b/contrib/views/slider/src/main/resources/ui/app/templates/slider_apps.hbs
@@ -57,7 +57,7 @@
<td>{{slider.status}}</td>
- <td>{{slider.appType.displayName}}</td>
+ <td>{{slider.appType}}</td>
<td>{{slider.user}}</td>
http://git-wip-us.apache.org/repos/asf/ambari/blob/0bbf2f32/contrib/views/slider/src/main/resources/ui/app/views/slider_apps_view.js
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/app/views/slider_apps_view.js b/contrib/views/slider/src/main/resources/ui/app/views/slider_apps_view.js
index caf9692..53252b7 100644
--- a/contrib/views/slider/src/main/resources/ui/app/views/slider_apps_view.js
+++ b/contrib/views/slider/src/main/resources/ui/app/views/slider_apps_view.js
@@ -22,9 +22,14 @@ App.SliderAppsView = App.TableView.extend({
statusList: [
"",
+ App.SliderApp.Status.accepted,
+ App.SliderApp.Status.failed,
+ App.SliderApp.Status.finished,
+ App.SliderApp.Status.killed,
+ App.SliderApp.Status.new,
+ App.SliderApp.Status.new_saving,
App.SliderApp.Status.running,
- App.SliderApp.Status.frozen,
- App.SliderApp.Status.destroyed,
+ App.SliderApp.Status.submitted
],
content: function () {