Author: yusaku
Date: Sat Jan 19 01:52:41 2013
New Revision: 1435457

URL: http://svn.apache.org/viewvc?rev=1435457&view=rev
Log:
AMBARI-1228. During Install, show warn on hosts that have tasks cancelled. 
(yusaku)

Modified:
    incubator/ambari/trunk/CHANGES.txt
    incubator/ambari/trunk/ambari-web/app/controllers/wizard/step9_controller.js

Modified: incubator/ambari/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1435457&r1=1435456&r2=1435457&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Sat Jan 19 01:52:41 2013
@@ -17,6 +17,9 @@ Trunk (unreleased changes):
 
  IMPROVEMENTS
 
+ AMBARI-1228. During Install, show "warn" on hosts that have tasks cancelled.
+ (yusaku)
+
  AMBARI-1225. Add Hosts wizard popup is too small. (yusaku)
 
  AMBARI-1224. Drop the "all" option from Hosts > Component Filter and

Modified: 
incubator/ambari/trunk/ambari-web/app/controllers/wizard/step9_controller.js
URL: 
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/wizard/step9_controller.js?rev=1435457&r1=1435456&r2=1435457&view=diff
==============================================================================
--- 
incubator/ambari/trunk/ambari-web/app/controllers/wizard/step9_controller.js 
(original)
+++ 
incubator/ambari/trunk/ambari-web/app/controllers/wizard/step9_controller.js 
Sat Jan 19 01:52:41 2013
@@ -39,9 +39,14 @@ App.WizardStep9Controller = Em.Controlle
       return 'failed';
     }
     if (this.hosts.someProperty('status', 'warning')) {
-      return 'warning';
+      if (this.isStepFailed()) {
+        return 'failed';
+      } else {
+        return 'warning';
+      }
     }
     if(this.get('progress') == '100') {
+      this.set('isStepCompleted', true);
       return 'success';
     }
     return 'info';
@@ -79,7 +84,7 @@ App.WizardStep9Controller = Em.Controlle
       if (clusterStatus === 'INSTALL FAILED') {
         this.loadStep();
         this.loadLogData(this.get('content.cluster.requestId'));
-        this.set('content.cluster.isStepCompleted', true);
+        this.set('isStepCompleted', true);
       } else if (clusterStatus === 'START FAILED') {
         this.loadStep();
         this.loadLogData(this.get('content.cluster.requestId'));
@@ -308,12 +313,13 @@ App.WizardStep9Controller = Em.Controlle
     }
   },
 
-  // marks a host's status as "warning" if at least one of the tasks is 
FAILED, ABORTED, or TIMEDOUT.
-  onWarningPerHost: function (actions, contentHost) {
+  // marks a host's status as "warning" if at least one of the tasks is 
FAILED, ABORTED, or TIMEDOUT and marks host's status as "failed" if at least 
one master component install task is FAILED.
+  onErrorPerHost: function (actions, contentHost) {
     if (actions.someProperty('Tasks.status', 'FAILED') || 
actions.someProperty('Tasks.status', 'ABORTED') || 
actions.someProperty('Tasks.status', 'TIMEDOUT')) {
-      console.log('step9: In warning');
       contentHost.set('status', 'warning');
-      this.set('status', 'warning');
+    }
+    if (this.get('content.cluster.status') === 'PENDING' && 
this.isMasterFailed(actions)) {
+      contentHost.set('status', 'failed');
     }
   },
 
@@ -361,59 +367,35 @@ App.WizardStep9Controller = Em.Controlle
     return polledData.everyProperty('Tasks.status', 'COMPLETED');
   },
 
