/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ var App = require('app'); App.WizardStep13Controller = App.HighAvailabilityProgressPageController.extend({ commands: ['stopServices', 'createHostComponents', 'putHostComponentsInMaintenanceMode', 'installHostComponents', 'reconfigure', 'startServices', 'deleteHostComponents'], clusterDeployStep: 'REASSIGN_MASTER_INSTALLING', componentsWithManualSteps: ['NAMENODE, SECONDARY_NAMENODE', 'JOBTRACKER'], multiTaskCounter: 0, hostComponents: [], serviceNames: [], loadStep: function () { if (['HIVE_METASTORE', 'WEBHCAT_SERVER'].contains(this.get('content.reassign.component_name'))) { //todo this.set('hostComponents', ['HIVE_METASTORE', 'WEBHCAT']); this.set('serviceNames', ['HIVE', 'WEBHCAT']); } else { this.set('hostComponents', [this.get('content.reassign.component_name')]); this.set('serviceNames', [this.get('content.reassign.service_id')]); } this._super(); }, initializeTasks: function () { var commands = this.get('commands'); var currentStep = App.router.get('reassignMasterController.currentStep'); var hostComponentsNames = ''; var serviceNames = ''; this.get('hostComponents').forEach(function (comp, index) { hostComponentsNames += index ? ', ' : ''; hostComponentsNames += App.format.role(comp); }, this); this.get('serviceNames').forEach(function (service, index) { serviceNames += index ? ', ' : ''; serviceNames += App.Service.find().findProperty('serviceName', service).get('displayName'); }, this); for (var i = 0; i < commands.length; i++) { var title = Em.I18n.t('installer.step13.task' + i + '.title').format(hostComponentsNames, serviceNames); this.get('tasks').pushObject(Ember.Object.create({ title: title, status: 'PENDING', id: i, command: commands[i], showRetry: false, showRollback: false, name: title, displayName: title, progress: 0, isRunning: false, hosts: [] })); } //todo /*if (this.get('componentsWithManualSteps').contains(this.get('content.reassign.component_name'))) { this.get('tasks').splice(4, 3); }*/ }, hideRollbackButton: function () { var failedTask = this.get('tasks').findProperty('showRollback'); if (failedTask) { failedTask.set('showRollback', false) } }.observes('tasks.@each.showRollback'), onComponentsTasksSuccess: function () { this.set('multiTaskCounter', this.get('multiTaskCounter') + 1); if (this.get('multiTaskCounter') >= this.get('hostComponents').length) { this.onTaskCompleted(); } }, stopServices: function () { this.set('multiTaskCounter', 0); var serviceNames = this.get('serviceNames'); for (var i = 0; i < serviceNames.length; i++) { App.ajax.send({ name: 'reassign.stop_service', sender: this, data: { serviceName: serviceNames[i], displayName: App.Service.find().findProperty('serviceName', serviceNames[i]).get('displayName'), taskNum: serviceNames.length }, success: 'startPolling', error: 'onTaskError' }); } }, createHostComponents: function () { this.set('multiTaskCounter', 0); var hostComponents = this.get('hostComponents'); var hostName = this.get('content.masterComponentHosts').findProperty('component', this.get('content.reassign.component_name')).hostName; for (var i = 0; i < hostComponents.length; i++) { this.createComponent(hostComponents[i], hostName); } }, onCreateComponent: function () { this.onComponentsTasksSuccess(); }, putHostComponentsInMaintenanceMode: function () { this.set('multiTaskCounter', 0); var hostComponents = this.get('hostComponents'); var hostName = this.get('content.reassign.host_id'); for (var i = 0; i < hostComponents.length; i++) { App.ajax.send({ name: 'reassign.maintenance_mode', sender: this, data: { hostName: hostName, componentName: hostComponents[i] }, success: 'onComponentsTasksSuccess', error: 'onTaskError' }); } }, installHostComponents: function () { this.set('multiTaskCounter', 0); var hostComponents = this.get('hostComponents'); var hostName = this.get('content.masterComponentHosts').findProperty('component', this.get('content.reassign.component_name')).hostName; for (var i = 0; i < hostComponents.length; i++) { this.installComponent(hostComponents[i], hostName, hostComponents.length); } }, reconfigure: function () { //todo this.onTaskCompleted(); }, startServices: function () { this.set('multiTaskCounter', 0); var serviceNames = this.get('serviceNames'); for (var i = 0; i < serviceNames.length; i++) { App.ajax.send({ name: 'reassign.start_components', sender: this, data: { serviceName: serviceNames[i], displayName: App.Service.find().findProperty('serviceName', serviceNames[i]).get('displayName'), taskNum: serviceNames.length }, success: 'startPolling', error: 'onTaskError' }); } }, deleteHostComponents: function () { this.set('multiTaskCounter', 0); var hostComponents = this.get('hostComponents'); var hostName = this.get('content.reassign.host_id'); for (var i = 0; i < hostComponents.length; i++) { App.ajax.send({ name: 'reassign.remove_component', sender: this, data: { hostName: hostName, componentName: hostComponents[i] }, success: 'onComponentsTasksSuccess', error: 'onTaskError' }); } } })