ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From atk...@apache.org
Subject git commit: AMBARI-4166 Improve responsiveness on step 9 when deploy in progress. (atkach)
Date Wed, 25 Dec 2013 10:42:23 GMT
Updated Branches:
  refs/heads/branch-1.4.3 20907b405 -> f211f1372


AMBARI-4166 Improve responsiveness on step 9 when deploy in progress. (atkach)


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

Branch: refs/heads/branch-1.4.3
Commit: f211f13721323221469696ade55efd1eadb8bacd
Parents: 20907b4
Author: atkach <atkach@hortonworks.com>
Authored: Wed Dec 25 12:42:19 2013 +0200
Committer: atkach <atkach@hortonworks.com>
Committed: Wed Dec 25 12:42:19 2013 +0200

----------------------------------------------------------------------
 .../app/controllers/wizard/step8_controller.js  |   9 +-
 .../app/controllers/wizard/step9_controller.js  | 147 +++++++++----------
 ambari-web/test/installer/step9_test.js         |  46 +++---
 3 files changed, 92 insertions(+), 110 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/f211f137/ambari-web/app/controllers/wizard/step8_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step8_controller.js b/ambari-web/app/controllers/wizard/step8_controller.js
index c0373e5..450da90 100644
--- a/ambari-web/app/controllers/wizard/step8_controller.js
+++ b/ambari-web/app/controllers/wizard/step8_controller.js
@@ -1399,10 +1399,7 @@ App.WizardStep8Controller = Em.Controller.extend({
       this.ajax({
         type: 'POST',
         url: url,
-        data: JSON.stringify(data),
-        beforeSend: function () {
-          console.log('BeforeSend: registerHostsToComponent for ' + queryStr + ' and component
' + componentName);
-        }
+        data: JSON.stringify(data)
       });
     }, this);
   },
