Repository: ambari
Updated Branches:
  refs/heads/branch-2.2 e016942d2 -> 3a11019c2


AMBARI-16074: Show number of PXFs Live widget on main dashboard (mithmatt)


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

Branch: refs/heads/branch-2.2
Commit: 3a11019c21104e05df12f2fa4e820e93f7da7c9a
Parents: e016942
Author: Matt <mmat...@pivotal.io>
Authored: Mon Apr 25 21:19:39 2016 -0700
Committer: Matt <mmat...@pivotal.io>
Committed: Mon Apr 25 21:19:39 2016 -0700

----------------------------------------------------------------------
 ambari-web/app/assets/test/tests.js             |   1 +
 .../app/mappers/components_state_mapper.js      |   5 +
 ambari-web/app/messages.js                      |   7 +-
 ambari-web/app/views.js                         |   1 +
 ambari-web/app/views/main/dashboard/widgets.js  |  19 +-
 .../main/dashboard/widgets/hawqsegment_live.js  |   6 +-
 .../views/main/dashboard/widgets/pxf_live.js    | 191 +++++++++++++++++++
 .../main/dashboard/widgets/pxf_live_test.js     |  69 +++++++
 8 files changed, 289 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/3a11019c/ambari-web/app/assets/test/tests.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/test/tests.js 
