123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961 |
- /**
- * 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.WizardStep14Controller = Em.Controller.extend({
- status: 'IN_PROGRESS',
- onStatusChange: function () {
- if (this.get('tasks').someProperty('status', 'FAILED')) {
- this.set('status', 'FAILED');
- if (this.get('tasks')[5].status == 'FAILED' || this.get('tasks')[6].status == 'FAILED') {
- this.set('showRetry', true);
- }
- } else if (this.get('tasks').everyProperty('status', 'COMPLETED')) {
- this.set('status', 'COMPLETED');
- this.set('isSubmitDisabled', false);
- } else {
- this.set('status', 'IN_PROGRESS')
- }
- var statuses = this.get('tasks').mapProperty('status');
- App.router.get(this.get('content.controllerName')).saveTasksStatuses(statuses);
- App.clusterStatus.setClusterStatus({
- clusterName: this.get('content.cluster.name'),
- clusterState: 'REASSIGN_MASTER_INSTALLING',
- wizardControllerName: this.get('content.controllerName'),
- localdb: App.db.data
- });
- this.setTasksMessages();
- this.navigateStep();
- },
- tasks: [],
- /**
- * Set messages for tasks depending on their status
- */
- setTasksMessages: function () {
- var service = this.get('service.displayName');
- var master = this.get('masterComponent.display_name');
- if (this.get('isCohosted')) {
- service = 'Hive, WebHCat';
- master = Em.I18n.t('installer.step5.hiveGroup');
- }
- for (i = 0; i < this.get('tasks').length; i++) {
- var status = this.get('tasks')[i].status.toLowerCase().replace('initialize', 'pending').replace('_', ' ');
- if (i == 0 || i == 6) {
- this.get('tasks')[i].set('message', Em.I18n.t('installer.step14.task' + i).format(service) + ' ' + status);
- } else {
- this.get('tasks')[i].set('message', Em.I18n.t('installer.step14.task' + i).format(master) + ' ' + status);
- }
- }
- },
- configs: [],
- globals: [],
- configMapping: require('data/config_mapping').all(),
- newConfigsTag: null,
- createdConfigs: [],
- currentRequestId: [],
- isSubmitDisabled: true,
- showRetry: false,
- service: function () {
- return App.Service.find().findProperty('serviceName', this.get('masterComponent.service_id'));
- }.property('masterComponent'),
- masterComponent: function () {
- return this.get('content.reassign');
- }.property('content.reassign'),
- isCohosted: function () {
- return this.get('masterComponent.component_name') == 'HIVE_SERVER';
- }.property('masterComponent'),
- loadStep: function () {
- this.clearStep();
- this.loadTasks();
- this.addObserver('tasks.@each.status', this, 'onStatusChange');
- this.onStatusChange();
- },
- clearStep: function () {
- this.removeObserver('tasks.@each.status', this, 'onStatusChange');
- this.removeObserver('createdConfigs.length', this, 'onCreateConfigsCompleted');
- var tasks = [];
- for (var i = 0; i < 8; i++) {
- tasks.pushObject(Ember.Object.create({
- status: 'INITIALIZE',
- logs: '',
- message: '',
- progress: 0
- }));
- }
- this.set('tasks', tasks);
- this.set('createdConfigsCount', 0);
- this.set('queueTasksCompleted', 0);
- this.set('dataPollCounter', 1);
- this.set('showRetry', false);
- this.set('isSubmitDisabled', true);
- this.get('configs').clear();
- this.get('globals').clear();
- this.get('createdConfigs').clear();
- },
- loadTasks: function () {
- var statuses = this.get('content.tasksStatuses');
- if (statuses) {
- statuses.forEach(function (status, index) {
- this.get('tasks')[index].status = status;
- }, this)
- }
- var statusesForRequestId = ['PENDING', 'QUEUED', 'IN_PROGRESS'];
- if (statusesForRequestId.contains(statuses[0]) || statusesForRequestId.contains(statuses[5]) || statusesForRequestId.contains(statuses[6])) {
- this.set('currentRequestId', this.get('content.cluster.requestId'));
- this.getLogsByRequest();
- }
- },
- /**
- * Run tasks in proper way
- */
- navigateStep: function () {
- if (this.get('tasks')[0].status == 'INITIALIZE') {
- this.stopService();
- }
- else if (this.get('tasks')[1].status == 'INITIALIZE') {
- this.createMasterComponent();
- }
- else if (this.taskIsReady(2)) {
- this.createConfigs();
- }
- else if (this.taskIsReady(3)) {
- this.applyConfigs();
- }
- else if (this.taskIsReady(4)) {
- this.putInMaintenanceMode();
- }
- else if (this.taskIsReady(5)) {
- this.installComponent();
- }
- else if (this.taskIsReady(6)) {
- this.startComponents();
- }
- else if (this.taskIsReady(7)) {
- this.removeComponent();
- }
- },
- /**
- * Determine preparedness to run task
- * @param task
- * @return {Boolean}
- */
- taskIsReady: function (task) {
- if (this.get('tasks')[task].status != 'INITIALIZE') {
- return false;
- }
- var startIndex = (task == 4) ? 0 : 1;
- var tempArr = this.get('tasks').mapProperty('status').slice(startIndex, task).uniq();
- return tempArr.length == 1 && tempArr[0] == 'COMPLETED';
- },
- queueTasksCompleted: 0,
- /**
- * Change status of the task
- * @param task
- * @param status
- */
- setTasksStatus: function (task, status) {
- if (status == 'COMPLETED' && this.get('isCohosted') && [1, 4, 7].contains(task) && this.get('queueTasksCompleted') < 2) {
- this.set('queueTasksCompleted', this.get('queueTasksCompleted') + 1);
- } else {
- this.get('tasks')[task].set('status', status);
- }
- },
- saveClusterStatus: function (requestId, status) {
- var clusterStatus = {
- status: status,
- requestId: requestId
- };
- App.router.get(this.get('content.controllerName')).saveClusterStatus(clusterStatus);
- },
- stopService: function () {
- this.set('currentRequestId', []);
- var serviceNames = [this.get('masterComponent.service_id')];
- if (this.get('isCohosted')) {
- serviceNames = ['HIVE', 'WEBHCAT'];
- }
- serviceNames.forEach(function (serviceName) {
- App.ajax.send({
- name: 'reassign.stop_service',
- sender: this,
- data: {
- serviceName: serviceName
- },
- beforeSend: 'onStopServiceBeforeSend',
- success: 'onStopServiceSuccess',
- error: 'onStopServiceError'
- });
- }, this);
- },
- onStopServiceBeforeSend: function () {
- this.setTasksStatus(0, 'PENDING');
- },
- onStopServiceSuccess: function (data) {
- if (data) {
- var requestId = data.Requests.id;
- this.get('currentRequestId').push(requestId);
- this.saveClusterStatus(this.get('currentRequestId'), 'PENDING');
- if ((this.get('isCohosted') && this.get('currentRequestId.length') == 2) || !this.get('isCohosted')) {
- this.getLogsByRequest();
- }
- } else {
- this.setTasksStatus(0, 'FAILED');
- }
- },
- onStopServiceError: function () {
- this.setTasksStatus(0, 'FAILED');
- },
- createMasterComponent: function () {
- var hostName = this.get('content.masterComponentHosts').findProperty('component', this.get('content.reassign.component_name')).hostName;
- var componentNames = [this.get('masterComponent.component_name')];
- if (this.get('isCohosted')) {
- this.set('queueTasksCompleted', 0);
- componentNames = ['HIVE_SERVER', 'WEBHCAT_SERVER', 'MYSQL_SERVER'];
- }
- componentNames.forEach(function (componentName) {
- if (App.testMode) {
- this.setTasksStatus(1, 'COMPLETED');
- } else {
- App.ajax.send({
- name: 'reassign.create_master',
- sender: this,
- data: {
- hostName: hostName,
- componentName: componentName
- },
- beforeSend: 'onCreateMasterComponentBeforeSend',
- success: 'onCreateMasterComponentSuccess',
- error: 'onCreateMasterComponentError'
- });
- }
- }, this);
- },
- onCreateMasterComponentBeforeSend: function () {
- this.setTasksStatus(1, 'PENDING');
- },
- onCreateMasterComponentSuccess: function () {
- this.setTasksStatus(1, 'COMPLETED');
- },
- onCreateMasterComponentError: function () {
- this.setTasksStatus(1, 'FAILED');
- },
- createConfigs: function () {
- if (this.get('service.serviceName') == 'GANGLIA' || App.testMode) {
- this.setTasksStatus(2, 'COMPLETED');
- } else {
- this.setTasksStatus(2, 'PENDING');
- this.loadGlobals();
- this.loadConfigs();
- this.set('newConfigsTag', 'version' + (new Date).getTime());
- var serviceName = this.get('service.serviceName');
- this.createConfigSite(this.createGlobalSiteObj());
- this.createConfigSite(this.createCoreSiteObj());
- if (serviceName == 'HDFS') {
- this.createConfigSite(this.createSiteObj('hdfs-site'));
- }
- if (serviceName == 'MAPREDUCE') {
- this.createConfigSite(this.createSiteObj('mapred-site'));
- }
- if (serviceName == 'HBASE') {
- this.createConfigSite(this.createSiteObj('hbase-site'));
- }
- if (serviceName == 'OOZIE') {
- this.createConfigSite(this.createSiteObj('oozie-site'));
- }
- if (serviceName == 'HIVE' || this.get('isCohosted')) {
- this.createConfigSite(this.createSiteObj('hive-site'));
- }
- if (serviceName == 'WEBHCAT' || this.get('isCohosted')) {
- this.createConfigSite(this.createSiteObj('webhcat-site'));
- }
- this.addObserver('createdConfigs.length', this, 'onCreateConfigsCompleted');
- this.onCreateConfigsCompleted();
- }
- },
- createConfigSite: function (configs) {
- configs.tag = this.get('newConfigsTag');
- App.ajax.send({
- name: 'reassign.create_configs',
- sender: this,
- data: {
- configs: configs
- },
- beforeSend: 'onCreateConfigsBeforeSend',
- success: 'onCreateConfigsSuccess',
- error: 'onCreateConfigsError'
- });
- },
- onCreateConfigsBeforeSend: function () {
- this.set('createdConfigsCount', this.get('createdConfigsCount') + 1);
- },
- onCreateConfigsSuccess: function (data, opts) {
- this.get('createdConfigs').pushObject(opts.configs.type);
- },
- onCreateConfigsError: function () {
- this.setTasksStatus(2, 'FAILED');
- },
- createdConfigsCount: 0,
- onCreateConfigsCompleted: function () {
- if (this.get('createdConfigs.length') == this.get('createdConfigsCount')) {
- this.setTasksStatus(2, 'COMPLETED');
- }
- },
- loadGlobals: function () {
- var globals = this.get('content.serviceConfigProperties').filterProperty('id', 'puppet var');
- if (globals.someProperty('name', 'hive_database')) {
- //TODO: Hive host depends on the type of db selected. Change puppet variable name if postgres is not the default db
- var hiveDb = globals.findProperty('name', 'hive_database');
- if (hiveDb.value === 'New MySQL Database') {
- if (globals.someProperty('name', 'hive_ambari_host')) {
- globals.findProperty('name', 'hive_ambari_host').name = 'hive_mysql_hostname';
- }
- globals = globals.without(globals.findProperty('name', 'hive_existing_host'));
- globals = globals.without(globals.findProperty('name', 'hive_existing_database'));
- } else {
- globals.findProperty('name', 'hive_existing_host').name = 'hive_mysql_hostname';
- globals = globals.without(globals.findProperty('name', 'hive_ambari_host'));
- globals = globals.without(globals.findProperty('name', 'hive_ambari_database'));
- }
- }
- this.set('globals', globals);
- },
- loadConfigs: function () {
- var storedConfigs = this.get('content.serviceConfigProperties').filterProperty('id', 'site property').filterProperty('value');
- var uiConfigs = this.loadUiSideConfigs();
- this.set('configs', storedConfigs.concat(uiConfigs));
- },
- loadUiSideConfigs: function () {
- var uiConfig = [];
- var configs = this.get('configMapping').filterProperty('foreignKey', null);
- configs.forEach(function (_config) {
- var value = this.getGlobConfigValue(_config.templateName, _config.value, _config.name);
- uiConfig.pushObject({
- "id": "site property",
- "name": _config.name,
- "value": value,
- "filename": _config.filename
- });
- }, this);
- var dependentConfig = this.get('configMapping').filterProperty('foreignKey');
- dependentConfig.forEach(function (_config) {
- this.setConfigValue(uiConfig, _config);
- uiConfig.pushObject({
- "id": "site property",
- "name": _config.name,
- "value": _config.value,
- "filename": _config.filename
- });
- }, this);
- return uiConfig;
- },
- getGlobConfigValue: function (templateName, expression, name) {
- var express = expression.match(/<(.*?)>/g);
- var value = expression;
- if (express == null) {
- return expression;
- }
- express.forEach(function (_express) {
- var index = parseInt(_express.match(/\[([\d]*)(?=\])/)[1]);
- if (this.get('globals').someProperty('name', templateName[index])) {
- var globValue = this.get('globals').findProperty('name', templateName[index]).value;
- // Hack for templeton.zookeeper.hosts
- if (value !== null) { // if the property depends on more than one template name like <templateName[0]>/<templateName[1]> then don't proceed to the next if the prior is null or not found in the global configs
- if (name === "templeton.zookeeper.hosts" || name === 'hbase.zookeeper.quorum') {
- // globValue is an array of ZooKeeper Server hosts
- var zooKeeperPort = '2181';
- if (name === "templeton.zookeeper.hosts") {
- var zooKeeperServers = globValue.map(function (item) {
- return item + ':' + zooKeeperPort;
- }).join(',');
- value = value.replace(_express, zooKeeperServers);
- } else {
- value = value.replace(_express, globValue.join(','));
- }
- } else {
- value = value.replace(_express, globValue);
- }
- }
- } else {
- value = null;
- }
- }, this);
- return value;
- },
- /**
- * Set all site property that are derived from other site-properties
- */
- setConfigValue: function (uiConfig, config) {
- if (config.value == null) {
- return;
- }
- var fkValue = config.value.match(/<(foreignKey.*?)>/g);
- if (fkValue) {
- fkValue.forEach(function (_fkValue) {
- var index = parseInt(_fkValue.match(/\[([\d]*)(?=\])/)[1]);
- if (uiConfig.someProperty('name', config.foreignKey[index])) {
- var globalValue = uiConfig.findProperty('name', config.foreignKey[index]).value;
- config.value = config.value.replace(_fkValue, globalValue);
- } else if (this.get('content.serviceConfigProperties').someProperty('name', config.foreignKey[index])) {
- var globalValue;
- if (this.get('content.serviceConfigProperties').findProperty('name', config.foreignKey[index]).value === '') {
- globalValue = this.get('content.serviceConfigProperties').findProperty('name', config.foreignKey[index]).defaultValue;
- } else {
- globalValue = this.get('content.serviceConfigProperties').findProperty('name', config.foreignKey[index]).value;
- }
- config.value = config.value.replace(_fkValue, globalValue);
- }
- }, this);
- }
- if (fkValue = config.name.match(/<(foreignKey.*?)>/g)) {
- fkValue.forEach(function (_fkValue) {
- var index = parseInt(_fkValue.match(/\[([\d]*)(?=\])/)[1]);
- if (uiConfig.someProperty('name', config.foreignKey[index])) {
- var globalValue = uiConfig.findProperty('name', config.foreignKey[index]).value;
- config.name = config.name.replace(_fkValue, globalValue);
- } else if (this.get('content.serviceConfigProperties').someProperty('name', config.foreignKey[index])) {
- var globalValue;
- if (this.get('content.serviceConfigProperties').findProperty('name', config.foreignKey[index]).value === '') {
- globalValue = this.get('content.serviceConfigProperties').findProperty('name', config.foreignKey[index]).defaultValue;
- } else {
- globalValue = this.get('content.serviceConfigProperties').findProperty('name', config.foreignKey[index]).value;
- }
- config.name = config.name.replace(_fkValue, globalValue);
- }
- }, this);
- }
- //For properties in the configMapping file having foreignKey and templateName properties.
- var templateValue = config.value.match(/<(templateName.*?)>/g);
- if (templateValue) {
- templateValue.forEach(function (_value) {
- var index = parseInt(_value.match(/\[([\d]*)(?=\])/)[1]);
- if (this.get('globals').someProperty('name', config.templateName[index])) {
- var globalValue = this.get('globals').findProperty('name', config.templateName[index]).value;
- config.value = config.value.replace(_value, globalValue);
- } else {
- config.value = null;
- }
- }, this);
- }
- },
- /**
- * Set property of the site variable
- */
- setSiteProperty: function (key, value, filename) {
- this.get('configs').pushObject({
- "id": "site property",
- "name": key,
- "value": value,
- "filename": filename
- });
- },
- createGlobalSiteObj: function () {
- var globalSiteProperties = {};
- //this.get('globals').filterProperty('domain', 'global').forEach(function (_globalSiteObj) {
- this.get('globals').forEach(function (_globalSiteObj) {
- // do not pass any globals whose name ends with _host or _hosts
- if (!/_hosts?$/.test(_globalSiteObj.name)) {
- // append "m" to JVM memory options except for hadoop_heapsize
- if (/_heapsize|_newsize|_maxnewsize$/.test(_globalSiteObj.name) && _globalSiteObj.name !== 'hadoop_heapsize') {
- globalSiteProperties[_globalSiteObj.name] = _globalSiteObj.value + "m";
- } else {
- globalSiteProperties[_globalSiteObj.name] = _globalSiteObj.value;
- }
- }
- }, this);
- return {"type": "global", "properties": globalSiteProperties};
- },
- createCoreSiteObj: function () {
- var serviceName = this.get('service.serviceName');
- var coreSiteObj = this.get('configs').filterProperty('filename', 'core-site.xml');
- var coreSiteProperties = {};
- // hadoop.proxyuser.oozie.hosts needs to be skipped if oozie is not selected
- var isOozieSelected = serviceName == 'OOZIE';
- var oozieUser = this.get('globals').someProperty('name', 'oozie_user') ? this.get('globals').findProperty('name', 'oozie_user').value : null;
- var isHiveSelected = serviceName == 'HIVE';
- var hiveUser = this.get('globals').someProperty('name', 'hive_user') ? this.get('globals').findProperty('name', 'hive_user').value : null;
- var isHcatSelected = serviceName == 'WEBHCAT';
- var hcatUser = this.get('globals').someProperty('name', 'hcat_user') ? this.get('globals').findProperty('name', 'hcat_user').value : null;
- coreSiteObj.forEach(function (_coreSiteObj) {
- if ((isOozieSelected || (_coreSiteObj.name != 'hadoop.proxyuser.' + oozieUser + '.hosts' && _coreSiteObj.name != 'hadoop.proxyuser.' + oozieUser + '.groups')) && (isHiveSelected || (_coreSiteObj.name != 'hadoop.proxyuser.' + hiveUser + '.hosts' && _coreSiteObj.name != 'hadoop.proxyuser.' + hiveUser + '.groups')) && (isHcatSelected || (_coreSiteObj.name != 'hadoop.proxyuser.' + hcatUser + '.hosts' && _coreSiteObj.name != 'hadoop.proxyuser.' + hcatUser + '.groups'))) {
- coreSiteProperties[_coreSiteObj.name] = _coreSiteObj.value;
- }
- }, this);
- return {"type": "core-site", "properties": coreSiteProperties};
- },
- createSiteObj: function (name) {
- var fileName = name + '.xml';
- var configs = this.get('configs').filterProperty('filename', fileName);
- var properties = {};
- configs.forEach(function (_configProperty) {
- properties[_configProperty.name] = _configProperty.value;
- }, this);
- return {type: name, properties: properties};
- },
- applyConfigs: function () {
- if (this.get('service.serviceName') == 'GANGLIA' || App.testMode) {
- this.setTasksStatus(3, 'COMPLETED');
- } else {
- var serviceName = this.get('service.serviceName');
- App.ajax.send({
- name: 'reassign.check_configs',
- sender: this,
- data: {
- serviceName: serviceName
- },
- success: 'onCheckConfigsSuccess',
- error: 'onCheckConfigsError'
- });
- }
- },
- onCheckConfigsSuccess: function (configs) {
- var configTags = configs.ServiceInfo.desired_configs;
- if (!configTags) {
- this.setTasksStatus(0, 'FAILED');
- return;
- }
- for (var tag in configTags) {
- if (this.get('createdConfigs').contains(tag)) {
- configTags[tag] = this.get('newConfigsTag');
- }
- }
- var data = {config: configTags};
- var serviceName = this.get('service.serviceName');
- App.ajax.send({
- name: 'reassign.apply_configs',
- sender: this,
- data: {
- serviceName: serviceName,
- configs: data
- },
- beforeSend: 'onApplyConfigsBeforeSend',
- success: 'onApplyConfigsSuccess',
- error: 'onApplyConfigsError'
- });
- },
- onCheckConfigsError: function () {
- this.setTasksStatus(3, 'FAILED');
- },
- onApplyConfigsBeforeSend: function () {
- this.setTasksStatus(3, 'PENDING');
- },
- onApplyConfigsSuccess: function () {
- this.setTasksStatus(3, 'COMPLETED');
- },
- onApplyConfigsError: function () {
- this.setTasksStatus(3, 'FAILED');
- },
- putInMaintenanceMode: function () {
- if (App.testMode) {
- this.setTasksStatus(4, 'COMPLETED');
- } else {
- var hostName = this.get('content.reassign.host_id');
- var componentNames = [this.get('masterComponent.component_name')];
- if (this.get('isCohosted')) {
- componentNames = ['HIVE_SERVER', 'WEBHCAT_SERVER', 'MYSQL_SERVER'];
- this.set('queueTasksCompleted', 0);
- }
- componentNames.forEach(function (componentName) {
- App.ajax.send({
- name: 'reassign.maintenance_mode',
- sender: this,
- data: {
- hostName: hostName,
- componentName: componentName
- },
- beforeSend: 'onPutInMaintenanceModeBeforeSend',
- success: 'onPutInMaintenanceModeSuccess',
- error: 'onPutInMaintenanceModeError'
- });
- }, this);
- }
- },
- onPutInMaintenanceModeBeforeSend: function () {
- this.setTasksStatus(4, 'PENDING');
- },
- onPutInMaintenanceModeSuccess: function () {
- this.setTasksStatus(4, 'COMPLETED');
- },
- onPutInMaintenanceModeError: function () {
- this.setTasksStatus(4, 'FAILED');
- },
- installComponent: function () {
- this.set('currentRequestId', []);
- var componentNames = [this.get('masterComponent.component_name')];
- if (this.get('isCohosted')) {
- componentNames = ['HIVE_SERVER', 'WEBHCAT_SERVER', 'MYSQL_SERVER'];
- }
- var hostName = this.get('content.masterComponentHosts').findProperty('component', this.get('content.reassign.component_name')).hostName;
- componentNames.forEach(function (componentName) {
- App.ajax.send({
- name: 'reassign.install_component',
- sender: this,
- data: {
- hostName: hostName,
- componentName: componentName
- },
- beforeSend: 'onInstallComponentBeforeSend',
- success: 'onInstallComponentSuccess',
- error: 'onInstallComponentError'
- });
- }, this);
- },
- onInstallComponentBeforeSend: function () {
- this.setTasksStatus(5, 'PENDING');
- },
- onInstallComponentSuccess: function (data) {
- if (data) {
- var requestId = data.Requests.id;
- this.get('currentRequestId').push(requestId);
- this.saveClusterStatus(this.get('currentRequestId'), 'PENDING');
- if ((this.get('isCohosted') && this.get('currentRequestId.length') == 3) || !this.get('isCohosted')) {
- this.getLogsByRequest();
- }
- } else {
- this.setTasksStatus(5, 'FAILED');
- }
- },
- onInstallComponentError: function () {
- this.setTasksStatus(5, 'FAILED');
- },
- startComponents: function () {
- this.set('currentRequestId', []);
- var serviceNames = [this.get('masterComponent.service_id')];
- if (this.get('isCohosted')) {
- serviceNames = ['HIVE', 'WEBHCAT'];
- }
- serviceNames.forEach(function (serviceName) {
- App.ajax.send({
- name: 'reassign.start_components',
- sender: this,
- data: {
- serviceName: serviceName
- },
- beforeSend: 'onStartComponentsBeforeSend',
- success: 'onStartComponentsSuccess',
- error: 'onStartComponentsError'
- });
- }, this);
- },
- onStartComponentsBeforeSend: function () {
- this.setTasksStatus(6, 'PENDING');
- },
- onStartComponentsSuccess: function (data) {
- if (data) {
- var requestId = data.Requests.id;
- this.get('currentRequestId').push(requestId);
- this.saveClusterStatus(this.get('currentRequestId'), 'PENDING');
- if ((this.get('isCohosted') && this.get('currentRequestId.length') == 2) || !this.get('isCohosted')) {
- this.getLogsByRequest();
- }
- } else {
- this.setTasksStatus(6, 'FAILED');
- }
- },
- onStartComponentsError: function () {
- this.setTasksStatus(6, 'FAILED');
- },
- /**
- * Parse logs to define status of Start, Stop ot Install task
- * @param logs
- */
- parseLogs: function (logs) {
- var self = this;
- var task;
- var stopPolling = false;
- var polledData = [];
- logs.forEach(function (item) {
- polledData = polledData.concat(item.tasks);
- }, this);
- if (this.get('tasks')[0].status == 'COMPLETED') {
- task = this.get('tasks')[5].status == 'COMPLETED' ? 6 : 5;
- } else {
- task = 0;
- }
- if (!polledData.someProperty('Tasks.status', 'PENDING') && !polledData.someProperty('Tasks.status', 'QUEUED') && !polledData.someProperty('Tasks.status', 'IN_PROGRESS')) {
- if (polledData.someProperty('Tasks.status', 'FAILED')) {
- this.setTasksStatus(task, 'FAILED');
- } else {
- this.setTasksStatus(task, 'COMPLETED');
- }
- stopPolling = true;
- } else if (polledData.someProperty('Tasks.status', 'IN_PROGRESS')) {
- if (task == 5) {
- this.get('tasks')[5].set('progress', 50);
- } else {
- var progress = polledData.filterProperty('Tasks.status', 'COMPLETED').length / polledData.length * 100;
- this.get('tasks')[task].set('progress', Math.round(progress));
- }
- this.setTasksStatus(task, 'IN_PROGRESS');
- }
- if (!stopPolling) {
- window.setTimeout(function () {
- self.getLogsByRequest()
- }, self.POLL_INTERVAL);
- }
- },
- POLL_INTERVAL: 4000,
- dataPollCounter: 1,
- getLogsByRequest: function () {
- this.set('logs', []);
- if (App.testMode) {
- var data = require('data/mock/step14PolledData/tasks_poll' + this.get('dataPollCounter'));
- this.set('dataPollCounter', this.get('dataPollCounter') + 1);
- if (this.get('dataPollCounter') == 6) {
- this.set('dataPollCounter', 1);
- }
- this.onGetLogsByRequestSuccess(data);
- } else {
- var requestIds = this.get('currentRequestId');
- requestIds.forEach(function (requestId) {
- App.ajax.send({
- name: 'reassign.get_logs',
- sender: this,
- data: {
- requestId: requestId
- },
- success: 'onGetLogsByRequestSuccess',
- error: 'onGetLogsByRequestError'
- });
- }, this);
- }
- },
- logs: [],
- onGetLogsByRequestSuccess: function (data) {
- this.get('logs').push(data);
- if (this.get('logs.length') == this.get('currentRequestId.length') || App.testMode) {
- this.parseLogs(this.get('logs'))
- }
- },
- onGetLogsByRequestError: function () {
- this.set('status', 'FAILED');
- },
- removeComponent: function () {
- if (App.testMode) {
- this.setTasksStatus(7, 'COMPLETED');
- } else {
- var hostName = this.get('content.reassign.host_id');
- var componentNames = [this.get('masterComponent.component_name')];
- if (this.get('isCohosted')) {
- componentNames = ['HIVE_SERVER', 'WEBHCAT_SERVER', 'MYSQL_SERVER'];
- this.set('queueTasksCompleted', 0);
- }
- componentNames.forEach(function (componentName) {
- App.ajax.send({
- name: 'reassign.remove_component',
- sender: this,
- data: {
- hostName: hostName,
- componentName: componentName
- },
- beforeSend: 'onRemoveComponentBeforeSend',
- success: 'onRemoveComponentSuccess',
- error: 'onRemoveComponentError'
- });
- }, this);
- }
- },
- onRemoveComponentBeforeSend: function () {
- this.setTasksStatus(7, 'PENDING');
- },
- onRemoveComponentSuccess: function () {
- this.setTasksStatus(7, 'COMPLETED');
- },
- onRemoveComponentError: function () {
- this.setTasksStatus(7, 'FAILED');
- },
- retry: function () {
- if (this.get('tasks')[5].status == 'FAILED') {
- this.installComponent();
- } else {
- this.startComponents();
- }
- this.set('showRetry', false);
- },
- abort: function () {
- var hostName = this.get('content.masterComponentHosts').findProperty('component', this.get('content.reassign.component_name')).hostName;
- var componentNames = [this.get('masterComponent.component_name')];
- if (this.get('isCohosted')) {
- componentNames = ['HIVE_SERVER', 'WEBHCAT_SERVER', 'MYSQL_SERVER'];
- this.set('queueTasksCompleted', 0);
- }
- componentNames.forEach(function (componentName) {
- App.ajax.send({
- name: 'reassign.maintenance_mode',
- sender: this,
- data: {
- hostName: hostName,
- componentName: componentName
- },
- success: 'onAbortMaintenance',
- error: 'onAbortError'
- });
- }, this);
- },
- onAbortMaintenance: function () {
- if (this.get('isCohosted') && this.get('queueTasksCompleted') < 2) {
- this.set('queueTasksCompleted', this.get('queueTasksCompleted') + 1);
- } else {
- var hostName = this.get('content.masterComponentHosts').findProperty('component', this.get('content.reassign.component_name')).hostName;
- var componentNames = [this.get('masterComponent.component_name')];
- if (this.get('isCohosted')) {
- componentNames = ['HIVE_SERVER', 'WEBHCAT_SERVER', 'MYSQL_SERVER'];
- this.set('queueTasksCompleted', 0);
- }
- componentNames.forEach(function (componentName) {
- App.ajax.send({
- name: 'reassign.remove_component',
- sender: this,
- data: {
- hostName: hostName,
- componentName: componentName
- },
- success: 'onAbortRemoveComponent',
- error: 'onAbortError'
- });
- }, this);
- }
- },
- onAbortRemoveComponent: function () {
- if (this.get('isCohosted') && this.get('queueTasksCompleted') < 2) {
- this.set('queueTasksCompleted', this.get('queueTasksCompleted') + 1);
- } else {
- var hostName = this.get('content.reassign.host_id');
- var componentNames = [this.get('masterComponent.component_name')];
- if (this.get('isCohosted')) {
- componentNames = ['HIVE_SERVER', 'WEBHCAT_SERVER', 'MYSQL_SERVER'];
- this.set('queueTasksCompleted', 0);
- }
- componentNames.forEach(function (componentName) {
- App.ajax.send({
- name: 'reassign.install_component',
- sender: this,
- data: {
- hostName: hostName,
- componentName: componentName
- },
- success: 'onAbortCompleted',
- error: 'onAbortError'
- });
- }, this);
- }
- },
- onAbortCompleted: function () {
- if (this.get('isCohosted') && this.get('queueTasksCompleted') < 2) {
- this.set('queueTasksCompleted', this.get('queueTasksCompleted') + 1);
- } else {
- App.clusterStatus.setClusterStatus({
- clusterName: this.get('content.cluster.name'),
- clusterState: 'REASSIGN_MASTER_ABORTED',
- wizardControllerName: this.get('content.controllerName'),
- localdb: App.db.data
- });
- App.router.send('back');
- }
- },
- onAbortError: function () {
- App.ModalPopup.show({
- header: Em.I18n.translations['common.error'],
- secondary: false,
- onPrimary: function () {
- this.hide();
- },
- bodyClass: Ember.View.extend({
- template: Ember.Handlebars.compile('<p>{{t installer.step14.abortError}}</p>')
- })
- });
- }
- })
|