ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From atk...@apache.org
Subject [ambari] branch trunk updated: AMBARI-23309 YARN cluster memory graph is not loading in Ambari 2.6
Date Tue, 27 Mar 2018 13:24:17 GMT
This is an automated email from the ASF dual-hosted git repository.

atkach pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/trunk by this push:
     new b40a1af  AMBARI-23309 YARN cluster memory graph is not loading in Ambari 2.6
b40a1af is described below

commit b40a1af2d3ed7df250613eda09a33ff5162002d5
Author: Andrii Tkach <atkach@apache.org>
AuthorDate: Wed Mar 21 13:54:47 2018 +0200

    AMBARI-23309 YARN cluster memory graph is not loading in Ambari 2.6
---
 .../service/widgets/create/step2_controller.js     |  9 ++++-
 .../app/mixins/common/widgets/widget_mixin.js      |  2 +-
 ambari-web/test/mixins/common/widget_mixin_test.js | 45 ++++++++++++++++++++++
 3 files changed, 53 insertions(+), 3 deletions(-)

diff --git a/ambari-web/app/controllers/main/service/widgets/create/step2_controller.js b/ambari-web/app/controllers/main/service/widgets/create/step2_controller.js
index 8b1045a..15cb627 100644
--- a/ambari-web/app/controllers/main/service/widgets/create/step2_controller.js
+++ b/ambari-web/app/controllers/main/service/widgets/create/step2_controller.js
@@ -405,9 +405,14 @@ App.WidgetWizardStep2Controller = Em.Controller.extend({
             metricObj.host_component_criteria = element.hostComponentCriteria;
           }
           metrics.push(metricObj);
-
         }
-        value += element.name;
+        if (element.isOperator) {
+          // operators should have spaces around in order to differentiate them when symbol
is a part of metric name
+          // e.g "metric-a" and "metric1 - metric2"
+          value += " " + element.name + " ";
+        } else {
+          value += element.name;
+        }
       }, this);
       value += '}';
     }
diff --git a/ambari-web/app/mixins/common/widgets/widget_mixin.js b/ambari-web/app/mixins/common/widgets/widget_mixin.js
index 1b1de93..3b438f8 100644
--- a/ambari-web/app/mixins/common/widgets/widget_mixin.js
+++ b/ambari-web/app/mixins/common/widgets/widget_mixin.js
@@ -42,7 +42,7 @@ App.WidgetMixin = Ember.Mixin.create({
    * @type {RegExp}
    * @const
    */
-  VALUE_NAME_REGEX: /(\w+\s+\w+)?[\w\.\,\-\:\=\[\]]+/g,
+  VALUE_NAME_REGEX: /[^(\s+\-\*\/\\+\s+)+](\w+\s+\w+)?[\w\.\,\-\:\=\[\]]*/g,
 
   /**
    * @type {string}
diff --git a/ambari-web/test/mixins/common/widget_mixin_test.js b/ambari-web/test/mixins/common/widget_mixin_test.js
index 48c7c3b..fb8c5d0 100644
--- a/ambari-web/test/mixins/common/widget_mixin_test.js
+++ b/ambari-web/test/mixins/common/widget_mixin_test.js
@@ -32,6 +32,51 @@ describe('App.WidgetMixin', function () {
     mixinObject.destroy();
   });
 
+
+  describe('#VALUE_NAME_REGEX', function() {
+    var testCases = [
+      {
+        data: 'a-a - b',
+        expected: ['a-a', 'b']
+      },
+      {
+        data: 'a.a / b',
+        expected: ['a.a', 'b']
+      },
+      {
+        data: 'a=a * b',
+        expected: ['a=a', 'b']
+      },
+      {
+        data: 'a,a + b',
+        expected: ['a,a', 'b']
+      },
+      {
+        data: 'a:a + b',
+        expected: ['a:a', 'b']
+      },
+      {
+        data: 'a[a] + b',
+        expected: ['a[a]', 'b']
+      },
+      {
+        data: 'Total tasks - Free tasks',
+        expected: ['Total tasks', 'Free tasks']
+      },
+      {
+        data: 'Hadoop:service=azure-file-system,name=AzureFileSystemMetrics4 - 1',
+        expected: ['Hadoop:service=azure-file-system,name=AzureFileSystemMetrics4', '1']
+      }
+    ];
+    var regex = mixinClass.create().get('VALUE_NAME_REGEX');
+
+    testCases.forEach(function(test) {
+      it(test.data + ' should match ' + test.expected, function() {
+        expect(test.data.match(regex)).to.be.eql(test.expected);
+      });
+    });
+  });
+
   describe('#loadMetrics()', function () {
     beforeEach(function () {
       this.mock = sinon.stub(mixinObject, 'getRequestData');

-- 
To stop receiving notification emails like this one, please contact
atkach@apache.org.

Mime
View raw message