b/ambari-web/app/assets/test/tests.js
index f32ae68..f173e00 100644
--- a/ambari-web/app/assets/test/tests.js
+++ b/ambari-web/app/assets/test/tests.js
@@ -235,6 +235,7 @@ var files = ['test/init_model_test',
   'test/views/main/dashboard/widgets/node_managers_live_test',
   'test/views/main/dashboard/widgets/datanode_live_test',
   'test/views/main/dashboard/widgets/hawqsegment_live_test',
+  'test/views/main/dashboard/widgets/pxf_live_test',
   'test/views/main/dashboard/widgets/hbase_average_load_test',
   'test/views/main/dashboard/widgets/hbase_regions_in_transition_test',
   'test/views/main/dashboard/widgets/namenode_rpc_test',

http://git-wip-us.apache.org/repos/asf/ambari/blob/3a11019c/ambari-web/app/mappers/components_state_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/components_state_mapper.js 
b/ambari-web/app/mappers/components_state_mapper.js
index 755c0f5..96eb52b 100644
--- a/ambari-web/app/mappers/components_state_mapper.js
+++ b/ambari-web/app/mappers/components_state_mapper.js
@@ -65,6 +65,11 @@ App.componentsStateMapper = App.QuickDataMapper.create({
       hawq_segments_installed: 'INSTALLED_PATH',
       hawq_segments_total: 'TOTAL_PATH'
     },
+    'PXF': {
+      pxfs_started: 'STARTED_PATH',
+      pxfs_installed: 'INSTALLED_PATH',
+      pxfs_total: 'TOTAL_PATH'
+    },
     'HBASE_REGIONSERVER': {
       region_servers_started: 'STARTED_PATH',
       region_servers_installed: 'INSTALLED_PATH',

http://git-wip-us.apache.org/repos/asf/ambari/blob/3a11019c/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 2f844c6..d5cdf68 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -2518,6 +2518,7 @@ Em.I18n.translations = {
   'dashboard.widgets.error.invalid': 'Invalid! Enter a number between 0 - {0}',
   'dashboard.widgets.error.smaller': 'Threshold 1 should be smaller than 
threshold 2!',
   'dashboard.widgets.HawqSegmentUp': 'HAWQ Segments Live',
+  'dashboard.widgets.PxfUp': 'PXFs Live',
 
   'dashboard': {
     'widgets': {
@@ -2624,9 +2625,9 @@ Em.I18n.translations = {
   'dashboard.services.hbase.masterStarted':'Master Started',
   'dashboard.services.hbase.masterActivated':'Master Activated',
 
-  'dashboard.services.hawq.segments.started':'started',
-  'dashboard.services.hawq.segments.stopped':'stopped',
-  'dashboard.services.hawq.segments.total':'in total',
+  'dashboard.services.components.started':'started',
+  'dashboard.services.components.stopped':'stopped',
+  'dashboard.services.components.total':'in total',
 
   'dashboard.services.hive.clients':'Hive Clients',
   'dashboard.services.hive.client':'Hive Client',

http://git-wip-us.apache.org/repos/asf/ambari/blob/3a11019c/ambari-web/app/views.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views.js b/ambari-web/app/views.js
index 58df202..753f598 100644
--- a/ambari-web/app/views.js
+++ b/ambari-web/app/views.js
@@ -223,6 +223,7 @@ require('views/main/dashboard/widgets/namenode_cpu');
 require('views/main/dashboard/widgets/hdfs_capacity');
 require('views/main/dashboard/widgets/datanode_live');
 require('views/main/dashboard/widgets/hawqsegment_live');
+require('views/main/dashboard/widgets/pxf_live');
 require('views/main/dashboard/widgets/namenode_rpc');
 require('views/main/dashboard/widgets/metrics_memory');
 require('views/main/dashboard/widgets/metrics_network');

http://git-wip-us.apache.org/repos/asf/ambari/blob/3a11019c/ambari-web/app/views/main/dashboard/widgets.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/dashboard/widgets.js 
b/ambari-web/app/views/main/dashboard/widgets.js
index 52513bc..72f76bc 100644
--- a/ambari-web/app/views/main/dashboard/widgets.js
+++ b/ambari-web/app/views/main/dashboard/widgets.js
@@ -129,7 +129,8 @@ App.MainDashboardWidgetsView = Em.View.extend(App.UserPref, 
App.LocalStorage, Ap
       '17', '18', '19', '20', '23', // all yarn
       '21', // storm
       '22', // flume
-      '24' // hawq
+      '24', // hawq
+      '25' // pxf
     ]; // all in order
     var hiddenFull = [
       ['15', 'Region In Transition']
@@ -180,6 +181,12 @@ App.MainDashboardWidgetsView = 
Em.View.extend(App.UserPref, App.LocalStorage, Ap
         visibleFull = visibleFull.without(item);
       }, this);
     }
+    if (this.get('pxf_model') == null) {
+      var pxf = ['25'];
+      pxf.forEach(function (item) {
+        visibleFull = visibleFull.without(item);
+      }, this);
+    }
     var obj = this.get('initPrefObject');
     obj.set('visible', visibleFull);
     obj.set('hidden', hiddenFull);
@@ -201,6 +208,8 @@ App.MainDashboardWidgetsView = Em.View.extend(App.UserPref, 
App.LocalStorage, Ap
 
   hawq_model: null,
 
+  pxf_model: null,
+
   /**
    * List of visible widgets
    * @type {Ember.Enumerable}
@@ -393,7 +402,8 @@ App.MainDashboardWidgetsView = Em.View.extend(App.UserPref, 
App.LocalStorage, Ap
       yarn_model: ['17', '18', '19', '20', '23'],
       storm_model: ['21'],
       flume_model: ['22'],
-      hawq_model: ['24']
+      hawq_model: ['24'],
+      pxf_model: ['25']
     };
 
     // check each service, find out the newly added service and already 
deleted service
@@ -461,7 +471,8 @@ App.MainDashboardWidgetsView = Em.View.extend(App.UserPref, 
App.LocalStorage, Ap
       '21': App.SuperVisorUpView,
       '22': App.FlumeAgentUpView,
       '23': App.YARNLinksView,
-      '24': App.HawqSegmentUpView
+      '24': App.HawqSegmentUpView,
+      '25': App.PxfUpView
     }, id);
   },
 
@@ -478,7 +489,7 @@ App.MainDashboardWidgetsView = Em.View.extend(App.UserPref, 
App.LocalStorage, Ap
     visible: [],
     hidden: [],
     threshold: {1: [80, 90], 2: [85, 95], 3: [90, 95], 4: [80, 90], 5: [1000, 
3000], 6: [], 7: [], 8: [], 9: [], 10: [], 11: [], 12: [], 13: [70, 90], 14: 
[150, 250], 15: [3, 10], 16: [],
-      17: [70, 90], 18: [], 19: [50, 75], 20: [50, 75], 21: [85, 95], 22: [85, 
95], 23: [], 24: [75, 90]} // id:[thresh1, thresh2]
+      17: [70, 90], 18: [], 19: [50, 75], 20: [50, 75], 21: [85, 95], 22: [85, 
95], 23: [], 24: [75, 90], 25: [75, 90]} // id:[thresh1, thresh2]
   }),
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/3a11019c/ambari-web/app/views/main/dashboard/widgets/hawqsegment_live.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/dashboard/widgets/hawqsegment_live.js 
b/ambari-web/app/views/main/dashboard/widgets/hawqsegment_live.js
index f67ab47..79e6ca6 100644
--- a/ambari-web/app/views/main/dashboard/widgets/hawqsegment_live.js
+++ b/ambari-web/app/views/main/dashboard/widgets/hawqsegment_live.js
@@ -30,9 +30,9 @@ App.HawqSegmentUpView = App.TextDashboardWidgetView.extend({
 
   hiddenInfo: function () {
     var result = [];
-    result.pushObject(this.get('hawqSegmentsStarted') + ' ' + 
Em.I18n.t('dashboard.services.hawq.segments.started'));
-    result.pushObject(this.get('hawqSegmentsInstalled') + ' ' + 
Em.I18n.t('dashboard.services.hawq.segments.stopped'));
-    result.pushObject(this.get('hawqSegmentsTotal')+ ' ' + 
Em.I18n.t('dashboard.services.hawq.segments.total'));
+    result.pushObject(this.get('hawqSegmentsStarted') + ' ' + 
Em.I18n.t('dashboard.services.components.started'));
+    result.pushObject(this.get('hawqSegmentsInstalled') + ' ' + 
Em.I18n.t('dashboard.services.components.stopped'));
+    result.pushObject(this.get('hawqSegmentsTotal')+ ' ' + 
Em.I18n.t('dashboard.services.components.total'));
     return result;
   }.property('hawqSegmentsStarted', 'hawqSegmentsInstalled', 
'hawqSegmentsTotal'),
   hiddenInfoClass: "hidden-info-three-line",

http://git-wip-us.apache.org/repos/asf/ambari/blob/3a11019c/ambari-web/app/views/main/dashboard/widgets/pxf_live.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/dashboard/widgets/pxf_live.js 
b/ambari-web/app/views/main/dashboard/widgets/pxf_live.js
new file mode 100644
index 0000000..95b994d
--- /dev/null
+++ b/ambari-web/app/views/main/dashboard/widgets/pxf_live.js
@@ -0,0 +1,191 @@
+/**
+ * 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.
+ */
+
+var App = require('app');
+
+App.PxfUpView = App.TextDashboardWidgetView.extend({
+
+  title: Em.I18n.t('dashboard.widgets.PxfUp'),
+  id: '25',
+
+  isPieChart: false,
+  isText: true,
+  isProgressBar: false,
+  model_type: 'pxf',
+
+  hiddenInfo: function () {
+    var result = [];
+    result.pushObject(this.get('pxfsStarted') + ' ' + 
Em.I18n.t('dashboard.services.components.started'));
+    result.pushObject(this.get('pxfsInstalled') + ' ' + 
Em.I18n.t('dashboard.services.components.stopped'));
+    result.pushObject(this.get('pxfsTotal')+ ' ' + 
Em.I18n.t('dashboard.services.components.total'));
+    return result;
+  }.property('pxfsStarted', 'pxfsInstalled', 'pxfsTotal'),
+  hiddenInfoClass: "hidden-info-three-line",
+
+  thresh1: 75,
+  thresh2: 90,
+  maxValue: 100,
+
+  pxfsStarted: function () {
+    if (Em.isNone(this.get('model.pxfsStarted'))) {
+      return Em.I18n.t('services.service.summary.notAvailable');
+    }
+    return this.get('model.pxfsStarted');
+  }.property('model.pxfsStarted'),
+
+  pxfsInstalled: function () {
+    if (Em.isNone(this.get('model.pxfsInstalled'))) {
+      return Em.I18n.t('services.service.summary.notAvailable');
+    }
+    return this.get('model.pxfsInstalled');
+  }.property('model.pxfsInstalled'),
+
+
+  pxfsTotal: function () {
+    if (Em.isNone(this.get('model.pxfsTotal'))) {
+      return Em.I18n.t('services.service.summary.notAvailable');
+    }
+    return this.get('model.pxfsTotal');
+  }.property('model.pxfsTotal'),
+
+  data: function () {
+    if (Em.isNone(this.get('model.pxfsStarted')) || 
Em.isNone(this.get('model.pxfsTotal'))) {
+      return null;
+    } else {
+      return ((this.get('pxfsStarted') / 
this.get('model.pxfsTotal')).toFixed(2)) * 100;
+    }
+  }.property('model.pxfsTotal', 'pxfsStarted'),
+
+  content: function () {
+    if (Em.isNone(this.get('model.pxfsStarted')) || 
Em.isNone(this.get('model.pxfsTotal'))) {
+      return Em.I18n.t('services.service.summary.notAvailable');
+    } else {
+      return this.get('pxfsStarted') + "/" + this.get('model.pxfsTotal');
+    }
+  }.property('model.pxfsTotal', 'pxfsStarted'),
+
+  editWidget: function (event) {
+    var parent = this;
+    var max_tmp =  parseFloat(parent.get('maxValue'));
+    var configObj = Ember.Object.create({
+      thresh1: parent.get('thresh1') + '',
+      thresh2: parent.get('thresh2') + '',
+      hintInfo: Em.I18n.t('dashboard.widgets.hintInfo.hint1').format(max_tmp),
+      isThresh1Error: false,
+      isThresh2Error: false,
+      errorMessage1: "",
+      errorMessage2: "",
+      maxValue: max_tmp,
+      observeNewThresholdValue: function () {
+        var thresh1 = this.get('thresh1');
+        var thresh2 = this.get('thresh2');
+        if (thresh1.trim() != "") {
+          if (isNaN(thresh1) || thresh1 > max_tmp || thresh1 < 0){
+            this.set('isThresh1Error', true);
+            this.set('errorMessage1', 'Invalid! Enter a number between 0 - ' + 
max_tmp);
+          } else if ( this.get('isThresh2Error') === false && 
parseFloat(thresh2)<= parseFloat(thresh1)) {
+            this.set('isThresh1Error', true);
+            this.set('errorMessage1', 'Threshold 1 should be smaller than 
threshold 2 !');
+          } else {
+            this.set('isThresh1Error', false);
+            this.set('errorMessage1', '');
+          }
+        } else {
+          this.set('isThresh1Error', true);
+          this.set('errorMessage1', 'This is required');
+        }
+
+        if (thresh2.trim() != "") {
+          if (isNaN(thresh2) || thresh2 > max_tmp || thresh2 < 0) {
+            this.set('isThresh2Error', true);
+            this.set('errorMessage2', 'Invalid! Enter a number between 0 - ' + 
max_tmp);
+          } else {
+            this.set('isThresh2Error', false);
+            this.set('errorMessage2', '');
+          }
+        } else {
+          this.set('isThresh2Error', true);
+          this.set('errorMessage2', 'This is required');
+        }
+
+        // update the slider handles and color
+        if (this.get('isThresh1Error') === false && this.get('isThresh2Error') 
=== false) {
+          $("#slider-range").slider('values', 0 , parseFloat(thresh1));
+          $("#slider-range").slider('values', 1 , parseFloat(thresh2));
+        }
+      }.observes('thresh1', 'thresh2')
+
+    });
+
+    var browserVerion = this.getInternetExplorerVersion();
+    App.ModalPopup.show({
+      header: Em.I18n.t('dashboard.widgets.popupHeader'),
+      classNames: [ 'sixty-percent-width-modal-edit-widget'],
+      bodyClass: Ember.View.extend({
+        templateName: require('templates/main/dashboard/edit_widget_popup'),
+        configPropertyObj: configObj
+      }),
+      primary: Em.I18n.t('common.apply'),
+      onPrimary: function () {
+        configObj.observeNewThresholdValue();
+        if (!configObj.isThresh1Error && !configObj.isThresh2Error) {
+          parent.set('thresh1', parseFloat(configObj.get('thresh1')) );
+          parent.set('thresh2', parseFloat(configObj.get('thresh2')) );
+          if (!App.get('testMode')) {
+            var big_parent = parent.get('parentView');
+            big_parent.getUserPref(big_parent.get('persistKey'));
+            var oldValue = big_parent.get('currentPrefObject');
+            oldValue.threshold[parseInt(parent.id)] = 
[configObj.get('thresh1'), configObj.get('thresh2')];
+            big_parent.postUserPref(big_parent.get('persistKey'),oldValue);
+          }
+          this.hide();
+        }
+      },
+
+      didInsertElement: function () {
+        var handlers = [configObj.get('thresh1'), configObj.get('thresh2')];
+        var colors = [App.healthStatusRed, App.healthStatusOrange, 
App.healthStatusGreen]; //color red, orange, green
+
+        if (browserVerion == -1 || browserVerion > 9) {
+          configObj.set('isIE9', false);
+          configObj.set('isGreenOrangeRed', false);
+          $("#slider-range").slider({
+            range: true,
+            min: 0,
+            max: max_tmp,
+            values: handlers,
+            create: function (event, ui) {
+              parent.updateColors(handlers, colors);
+            },
+            slide: function (event, ui) {
+              parent.updateColors(ui.values, colors);
+              configObj.set('thresh1', ui.values[0] + '');
+              configObj.set('thresh2', ui.values[1] + '');
+            },
+            change: function (event, ui) {
+              parent.updateColors(ui.values, colors);
+            }
+          });
+        } else {
+          configObj.set('isIE9', true);
+          configObj.set('isGreenOrangeRed', false);
+        }
+      }
+    });
+  }
+});

http://git-wip-us.apache.org/repos/asf/ambari/blob/3a11019c/ambari-web/test/views/main/dashboard/widgets/pxf_live_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/dashboard/widgets/pxf_live_test.js 
b/ambari-web/test/views/main/dashboard/widgets/pxf_live_test.js
new file mode 100644
index 0000000..d1992ca
--- /dev/null
+++ b/ambari-web/test/views/main/dashboard/widgets/pxf_live_test.js
@@ -0,0 +1,69 @@
+/**
+ * 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.
+ */
+
+var App = require('app');
+
+require('views/main/dashboard/widget');
+require('views/main/dashboard/widgets/text_widget');
+require('views/main/dashboard/widgets/pxf_live');
+
+describe('App.PxfUpView', function() {
+
+  var tests = [
+    {
+      data: 100,
+      e: {
+        isRed: false,
+        isOrange: false,
+        isGreen: true
+      }
+    },
+    {
+      data: 0,
+      e: {
+        isRed: true,
+        isOrange: false,
+        isGreen: false
+      }
+    },
+    {
+      data: 80,
+      e: {
+        isRed: false,
+        isOrange: true,
+        isGreen: false
+      }
+    }
+  ];
+
+  tests.forEach(function(test) {
+    describe('', function() {
+      var hawqSegmentUpView = App.HawqSegmentUpView.create({model_type:null, 
data: test.data, content: test.data.toString()});
+      it('shows red', function() {
+        expect(hawqSegmentUpView.get('isRed')).to.equal(test.e.isRed);
+      });
+      it('shows orange', function() {
+        expect(hawqSegmentUpView.get('isOrange')).to.equal(test.e.isOrange);
+      });
+      it('shows green', function() {
+        expect(hawqSegmentUpView.get('isGreen')).to.equal(test.e.isGreen);
+      });
+    });
+  });
+
+});

Reply via email to