Repository: ambari
Updated Branches:
  refs/heads/trunk 01b86400d -> c1fd867e2


AMBARI-9059 Show Upgrade progress in top nav. (ababiichuk)


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

Branch: refs/heads/trunk
Commit: c1fd867e29d629b79a9c08f171e7eb9778673e00
Parents: 39aeeb0
Author: aBabiichuk <[email protected]>
Authored: Fri Jan 9 15:03:11 2015 +0200
Committer: aBabiichuk <[email protected]>
Committed: Fri Jan 9 15:41:00 2015 +0200

----------------------------------------------------------------------
 ambari-web/app/app.js                           |  17 ++
 .../background_operations/list_on_start.json    | 237 +++++++++++++++++--
 .../global/background_operations_controller.js  |  13 +
 ambari-web/app/messages.js                      |   2 +
 ambari-web/app/styles/application.less          |  47 ++++
 ambari-web/app/templates/application.hbs        |   8 +
 .../global/background_operations_test.js        |  34 +++
 7 files changed, 340 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/c1fd867e/ambari-web/app/app.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/app.js b/ambari-web/app/app.js
index 2f12795..3466f28 100644
--- a/ambari-web/app/app.js
+++ b/ambari-web/app/app.js
@@ -48,6 +48,23 @@ module.exports = Em.Application.create({
   upgradeState: 'INIT',
 
   /**
+   * flag is true when upgrade process is running
+   * @returns {boolean}
+   */
+  upgradeInProgress: function() {
+    return ["IN_PROGRESS"].contains(this.get('upgradeState'));
+  }.property('upgradeState'),
+
+  /**
+   * flag is true when upgrade process is waiting for user action
+   * to procced, retry, perform manual steps etc.
+   * @returns {boolean}
+   */
+  upgradeHolding: function() {
+    return this.get('upgradeState').contains("HOLDING");
+  }.property('upgradeState'),
+
+  /**
    * compute user access rights by permission type
    * types:
    *  - ADMIN

http://git-wip-us.apache.org/repos/asf/ambari/blob/c1fd867e/ambari-web/app/assets/data/background_operations/list_on_start.json
----------------------------------------------------------------------
diff --git 
a/ambari-web/app/assets/data/background_operations/list_on_start.json 
b/ambari-web/app/assets/data/background_operations/list_on_start.json
index 57a974c..7d47c15 100644
--- a/ambari-web/app/assets/data/background_operations/list_on_start.json
+++ b/ambari-web/app/assets/data/background_operations/list_on_start.json
@@ -1,55 +1,256 @@
 {
-  "href" : 
"http://192.168.56.101:8080/api/v1/clusters/perf/requests?to=end&page_size=10&fields=Requests";,
+  "href" : 
"http://162.216.151.112:8080/api/v1/clusters/c1/requests?to=end&page_size=10&fields=Requests&_=1420804171828";,
+  "itemTotal" : "10",
   "items" : [
     {
-      "href" : "http://192.168.56.101:8080/api/v1/clusters/c1/requests/12";,
+      "href" : "http://162.216.151.112:8080/api/v1/clusters/c1/requests/17";,
       "Requests" : {
         "aborted_task_count" : 0,
         "cluster_name" : "c1",
-        "completed_task_count" : 2,
-        "create_time" : 1414410974460,
-        "end_time" : 1414411113883,
+        "completed_task_count" : 3,
+        "create_time" : 1420732929053,
+        "end_time" : 1420733166162,
         "exclusive" : false,
         "failed_task_count" : 0,
-        "id" : 12,
+        "id" : 17,
         "inputs" : null,
         "operation_level" : null,
         "progress_percent" : 100.0,
         "queued_task_count" : 0,
-        "request_context" : "Install Services",
+        "request_context" : "Distribute repositories/install packages",
         "request_schedule" : null,
         "request_status" : "COMPLETED",
         "resource_filters" : [ ],
-        "start_time" : 1414410974489,
-        "task_count" : 2,
+        "start_time" : 1420732929071,
+        "task_count" : 3,
         "timed_out_task_count" : 0,
         "type" : "INTERNAL_REQUEST"
       }
     },
     {
-      "href" : "http://192.168.56.101:8080/api/v1/clusters/c1/requests/13";,
+      "href" : "http://162.216.151.112:8080/api/v1/clusters/c1/requests/18";,
       "Requests" : {
         "aborted_task_count" : 0,
         "cluster_name" : "c1",
-        "completed_task_count" : 2,
-        "create_time" : 1414411114097,
-        "end_time" : 1414411129173,
+        "completed_task_count" : 3,
+        "create_time" : 1420741144265,
+        "end_time" : 1420741162446,
         "exclusive" : false,
         "failed_task_count" : 0,
-        "id" : 13,
+        "id" : 18,
         "inputs" : null,
         "operation_level" : null,
         "progress_percent" : 100.0,
         "queued_task_count" : 0,
-        "request_context" : "Start Added Services",
+        "request_context" : "Distribute repositories/install packages",
         "request_schedule" : null,
         "request_status" : "COMPLETED",
         "resource_filters" : [ ],
-        "start_time" : 1414411114179,
-        "task_count" : 2,
+        "start_time" : 1420741144295,
+        "task_count" : 3,
+        "timed_out_task_count" : 0,
+        "type" : "INTERNAL_REQUEST"
+      }
+    },
+    {
+      "href" : "http://162.216.151.112:8080/api/v1/clusters/c1/requests/19";,
+      "Requests" : {
+        "aborted_task_count" : 20,
+        "cluster_name" : "c1",
+        "completed_task_count" : 21,
+        "create_time" : 1420741278556,
+        "end_time" : 1420742042708,
+        "exclusive" : false,
+        "failed_task_count" : 1,
+        "id" : 19,
+        "inputs" : null,
+        "operation_level" : null,
+        "progress_percent" : 100.0,
+        "queued_task_count" : 0,
+        "request_context" : "Upgrading to 2.2.4.3-885",
+        "request_schedule" : null,
+        "request_status" : "FAILED",
+        "resource_filters" : [ ],
+        "start_time" : 1420741278615,
+        "task_count" : 21,
+        "timed_out_task_count" : 0,
+        "type" : "INTERNAL_REQUEST"
+      }
+    },
+    {
+      "href" : "http://162.216.151.112:8080/api/v1/clusters/c1/requests/20";,
+      "Requests" : {
+        "aborted_task_count" : 20,
+        "cluster_name" : "c1",
+        "completed_task_count" : 21,
+        "create_time" : 1420742881366,
+        "end_time" : 1420742911600,
+        "exclusive" : false,
+        "failed_task_count" : 1,
+        "id" : 20,
+        "inputs" : null,
+        "operation_level" : null,
+        "progress_percent" : 100.0,
+        "queued_task_count" : 0,
+        "request_context" : "Upgrading to 2.2.0.1-885",
+        "request_schedule" : null,
+        "request_status" : "FAILED",
+        "resource_filters" : [ ],
+        "start_time" : 1420742881426,
+        "task_count" : 21,
+        "timed_out_task_count" : 0,
+        "type" : "INTERNAL_REQUEST"
+      }
+    },
+    {
+      "href" : "http://162.216.151.112:8080/api/v1/clusters/c1/requests/21";,
+      "Requests" : {
+        "aborted_task_count" : 20,
+        "cluster_name" : "c1",
+        "completed_task_count" : 20,
+        "create_time" : 1420743882836,
+        "end_time" : 1420801978445,
+        "exclusive" : false,
+        "failed_task_count" : 0,
+        "id" : 21,
+        "inputs" : null,
+        "operation_level" : null,
+        "progress_percent" : 98.57142857142857,
+        "queued_task_count" : 0,
+        "request_context" : "Upgrading to 2.2.0.1-885",
+        "request_schedule" : null,
+        "request_status" : "HOLDING_FAILED",
+        "resource_filters" : [ ],
+        "start_time" : 1420743882894,
+        "task_count" : 21,
+        "timed_out_task_count" : 0,
+        "type" : "INTERNAL_REQUEST"
+      }
+    },
+    {
+      "href" : "http://162.216.151.112:8080/api/v1/clusters/c1/requests/22";,
+      "Requests" : {
+        "aborted_task_count" : 0,
+        "cluster_name" : "c1",
+        "completed_task_count" : 3,
+        "create_time" : 1420801929946,
+        "end_time" : 1420801992902,
+        "exclusive" : false,
+        "failed_task_count" : 0,
+        "id" : 22,
+        "inputs" : null,
+        "operation_level" : null,
+        "progress_percent" : 100.0,
+        "queued_task_count" : 0,
+        "request_context" : "Distribute repositories/install packages",
+        "request_schedule" : null,
+        "request_status" : "COMPLETED",
+        "resource_filters" : [ ],
+        "start_time" : 1420801978494,
+        "task_count" : 3,
+        "timed_out_task_count" : 0,
+        "type" : "INTERNAL_REQUEST"
+      }
+    },
+    {
+      "href" : "http://162.216.151.112:8080/api/v1/clusters/c1/requests/23";,
+      "Requests" : {
+        "aborted_task_count" : 20,
+        "cluster_name" : "c1",
+        "completed_task_count" : 21,
+        "create_time" : 1420802322402,
+        "end_time" : 1420802372784,
+        "exclusive" : false,
+        "failed_task_count" : 1,
+        "id" : 23,
+        "inputs" : null,
+        "operation_level" : null,
+        "progress_percent" : 100.0,
+        "queued_task_count" : 0,
+        "request_context" : "Upgrading to 2.2.0-2041",
+        "request_schedule" : null,
+        "request_status" : "FAILED",
+        "resource_filters" : [ ],
+        "start_time" : 1420802322463,
+        "task_count" : 21,
+        "timed_out_task_count" : 0,
+        "type" : "INTERNAL_REQUEST"
+      }
+    },
+    {
+      "href" : "http://162.216.151.112:8080/api/v1/clusters/c1/requests/24";,
+      "Requests" : {
+        "aborted_task_count" : 0,
+        "cluster_name" : "c1",
+        "completed_task_count" : 3,
+        "create_time" : 1420802446657,
+        "end_time" : 1420802467535,
+        "exclusive" : false,
+        "failed_task_count" : 0,
+        "id" : 24,
+        "inputs" : null,
+        "operation_level" : null,
+        "progress_percent" : 100.0,
+        "queued_task_count" : 0,
+        "request_context" : "Distribute repositories/install packages",
+        "request_schedule" : null,
+        "request_status" : "COMPLETED",
+        "resource_filters" : [ ],
+        "start_time" : 1420802446679,
+        "task_count" : 3,
+        "timed_out_task_count" : 0,
+        "type" : "INTERNAL_REQUEST"
+      }
+    },
+    {
+      "href" : "http://162.216.151.112:8080/api/v1/clusters/c1/requests/25";,
+      "Requests" : {
+        "aborted_task_count" : 20,
+        "cluster_name" : "c1",
+        "completed_task_count" : 21,
+        "create_time" : 1420802506244,
+        "end_time" : 1420802526532,
+        "exclusive" : false,
+        "failed_task_count" : 1,
+        "id" : 25,
+        "inputs" : null,
+        "operation_level" : null,
+        "progress_percent" : 100.0,
+        "queued_task_count" : 0,
+        "request_context" : "Upgrading to 2.2.0-2041",
+        "request_schedule" : null,
+        "request_status" : "FAILED",
+        "resource_filters" : [ ],
+        "start_time" : 1420802506371,
+        "task_count" : 21,
+        "timed_out_task_count" : 0,
+        "type" : "INTERNAL_REQUEST"
+      }
+    },
+    {
+      "href" : "http://162.216.151.112:8080/api/v1/clusters/c1/requests/26";,
+      "Requests" : {
+        "aborted_task_count" : 0,
+        "cluster_name" : "c1",
+        "completed_task_count" : 9,
+        "create_time" : 1420802576635,
+        "end_time" : -1,
+        "exclusive" : false,
+        "failed_task_count" : 2,
+        "id" : 26,
+        "inputs" : null,
+        "operation_level" : null,
+        "progress_percent" : 42.857142857142854,
+        "queued_task_count" : 0,
+        "request_context" : "Upgrading to 2.2.1.0-2191",
+        "request_schedule" : null,
+        "request_status" : "FAILED",
+        "resource_filters" : [ ],
+        "start_time" : 1420802576700,
+        "task_count" : 21,
         "timed_out_task_count" : 0,
         "type" : "INTERNAL_REQUEST"
       }
     }
   ]
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/c1fd867e/ambari-web/app/controllers/global/background_operations_controller.js
----------------------------------------------------------------------
diff --git 
a/ambari-web/app/controllers/global/background_operations_controller.js 
b/ambari-web/app/controllers/global/background_operations_controller.js
index e6461d6..328575f 100644
--- a/ambari-web/app/controllers/global/background_operations_controller.js
+++ b/ambari-web/app/controllers/global/background_operations_controller.js
@@ -189,6 +189,16 @@ App.BackgroundOperationsController = Em.Controller.extend({
   },
 
   /**
+   * returns true if it's upgrade equest
+   * use this flag to exclude upgrade requests from bgo
+   * @param {object} request
+   * @returns {boolean}
+   */
+  isUpgradeRequest: function(request) {
+    var context = Em.get(request, 'Requests.request_context');
+    return context ? context.toLowerCase().contains('upgrading') : false;
+  },
+  /**
    * Prepare, received from server, requests for host component popup
    * @param data
    */
@@ -199,6 +209,9 @@ App.BackgroundOperationsController = Em.Controller.extend({
     var countGot = data.itemTotal;
    
     data.items.forEach(function (request) {
+      if (this.isUpgradeRequest(request)) {
+        return;
+      }
       var rq = this.get("services").findProperty('id', request.Requests.id);
       var isRunning = this.isRequestRunning(request);
       var requestParams = 
this.parseRequestContext(request.Requests.request_context);

http://git-wip-us.apache.org/repos/asf/ambari/blob/c1fd867e/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 947110e..e8dc05b 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -44,6 +44,8 @@ Em.I18n.translations = {
   'app.aboutAmbari.getInvolved': 'Get involved!',
   'app.aboutAmbari.version': 'Version',
   'app.aboutAmbari.licensed': 'Licensed under the Apache License, Version 2.0',
+  'app.upgrade.inProgress': 'Upgrade: In Process',
+  'app.upgrade.holding': 'Upgrade: Action Required',
 
   'apply':'apply',
   'and':'and',

http://git-wip-us.apache.org/repos/asf/ambari/blob/c1fd867e/ambari-web/app/styles/application.less
----------------------------------------------------------------------
diff --git a/ambari-web/app/styles/application.less 
b/ambari-web/app/styles/application.less
index 1d793ff..3410a1b 100644
--- a/ambari-web/app/styles/application.less
+++ b/ambari-web/app/styles/application.less
@@ -22,6 +22,25 @@
 @space-m: 10px;
 @space-l: 20px;
 
+@-webkit-keyframes orangePulse {
+  from { background-color: #fdb82f; }
+  50% { background-color: #fd910e; }
+  to { background-color: #fdb82f; }
+}
+
+@-moz-keyframes orangePulse {
+  from { background-color: #fdb82f; }
+  50% { background-color: #fd910e; }
+  to { background-color: #fdb82f; }
+}
+
+@keyframes orangePulse
+{
+  0% { background-color: #fdb82f; }
+  50% { background-color: #fd910e; }
+  100% { background-color: #fdb82f; }
+}
+
 @-webkit-keyframes greenPulse {
   from { background-color: #118fff; }
   50% { background-color: #006DCC; }
@@ -217,6 +236,34 @@ footer {
         animation-iteration-count: infinite;
       }
 
+      .upgrade-in-progress {
+        text-shadow: none;
+        background-color: #006DCC;
+        -webkit-animation-name: greenPulse;
+        -webkit-animation-duration: 1s;
+        -webkit-animation-iteration-count: infinite;
+        -moz-animation-name: greenPulse;
+        -moz-animation-duration: 1s;
+        -moz-animation-iteration-count: infinite;
+        animation-name: greenPulse;
+        animation-duration: 1s;
+        animation-iteration-count: infinite;
+      }
+
+      .upgrade-holding {
+        text-shadow: none;
+        background-color: @health-status-orange;
+        -webkit-animation-name: orangePulse;
+        -webkit-animation-duration: 1s;
+        -webkit-animation-iteration-count: infinite;
+        -moz-animation-name: orangePulse;
+        -moz-animation-duration: 1s;
+        -moz-animation-iteration-count: infinite;
+        animation-name: orangePulse;
+        animation-duration: 1s;
+        animation-iteration-count: infinite;
+      }
+
     }
     .top-nav-menu.nav {
       display: block;

http://git-wip-us.apache.org/repos/asf/ambari/blob/c1fd867e/ambari-web/app/templates/application.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/application.hbs 
b/ambari-web/app/templates/application.hbs
index bf123dd..7fc2606 100644
--- a/ambari-web/app/templates/application.hbs
+++ b/ambari-web/app/templates/application.hbs
@@ -44,6 +44,14 @@
                   {{allAlertsCount}} {{pluralize allAlertsCount 
singular="alert" plural="alerts"}}</span>
                 {{/if}}
               {{/with}}
+              {{#if App.upgradeInProgress}}
+                <span class="label upgrade-in-progress" {{action 
"openUpgradeDialog" target="App.router.mainAdminStackAndUpgradeController"}}>
+                  <i class="icon-cog"></i> {{t app.upgrade.inProgress}}</span>
+              {{/if}}
+              {{#if App.upgradeHolding}}
+                <span class="label upgrade-holding" {{action 
"openUpgradeDialog" target="App.router.mainAdminStackAndUpgradeController"}}>
+                  <i class="icon-pause"></i> {{t app.upgrade.holding}}</span>
+              {{/if}}
             </a>
           {{else}}
             <a class="logo"><img src="/img/logo-white.png" alt="Apache Ambari" 
title="Apache Ambari"></a>

http://git-wip-us.apache.org/repos/asf/ambari/blob/c1fd867e/ambari-web/test/controllers/global/background_operations_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/global/background_operations_test.js 
b/ambari-web/test/controllers/global/background_operations_test.js
index 5207040..51925b7 100644
--- a/ambari-web/test/controllers/global/background_operations_test.js
+++ b/ambari-web/test/controllers/global/background_operations_test.js
@@ -153,6 +153,25 @@ describe('App.BackgroundOperationsController', function () 
{
     });
   });
 
+  describe('#isUpgradeRequest', function() {
+
+    it('defines if request is upgrade task (true)', function() {
+      expect(controller.isUpgradeRequest({Requests: {request_context: 
"upgrading"}})).to.be.true;
+    });
+
+    it('defines if request is upgrade task (true - with uppercase)', 
function() {
+      expect(controller.isUpgradeRequest({Requests: {request_context: 
"UPGRADING"}})).to.be.true;
+    });
+
+    it('defines if request is upgrade task (false)', function() {
+      expect(controller.isUpgradeRequest({Requests: {request_context: 
"install"}})).to.be.false;
+    });
+
+    it('defines if request is upgrade task (false - invalid param)', 
function() {
+      expect(controller.isUpgradeRequest({Requests: {}})).to.be.false;
+    });
+  });
+
   describe('#callBackForMostRecent()', function () {
     it('No requests exists', function () {
       var data = {
@@ -184,6 +203,21 @@ describe('App.BackgroundOperationsController', function () 
{
       expect(controller.get("services").mapProperty('id')).to.eql([1]);
     });
 
+    it('One request that is excluded', function () {
+      var data = {
+        items: [
+          {
+            Requests: {
+              id: 1,
+              request_context: 'upgrading'
+            }
+          }
+        ]
+      };
+      controller.callBackForMostRecent(data);
+      expect(controller.get("allOperationsCount")).to.equal(0);
+      expect(controller.get("services").mapProperty('id')).to.eql([]);
+    });
 
     it('One running request', function () {
       var data = {

Reply via email to