Updated Branches: refs/heads/trunk 935224014 -> ff9c50aab
AMBARI-3275. NameNode HA wizard (rollback): Before sending delete command check if component exists Project: http://git-wip-us.apache.org/repos/asf/incubator-ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ambari/commit/ff9c50aa Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/ff9c50aa Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/ff9c50aa Branch: refs/heads/trunk Commit: ff9c50aaba8c0f86afab70367eccce153d152629 Parents: 9352240 Author: Alex Antonenko <[email protected]> Authored: Wed Sep 18 23:06:19 2013 +0300 Committer: Alex Antonenko <[email protected]> Committed: Wed Sep 18 23:19:38 2013 +0300 ---------------------------------------------------------------------- .../highAvailability/rollback_controller.js | 57 +++++++++++++++++--- ambari-web/app/utils/ajax.js | 4 ++ 2 files changed, 55 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/ff9c50aa/ambari-web/app/controllers/main/admin/highAvailability/rollback_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/admin/highAvailability/rollback_controller.js b/ambari-web/app/controllers/main/admin/highAvailability/rollback_controller.js index a07a051..f15bac7 100644 --- a/ambari-web/app/controllers/main/admin/highAvailability/rollback_controller.js +++ b/ambari-web/app/controllers/main/admin/highAvailability/rollback_controller.js @@ -28,6 +28,7 @@ App.HighAvailabilityRollbackController = App.HighAvailabilityProgressPageControl deletedHdfsClients: 0, numOfDelOperations: 0, isRollback: true, + hostsToPerformDel: [], content: Em.Object.create({ @@ -231,7 +232,7 @@ App.HighAvailabilityRollbackController = App.HighAvailabilityProgressPageControl }, deleteFailoverControllers: function(){ var hostNames = this.get('content.masterComponentHosts').filterProperty('component', 'NAMENODE').mapProperty('hostName'); - this.deleteComponent('ZKFC', hostNames); + this.checkBeforeDelete('ZKFC', hostNames); }, stopStandbyNameNode: function(){ var hostName = this.get('content.masterComponentHosts').findProperty('isAddNameNode', true).hostName;; @@ -386,18 +387,62 @@ App.HighAvailabilityRollbackController = App.HighAvailabilityProgressPageControl data: { hostName: hostName[i], componentName: componentName, - taskNum: hostName.length + taskNum: hostName.length, + callback: 'checkBeforeDelete' }, - success: 'onMaintenanceComponent', - error: 'onTaskError' + success: 'checkResult', + error: 'checkResult' }); } }, - onMaintenanceComponent: function () { + checkBeforeDelete: function (componentName, hostName){ + this.set('hostsToPerformDel', []); + if (!(hostName instanceof Array)) { + hostName = [hostName]; + } + for (var i = 0; i < hostName.length; i++) { + App.ajax.send({ + name: 'admin.high_availability.getHostComponent', + sender: this, + data: { + componentName: componentName, + hostName: hostName[i], + taskNum: hostName.length, + callback: 'deleteComponent' + }, + success: 'checkResult', + error: 'checkResult' + }); + } + }, + + checkResult: function () { + var callback = arguments[2].callback; var hostName = arguments[2].hostName; var componentName = arguments[2].componentName; - this.deleteComponent(componentName, hostName); + var taskNum = arguments[2].taskNum; + var hostsToPerformDel = this.get('hostsToPerformDel'); + if(arguments[1] != 'error'){ + hostsToPerformDel.push({ + hostName: hostName, + isOnHost: true + }); + }else{ + hostsToPerformDel.push({ + hostName: 'error', + isOnHost: false + }); + } + if(hostsToPerformDel.length == taskNum){ + var hostsForDel = hostsToPerformDel.filterProperty('isOnHost', true).mapProperty('hostName'); + this.set('hostsToPerformDel', []); + if(hostsForDel.length == 0){ + this.onTaskCompleted(); + return; + } + this[callback](componentName, hostsForDel); + } }, deleteComponent: function (componentName, hostName) { http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/ff9c50aa/ambari-web/app/utils/ajax.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/ajax.js b/ambari-web/app/utils/ajax.js index 19dd80a..adf7d16 100644 --- a/ambari-web/app/utils/ajax.js +++ b/ambari-web/app/utils/ajax.js @@ -644,6 +644,10 @@ var urls = { 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/JOURNALNODE?fields=metrics', 'mock': '' }, + 'admin.high_availability.getHostComponent': { + 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}', + 'mock': '' + }, 'admin.high_availability.create_component': { 'real': '/clusters/{clusterName}/hosts?Hosts/host_name={hostName}', 'mock': '',
