You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by xi...@apache.org on 2015/12/03 22:46:23 UTC

ambari git commit: AMBARI-14168. Tolerate null hostname for a AMBARI_SERVER_ACTION with no hostname for task.(xiwang)

Repository: ambari
Updated Branches:
  refs/heads/branch-2.2 10543dd33 -> e32f9bfdb


AMBARI-14168. Tolerate null hostname for a AMBARI_SERVER_ACTION with no hostname for task.(xiwang)


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

Branch: refs/heads/branch-2.2
Commit: e32f9bfdba8548b00a6e9e95179fe1ed532eda52
Parents: 10543dd
Author: Xi Wang <xi...@apache.org>
Authored: Wed Dec 2 18:32:32 2015 -0800
Committer: Xi Wang <xi...@apache.org>
Committed: Thu Dec 3 13:45:05 2015 -0800

----------------------------------------------------------------------
 ambari-web/app/messages.js                      |  2 +
 ambari-web/app/utils/host_progress_popup.js     | 26 +++++++-
 .../test/utils/host_progress_popup_test.js      | 62 +++++++++++++++-----
 3 files changed, 72 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/e32f9bfd/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index d263be3..9396965 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -326,6 +326,8 @@ Em.I18n.translations = {
   'hostPopup.noServicesToShow':'No services to show',
   'hostPopup.noHostsToShow':'No hosts to show',
   'hostPopup.noTasksToShow':'No tasks to show',
+  'hostPopup.Tasks.role.ambariServerAction':'AMBARI_SERVER_ACTION',
+  'hostPopup.Hosts.ambariServerHost':'Ambari Server Host',
   'hostPopup.status.category.all':'All ({0})',
   'hostPopup.status.category.pending':'Pending ({0})',
   'hostPopup.status.category.inProgress':'In Progress ({0})',

http://git-wip-us.apache.org/repos/asf/ambari/blob/e32f9bfd/ambari-web/app/utils/host_progress_popup.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/host_progress_popup.js b/ambari-web/app/utils/host_progress_popup.js
index d730f79..edc1691 100644
--- a/ambari-web/app/utils/host_progress_popup.js
+++ b/ambari-web/app/utils/host_progress_popup.js
@@ -271,6 +271,24 @@ App.HostPopup = Em.Object.create({
   },
 
   /**
+   * Get hostname to display: return "n/a" for safety measure if hostname is null
+   * return "Ambari Server Host" if task role is AMBARI_SERVER_ACTION
+   * @param {Array} tasks
+   * @param {String} hostname
+   * @return {String} hostname to display
+   */
+  getDisplayHostname: function (hostname, tasks) {
+    if ((!hostname || hostname == "null") && tasks.someProperty('Tasks.role', Em.I18n.t('hostPopup.Tasks.role.ambariServerAction'))) {
+      // change hostname to "ambari server host"
+      return Em.I18n.t('hostPopup.Hosts.ambariServerHost');
+    } else if ((!hostname || hostname == "null")){
+      // just for safety measure
+      return Em.I18n.t('common.na');
+    }
+    return hostname;
+  },
+
+  /**
    * Count number of operations for select box options
    * @param {Object[]} obj
    * @param {Object[]} categories
@@ -574,8 +592,12 @@ App.HostPopup = Em.Object.create({
           var hostInfo = Ember.Object.create({
             name: hostName,
             publicName: _host.publicName,
+            publicNameDisplay: function () {
+              return self.getDisplayHostname(this.get('publicName'), tasks);
+            }.property('publicName'),
             displayName: function () {
-              return this.get('name').length < 43 ? this.get('name') : (this.get('name').substr(0, 40) + '...');
+              var name = self.getDisplayHostname(this.get('name'), tasks);
+              return name.length < 43 ? name : (name.substr(0, 40) + '...');
             }.property('name'),
             progress: 0,
             status: App.format.taskStatus("PENDING"),
@@ -1128,7 +1150,7 @@ App.HostPopup = Em.Object.create({
             tasksInfo.pushObject(this.get("controller").createTask(_task));
           }, this);
           if (tasksInfo.length) {
-            this.get("controller").set("popupHeaderName", event.context.publicName);
+            this.get("controller").set("popupHeaderName", event.context.get('publicNameDisplay'));
             this.get("controller").set("currentHostName", event.context.publicName);
           }
           this.switchLevel("TASKS_LIST");

http://git-wip-us.apache.org/repos/asf/ambari/blob/e32f9bfd/ambari-web/test/utils/host_progress_popup_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/host_progress_popup_test.js b/ambari-web/test/utils/host_progress_popup_test.js
index 5a7ab02..244a87d 100644
--- a/ambari-web/test/utils/host_progress_popup_test.js
+++ b/ambari-web/test/utils/host_progress_popup_test.js
@@ -101,53 +101,63 @@ describe('App.HostPopup', function () {
         {
           Tasks: {
             status: 'COMPLETED',
-            id: 2
+            id: 2,
+            role: "NAMENODE"
           }
         },
         {
           Tasks: {
             status: 'COMPLETED',
-            id: 3
+            id: 3,
+            role: "NAMENODE"
           }
         },
         {
           Tasks: {
             status: 'COMPLETED',
-            id: 1
+            id: 1,
+            role: "NAMENODE"
           }
         }
       ],
       m: 'All COMPLETED',
       r: 'SUCCESS',
       p: 100,
-      ids: [1,2,3]
+      ids: [1,2,3],
+      name: "host1",
+      displayHostNameResult: "host1"
     },
     {
       t: [
         {
           Tasks: {
             status: 'FAILED',
-            id: 2
+            id: 2,
+            role: "NAMENODE"
           }
         },
         {
           Tasks: {
             status: 'COMPLETED',
-            id: 1
+            id: 1,
+            role: "NAMENODE"
           }
         }
         ,
         {
           Tasks: {
             status: 'COMPLETED',
-            id: 3
+            id: 3,
+            role: "NAMENODE"
           }
         }
       ],
       m: 'One FAILED',
       r: 'FAILED',
       p: 100,
-      ids: [1,2,3]
+      ids: [1,2,3],
+      name: "",
+      displayHostNameResult: "n/a"
     },
     {
       t: [
@@ -167,47 +177,57 @@ describe('App.HostPopup', function () {
       m: 'One ABORTED',
       r: 'ABORTED',
       p: 100,
-      ids: [1,2]
+      ids: [1,2],
+      name: null,
+      displayHostNameResult: "n/a"
     },
     {
       t: [
         {
           Tasks: {
             status: 'TIMEDOUT',
-            id: 3
+            id: 3,
+            role: "NAMENODE"
           }
         },
         {
           Tasks: {
             status: 'COMPLETED',
-            id: 1
+            id: 1,
+            role: "AMBARI_SERVER_ACTION"
           }
         }
       ],
       m: 'One TIMEDOUT',
       r: 'TIMEDOUT',
       p: 100,
-      ids: [1,3]
+      ids: [1,3],
+      name: "host2",
+      displayHostNameResult: "host2"
     },
     {
       t: [
         {
           Tasks: {
             status: 'IN_PROGRESS',
-            id: 1
+            id: 1,
+            role: "NAMENODE"
           }
         },
         {
           Tasks: {
             status: 'COMPLETED',
-            id: 2
+            id: 2,
+            role: "AMBARI_SERVER_ACTION"
           }
         }
       ],
       m: 'One IN_PROGRESS',
       r: 'IN_PROGRESS',
       p: 68,
-      ids: [1,2]
+      ids: [1,2],
+      name: null,
+      displayHostNameResult: "Ambari Server Host"
     },
     {
       t: [
@@ -227,7 +247,9 @@ describe('App.HostPopup', function () {
       m: 'Something else',
       r: 'PENDING',
       p: 55,
-      ids: [2,3]
+      ids: [2,3],
+      name: undefined,
+      displayHostNameResult: "n/a"
     }
   ];
 
@@ -361,6 +383,14 @@ describe('App.HostPopup', function () {
     });
   });
 
+  describe('#getDisplayHostname', function() {
+    test_tasks.forEach(function(test_task) {
+      it(test_task.m, function() {
+        expect(App.HostPopup.getDisplayHostname(test_task.name, test_task.t)).to.equal(test_task.displayHostNameResult);
+      });
+    });
+  });
+
   describe('#isAbortableByStatus', function () {
     statusCases.forEach(function (item) {
       it('should return ' + item.result + ' for ' + item.status, function () {