-  // for DATANODE, TASKTRACKER, HBASE_REGIONSERVER, and GANGLIA_MONITOR, if 
more than 50% fail, then it's a fatal error;
-  // otherwise, it's only a warning and installation/start can continue
-  getSuccessFactor: function (role) {
-    return ['DATANODE', 'TASKTRACKER', 'HBASE_REGIONSERVER', 
'GANGLIA_MONITOR'].contains(role) ? 50 : 100;
-  },
-
-  isStepFailed: function (polledData) {
+  //return true if at least 50% of the slave host components for the 
particular service component fails to install
+  isStepFailed: function () {
     var failed = false;
-    polledData.forEach(function (_polledData) {
-      var successFactor = this.getSuccessFactor(_polledData.Tasks.role);
-      console.log("Step9: isStepFailed sf value: " + successFactor);
-      var actionsPerRole = polledData.filterProperty('Tasks.role', 
_polledData.Tasks.role);
-      var actionsFailed = actionsPerRole.filterProperty('Tasks.status', 
'FAILED');
-      var actionsAborted = actionsPerRole.filterProperty('Tasks.status', 
'ABORTED');
-      var actionsTimedOut = actionsPerRole.filterProperty('Tasks.status', 
'TIMEDOUT');
-      if ((((actionsFailed.length + actionsAborted.length + 
actionsTimedOut.length) / actionsPerRole.length) * 100) > (100 - 
successFactor)) {
-        console.log('TRACE: Entering success factor and result is failed');
-        failed = true;
+    var polledData = this.get('polledData');
+    polledData.filterProperty('Tasks.command', 
'INSTALL').mapProperty('Tasks.role').uniq().forEach(function (role) {
+      if (['DATANODE', 'TASKTRACKER', 'HBASE_REGIONSERVER', 
'GANGLIA_MONITOR'].contains(role)) {
+        var actionsPerRole = polledData.filterProperty('Tasks.role', role);
+        var actionsFailed = actionsPerRole.filterProperty('Tasks.status', 
'FAILED');
+        var actionsAborted = actionsPerRole.filterProperty('Tasks.status', 
'ABORTED');
+        var actionsTimedOut = actionsPerRole.filterProperty('Tasks.status', 
'TIMEDOUT');
+        if ((((actionsFailed.length + actionsAborted.length + 
actionsTimedOut.length) / actionsPerRole.length) * 100) > 50) {
+          failed = true;
+        }
       }
     }, this);
     return failed;
   },
 
-  getFailedHostsForFailedRoles: function (polledData) {
-    var hostArr = new Ember.Set();
-    polledData.forEach(function (_polledData) {
-      var successFactor = this.getSuccessFactor(_polledData.Tasks.role);
-      var actionsPerRole = polledData.filterProperty('Tasks.role', 
_polledData.Tasks.role);
-      var actionsFailed = actionsPerRole.filterProperty('Tasks.status', 
'FAILED');
-      var actionsAborted = actionsPerRole.filterProperty('Tasks.status', 
'ABORTED');
-      var actionsTimedOut = actionsPerRole.filterProperty('Tasks.status', 
'TIMEDOUT');
-      if ((((actionsFailed.length + actionsAborted.length + 
actionsTimedOut.length) / actionsPerRole.length) * 100) > (100 - 
successFactor)) {
-        actionsFailed.forEach(function (_actionFailed) {
-          hostArr.add(_actionFailed.Tasks.host_name);
-        });
-        actionsAborted.forEach(function (_actionFailed) {
-          hostArr.add(_actionFailed.Tasks.host_name);
-        });
-        actionsTimedOut.forEach(function (_actionFailed) {
-          hostArr.add(_actionFailed.Tasks.host_name);
-        });
-      }
-    }, this);
-    return hostArr;
-  },
-
-  setHostsStatus: function (hostNames, status) {
-    hostNames.forEach(function (_hostName) {
-      var host = this.hosts.findProperty('name', _hostName);
-      if (host) {
-        host.set('status', status).set('progress', '100');
-      }
-    }, this);
+  //return true if there is at least one FAILED task of master component 
install
+  isMasterFailed: function(polledData) {
+    var result = false;
+    polledData.filterProperty('Tasks.status', 
'FAILED').mapProperty('Tasks.role').forEach (
+        function (task) {
+          if (!['DATANODE', 'TASKTRACKER', 'HBASE_REGIONSERVER', 
'GANGLIA_MONITOR'].contains(task)) {
+            result = true;
+          }
+        }
+    );
+    return result;
   },
 
   // makes a state transition
@@ -439,10 +421,8 @@ App.WizardStep9Controller = Em.Controlle
           var serviceStartTime = new Date().getTime();
           var timeToStart = ((parseInt(serviceStartTime) - 
parseInt(this.get('content.cluster.installStartTime'))) / 60000).toFixed(2);
           clusterStatus.installTime = timeToStart;
-          this.set('status', 'success');
         } else {
             clusterStatus.status = 'START FAILED'; // 'START FAILED' implies 
to step10 that installation was successful but start failed
-            this.set('status', 'warning');
         }
         
App.router.get(this.get('content.controllerName')).saveClusterStatus(clusterStatus);
         this.set('isStepCompleted', true);
@@ -457,12 +437,10 @@ App.WizardStep9Controller = Em.Controlle
           requestId: requestId,
           isCompleted: false
         }
-        if (this.isStepFailed(polledData)) {
-          console.log("In installation failure");
+        if (this.get('status') === 'failed') {
           clusterStatus.status = 'INSTALL FAILED';
           this.set('progress', '100');
-          this.set('status', 'failed');
-          this.setHostsStatus(this.getFailedHostsForFailedRoles(polledData), 
'failed');
+          this.get('hosts').setEach('progress', '100');
           
App.router.get(this.get('content.controllerName')).saveClusterStatus(clusterStatus);
           this.set('isStepCompleted', true);
         } else {
@@ -474,20 +452,10 @@ App.WizardStep9Controller = Em.Controlle
         
App.router.get(this.get('content.controllerName')).saveInstalledHosts(this);
         return true;
       }
-    } else if (this.get('content.cluster.status') === 'INSTALL FAILED') {
-      this.set('progress', '100');
-      this.set('status', 'failed');
-      return true;
-    } else if (this.get('content.cluster.status') === 'START FAILED') {
+    } else if (this.get('content.cluster.status') === 'INSTALL FAILED' || 
this.get('content.cluster.status') === 'START FAILED' || 
this.get('content.cluster.status') === 'STARTED') {
       this.set('progress', '100');
-      this.set('status', 'warning');
-      return true;
-    } else if (this.get('content.cluster.status') === 'STARTED') {
-      this.set('progress', '100');
-      this.set('status', 'success');
       return true;
     }
-
     return false;
   },
 
@@ -532,11 +500,6 @@ App.WizardStep9Controller = Em.Controlle
     console.log('TRACE: Entering host info function');
     var self = this;
     var totalProgress = 0;
-    /* if (this.get('content.cluster.status') === 'INSTALLED') {
-     totalProgress = 34;
-     } else {
-     totalProgress = 0;
-     }  */
     var tasksData = polledData.tasks;
     console.log("The value of tasksData is: ", tasksData);
     if (!tasksData) {
@@ -544,9 +507,9 @@ App.WizardStep9Controller = Em.Controlle
     }
     var requestId = this.get('content.cluster.requestId');
     if(polledData.Requests && polledData.Requests.id && 
polledData.Requests.id!=requestId){
-      // We dont want to use non-current requestId's tasks data to 
-      // determine the current install status. 
-      // Also, we dont want to keep polling if it is not the 
+      // We dont want to use non-current requestId's tasks data to
+      // determine the current install status.
+      // Also, we dont want to keep polling if it is not the
       // current requestId.
       return false;
     }
@@ -560,7 +523,7 @@ App.WizardStep9Controller = Em.Controlle
       if (actionsPerHost !== null && actionsPerHost !== undefined && 
actionsPerHost.length !== 0) {
         this.setLogTasksStatePerHost(actionsPerHost, _host);
         this.onSuccessPerHost(actionsPerHost, _host);     // every action 
should be a success
-        this.onWarningPerHost(actionsPerHost, _host);     // any action should 
be a failure
+        this.onErrorPerHost(actionsPerHost, _host);     // any action should 
be a failure
         this.onInProgressPerHost(actionsPerHost, _host);  // current running 
action for a host
         totalProgress += self.progressPerHost(actionsPerHost, _host);
       }


Reply via email to