@@ -1739,7 +1736,6 @@ App.WizardStep8Controller = Em.Controller.extend({
     this.set('ajaxQueueLeft', this.get('ajaxQueue').length);
 
     this.set('ajaxBusy', true);
-    console.log('AJAX send ' + first.url);
     $.ajax(first);
 
   },
@@ -1833,10 +1829,7 @@ App.WizardStep8Controller = Em.Controller.extend({
         // console.log('Step8: Error message is: ' + request.responseText);
       },
       success: function (data) {
-        var jsonData = jQuery.parseJSON(data);
         console.log("TRACE: STep8 -> In success function");
-        console.log("TRACE: STep8 -> value of the url is: " + params.url);
-        console.log("TRACE: STep8 -> value of the received data is: " + jsonData);
       }
     }, params);
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/f211f137/ambari-web/app/controllers/wizard/step9_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step9_controller.js b/ambari-web/app/controllers/wizard/step9_controller.js
index 35bd222..a8e1489 100644
--- a/ambari-web/app/controllers/wizard/step9_controller.js
+++ b/ambari-web/app/controllers/wizard/step9_controller.js
@@ -49,23 +49,8 @@ App.WizardStep9Controller = Em.Controller.extend({
   numPolls: 1,
   POLL_INTERVAL: 4000,
 
-  status: function () {
-    if (this.get('hosts').someProperty('status', 'failed')) {
-      return 'failed';
-    }
-    if (this.get('hosts').someProperty('status', 'warning')) {
-      if (this.isStepFailed()) {
-        return 'failed';
-      } else {
-        return 'warning';
-      }
-    }
-    if(this.get('progress') == '100') {
-      this.set('isStepCompleted', true);
-      return 'success';
-    }
-    return 'info';
-  }.property('hosts.@each.status', 'progress'),
+  visibleHosts: [],
+  status: 'info',
 
   showRetry: function () {
     return this.get('content.cluster.status') == 'INSTALL FAILED';
@@ -112,19 +97,43 @@ App.WizardStep9Controller = Em.Controller.extend({
     return categories;
   }.property(),
   category: false,
-  visibleHosts: function(){
+
+  hostStatusObserver: function(){
+    Ember.run.once(this, 'hostStatusUpdates');
+  }.observes('hosts.@each.status'),
+
+  hostStatusUpdates: function () {
+    this.updateVisibleHosts();
+    this.updateStatus();
+  },
+
+  updateVisibleHosts: function () {
     var targetStatus = this.get('category.hostStatus');
-    var visibleHosts =  this.get('hosts').filter(function(_host) {
-      if (targetStatus == 'all') {
-        return true;
-      }
+    var visibleHosts = (targetStatus === 'all') ? this.get('hosts') : this.get('hosts').filter(function
(_host) {
       if (targetStatus == 'inProgress') {   // queued, pending, in_progress map to inProgress
         return (_host.get('status') !== 'success' && _host.get('status') !== 'failed'
&& _host.get('status') !== 'warning');
       }
       return (_host.get('status') == targetStatus);
     }, this);
-    return visibleHosts;
-  }.property('category', 'hosts.@each.status'),
+    this.set('visibleHosts', visibleHosts);
+  }.observes('category'),
+
+  updateStatus: function () {
+    var status = 'info';
+    if (this.get('hosts').someProperty('status', 'failed')) {
+      status = 'failed';
+    } else if (this.get('hosts').someProperty('status', 'warning')) {
+      if (this.isStepFailed()) {
+        status = 'failed';
+      } else {
+        status = 'warning';
+      }
+    } else if (this.get('progress') == '100') {
+      this.set('isStepCompleted', true);
+      status = 'success';
+    }
+    this.set('status', status);
+  }.observes('progress'),
 
   logTasksChangesCounter: 0,
 
@@ -199,7 +208,7 @@ App.WizardStep9Controller = Em.Controller.extend({
   loadStep: function () {
     console.log("TRACE: Loading step9: Install, Start and Test");
     this.clearStep();
-    this.renderHosts(this.loadHosts());
+    this.loadHosts();
   },
   /**
    * reset status and message of all hosts when retry install
@@ -214,33 +223,20 @@ App.WizardStep9Controller = Em.Controller.extend({
   },
 
   loadHosts: function () {
-    var hostInfo = this.get('content.hosts');
-    var hosts = new Ember.Set();
-    for (var index in hostInfo) {
-      var obj = Em.Object.create(hostInfo[index]);
-      obj.message = (obj.message) ? obj.message : 'Waiting';
-      obj.progress = 0;
-      obj.status = (obj.status) ? obj.status : 'info';
-      obj.tasks = [];
-      obj.logTasks = [];
-      hosts.add(obj);
+    var hosts = this.get('content.hosts');
+    for (var index in hosts) {
+      if (hosts[index].bootStatus === 'REGISTERED') {
+        var hostInfo = App.HostInfo.create({
+          name: hosts[index].name,
+          status: (hosts[index].status) ? hosts[index].status : 'info',
+          tasks: [],
+          logTasks: [],
+          message: (hosts[index].message) ? hosts[index].message : 'Waiting',
+          progress: 0
+        });
+        this.get('hosts').pushObject(hostInfo);
+      }
     }
-    return hosts.filterProperty('bootStatus', 'REGISTERED');
-  },
-
-  // sets this.hosts, where each element corresponds to a status and progress info on a host
-  renderHosts: function (hostsInfo) {
-    hostsInfo.forEach(function (_hostInfo) {
-      var hostInfo = App.HostInfo.create({
-        name: _hostInfo.name,
-        status: _hostInfo.status,
-        tasks: _hostInfo.tasks,
-        logTasks: _hostInfo.logTasks,
-        message: _hostInfo.message,
-        progress: _hostInfo.progress
-      });
-      this.get('hosts').pushObject(hostInfo);
-    }, this);
   },
 
   replacePolledData: function (polledData) {
@@ -450,7 +446,6 @@ App.WizardStep9Controller = Em.Controller.extend({
 
   // marks a host's status as "success" if all tasks are in COMPLETED state
   onSuccessPerHost: function (actions, contentHost) {
-    if (!actions) return;
     if (actions.everyProperty('Tasks.status', 'COMPLETED') && this.get('content.cluster.status')
=== 'INSTALLED') {
       contentHost.set('status', 'success');
     }
@@ -482,7 +477,6 @@ App.WizardStep9Controller = Em.Controller.extend({
   },
 
   onInProgressPerHost: function (actions, contentHost) {
-    if (!actions) return;
     var runningAction = actions.findProperty('Tasks.status', 'IN_PROGRESS');
     if (runningAction === undefined || runningAction === null) {
       runningAction = actions.findProperty('Tasks.status', 'QUEUED');
@@ -505,13 +499,14 @@ App.WizardStep9Controller = Em.Controller.extend({
   progressPerHost: function (actions, contentHost) {
     var progress = 0;
     var actionsPerHost = actions.length;
-    // TODO: consolidate to a single filter function for better performance
-    var completedActions = actions.filterProperty('Tasks.status', 'COMPLETED').length
-      + actions.filterProperty('Tasks.status', 'FAILED').length
-      + actions.filterProperty('Tasks.status', 'ABORTED').length
-      + actions.filterProperty('Tasks.status', 'TIMEDOUT').length;
-    var queuedActions = actions.filterProperty('Tasks.status', 'QUEUED').length;
-    var inProgressActions = actions.filterProperty('Tasks.status', 'IN_PROGRESS').length;
+    var completedActions = 0;
+    var queuedActions = 0;
+    var inProgressActions = 0;
+    actions.forEach(function (action) {
+      completedActions += +(['COMPLETED', 'FAILED', 'ABORTED', 'TIMEDOUT'].contains(action.Tasks.status));
+      queuedActions += +(action.Tasks.status === 'QUEUED');
+      inProgressActions += +(action.Tasks.status === 'IN_PROGRESS');
+    }, this);
     /** for the install phase (PENDING), % completed per host goes up to 33%; floor(100 /
3)
      * for the start phase (INSTALLED), % completed starts from 34%
      * when task in queued state means it's completed on 9%
@@ -667,15 +662,15 @@ App.WizardStep9Controller = Em.Controller.extend({
 
   // This is done at HostRole level.
   setLogTasksStatePerHost: function (tasksPerHost, host) {
-    if (!tasksPerHost) return;
     tasksPerHost.forEach(function (_task) {
       var task = host.logTasks.findProperty('Tasks.id', _task.Tasks.id);
       if (task) {
-        host.logTasks.removeObject(task);
+        task.Tasks.status = _task.Tasks.status;
+        task.Tasks.exit_code = _task.Tasks.exit_code;
+      } else {
+        host.logTasks.pushObject(_task);
       }
-      host.logTasks.pushObject(_task);
     }, this);
-    this.set('logTasksChangesCounter', this.get('logTasksChangesCounter') + 1);
   },
 
   parseHostInfo: function (polledData) {
@@ -695,19 +690,18 @@ App.WizardStep9Controller = Em.Controller.extend({
       // current requestId.
       return false;
     }
-    tasksData.setEach('Tasks.stderr', '');
-    tasksData.setEach('Tasks.stdout', '');
-    if (this.get('currentOpenTaskId')) {
-      var currentTask = tasksData.findProperty('Tasks.id', this.get('currentOpenTaskId'));
-      var log = this.get('currentOpenTaskLog');
-      if (currentTask && log) {
-        currentTask.Tasks.stderr = log.stderr;
-        currentTask.Tasks.stdout = log.stdout;
-      }
-    }
     this.replacePolledData(tasksData);
+    var tasksHostMap = {};
+    tasksData.forEach(function(task){
+      if(tasksHostMap[task.Tasks.host_name]) {
+        tasksHostMap[task.Tasks.host_name].push(task);
+      } else {
+        tasksHostMap[task.Tasks.host_name] = [task];
+      }
+    });
+
     this.get('hosts').forEach(function (_host) {
-      var actionsPerHost = tasksData.filterProperty('Tasks.host_name', _host.name); // retrieved
from polled Data
+      var actionsPerHost = tasksHostMap[_host.name] || []; // retrieved from polled Data
       if (actionsPerHost.length === 0) {
         if(this.get('content.cluster.status') === 'PENDING') {
           _host.set('progress', '33');
@@ -729,6 +723,7 @@ App.WizardStep9Controller = Em.Controller.extend({
         _host.set('status', 'pending');
       }
     }, this);
+    this.set('logTasksChangesCounter', this.get('logTasksChangesCounter') + 1);
     totalProgress = Math.floor(totalProgress / this.get('hosts.length'));
     this.set('progress', totalProgress.toString());
     console.log("INFO: right now the progress is: " + this.get('progress'));
@@ -743,7 +738,7 @@ App.WizardStep9Controller = Em.Controller.extend({
   getUrl: function (requestId) {
     var clusterName = this.get('content.cluster.name');
     var requestId = requestId || this.get('content.cluster.requestId');
-    var url = App.apiPrefix + '/clusters/' + clusterName + '/requests/' + requestId + '?fields=*,tasks/Tasks/command,tasks/Tasks/exit_code,tasks/Tasks/host_name,tasks/Tasks/id,tasks/Tasks/role,tasks/Tasks/status';
+    var url = App.apiPrefix + '/clusters/' + clusterName + '/requests/' + requestId + '?fields=tasks/Tasks/command,tasks/Tasks/exit_code,tasks/Tasks/host_name,tasks/Tasks/id,tasks/Tasks/role,tasks/Tasks/status';
     console.log("URL for step9 is: " + url);
     return url;
   },

http://git-wip-us.apache.org/repos/asf/ambari/blob/f211f137/ambari-web/test/installer/step9_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/installer/step9_test.js b/ambari-web/test/installer/step9_test.js
index b0bb7b2..c8ef4d1 100644
--- a/ambari-web/test/installer/step9_test.js
+++ b/ambari-web/test/installer/step9_test.js
@@ -21,6 +21,7 @@ var Ember = require('ember');
 var App = require('app');
 require('models/hosts');
 require('controllers/wizard/step9_controller');
+require('utils/helper');
 
 describe('App.InstallerStep9Controller', function () {
 
@@ -98,6 +99,7 @@ describe('App.InstallerStep9Controller', function () {
     ];
     tests.forEach(function(test) {
       var controller = App.WizardStep9Controller.create({hosts: test.hosts, isStepFailed:
function(){return test.isStepFailed}, progress: test.progress});
+      controller.updateStatus();
       it(test.m, function() {
         expect(controller.get('status')).to.equal(test.e);
       });
@@ -191,7 +193,8 @@ describe('App.InstallerStep9Controller', function () {
   
   describe('#loadHosts', function() {
     var controller = App.WizardStep9Controller.create({content: {hosts: hosts_for_load_and_render}});
-    var loaded_hosts = controller.loadHosts();
+    controller.loadHosts();
+    var loaded_hosts = controller.get('hosts');
     it('Only REGISTERED hosts', function() {
       expect(loaded_hosts.length).to.equal(2);
     });
@@ -207,15 +210,6 @@ describe('App.InstallerStep9Controller', function () {
     });
   });
 
-  describe('#renderHosts', function() {
-    var controller = App.WizardStep9Controller.create({content: {hosts: hosts_for_load_and_render}});
-    var loaded_hosts = controller.loadHosts();
-    controller.renderHosts(loaded_hosts);
-    it('All host should be rendered', function() {
-      expect(controller.get('hosts.length')).to.equal(loaded_hosts.length);
-    });
-  });
-
   describe('#hostHasClientsOnly', function() {
     var tests = [
       {
@@ -668,9 +662,9 @@ describe('App.InstallerStep9Controller', function () {
     it('check requestId priority', function() {
       cluster.set('content.cluster.requestId', 123);
       var url = cluster.getUrl(321);
-      expect(url).to.equal(App.apiPrefix + '/clusters/' + clusterName + '/requests/' + '321'
+ '?fields=tasks/*');
+      expect(url).to.equal(App.apiPrefix + '/clusters/' + clusterName + '/requests/' + '321'
+ '?fields=tasks/Tasks/command,tasks/Tasks/exit_code,tasks/Tasks/host_name,tasks/Tasks/id,tasks/Tasks/role,tasks/Tasks/status');
       url = cluster.getUrl();
-      expect(url).to.equal(App.apiPrefix + '/clusters/' + clusterName + '/requests/' + '123'
+ '?fields=tasks/*');
+      expect(url).to.equal(App.apiPrefix + '/clusters/' + clusterName + '/requests/' + '123'
+ '?fields=tasks/Tasks/command,tasks/Tasks/exit_code,tasks/Tasks/host_name,tasks/Tasks/id,tasks/Tasks/role,tasks/Tasks/status');
     });
   });
 
@@ -795,38 +789,36 @@ describe('App.InstallerStep9Controller', function () {
   describe('#setLogTasksStatePerHost', function() {
     var tests = [
       {
-        tasksPerHost: [{Tasks: {id: 1,message: '2'}},{Tasks: {id: 2,message: '2'}}],
+        tasksPerHost: [{Tasks: {id: 1,status: 'COMPLETED'}},{Tasks: {id: 2,status: 'COMPLETED'}}],
         tasks: [],
-        e: {m: '2',l: 2},
+        e: {m: 'COMPLETED',l: 2},
         m: 'host didn\'t have tasks and got 2 new'
       },
       {
-        tasksPerHost: [{Tasks: {id: 1,message: '2'}},{Tasks: {id: 2,message: '2'}}],
-        tasks: [{Tasks: {id: 1,message: '1'}},{Tasks: {id: 2,message: '1'}}],
-        e: {m: '2',l: 2},
+        tasksPerHost: [{Tasks: {id: 1,status: 'COMPLETED'}},{Tasks: {id: 2,status: 'COMPLETED'}}],
+        tasks: [{Tasks: {id: 1,status: 'IN_PROGRESS'}},{Tasks: {id: 2,status: 'IN_PROGRESS'}}],
+        e: {m: 'COMPLETED',l: 2},
         m: 'host had 2 tasks and got both updated'
       },
       {
         tasksPerHost: [],
-        tasks: [{Tasks: {id: 1,message: '1'}},{Tasks: {id: 2,message: '1'}}],
-        e: {m: '1',l: 2},
+        tasks: [{Tasks: {id: 1,status: 'IN_PROGRESS'}},{Tasks: {id: 2,status: 'IN_PROGRESS'}}],
+        e: {m: 'IN_PROGRESS',l: 2},
         m: 'host had 2 tasks and didn\'t get updates'
       },
       {
-        tasksPerHost: [{Tasks: {id: 1,message: '2'}},{Tasks: {id: 2,message: '2'}},{Tasks:
{id: 3,message: '2'}}],
-        tasks: [{Tasks: {id: 1,message: '1'}},{Tasks: {id: 2,message: '1'}}],
-        e: {m: '2',l: 3},
+        tasksPerHost: [{Tasks: {id: 1,status: 'COMPLETED'}},{Tasks: {id: 2,status: 'COMPLETED'}},{Tasks:
{id: 3,status: 'COMPLETED'}}],
+        tasks: [{Tasks: {id: 1,status: 'IN_PROGRESS'}},{Tasks: {id: 2,status: 'IN_PROGRESS'}}],
+        e: {m: 'COMPLETED',l: 3},
         m: 'host had 2 tasks and got both updated and 1 new'
       }
     ];
     tests.forEach(function(test) {
       it(test.m, function() {
         var controller = App.WizardStep9Controller.create({hosts: [Em.Object.create({logTasks:
test.tasks})]});
-        var logTasksChangesCounter = controller.get('logTasksChangesCounter');
         controller.setLogTasksStatePerHost(test.tasksPerHost, controller.get('hosts')[0]);
-        expect(controller.get('hosts')[0].get('logTasks').everyProperty('Tasks.message',
test.e.m)).to.equal(true);
+        expect(controller.get('hosts')[0].get('logTasks').everyProperty('Tasks.status', test.e.m)).to.equal(true);
         expect(controller.get('hosts')[0].get('logTasks.length')).to.equal(test.e.l);
-        expect(controller.get('logTasksChangesCounter')).to.equal(logTasksChangesCounter
+ 1);
       });
     });
   });
@@ -965,7 +957,9 @@ describe('App.InstallerStep9Controller', function () {
     tests.forEach(function(test) {
       it(test.m, function() {
         var controller = App.WizardStep9Controller.create({hosts: test.hosts, content: {cluster:{status:
test.cluster.status}}, finishState: function(){return false;}});
+        var logTasksChangesCounter = controller.get('logTasksChangesCounter');
         controller.parseHostInfo(test.polledData);
+        expect(controller.get('logTasksChangesCounter')).to.equal(logTasksChangesCounter
+ 1);
         for (var name in test.e.hosts) {
           expect(controller.get('hosts').findProperty('name', name).get('progress')).to.equal(test.e.hosts[name].progress);
         }
@@ -974,4 +968,4 @@ describe('App.InstallerStep9Controller', function () {
     });
   });
 
-});
\ No newline at end of file
+});


Mime
View raw message