1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500 |
- /**
- * 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');
- var batchUtils = require('utils/batch_scheduled_requests');
- var hostsManagement = require('utils/hosts');
- var stringUtils = require('utils/string_utils');
- require('utils/configs/add_component_config_initializer');
- App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDownload, App.InstallComponent, App.InstallNewVersion, {
- name: 'mainHostDetailsController',
- /**
- * Viewed host
- * @type {App.Host|null}
- */
- content: null,
- /**
- * Does user come from hosts page
- * @type {bool}
- */
- isFromHosts: false,
- /**
- * Are we adding hive server2 component
- * @type {bool}
- */
- addHiveServer: false,
- /**
- * path to page visited before
- * @type {string}
- */
- referer: '',
- /**
- * Host on which Hive Metastore will be added
- * @type {string}
- */
- hiveMetastoreHost: '',
- /**
- * Deferred object will be resolved when Oozie configs are downloaded
- * @type {object}
- */
- isOozieConfigLoaded: $.Deferred(),
- /**
- * @type {bool}
- */
- isOozieServerAddable: true,
- /**
- * Open dashboard page
- * @method routeHome
- */
- routeHome: function () {
- App.router.transitionTo('main.dashboard.index');
- },
- /**
- * List of active (not in passive state) host components
- * @type {Ember.Enumerable}
- */
- serviceActiveComponents: function () {
- return this.get('content.hostComponents').filterProperty('service.isInPassive', false);
- }.property('content.hostComponents'),
- /**
- * List of active host components which aren't clients
- * @type {Ember.Enumerable}
- */
- serviceNonClientActiveComponents: Em.computed.filterBy('serviceActiveComponents', 'isClient', false),
- /**
- * send command to server to start selected host component
- * @param {object} event
- * @method startComponent
- */
- startComponent: function (event) {
- var self = this;
- return App.showConfirmationPopup(function () {
- var component = event.context;
- var context = Em.I18n.t('requestInfo.startHostComponent') + " " + component.get('displayName');
- self.sendComponentCommand(component, context, App.HostComponentStatus.started);
- });
- },
- /**
- * send command to server to stop selected host component
- * @param {object} event
- * @method startComponent
- */
- stopComponent: function (event) {
- var self = this;
- if (event.context.get('componentName') == 'NAMENODE' ) {
- this.checkNnLastCheckpointTime(function () {
- return App.showConfirmationPopup(function () {
- var component = event.context;
- var context = Em.I18n.t('requestInfo.stopHostComponent') + " " + component.get('displayName');
- self.sendComponentCommand(component, context, App.HostComponentStatus.stopped);
- });
- });
- } else {
- return App.showConfirmationPopup(function () {
- var component = event.context;
- var context = Em.I18n.t('requestInfo.stopHostComponent') + " " + component.get('displayName');
- self.sendComponentCommand(component, context, App.HostComponentStatus.stopped);
- });
- }
- },
- /**
- * PUTs a command to server to start/stop a component. If no
- * specific component is provided, all components are started.
- * @param {object} component When <code>null</code> all startable components are started.
- * @param {String} context Context under which this command is beign sent.
- * @param {String} state - desired state of component can be 'STARTED' or 'STOPPED'
- * @method sendComponentCommand
- */
- sendComponentCommand: function (component, context, state) {
- var data = {
- hostName: this.get('content.hostName'),
- context: context,
- component: component,
- HostRoles: {
- state: state
- }
- };
- if (Array.isArray(component)) {
- data.query = "HostRoles/component_name.in(" + component.mapProperty('componentName').join(',') + ")";
- } else {
- data.componentName = component.get('componentName');
- data.serviceName = component.get('service.serviceName');
- }
- App.ajax.send({
- name: (Array.isArray(component)) ? 'common.host.host_components.update' : 'common.host.host_component.update',
- sender: this,
- data: data,
- success: 'sendComponentCommandSuccessCallback',
- error: 'ajaxErrorCallback'
- });
- },
- /**
- * Success callback for stop/start host component request
- * @param {object} data
- * @param {object} opt
- * @param {object} params
- * @method stopComponentSuccessCallback
- */
- sendComponentCommandSuccessCallback: function (data, opt, params) {
- var running = (params.HostRoles.state === App.HostComponentStatus.stopped) ? App.HostComponentStatus.stopping : App.HostComponentStatus.starting;
- params.component.set('workStatus', running);
- if (App.get('testMode')) {
- this.mimicWorkStatusChange(params.component, running, params.HostRoles.state);
- }
- this.showBackgroundOperationsPopup();
- },
- /**
- * Return true if hdfs user data is loaded via App.MainServiceInfoConfigsController
- */
- getHdfsUser: function () {
- var self = this;
- var dfd = $.Deferred();
- var miscController = App.MainAdminServiceAccountsController.create();
- miscController.loadUsers();
- var interval = setInterval(function () {
- if (miscController.get('dataIsLoaded') && miscController.get('users')) {
- self.set('hdfsUser', miscController.get('users').findProperty('name', 'hdfs_user').get('value'));
- dfd.resolve();
- clearInterval(interval);
- }
- }, 10);
- return dfd.promise();
- },
- /**
- * this function will be called from :1) stop NN 2) restart NN 3) stop all components
- * @param callback - callback function to continue next operation
- * @param hostname - namenode host (by default is current host)
- */
- checkNnLastCheckpointTime: function(callback, hostName) {
- var self = this;
- this.pullNnCheckPointTime(hostName).complete(function () {
- var isNNCheckpointTooOld = self.get('isNNCheckpointTooOld');
- self.set('isNNCheckpointTooOld', null);
- if (isNNCheckpointTooOld) {
- // too old
- self.getHdfsUser().done(function() {
- var msg = Em.Object.create({
- confirmMsg: Em.I18n.t('services.service.stop.HDFS.warningMsg.checkPointTooOld').format(App.nnCheckpointAgeAlertThreshold) +
- Em.I18n.t('services.service.stop.HDFS.warningMsg.checkPointTooOld.instructions').format(isNNCheckpointTooOld, self.get('hdfsUser')),
- confirmButton: Em.I18n.t('common.next')
- });
- return App.showConfirmationFeedBackPopup(callback, msg);
- });
- } else if (isNNCheckpointTooOld == null) {
- // not available
- return App.showConfirmationPopup(
- callback, Em.I18n.t('services.service.stop.HDFS.warningMsg.checkPointNA'), null,
- Em.I18n.t('common.warning'), Em.I18n.t('common.proceedAnyway'), true
- );
- } else {
- // still young
- callback();
- }
- });
- },
- pullNnCheckPointTime: function (hostName) {
- return App.ajax.send({
- name: 'common.host_component.getNnCheckPointTime',
- sender: this,
- data: {
- host: hostName || this.get('content.hostName')
- },
- success: 'parseNnCheckPointTime'
- });
- },
- parseNnCheckPointTime: function (data) {
- var lastCheckpointTime = Em.get(data, 'metrics.dfs.FSNamesystem.LastCheckpointTime');
- var hostName = Em.get(data, 'HostRoles.host_name');
- if (Em.get(data, 'metrics.dfs.FSNamesystem.HAState') == 'active') {
- if (!lastCheckpointTime) {
- this.set("isNNCheckpointTooOld", null);
- } else {
- var time_criteria = App.nnCheckpointAgeAlertThreshold; // time in hours to define how many hours ago is too old
- var time_ago = (Math.round(App.dateTime() / 1000) - (time_criteria * 3600)) *1000;
- if (lastCheckpointTime <= time_ago) {
- // too old, set the effected hostName
- this.set("isNNCheckpointTooOld", hostName);
- } else {
- // still young
- this.set("isNNCheckpointTooOld", false);
- }
- }
- } else if (Em.get(data, 'metrics.dfs.FSNamesystem.HAState') == 'standby') {
- this.set("isNNCheckpointTooOld", false);
- }
- },
- /**
- * mimic status transition in test mode
- * @param entity
- * @param transitionalState
- * @param finalState
- */
- mimicWorkStatusChange: function (entity, transitionalState, finalState) {
- if (Em.isArray(entity)) {
- entity.forEach(function (item) {
- item.set('workStatus', transitionalState);
- setTimeout(function () {
- item.set('workStatus', finalState);
- }, App.testModeDelayForActions);
- });
- } else {
- entity.set('workStatus', transitionalState);
- setTimeout(function () {
- entity.set('workStatus', finalState);
- }, App.testModeDelayForActions);
- }
- },
- /**
- * load data (if we need to show this background operations popup) from persist
- * @param callback
- */
- showBackgroundOperationsPopup: function (callback) {
- App.router.get('userSettingsController').dataLoading('show_bg').done(function (initValue) {
- if (initValue) {
- App.router.get('backgroundOperationsController').showPopup();
- }
- if (typeof callback === 'function') {
- callback();
- }
- });
- },
- /**
- * Send command to server to delete selected host component
- * @param {object} event
- * @method deleteComponent
- */
- deleteComponent: function (event) {
- if ($(event.target).closest('li').hasClass('disabled')) {
- return;
- }
- var self = this;
- var component = event.context;
- var componentName = component.get('componentName');
- var displayName = component.get('displayName');
- var isLastComponent = (this.getTotalComponent(component) === 1);
- return App.ModalPopup.show({
- header: Em.I18n.t('popup.confirmation.commonHeader'),
- primary: Em.I18n.t('hosts.host.deleteComponent.popup.confirm'),
- bodyClass: Em.View.extend({
- templateName: require('templates/main/host/details/deleteComponentPopup')
- }),
- isHiveMetastore: componentName == 'HIVE_METASTORE',
- isWebHCatServer: componentName == 'WEBHCAT_SERVER',
- isNimbus: componentName == 'NIMBUS',
- isRangerKMSServer: componentName == 'RANGER_KMS_SERVER',
- isZkServer: componentName == 'ZOOKEEPER_SERVER',
- deleteHiveMetastoreMsg: Em.I18n.t('hosts.host.deleteComponent.popup.deleteHiveMetastore'),
- deleteWebHCatServerMsg: Em.I18n.t('hosts.host.deleteComponent.popup.deleteWebHCatServer'),
- deleteNimbusMsg: Em.I18n.t('hosts.host.deleteComponent.popup.deleteNimbus'),
- deleteRangerKMSServereMsg: Em.I18n.t('hosts.host.deleteComponent.popup.deleteRangerKMSServer'),
- lastComponentError: Em.I18n.t('hosts.host.deleteComponent.popup.warning').format(displayName),
- deleteComponentMsg: Em.I18n.t('hosts.host.deleteComponent.popup.msg1').format(displayName),
- deleteZkServerMsg: Em.I18n.t('hosts.host.deleteComponent.popup.deleteZooKeeperServer'),
- isChecked: false,
- disablePrimary: Em.computed.not('isChecked'),
- lastComponent: function () {
- this.set('isChecked', !isLastComponent);
- return isLastComponent;
- }.property(),
- onPrimary: function () {
- var popup = this;
- self._doDeleteHostComponent(component, function () {
- self.set('redrawComponents', true);
- popup.hide();
- });
- }
- });
- },
- /**
- * get total count of host-components
- * @method getTotalComponent
- * @param component
- * @return {Number}
- */
- getTotalComponent: function (component) {
- var count;
- if (component.get('isSlave')) {
- count = App.SlaveComponent.find(component.get('componentName')).get('totalCount');
- } else if (component.get('isClient')) {
- count = App.ClientComponent.find(component.get('componentName')).get('totalCount');
- } else {
- count = App.HostComponent.find().filterProperty('componentName', component.get('componentName')).get('length');
- }
- return count || 0;
- },
- /**
- * Trigger to reset list of master/slaves components on the view
- * @type {bool}
- */
- redrawComponents: false,
- /**
- * Deletes the given host component, or all host components.
- *
- * @param {object|null} component When <code>null</code> all host components are deleted.
- * @return <code>null</code> when components get deleted.
- * <code>{xhr: XhrObj, url: "http://", method: "DELETE"}</code>
- * when components failed to get deleted.
- * @method _doDeleteHostComponent
- */
- _doDeleteHostComponent: function (component, callback) {
- callback = callback || Em.K;
- App.ajax.send({
- name: (Em.isNone(component)) ? 'common.delete.host' : 'common.delete.host_component',
- sender: this,
- data: {
- componentName: (component) ? component.get('componentName') : '',
- hostName: this.get('content.hostName')
- },
- success: '_doDeleteHostComponentSuccessCallback',
- error: '_doDeleteHostComponentErrorCallback'
- }).then(callback, callback);
- },
- /**
- * Result of delete component(s) request
- * @type {object}
- */
- _deletedHostComponentResult: null,
- /**
- * Success callback for delete host component request
- * @method _doDeleteHostComponentSuccessCallback
- */
- _doDeleteHostComponentSuccessCallback: function (response, request, data) {
- var self = this;
- this.set('_deletedHostComponentResult', null);
- this.removeHostComponentModel(data.componentName, data.hostName);
- if (data.componentName == 'ZOOKEEPER_SERVER') {
- this.set('fromDeleteZkServer', true);
- this.updateStormConfigs();
- self.isServiceMetricsLoaded(function () {
- self.loadConfigs();
- });
- } else if (data.componentName == 'HIVE_METASTORE') {
- this.set('deleteHiveMetaStore', true);
- this.loadConfigs('loadHiveConfigs');
- } else if (data.componentName == 'WEBHCAT_SERVER') {
- this.set('deleteWebHCatServer', true);
- this.loadConfigs('loadWebHCatConfigs');
- } else if (data.componentName == 'HIVE_SERVER') {
- this.set('deleteHiveServer', true);
- this.loadConfigs('loadHiveConfigs');
- } else if (data.componentName == 'NIMBUS') {
- this.set('deleteNimbusHost', true);
- this.loadConfigs('loadStormConfigs');
- } else if (data.componentName == 'RANGER_KMS_SERVER') {
- this.set('deleteRangerKMSServer', true);
- this.loadConfigs('loadRangerConfigs');
- }
- },
- /**
- * Error-callback for delete host component request
- * @param {object} xhr
- * @param {string} textStatus
- * @param {object} errorThrown
- * @method _doDeleteHostComponentErrorCallback
- */
- _doDeleteHostComponentErrorCallback: function (xhr, textStatus, errorThrown, data) {
- this.set('_deletedHostComponentResult', {xhr: xhr, url: data.url, method: 'DELETE'});
- },
- /**
- * Remove host component data from App.HostComponent model.
- *
- * @param {String} componentName
- * @param {String} hostName
- */
- removeHostComponentModel: function (componentName, hostName) {
- var component = App.HostComponent.find().filterProperty('componentName', componentName).findProperty('hostName', hostName);
- var serviceInCache = App.cache['services'].findProperty('ServiceInfo.service_name', component.get('service.serviceName'));
- serviceInCache.host_components = serviceInCache.host_components.without(component.get('id'));
- App.serviceMapper.deleteRecord(component);
- },
- /**
- * Send command to server to upgrade selected host component
- * @param {object} event
- * @method upgradeComponent
- */
- upgradeComponent: function (event) {
- var self = this;
- var component = event.context;
- return App.showConfirmationPopup(function () {
- App.ajax.send({
- name: 'host.host_component.upgrade',
- sender: self,
- data: {
- component: component,
- hostName: self.get('content.hostName'),
- componentName: component.get('componentName'),
- data: JSON.stringify({
- RequestInfo: {
- "context": Em.I18n.t('requestInfo.upgradeHostComponent') + " " + component.get('displayName')
- },
- Body: {
- HostRoles: {
- stack_id: 'HDP-1.2.2',
- state: 'INSTALLED'
- }
- }
- })
- },
- success: 'upgradeComponentSuccessCallback',
- error: 'ajaxErrorCallback'
- });
- });
- },
- /**
- * Success callback for upgrade host component request
- * @param {object} data
- * @param {object} opt
- * @param {object} params
- * @method upgradeComponentSuccessCallback
- */
- upgradeComponentSuccessCallback: function (data, opt, params) {
- if (App.get('testMode')) {
- this.mimicWorkStatusChange(params.component, App.HostComponentStatus.starting, App.HostComponentStatus.started);
- }
- this.showBackgroundOperationsPopup();
- },
- /**
- * Send command to server to restart selected components
- * @param {object} event
- * @method restartComponent
- */
- restartComponent: function (event) {
- var component = event.context;
- if (event.context.get('componentName') == 'NAMENODE') {
- this.checkNnLastCheckpointTime(function () {
- return App.showConfirmationPopup(function () {
- batchUtils.restartHostComponents([component], Em.I18n.t('rollingrestart.context.selectedComponentOnSelectedHost').format(component.get('displayName')), "HOST_COMPONENT");
- });
- });
- } else {
- return App.showConfirmationPopup(function () {
- batchUtils.restartHostComponents([component], Em.I18n.t('rollingrestart.context.selectedComponentOnSelectedHost').format(component.get('displayName')), "HOST_COMPONENT");
- });
- }
- },
- /**
- * add component as <code>addComponent<code> method but perform
- * kdc sessionstate if cluster is secure;
- * @param event
- */
- addComponentWithCheck: function (event) {
- var componentName = event.context ? event.context.get('componentName') : "";
- event.hiveMetastoreHost = (componentName == "HIVE_METASTORE" && !!this.get('content.hostName')) ? this.get('content.hostName') : null;
- App.get('router.mainAdminKerberosController').getSecurityType(function (event) {
- App.get('router.mainAdminKerberosController').getKDCSessionState(this.addComponent.bind(this, event));
- }.bind(this, event));
- },
- /**
- * Send command to server to install selected host component
- * @param {object} event
- * @method addComponent
- */
- addComponent: function (event) {
- var
- returnFunc,
- self = this,
- component = event.context,
- hostName = event.selectedHost || this.get('content.hostName'),
- componentName = component.get('componentName'),
- missedComponents = event.selectedHost ? [] : this.checkComponentDependencies(componentName, {
- scope: 'host',
- installedComponents: this.get('content.hostComponents').mapProperty('componentName')
- }),
- isManualKerberos = App.get('router.mainAdminKerberosController.isManualKerberos'),
- manualKerberosWarning = isManualKerberos ? Em.I18n.t('hosts.host.manualKerberosWarning') : '';
- if (!!missedComponents.length) {
- var popupMessage = Em.I18n.t('host.host.addComponent.popup.dependedComponents.body').format(component.get('displayName'),
- stringUtils.getFormattedStringFromArray(missedComponents.map(function (cName) {
- return App.StackServiceComponent.find(cName).get('displayName');
- })));
- return App.showAlertPopup(Em.I18n.t('host.host.addComponent.popup.dependedComponents.header'), popupMessage);
- }
- switch (componentName) {
- case 'ZOOKEEPER_SERVER':
- returnFunc = App.showConfirmationPopup(function () {
- self.installHostComponentCall(self.get('content.hostName'), component)
- }, Em.I18n.t('hosts.host.addComponent.' + componentName) + manualKerberosWarning);
- break;
- case 'HIVE_METASTORE':
- returnFunc = App.showConfirmationPopup(function () {
- self.set('hiveMetastoreHost', hostName);
- self.loadConfigs("loadHiveConfigs");
- }, Em.I18n.t('hosts.host.addComponent.' + componentName) + manualKerberosWarning);
- break;
- case 'WEBHCAT_SERVER':
- returnFunc = App.showConfirmationPopup(function () {
- self.set('webhcatServerHost', hostName);
- self.loadConfigs("loadWebHCatConfigs");
- }, Em.I18n.t('hosts.host.addComponent.' + componentName) + manualKerberosWarning);
- break;
- case 'NIMBUS':
- returnFunc = App.showConfirmationPopup(function () {
- self.set('nimbusHost', hostName);
- self.loadConfigs("loadStormConfigs");
- }, Em.I18n.t('hosts.host.addComponent.' + componentName) + manualKerberosWarning);
- break;
- case 'RANGER_KMS_SERVER':
- returnFunc = App.showConfirmationPopup(function () {
- self.set('rangerKMSServerHost', hostName);
- self.loadConfigs("loadRangerConfigs");
- }, Em.I18n.t('hosts.host.addComponent.' + componentName) + manualKerberosWarning);
- break;
- default:
- returnFunc = this.addClientComponent(component, isManualKerberos);
- }
- return returnFunc;
- },
- /**
- * Send command to server to install client on selected host
- * @param component
- */
- addClientComponent: function (component, isManualKerberos) {
- var self = this;
- var message = this.formatClientsMessage(component);
- return this.showAddComponentPopup(message, isManualKerberos, function () {
- self.installHostComponentCall(self.get('content.hostName'), component);
- });
- },
- showAddComponentPopup: function (message, isManualKerberos, primary) {
- isManualKerberos = isManualKerberos || false;
- return App.ModalPopup.show({
- primary: Em.I18n.t('hosts.host.addComponent.popup.confirm'),
- header: Em.I18n.t('popup.confirmation.commonHeader'),
- addComponentMsg: Em.I18n.t('hosts.host.addComponent.msg').format(message),
- manualKerberosWarning: isManualKerberos ? Em.I18n.t('hosts.host.manualKerberosWarning') : '',
- bodyClass: Em.View.extend({
- templateName: require('templates/main/host/details/addComponentPopup')
- }),
- onPrimary: function () {
- this.hide();
- primary();
- }
- });
- },
- /**
- * format message for operation of adding clients
- * @param client
- */
- formatClientsMessage: function (client) {
- var displayName = Em.isNone(client.get('displayName')) ? '' : client.get('displayName');
- var subComponentNames = client.get('subComponentNames');
- if (subComponentNames && subComponentNames.length > 0) {
- var dns = [];
- subComponentNames.forEach(function (scn) {
- dns.push(App.format.role(scn, false));
- });
- displayName += " (" + dns.join(", ") + ")";
- }
- return displayName;
- },
- /**
- * Success callback for install host component request (sent in <code>addNewComponentSuccessCallback</code>)
- * @param {object} data
- * @param {object} opt
- * @param {object} params
- * @method installNewComponentSuccessCallback
- */
- installNewComponentSuccessCallback: function (data, opt, params) {
- if (!data || !data.Requests || !data.Requests.id) {
- return false;
- }
- var self = this;
- if (App.get('testMode')) {
- this.mimicWorkStatusChange(params.component, App.HostComponentStatus.installing, App.HostComponentStatus.stopped);
- }
- this.showBackgroundOperationsPopup(function () {
- if (params.componentName === 'ZOOKEEPER_SERVER' || params.componentName === 'HIVE_SERVER') {
- self.set(params.componentName === 'ZOOKEEPER_SERVER' ? 'zkRequestId' : 'hiveRequestId', data.Requests.id);
- self.addObserver(
- 'App.router.backgroundOperationsController.serviceTimestamp',
- self,
- (params.componentName === 'ZOOKEEPER_SERVER' ? self.checkZkConfigs : self.checkHiveDone)
- );
- params.componentName === 'ZOOKEEPER_SERVER' ? self.checkZkConfigs() : self.checkHiveDone();
- }
- });
- return true;
- },
- /**
- * Call <code>setRackInfo</code> function to show Set Rack Id popup
- * @param data
- */
- setRackId: function (data) {
- var rack = data.context.get('rack');
- var hosts = [data.context];
- var operationData = {message: Em.I18n.t('hosts.host.details.setRackId')};
- hostsManagement.setRackInfo(operationData, hosts, rack);
- },
- /**
- * Call load tags
- * @method checkHiveDone
- */
- checkHiveDone: function () {
- var bg = App.router.get('backgroundOperationsController.services').findProperty('id', this.get('hiveRequestId'));
- if (bg && !bg.get('isRunning')) {
- var self = this;
- this.removeObserver('App.router.backgroundOperationsController.serviceTimestamp', this, this.checkHiveDone);
- setTimeout(function () {
- self.set('addHiveServer', true);
- self.loadConfigs("loadHiveConfigs");
- }, App.get('componentsUpdateInterval'));
- }
- },
- /**
- * Success callback for load configs request
- * @param {object} data
- * @method loadOozieConfigs
- */
- loadOozieConfigs: function (data) {
- return App.ajax.send({
- name: 'admin.get.all_configurations',
- sender: this,
- data: {
- urlParams: '(type=oozie-env&tag=' + data.Clusters.desired_configs['oozie-env'].tag + ')'
- },
- success: 'onLoadOozieConfigs',
- error: 'onLoadConfigsErrorCallback'
- });
- },
- /**
- * get Oozie database config and set databaseType
- * @param {object} data
- * @method onLoadHiveConfigs
- */
- onLoadOozieConfigs: function (data) {
- var configs = {};
- data.items.forEach(function (item) {
- $.extend(configs, item.properties);
- });
- this.set('isOozieServerAddable', !(Em.isEmpty(configs["oozie_database"]) || configs["oozie_database"] === 'New Derby Database'));
- this.get('isOozieConfigLoaded').resolve();
- },
- /**
- * Success callback for Storm load configs request
- * @param {object} data
- * @method loadStormConfigs
- */
- loadStormConfigs: function (data) {
- App.ajax.send({
- name: 'admin.get.all_configurations',
- sender: this,
- data: {
- urlParams: '(type=storm-site&tag=' + data.Clusters.desired_configs['storm-site'].tag + ')'
- },
- success: 'onLoadStormConfigs'
- });
- },
- /**
- * Update zk configs
- * @param {object} configs
- * @method updateZkConfigs
- */
- updateZkConfigs: function (configs) {
- var portValue = configs['zoo.cfg'] && Em.get(configs['zoo.cfg'], 'clientPort');
- var zkPort = typeof portValue === 'undefined' ? '2181' : portValue;
- var initializer = App.AddZooKeeperComponentsInitializer;
- var hostComponentsTopology = {
- masterComponentHosts: []
- };
- var masterComponents = this.bootstrapHostsMapping('ZOOKEEPER_SERVER');
- if (this.get('fromDeleteHost') || this.get('fromDeleteZkServer')) {
- this.set('fromDeleteHost', false);
- this.set('fromDeleteZkServer', false);
- var removedHost = masterComponents.findProperty('hostName', this.get('content.hostName'));
- if (!Em.isNone(removedHost)) {
- Em.set(removedHost, 'isInstalled', false);
- }
- }
- var dependencies = {
- zkClientPort: zkPort
- };
- hostComponentsTopology.masterComponentHosts = masterComponents;
- Em.keys(configs).forEach(function(fileName) {
- var properties = configs[fileName];
- Em.keys(properties).forEach(function(propertyName) {
- var propertyDef = {
- fileName: fileName,
- name: propertyName,
- value: properties[propertyName]
- };
- var configProperty = initializer.initialValue(propertyDef, hostComponentsTopology, dependencies);
- initializer.updateSiteObj(configs[fileName], configProperty);
- });
- });
- },
- /**
- *
- * @param {string} componentName
- * @param {string[]} [hostNames]
- * @returns {}
- */
- bootstrapHostsMapping: function(componentName, hostNames) {
- if (Em.isNone(hostNames)) {
- hostNames = App.HostComponent.find().filterProperty('componentName', componentName).mapProperty('hostName');
- }
- return hostNames.map(function(hostName) {
- return {
- component: componentName,
- hostName: hostName,
- isInstalled: true
- };
- });
- },
- /**
- * update and save Storm related configs to server
- * @param {object} data
- * @method onLoadStormConfigs
- */
- onLoadStormConfigs: function (data) {
- var nimbusHost = this.get('nimbusHost'),
- stormNimbusHosts = this.getStormNimbusHosts(),
- configs = {},
- attributes = {};
- data.items.forEach(function (item) {
- configs[item.type] = item.properties;
- attributes[item.type] = item.properties_attributes || {};
- }, this);
- this.updateZkConfigs(configs);
- configs['storm-site']['nimbus.seeds'] = JSON.stringify(stormNimbusHosts).replace(/"/g, "'");
- var groups = [
- {
- properties: {
- 'storm-site': configs['storm-site']
- },
- properties_attributes: {
- 'storm-site': attributes['storm-site']
- }
- }
- ];
- this.saveConfigsBatch(groups, 'NIMBUS', nimbusHost);
- },
- /**
- * Success callback for load configs request
- * @param {object} data
- * @method loadHiveConfigs
- */
- loadWebHCatConfigs: function (data) {
- return App.ajax.send({
- name: 'admin.get.all_configurations',
- sender: this,
- data: {
- webHCat: true,
- urlParams: [
- '(type=hive-site&tag=' + data.Clusters.desired_configs['hive-site'].tag + ')',
- '(type=webhcat-site&tag=' + data.Clusters.desired_configs['webhcat-site'].tag + ')',
- '(type=hive-env&tag=' + data.Clusters.desired_configs['hive-env'].tag + ')',
- '(type=core-site&tag=' + data.Clusters.desired_configs['core-site'].tag + ')'
- ].join('|')
- },
- success: 'onLoadHiveConfigs'
- });
- },
- /**
- * Success callback for load configs request
- * @param {object} data
- * @method loadHiveConfigs
- */
- loadHiveConfigs: function (data) {
- return App.ajax.send({
- name: 'admin.get.all_configurations',
- sender: this,
- data: {
- urlParams: [
- '(type=hive-site&tag=' + data.Clusters.desired_configs['hive-site'].tag + ')',
- '(type=webhcat-site&tag=' + data.Clusters.desired_configs['webhcat-site'].tag + ')',
- '(type=hive-env&tag=' + data.Clusters.desired_configs['hive-env'].tag + ')',
- '(type=core-site&tag=' + data.Clusters.desired_configs['core-site'].tag + ')'
- ].join('|')
- },
- success: 'onLoadHiveConfigs'
- });
- },
- /**
- * update and save Hive related configs to server
- * @param {object} data
- * @param {object} opt
- * @param {object} params
- * @method onLoadHiveConfigs
- */
- onLoadHiveConfigs: function (data, opt, params) {
- var hiveMetastoreHost = this.get('hiveMetastoreHost');
- var webhcatServerHost = this.get('webhcatServerHost');
- var port = "";
- var configs = {};
- var attributes = {};
- var userSetup = {};
- var localDB = {
- masterComponentHosts: this.getHiveHosts()
- };
- var dependencies = {
- hiveMetastorePort: ""
- };
- var initializer = params.webHCat ? App.AddWebHCatComponentsInitializer : App.AddHiveComponentsInitializer;
- data.items.forEach(function (item) {
- configs[item.type] = item.properties;
- attributes[item.type] = item.properties_attributes || {};
- }, this);
- port = configs['hive-site']['hive.metastore.uris'].match(/:[0-9]{2,4}/);
- port = port ? port[0].slice(1) : "9083";
- dependencies.hiveMetastorePort = port;
- if (params.webHCat) {
- userSetup.webhcatUser = configs['hive-env']['webhcat_user'];
- } else {
- userSetup.hiveUser = configs['hive-env']['hive_user'];
- }
- initializer.setup(userSetup);
- ['hive-site', 'webhcat-site', 'hive-env', 'core-site'].forEach(function(fileName) {
- if (configs[fileName]) {
- Em.keys(configs[fileName]).forEach(function(propertyName) {
- var propertyDef = {
- fileName: fileName,
- name: propertyName,
- value: configs[fileName][propertyName]
- };
- configs[fileName][propertyName] = Em.get(initializer.initialValue(propertyDef, localDB, dependencies), 'value');
- });
- }
- });
- initializer.cleanup();
- var groups = [
- {
- properties: {
- 'hive-site': configs['hive-site'],
- 'webhcat-site': configs['webhcat-site'],
- 'hive-env': configs['hive-env']
- },
- properties_attributes: {
- 'hive-site': attributes['hive-site'],
- 'webhcat-site': attributes['webhcat-site'],
- 'hive-env': attributes['hive-env']
- }
- },
- {
- properties: {
- 'core-site': configs['core-site']
- },
- properties_attributes: {
- 'core-site': attributes['core-site']
- }
- }
- ];
- var params = [groups];
- var componentName = this.get('addHiveServer') ? 'HIVE_SERVER' : (hiveMetastoreHost ? 'HIVE_METASTORE' : 'WEBHCAT_SERVER');
- var host = webhcatServerHost || hiveMetastoreHost;
- params.pushObjects([componentName, host]);
- this.saveConfigsBatch.apply(this, params);
- this.set('addHiveServer', false);
- },
- /**
- * save configs' sites in batch
- * @param groups
- * @param componentName
- * @param host
- */
- saveConfigsBatch: function (groups, componentName, host) {
- groups.forEach(function (group) {
- var desiredConfigs = [],
- tag = 'version' + (new Date).getTime(),
- properties = group.properties;
- for (var site in properties) {
- if (!properties.hasOwnProperty(site) || Em.isNone(properties[site])) continue;
- desiredConfigs.push({
- "type": site,
- "tag": tag,
- "properties": properties[site],
- "properties_attributes": group.properties_attributes[site],
- "service_config_version_note": Em.I18n.t('hosts.host.configs.save.note').format(App.format.role(componentName, false))
- });
- }
- if (desiredConfigs.length > 0) {
- App.ajax.send({
- name: 'common.service.configurations',
- sender: this,
- data: {
- desired_config: desiredConfigs,
- componentName: componentName,
- host: host
- },
- success: 'installHostComponent'
- });
- }
- //clear hive metastore host not to send second request to install component
- host = null;
- }, this);
- },
- /**
- * success callback for saveConfigsBatch method
- * @param data
- * @param opt
- * @param params
- */
- installHostComponent: function (data, opt, params) {
- if (App.router.get('location.location.hash').contains('configs')) {
- App.router.get('mainServiceInfoConfigsController').loadStep();
- }
- if (params.host) {
- this.installHostComponentCall(params.host, App.StackServiceComponent.find(params.componentName));
- }
- },
- /**
- * Delete Hive Metastore is performed
- * @type {bool}
- */
- deleteHiveMetaStore: false,
- /**
- * Delete WebHCat Server is performed
- *
- * @type {bool}
- */
- deleteWebHCatServer: false,
- getHiveHosts: function () {
- var self = this;
- var removePerformed = this.get('fromDeleteHost') || this.get('deleteHiveMetaStore') || this.get('deleteHiveServer') || this.get('deleteWebHCatServer');
- var hiveMasterComponents = ['WEBHCAT_SERVER', 'HIVE_METASTORE', 'HIVE_SERVER'];
- var masterComponentsMap = hiveMasterComponents.map(function(componentName) {
- return self.bootstrapHostsMapping(componentName);
- }).reduce(function(p,c) {
- return p.concat(c);
- });
- if (removePerformed) {
- self.setProperties({
- deleteHiveMetaStore: false,
- deleteHiveServer: false,
- deleteWebHCatServer: false,
- fromDeleteHost: false
- });
- masterComponentsMap = masterComponentsMap.map(function(masterComponent) {
- masterComponent.isInstalled = masterComponent.hostName !== self.get('content.hostName');
- return masterComponent;
- });
- }
- if (!!this.get('hiveMetastoreHost')) {
- masterComponentsMap.push({
- component: 'HIVE_METASTORE',
- hostName: this.get('hiveMetastoreHost'),
- isInstalled: !removePerformed
- });
- this.set('hiveMetastoreHost', '');
- }
- if (!!this.get('webhcatServerHost')) {
- masterComponentsMap.push({
- component: 'WEBHCAT_SERVER',
- hostName: this.get('webhcatServerHost'),
- isInstalled: !removePerformed
- });
- this.set('webhcatServerHost', '');
- }
- return masterComponentsMap;
- },
- /**
- * Success callback for load configs request
- * @param {object} data
- * @method loadHiveConfigs
- */
- loadRangerConfigs: function (data) {
- App.ajax.send({
- name: 'admin.get.all_configurations',
- sender: this,
- data: {
- urlParams: '(type=core-site&tag=' + data.Clusters.desired_configs['core-site'].tag + ')|(type=hdfs-site&tag=' + data.Clusters.desired_configs['hdfs-site'].tag + ')|(type=kms-env&tag=' + data.Clusters.desired_configs['kms-env'].tag + ')'
- },
- success: 'onLoadRangerConfigs'
- });
- },
- /**
- * update and save Hive hive.metastore.uris config to server
- * @param {object} data
- * @method onLoadHiveConfigs
- */
- onLoadRangerConfigs: function (data) {
- var hostToInstall = this.get('rangerKMSServerHost');
- var rkmsHosts = this.getRangerKMSServerHosts();
- var rkmsPort = data.items.findProperty('type', 'kms-env').properties['kms_port'];
- var coreSiteConfigs = data.items.findProperty('type', 'core-site');
- var hdfsSiteConfigs = data.items.findProperty('type', 'hdfs-site');
- var groups = [
- {
- properties: {
- 'core-site': coreSiteConfigs.properties,
- 'hdfs-site': hdfsSiteConfigs.properties
- },
- properties_attributes: {
- 'core-site': coreSiteConfigs.properties_attributes,
- 'hdfs-site': hdfsSiteConfigs.properties_attributes
- }
- }
- ];
- coreSiteConfigs.properties['hadoop.security.key.provider.path'] = 'kms://http@' + rkmsHosts.join(';') + ':' + rkmsPort + '/kms';
- hdfsSiteConfigs.properties['dfs.encryption.key.provider.uri'] = 'kms://http@' + rkmsHosts.join(';') + ':' + rkmsPort + '/kms';
- this.saveConfigsBatch(groups, 'RANGER_KMS_SERVER', hostToInstall);
- },
- /**
- * Delete Hive Metastore is performed
- * @type {bool}
- */
- deleteRangerKMSServer: false,
- getRangerKMSServerHosts: function () {
- var rkmsHosts = App.HostComponent.find().filterProperty('componentName', 'RANGER_KMS_SERVER').mapProperty('hostName');
- var rangerKMSServerHost = this.get('rangerKMSServerHost');
- if (!!rangerKMSServerHost) {
- rkmsHosts.push(rangerKMSServerHost);
- this.set('rangerKMSServerHost', '');
- }
- if (this.get('fromDeleteHost') || this.get('deleteRangerKMSServer')) {
- this.set('deleteRangerKMSServer', false);
- this.set('fromDeleteHost', false);
- return rkmsHosts.without(this.get('content.hostName'));
- }
- return rkmsHosts.sort();
- },
- /**
- * Delete Storm Nimbus is performed
- * @type {bool}
- */
- deleteNimbusHost: false,
- getStormNimbusHosts: function () {
- var
- stormNimbusHosts = App.HostComponent.find().filterProperty('componentName', 'NIMBUS').mapProperty('hostName'),
- nimbusHost = this.get('nimbusHost');
- if (!!nimbusHost) {
- stormNimbusHosts.push(nimbusHost);
- this.set('nimbusHost', '');
- }
- if (this.get('fromDeleteHost') || this.get('deleteNimbusHost')) {
- this.set('deleteNimbusHost', false);
- this.set('fromDeleteHost', false);
- return stormNimbusHosts.without(this.get('content.hostName'));
- }
- return stormNimbusHosts.sort();
- },
- /**
- * Send command to server to resfresh configs of selected component
- * @param {object} event
- * @method refreshComponentConfigs
- */
- refreshComponentConfigs: function (event) {
- var self = this;
- return App.showConfirmationPopup(function () {
- var component = event.context;
- var context = Em.I18n.t('requestInfo.refreshComponentConfigs').format(component.get('displayName'));
- self.sendRefreshComponentConfigsCommand(component, context);
- });
- },
- /**
- * PUTs a command to server to refresh configs of host component.
- * @param {object} component
- * @param {object} context Context under which this command is beign sent.
- * @method sendRefreshComponentConfigsCommand
- */
- sendRefreshComponentConfigsCommand: function (component, context) {
- var resource_filters = [
- {
- service_name: component.get('service.serviceName'),
- component_name: component.get('componentName'),
- hosts: component.get('host.hostName')
- }
- ];
- App.ajax.send({
- name: 'host.host_component.refresh_configs',
- sender: this,
- data: {
- resource_filters: resource_filters,
- context: context
- },
- success: 'refreshComponentConfigsSuccessCallback'
- });
- },
- /**
- * Success callback for refresh host component configs request
- * @method refreshComponentConfigsSuccessCallback
- */
- refreshComponentConfigsSuccessCallback: function () {
- this.showBackgroundOperationsPopup();
- },
- /**
- * Update storm config
- * @method updateStormConfigs
- */
- updateStormConfigs: function () {
- if (App.Service.find('STORM').get('isLoaded') && App.get('isHadoop23Stack')) {
- this.loadConfigs("loadStormConfigs");
- }
- },
- /**
- * Load tags
- * @method checkZkConfigs
- */
- checkZkConfigs: function () {
- var bg = App.router.get('backgroundOperationsController.services').findProperty('id', this.get('zkRequestId'));
- if (bg && !bg.get('isRunning')) {
- var self = this;
- this.removeObserver('App.router.backgroundOperationsController.serviceTimestamp', this, this.checkZkConfigs);
- setTimeout(function () {
- self.updateStormConfigs();
- var callback = function () {
- self.loadConfigs();
- };
- self.isServiceMetricsLoaded(callback);
- }, App.get('componentsUpdateInterval'));
- }
- },
- /**
- * Load configs
- * This function when used without a callback should be always used from successcallback function of the promise `App.router.get('mainController').isLoading.call(App.router.get('clusterController'), 'isServiceContentFullyLoaded').done(promise)`
- * This is required to make sure that service metrics API determining the HA state of components is loaded
- * @method loadConfigs
- */
- loadConfigs: function (callback) {
- App.ajax.send({
- name: 'config.tags',
- sender: this,
- success: callback ? callback : 'loadConfigsSuccessCallback',
- error: 'onLoadConfigsErrorCallback'
- });
- },
- /**
- * onLoadConfigsErrorCallback
- * @method onLoadConfigsErrorCallback
- */
- onLoadConfigsErrorCallback: function () {
- this.get('isOozieConfigLoaded').reject();
- },
- /**
- * Success callback for load configs request
- * @param {object} data
- * @method adConfigsSuccessCallback
- */
- loadConfigsSuccessCallback: function (data) {
- var urlParams = this.constructConfigUrlParams(data);
- if (urlParams.length > 0) {
- App.ajax.send({
- name: 'reassign.load_configs',
- sender: this,
- data: {
- urlParams: urlParams.join('|')
- },
- success: 'saveZkConfigs'
- });
- return true;
- }
- return false;
- },
- /**
- * construct URL params for query, that load configs
- * @param data {Object}
- * @return {Array}
- */
- constructConfigUrlParams: function (data) {
- var urlParams = [];
- var services = App.Service.find();
- if (App.get('isHaEnabled')) {
- urlParams.push('(type=core-site&tag=' + data.Clusters.desired_configs['core-site'].tag + ')');
- }
- if (services.someProperty('serviceName', 'HBASE')) {
- urlParams.push('(type=hbase-site&tag=' + data.Clusters.desired_configs['hbase-site'].tag + ')');
- }
- if (services.someProperty('serviceName', 'HIVE')) {
- urlParams.push('(type=webhcat-site&tag=' + data.Clusters.desired_configs['webhcat-site'].tag + ')');
- urlParams.push('(type=hive-site&tag=' + data.Clusters.desired_configs['hive-site'].tag + ')');
- }
- if (services.someProperty('serviceName', 'STORM')) {
- urlParams.push('(type=storm-site&tag=' + data.Clusters.desired_configs['storm-site'].tag + ')');
- }
- if (services.someProperty('serviceName', 'YARN')) {
- urlParams.push('(type=yarn-site&tag=' + data.Clusters.desired_configs['yarn-site'].tag + ')');
- urlParams.push('(type=zoo.cfg&tag=' + data.Clusters.desired_configs['zoo.cfg'].tag + ')');
- }
- if (services.someProperty('serviceName', 'ACCUMULO')) {
- urlParams.push('(type=accumulo-site&tag=' + data.Clusters.desired_configs['accumulo-site'].tag + ')');
- }
- if (services.someProperty('serviceName', 'KAFKA')) {
- urlParams.push('(type=kafka-broker&tag=' + data.Clusters.desired_configs['kafka-broker'].tag + ')');
- }
- return urlParams;
- },
- /**
- * save new ZooKeeper configs to server
- * @param {object} data
- * @method saveZkConfigs
- */
- saveZkConfigs: function (data) {
- var configs = {};
- var attributes = {};
- data.items.forEach(function (item) {
- configs[item.type] = item.properties;
- attributes[item.type] = item.properties_attributes || {};
- }, this);
- this.updateZkConfigs(configs);
- var groups = [
- {
- properties: {
- 'hive-site': configs['hive-site'],
- 'webhcat-site': configs['webhcat-site']
- },
- properties_attributes: {
- 'hive-site': attributes['hive-site'],
- 'webhcat-site': attributes['webhcat-site']
- }
- }
- ];
- var installedServiceNames = App.Service.find().mapProperty('serviceName');
- if (installedServiceNames.contains('YARN')) {
- groups.push(
- {
- properties: {
- 'yarn-site': configs['yarn-site']
- },
- properties_attributes: {
- 'yarn-site': attributes['yarn-site']
- }
- }
- );
- }
- if (installedServiceNames.contains('HBASE')) {
- groups.push(
- {
- properties: {
- 'hbase-site': configs['hbase-site']
- },
- properties_attributes: {
- 'hbase-site': attributes['hbase-site']
- }
- }
- );
- }
- if (installedServiceNames.contains('ACCUMULO')) {
- groups.push(
- {
- properties: {
- 'accumulo-site': configs['accumulo-site']
- },
- properties_attributes: {
- 'accumulo-site': attributes['accumulo-site']
- }
- }
- );
- }
- if (installedServiceNames.contains('KAFKA')) {
- groups.push(
- {
- properties: {
- 'kafka-broker': configs['kafka-broker']
- },
- properties_attributes: {
- 'kafka-broker': attributes['kafka-broker']
- }
- }
- );
- }
- this.saveConfigsBatch(groups, 'ZOOKEEPER_SERVER');
- },
- /**
- * Is deleteHost action id fired
- * @type {bool}
- */
- fromDeleteHost: false,
- /**
- * Is ZooKeeper Server being deleted from host
- * @type {bool}
- */
- fromDeleteZkServer: false,
- /**
- * Send command to server to install selected host component
- * @param {Object} event
- * @method installComponent
- */
- installComponent: function (event) {
- var self = this;
- var component = event.context;
- var componentName = component.get('componentName');
- var displayName = component.get('displayName');
- return App.ModalPopup.show({
- primary: Em.I18n.t('hosts.host.installComponent.popup.confirm'),
- header: Em.I18n.t('popup.confirmation.commonHeader'),
- installComponentMessage: Em.I18n.t('hosts.host.installComponent.msg').format(displayName),
- bodyClass: Em.View.extend({
- templateName: require('templates/main/host/details/installComponentPopup')
- }),
- onPrimary: function () {
- var _this = this;
- App.get('router.mainAdminKerberosController').getSecurityType(function () {
- App.get('router.mainAdminKerberosController').getKDCSessionState(function () {
- _this.hide();
- App.ajax.send({
- name: 'common.host.host_component.update',
- sender: self,
- data: {
- hostName: self.get('content.hostName'),
- serviceName: component.get('service.serviceName'),
- componentName: componentName,
- component: component,
- context: Em.I18n.t('requestInfo.installHostComponent') + " " + displayName,
- HostRoles: {
- state: 'INSTALLED'
- }
- },
- success: 'installComponentSuccessCallback',
- error: 'ajaxErrorCallback'
- });
- })
- });
- }
- });
- },
- /**
- * Success callback for install component request
- * @param {object} data
- * @param {object} opt
- * @param {object} params
- * @method installComponentSuccessCallback
- */
- installComponentSuccessCallback: function (data, opt, params) {
- if (App.get('testMode')) {
- this.mimicWorkStatusChange(params.component, App.HostComponentStatus.installing, App.HostComponentStatus.stopped);
- }
- this.showBackgroundOperationsPopup();
- },
- /**
- * Send command to server to run decommission on DATANODE, TASKTRACKER, NODEMANAGER, REGIONSERVER
- * @param {App.HostComponent} component
- * @method decommission
- */
- decommission: function (component) {
- var self = this;
- return App.showConfirmationPopup(function () {
- self.runDecommission.call(self, self.get('content.hostName'), component.get('service.serviceName'));
- });
- },
- /**
- * identify correct component to run decommission on them by service name,
- * in result run proper decommission method
- * @param hostName
- * @param svcName
- */
- runDecommission: function (hostName, svcName) {
- switch (svcName) {
- case 'HDFS':
- this.doDecommission(hostName, svcName, "NAMENODE", "DATANODE");
- break;
- case 'YARN':
- this.doDecommission(hostName, svcName, "RESOURCEMANAGER", "NODEMANAGER");
- break;
- case 'HBASE':
- this.warnBeforeDecommission(hostName);
- }
- },
- /**
- * Send command to server to run recommission on DATANODE, TASKTRACKER, NODEMANAGER
- * @param {App.HostComponent} component
- * @method recommission
- */
- recommission: function (component) {
- var self = this;
- return App.showConfirmationPopup(function () {
- self.runRecommission.call(self, self.get('content.hostName'), component.get('service.serviceName'));
- });
- },
- /**
- * identify correct component to run recommission on them by service name,
- * in result run proper recommission method
- * @param hostName
- * @param svcName
- */
- runRecommission: function (hostName, svcName) {
- switch (svcName) {
- case 'HDFS':
- this.doRecommissionAndStart(hostName, svcName, "NAMENODE", "DATANODE");
- break;
- case 'YARN':
- this.doRecommissionAndStart(hostName, svcName, "RESOURCEMANAGER", "NODEMANAGER");
- break;
- case 'HBASE':
- this.doRecommissionAndStart(hostName, svcName, "HBASE_MASTER", "HBASE_REGIONSERVER");
- }
- this.showBackgroundOperationsPopup();
- },
- /**
- * Performs Decommission (for DN, TT and NM)
- * @param {string} hostName
- * @param {string} serviceName
- * @param {string} componentName
- * @param {string} slaveType
- * @method doDecommission
- */
- doDecommission: function (hostName, serviceName, componentName, slaveType) {
- var contextNameString = 'hosts.host.' + slaveType.toLowerCase() + '.decommission';
- var context = Em.I18n.t(contextNameString);
- App.ajax.send({
- name: 'host.host_component.decommission_slave',
- sender: this,
- data: {
- context: context,
- command: 'DECOMMISSION',
- hostName: hostName,
- serviceName: serviceName,
- componentName: componentName,
- slaveType: slaveType
- },
- success: 'decommissionSuccessCallback',
- error: 'decommissionErrorCallback'
- });
- },
- /**
- * check is hbase regionserver in mm. If so - run decommission
- * otherwise shows warning
- * @method warnBeforeDecommission
- * @param {string} hostNames - list of host when run from bulk operations or current host
- */
- warnBeforeDecommission: function (hostNames) {
- if (this.get('content.hostComponents').findProperty('componentName', 'HBASE_REGIONSERVER').get('passiveState') == "OFF") {
- this.showHbaseActiveWarning();
- } else {
- this.checkRegionServerState(hostNames);
- }
- },
- /**
- * send call to check is this regionserver last in cluster which has desired_admin_state property "INSERVICE"
- * @method checkRegionServerState
- * @param hostNames
- */
- checkRegionServerState: function (hostNames) {
- return App.ajax.send({
- name: 'host.region_servers.in_inservice',
- sender: this,
- data: {
- hostNames: hostNames
- },
- success: 'checkRegionServerStateSuccessCallback'
- });
- },
- /**
- * check is this regionserver last in cluster which has desired_admin_state property "INSERVICE"
- * @method checkRegionServerStateSuccessCallback
- * @param data
- * @param opt
- * @param params
- */
- checkRegionServerStateSuccessCallback: function (data, opt, params) {
- var hostArray = params.hostNames.split(",");
- var decommissionPossible = (data.items.mapProperty('HostRoles.host_name').filter(function (hostName) {
- return !hostArray.contains(hostName);
- }, this).length >= 1);
- if (decommissionPossible) {
- this.doDecommissionRegionServer(params.hostNames, "HBASE", "HBASE_MASTER", "HBASE_REGIONSERVER");
- } else {
- this.showRegionServerWarning();
- }
- },
- /**
- * show warning that regionserver is last in cluster which has desired_admin_state property "INSERVICE"
- * @method showRegionServerWarning
- * @param hostNames
- */
- showRegionServerWarning: function () {
- return App.ModalPopup.show({
- header: Em.I18n.t('common.warning'),
- message: Em.I18n.t('hosts.host.hbase_regionserver.decommission.warning'),
- bodyClass: Ember.View.extend({
- template: Em.Handlebars.compile('<div class="alert alert-warning">{{message}}</div>')
- }),
- secondary: false
- });
- },
- /**
- * shows warning: put hbase regionserver in passive state
- * @method showHbaseActiveWarning
- * @return {App.ModalPopup}
- */
- showHbaseActiveWarning: function () {
- return App.ModalPopup.show({
- header: Em.I18n.t('common.warning'),
- message: Em.I18n.t('hostPopup.recommendation.beforeDecommission').format(App.format.components["HBASE_REGIONSERVER"]),
- bodyClass: Ember.View.extend({
- template: Em.Handlebars.compile('<div class="alert alert-warning">{{message}}</div>')
- }),
- secondary: false
- });
- },
- /**
- * Performs Decommission (for RegionServer)
- * @method doDecommissionRegionServer
- * @param {string} hostNames - list of host when run from bulk operations or current host
- * @param {string} serviceName - serviceName
- * @param {string} componentName - master compoent name
- * @param {string} slaveType - slave component name
- */
- doDecommissionRegionServer: function (hostNames, serviceName, componentName, slaveType) {
- var batches = [
- {
- "order_id": 1,
- "type": "POST",
- "uri": App.get('apiPrefix') + "/clusters/" + App.get('clusterName') + "/requests",
- "RequestBodyInfo": {
- "RequestInfo": {
- "context": Em.I18n.t('hosts.host.regionserver.decommission.batch1'),
- "command": "DECOMMISSION",
- "exclusive": "true",
- "parameters": {
- "slave_type": slaveType,
- "excluded_hosts": hostNames
- },
- 'operation_level': {
- level: "HOST_COMPONENT",
- cluster_name: App.get('clusterName'),
- host_name: hostNames,
- service_name: serviceName
- }
- },
- "Requests/resource_filters": [
- {"service_name": serviceName, "component_name": componentName}
- ]
- }
- }];
- var id = 2;
- var hAray = hostNames.split(",");
- for (var i = 0; i < hAray.length; i++) {
- batches.push({
- "order_id": id,
- "type": "PUT",
- "uri": App.get('apiPrefix') + "/clusters/" + App.get('clusterName') + "/hosts/" + hAray[i] + "/host_components/" + slaveType,
- "RequestBodyInfo": {
- "RequestInfo": {
- context: Em.I18n.t('hosts.host.regionserver.decommission.batch2'),
- exclusive: true,
- operation_level: {
- level: "HOST_COMPONENT",
- cluster_name: App.get('clusterName'),
- host_name: hostNames,
- service_name: serviceName || null
- }
- },
- "Body": {
- HostRoles: {
- state: "INSTALLED"
- }
- }
- }
- });
- id++;
- }
- batches.push({
- "order_id": id,
- "type": "POST",
- "uri": App.get('apiPrefix') + "/clusters/" + App.get('clusterName') + "/requests",
- "RequestBodyInfo": {
- "RequestInfo": {
- "context": Em.I18n.t('hosts.host.regionserver.decommission.batch3'),
- "command": "DECOMMISSION",
- "service_name": serviceName,
- "component_name": componentName,
- "parameters": {
- "slave_type": slaveType,
- "excluded_hosts": hostNames,
- "mark_draining_only": true
- },
- 'operation_level': {
- level: "HOST_COMPONENT",
- cluster_name: App.get('clusterName'),
- host_name: hostNames,
- service_name: serviceName
- }
- },
- "Requests/resource_filters": [
- {"service_name": serviceName, "component_name": componentName}
- ]
- }
- });
- App.ajax.send({
- name: 'host.host_component.recommission_and_restart',
- sender: this,
- data: {
- intervalTimeSeconds: 1,
- tolerateSize: 0,
- batches: batches
- },
- success: 'decommissionSuccessCallback',
- error: 'decommissionErrorCallback'
- });
- },
- /**
- * Error callback for decommission requests
- * @param {object} request
- * @param {object} ajaxOptions
- * @param {string} error
- * @method decommissionErrorCallback
- */
- decommissionErrorCallback: function (request, ajaxOptions, error) {
- },
- /**
- * Success ajax response for Recommission/Decommission slaves
- * @param {object} data
- * @method decommissionSuccessCallback
- * @return {Boolean}
- */
- decommissionSuccessCallback: function (data) {
- if (data && (data.Requests || data.resources[0].RequestSchedule)) {
- this.showBackgroundOperationsPopup();
- return true;
- } else {
- return false;
- }
- },
- /**
- * Performs Recommission and Start
- * @param {string} hostNames
- * @param {string} serviceName
- * @param {string} componentName
- * @param {string} slaveType
- * @method doRecommissionAndStart
- */
- doRecommissionAndStart: function (hostNames, serviceName, componentName, slaveType) {
- var contextNameString_1 = 'hosts.host.' + slaveType.toLowerCase() + '.recommission';
- var context_1 = Em.I18n.t(contextNameString_1);
- var contextNameString_2 = 'requestInfo.startHostComponent.' + slaveType.toLowerCase();
- var startContext = Em.I18n.t(contextNameString_2);
- var params = {
- "slave_type": slaveType,
- "included_hosts": hostNames
- };
- if (serviceName == "HBASE") {
- params.mark_draining_only = true;
- }
- var batches = [
- {
- "order_id": 1,
- "type": "POST",
- "uri": App.apiPrefix + "/clusters/" + App.get('clusterName') + "/requests",
- "RequestBodyInfo": {
- "RequestInfo": {
- "context": context_1,
- "command": "DECOMMISSION",
- "exclusive": "true",
- "parameters": params,
- 'operation_level': {
- level: "HOST_COMPONENT",
- cluster_name: App.get('clusterName'),
- host_name: hostNames,
- service_name: serviceName
- }
- },
- "Requests/resource_filters": [
- {"service_name": serviceName, "component_name": componentName}
- ]
- }
- }];
- var id = 2;
- var hAray = hostNames.split(",");
- for (var i = 0; i < hAray.length; i++) {
- batches.push({
- "order_id": id,
- "type": "PUT",
- "uri": App.get('apiPrefix') + "/clusters/" + App.get('clusterName') + "/hosts/" + hAray[i] + "/host_components/" + slaveType,
- "RequestBodyInfo": {
- "RequestInfo": {
- context: startContext,
- operation_level: {
- level: "HOST_COMPONENT",
- cluster_name: App.get('clusterName'),
- host_name: hostNames,
- service_name: serviceName || null
- }
- },
- "Body": {
- HostRoles: {
- state: "STARTED"
- }
- }
- }
- });
- id++;
- }
- App.ajax.send({
- name: 'host.host_component.recommission_and_restart',
- sender: this,
- data: {
- intervalTimeSeconds: 1,
- tolerateSize: 1,
- batches: batches
- },
- success: 'decommissionSuccessCallback',
- error: 'decommissionErrorCallback'
- });
- },
- /**
- * Handler for host-menu items actions
- * @param {object} option
- * @method doAction
- */
- doAction: function (option) {
- switch (option.context.action) {
- case "deleteHost":
- this.validateAndDeleteHost();
- break;
- case "startAllComponents":
- if (!this.get('content.isNotHeartBeating')) this.doStartAllComponents();
- break;
- case "stopAllComponents":
- if (!this.get('content.isNotHeartBeating')) this.doStopAllComponents();
- break;
- case "restartAllComponents":
- if (!this.get('content.isNotHeartBeating')) this.doRestartAllComponents();
- break;
- case "onOffPassiveModeForHost":
- this.onOffPassiveModeForHost(option.context);
- break;
- case "setRackId":
- this.setRackIdForHost();
- break;
- }
- },
- /**
- * Turn On/Off Passive Mode for host
- * @param {object} context
- * @method onOffPassiveModeForHost
- */
- onOffPassiveModeForHost: function (context) {
- var state = context.active ? 'ON' : 'OFF';
- var self = this;
- var message = Em.I18n.t('hosts.host.details.for.postfix').format(context.label);
- var popupInfo = Em.I18n.t('hosts.passiveMode.popup').format(context.active ? 'On' : 'Off', this.get('content.hostName'));
- if (state === 'OFF') {
- var hostVersion = this.get('content.stackVersions') && this.get('content.stackVersions').findProperty('isCurrent').get('repoVersion'),
- currentVersion = App.StackVersion.find().findProperty('isCurrent'),
- clusterVersion = currentVersion && currentVersion.get('repositoryVersion.repositoryVersion');
- if (hostVersion !== clusterVersion) {
- var msg = Em.I18n.t("hosts.passiveMode.popup.version.mismatch").format(this.get('content.hostName'), clusterVersion);
- popupInfo += '<br/><div class="alert alert-warning">' + msg + '</div>';
- }
- }
- return App.showConfirmationPopup(function () {
- self.hostPassiveModeRequest(state, message);
- }, popupInfo);
- },
- /**
- * Set rack id for host
- * @method setRackIdForHost
- */
- setRackIdForHost: function () {
- var hostNames = [{hostName: this.get('content.hostName')}];
- var rack = this.get('content.rack');
- var operationData = {message: Em.I18n.t('hosts.host.details.setRackId')};
- hostsManagement.setRackInfo(operationData, hostNames, rack);
- },
- /**
- * Send request to get passive state for host
- * @param {string} state
- * @param {string} message
- * @method hostPassiveModeRequest
- */
- hostPassiveModeRequest: function (state, message) {
- App.ajax.send({
- name: 'bulk_request.hosts.passive_state',
- sender: this,
- data: {
- hostNames: this.get('content.hostName'),
- passive_state: state,
- requestInfo: message
- },
- success: 'updateHost'
- });
- },
- /**
- * Success callback for receiving host passive state
- * @param {object} data
- * @param {object} opt
- * @param {object} params
- * @method updateHost
- */
- updateHost: function (data, opt, params) {
- this.set('content.passiveState', params.passive_state);
- batchUtils.infoPassiveState(params.passive_state);
- },
- /**
- * Send request to get passive state for hostComponent
- * @param {object} component - hostComponentn object
- * @param {string} state
- * @param {string} message
- * @method hostPassiveModeRequest
- */
- updateComponentPassiveState: function (component, state, message) {
- App.ajax.send({
- name: 'common.host.host_component.passive',
- sender: this,
- data: {
- hostName: this.get('content.hostName'),
- componentName: component.get('componentName'),
- component: component,
- passive_state: state,
- context: message
- },
- success: 'updateHostComponent'
- });
- },
- /**
- * Success callback for receiving hostComponent passive state
- * @param {object} data
- * @param {object} opt
- * @param {object} params
- * @method updateHost
- */
- updateHostComponent: function (data, opt, params) {
- params.component.set('passiveState', params.passive_state);
- batchUtils.infoPassiveState(params.passive_state);
- },
- /**
- * Show confirmation popup for action "start all components"
- * @method doStartAllComponents
- */
- doStartAllComponents: function () {
- var self = this;
- var components = this.get('serviceNonClientActiveComponents');
- if (components && components.get('length')) {
- return App.showConfirmationPopup(function () {
- self.sendComponentCommand(components, Em.I18n.t('hosts.host.maintainance.startAllComponents.context'), App.HostComponentStatus.started);
- });
- }
- },
- /**
- * Show confirmation popup for action "stop all components"
- * @method doStopAllComponents
- */
- doStopAllComponents: function () {
- var self = this;
- var components = this.get('serviceNonClientActiveComponents');
- if (components && components.get('length')) {
- if (components.someProperty('componentName', 'NAMENODE') &&
- this.get('content.hostComponents').filterProperty('componentName', 'NAMENODE').someProperty('workStatus', App.HostComponentStatus.started)) {
- this.checkNnLastCheckpointTime(function () {
- App.showConfirmationPopup(function () {
- self.sendComponentCommand(components, Em.I18n.t('hosts.host.maintainance.stopAllComponents.context'), App.HostComponentStatus.stopped);
- });
- });
- } else {
- return App.showConfirmationPopup(function () {
- self.sendComponentCommand(components, Em.I18n.t('hosts.host.maintainance.stopAllComponents.context'), App.HostComponentStatus.stopped);
- });
- }
- }
- },
- /**
- * Show confirmation popup for action "restart all components"
- * @method doRestartAllComponents
- */
- doRestartAllComponents: function () {
- var self = this;
- var components = this.get('serviceActiveComponents');
- if (components && components.get('length')) {
- if (components.someProperty('componentName', 'NAMENODE') &&
- this.get('content.hostComponents').filterProperty('componentName', 'NAMENODE').someProperty('workStatus', App.HostComponentStatus.started)) {
- this.checkNnLastCheckpointTime(function () {
- App.showConfirmationPopup(function () {
- batchUtils.restartHostComponents(components, Em.I18n.t('rollingrestart.context.allOnSelectedHost').format(self.get('content.hostName')), "HOST");
- });
- });
- } else {
- return App.showConfirmationPopup(function () {
- batchUtils.restartHostComponents(components, Em.I18n.t('rollingrestart.context.allOnSelectedHost').format(self.get('content.hostName')), "HOST");
- });
- }
- }
- },
- /**
- * get info about host-components, exactly:
- * - host-components grouped by status, features
- * - flag, that indicate whether ZooKeeper Server is installed
- * @return {Object}
- */
- getHostComponentsInfo: function () {
- var componentsOnHost = this.get('content.hostComponents');
- var allComponents = App.HostComponent.find();
- var stoppedStates = [App.HostComponentStatus.stopped,
- App.HostComponentStatus.install_failed,
- App.HostComponentStatus.upgrade_failed,
- App.HostComponentStatus.init,
- App.HostComponentStatus.unknown];
- var container = {
- zkServerInstalled: false,
- lastComponents: [],
- masterComponents: [],
- runningComponents: [],
- nonDeletableComponents: [],
- unknownComponents: [],
- toDecommissionComponents: []
- };
- var self = this;
- if (componentsOnHost && componentsOnHost.get('length') > 0) {
- componentsOnHost.forEach(function (cInstance) {
- if (cInstance.get('componentName') === 'ZOOKEEPER_SERVER') {
- container.zkServerInstalled = true;
- }
- if (allComponents.filterProperty('componentName', cInstance.get('componentName')).get('length') === 1) {
- container.lastComponents.push(cInstance.get('displayName'));
- }
- var workStatus = cInstance.get('workStatus');
- if (cInstance.get('isMaster') && !cInstance.get('isDeletable')) {
- container.masterComponents.push(cInstance.get('displayName'));
- }
- if (stoppedStates.indexOf(workStatus) < 0) {
- container.runningComponents.push(cInstance.get('displayName'));
- }
- if (!cInstance.get('isDeletable')) {
- container.nonDeletableComponents.push(cInstance.get('displayName'));
- }
- if (workStatus === App.HostComponentStatus.unknown) {
- container.unknownComponents.push(cInstance.get('displayName'));
- }
- if (App.get('components.decommissionAllowed').contains(cInstance.get('componentName')) && !cInstance.get('view.isComponentRecommissionAvailable')) {
- container.toDecommissionComponents.push(cInstance.get('displayName'));
- }
- });
- }
- return container;
- },
- /**
- * Deletion of hosts not supported for this version
- * @method validateAndDeleteHost
- */
- validateAndDeleteHost: function () {
- var container = this.getHostComponentsInfo();
- if (container.masterComponents.length > 0) {
- this.raiseDeleteComponentsError(container, 'masterList');
- return;
- } else if (container.nonDeletableComponents.length > 0) {
- this.raiseDeleteComponentsError(container, 'nonDeletableList');
- return;
- } else if (container.runningComponents.length > 0) {
- this.raiseDeleteComponentsError(container, 'runningList');
- return;
- }
- if (container.zkServerInstalled) {
- var self = this;
- return App.showConfirmationPopup(function () {
- self.confirmDeleteHost(container);
- }, Em.I18n.t('hosts.host.addComponent.deleteHostWithZooKeeper'));
- } else {
- this.confirmDeleteHost(container);
- }
- },
- /**
- * Show popup with info about reasons why host can't be deleted
- * @param {string[]} components
- * @param {string} type
- * @method raiseDeleteComponentsError
- */
- raiseDeleteComponentsError: function (container, type) {
- App.ModalPopup.show({
- header: Em.I18n.t('hosts.cant.do.popup.title'),
- type: type,
- showBodyEnd: Em.computed.existsIn('type', ['runningList', 'masterList']),
- container: container,
- components: function(){
- var container = this.get('container');
- switch (this.get('type')) {
- case 'masterList':
- return container.masterComponents;
- case 'nonDeletableList':
- return container.nonDeletableComponents;
- case 'runningList':
- return container.runningComponents;
- }
- }.property('type'),
- componentsStr: function () {
- return this.get('components').join(", ");
- }.property('components.[]'),
- componentsBody: Em.computed.i18nFormat('hosts.cant.do.popup.' + type + '.body', 'components.length'),
- componentsBodyEnd: function () {
- if (this.get('showBodyEnd')) {
- return Em.I18n.t('hosts.cant.do.popup.' + type + '.body.end').format(App.get('components.decommissionAllowed').map(function(c){return App.format.role(c, false)}).join(", "));
- }
- return '';
- }.property(),
- bodyClass: Em.View.extend({
- templateName: require('templates/main/host/details/raiseDeleteComponentErrorPopup')
- }),
- secondary: null
- });
- },
- /**
- * Show confirmation popup to delete host
- * @param {Object} container
- * @method confirmDeleteHost
- */
- confirmDeleteHost: function (container) {
- var self = this;
- return App.ModalPopup.show({
- header: Em.I18n.t('hosts.delete.popup.title'),
- deletePopupBody: Em.I18n.t('hosts.delete.popup.body').format(self.get('content.publicHostName')),
- lastComponent: function () {
- if (container.lastComponents && container.lastComponents.length) {
- this.set('isChecked', false);
- return true;
- } else {
- this.set('isChecked', true);
- return false;
- }
- }.property(),
- disablePrimary: Em.computed.not('isChecked'),
- isChecked: false,
- lastComponentError: Em.View.extend({
- template: Em.Handlebars.compile(Em.I18n.t('hosts.delete.popup.body.msg4').format(container.lastComponents))
- }),
- unknownComponents: function () {
- if (container.unknownComponents && container.unknownComponents.length) {
- return container.unknownComponents.join(", ");
- }
- return '';
- }.property(),
- decommissionWarning: Em.View.extend({
- template: Em.Handlebars.compile(Em.I18n.t('hosts.delete.popup.body.msg7').format(container.toDecommissionComponents.join(', ')))
- }),
- toDecommissionComponents: container.toDecommissionComponents,
- bodyClass: Em.View.extend({
- templateName: require('templates/main/host/details/doDeleteHostPopup')
- }),
- onPrimary: function () {
- var popup = this;
- var completeCallback = function () {
- var remainingHosts = App.db.getSelectedHosts('mainHostController').removeObject(self.get('content.hostName'));
- App.db.setSelectedHosts('mainHostController', remainingHosts);
- popup.hide();
- };
- self.doDeleteHost(completeCallback);
- }
- });
- },
- /**
- * send DELETE calls to components of host and after delete host itself
- * @param completeCallback
- * @method doDeleteHost
- */
- doDeleteHost: function (completeCallback) {
- this.set('fromDeleteHost', true);
- var allComponents = this.get('content.hostComponents');
- var deleteError = null;
- var dfd = $.Deferred();
- var self = this;
- if (allComponents.get('length') > 0) {
- allComponents.forEach(function (component, index) {
- var length = allComponents.get('length');
- if (!deleteError) {
- this._doDeleteHostComponent(component, function () {
- deleteError = self.get('_deletedHostComponentResult');
- if (index == length - 1) {
- dfd.resolve();
- }
- });
- }
- }, this);
- } else {
- dfd.resolve();
- }
- dfd.done(function () {
- if (!deleteError) {
- App.ajax.send({
- name: 'common.delete.host',
- sender: self,
- data: {
- hostName: self.get('content.hostName')
- },
- callback: completeCallback,
- success: 'deleteHostSuccessCallback',
- error: 'deleteHostErrorCallback'
- });
- }
- else {
- completeCallback();
- deleteError.xhr.responseText = "{\"message\": \"" + deleteError.xhr.statusText + "\"}";
- App.ajax.defaultErrorHandler(deleteError.xhr, deleteError.url, deleteError.method, deleteError.xhr.status);
- }
- });
- },
- deleteHostSuccessCallback: function (data, rq, requestBody) {
- var self = this;
- App.router.get('updateController').updateHost(function () {
- App.router.transitionTo('hosts.index');
- });
- if (!!(requestBody && requestBody.hostName))
- App.hostsMapper.deleteRecord(App.Host.find().findProperty('hostName', requestBody.hostName));
- App.router.get('clusterController').getAllHostNames();
- },
- deleteHostErrorCallback: function (xhr, textStatus, errorThrown, opt) {
- xhr.responseText = "{\"message\": \"" + xhr.statusText + "\"}";
- var self = this;
- var callback = function () {
- self.loadConfigs();
- };
- self.isServiceMetricsLoaded(callback);
- App.ajax.defaultErrorHandler(xhr, opt.url, 'DELETE', xhr.status);
- },
- /**
- * Send command to server to restart all host components with stale configs
- * @method restartAllStaleConfigComponents
- */
- restartAllStaleConfigComponents: function () {
- var self = this;
- var staleComponents = self.get('content.componentsWithStaleConfigs');
- if (staleComponents.someProperty('componentName', 'NAMENODE') &&
- this.get('content.hostComponents').filterProperty('componentName', 'NAMENODE').someProperty('workStatus', App.HostComponentStatus.started)) {
- this.checkNnLastCheckpointTime(function () {
- App.showConfirmationPopup(function () {
- batchUtils.restartHostComponents(staleComponents, Em.I18n.t('rollingrestart.context.allWithStaleConfigsOnSelectedHost').format(self.get('content.hostName')), "HOST");
- });
- });
- } else {
- return App.showConfirmationPopup(function () {
- batchUtils.restartHostComponents(staleComponents, Em.I18n.t('rollingrestart.context.allWithStaleConfigsOnSelectedHost').format(self.get('content.hostName')), "HOST");
- });
- }
- },
- /**
- * open Reassign Master Wizard with selected component
- * @param {object} event
- * @method moveComponent
- */
- moveComponent: function (event) {
- if ($(event.target).closest('li').hasClass('disabled')) {
- return;
- }
- return App.showConfirmationPopup(function () {
- var component = event.context;
- var reassignMasterController = App.router.get('reassignMasterController');
- reassignMasterController.saveComponentToReassign(component);
- reassignMasterController.setCurrentStep('1');
- App.router.transitionTo('reassign');
- });
- },
- /**
- * Restart clients host components to apply config changes
- * @param {object} event
- * @method refreshConfigs
- */
- refreshConfigs: function (event) {
- var self = this;
- var components = event.context;
- if (components.get('length') > 0) {
- return App.showConfirmationPopup(function () {
- batchUtils.restartHostComponents(components, Em.I18n.t('rollingrestart.context.allClientsOnSelectedHost').format(self.get('content.hostName')), "HOST");
- });
- }
- },
- toggleMaintenanceMode: function (event) {
- var state, message, self = this;
- if (event.context.get('isImpliedState')) return null;
- state = event.context.get('passiveState') === "ON" ? "OFF" : "ON";
- message = Em.I18n.t('passiveState.turn' + state.toCapital() + 'For').format(event.context.get('displayName'));
- return App.showConfirmationPopup(function () {
- self.updateComponentPassiveState(event.context, state, message);
- });
- },
- downloadClientConfigs: function (event) {
- this.downloadClientConfigsCall({
- hostName: event.context.get('hostName'),
- componentName: event.context.get('componentName'),
- displayName: event.context.get('displayName')
- });
- },
- installClients: function (event) {
- var clientsToInstall = [],
- clientsToAdd = [],
- missedComponents = [],
- dependentComponents = [],
- self = this;
- event.context.forEach(function (component) {
- if (['INIT', 'INSTALL_FAILED'].contains(component.get('workStatus'))) {
- clientsToInstall.push(component);
- } else if (typeof component.get('workStatus') == 'undefined') {
- clientsToAdd.push(component);
- }
- });
- clientsToAdd.forEach(function (component, index, array) {
- var dependencies = this.checkComponentDependencies(component.get('componentName'), {
- scope: 'host',
- installedComponents: this.get('content.hostComponents').mapProperty('componentName')
- }).reject(function (componentName) {
- return array.mapProperty('componentName').contains(componentName);
- });
- if (dependencies.length) {
- missedComponents.pushObjects(dependencies);
- dependentComponents.push(component.get('displayName'));
- }
- }, this);
- missedComponents = missedComponents.uniq();
- if (missedComponents.length) {
- var popupMessage = Em.I18n.t('host.host.addComponent.popup.clients.dependedComponents.body').format(stringUtils.getFormattedStringFromArray(dependentComponents),
- stringUtils.getFormattedStringFromArray(missedComponents.map(function (componentName) {
- return App.StackServiceComponent.find(componentName).get('displayName');
- })));
- App.showAlertPopup(Em.I18n.t('host.host.addComponent.popup.dependedComponents.header'), popupMessage);
- } else {
- App.get('router.mainAdminKerberosController').getSecurityType(function () {
- App.get('router.mainAdminKerberosController').getKDCSessionState(function () {
- var sendInstallCommand = function () {
- if (clientsToInstall.length) {
- self.sendComponentCommand(clientsToInstall, Em.I18n.t('host.host.details.installClients'), 'INSTALLED');
- }
- };
- if (clientsToAdd.length) {
- var message = stringUtils.getFormattedStringFromArray(clientsToAdd.mapProperty('displayName'));
- var isManualKerberos = App.get('router.mainAdminKerberosController.isManualKerberos');
- self.showAddComponentPopup(message, isManualKerberos, function () {
- sendInstallCommand();
- clientsToAdd.forEach(function (component) {
- self.installHostComponentCall(self.get('content.hostName'), component);
- });
- });
- } else {
- sendInstallCommand();
- }
- });
- }.bind(this));
- }
- },
- /**
- * Check if all required components are installed on host.
- * Available options:
- * scope: 'host' - dependency level `host`,`cluster` or `*`.
- * hostName: 'example.com' - host name to search installed components
- * installedComponents: ['A', 'B'] - names of installed components
- *
- * By default scope level is `*`
- * For host level dependency you should specify at least `hostName` or `installedComponents` attribute.
- *
- * @param {String} componentName
- * @param {Object} opt - options. Allowed options are `hostName`, `installedComponents`, `scope`.
- * @return {Array} - names of missed components
- */
- checkComponentDependencies: function (componentName, opt) {
- opt = opt || {};
- opt.scope = opt.scope || '*';
- var installedComponents;
- var dependencies = App.StackServiceComponent.find(componentName).get('dependencies');
- dependencies = opt.scope === '*' ? dependencies : dependencies.filterProperty('scope', opt.scope);
- if (dependencies.length == 0) return [];
- switch (opt.scope) {
- case 'host':
- Em.assert("You should pass at least `hostName` or `installedComponents` to options.", opt.hostName || opt.installedComponents);
- installedComponents = opt.installedComponents || App.HostComponent.find().filterProperty('hostName', opt.hostName).mapProperty('componentName').uniq();
- break;
- default:
- // @todo: use more appropriate value regarding installed components
- installedComponents = opt.installedComponents || App.HostComponent.find().mapProperty('componentName').uniq();
- break;
- }
- return dependencies.filter(function (dependency) {
- return !installedComponents.contains(dependency.componentName);
- }).mapProperty('componentName');
- },
- /**
- * On click handler for custom command from items menu
- * @param context
- */
- executeCustomCommand: function(event) {
- var controller = this;
- var context = event.context;
- return App.showConfirmationPopup(function() {
- App.ajax.send({
- name : 'service.item.executeCustomCommand',
- sender: controller,
- data : {
- command : context.command,
- context : context.context || Em.I18n.t('services.service.actions.run.executeCustomCommand.context').format(context.command),
- hosts : context.hosts,
- serviceName : context.service,
- componentName : context.component
- },
- success : 'executeCustomCommandSuccessCallback',
- error : 'executeCustomCommandErrorCallback'
- });
- });
- },
- executeCustomCommandSuccessCallback : function(data, ajaxOptions, params) {
- if (data.Requests.id) {
- App.router.get('backgroundOperationsController').showPopup();
- }
- },
- executeCustomCommandErrorCallback : function(data) {
- var error = Em.I18n.t('services.service.actions.run.executeCustomCommand.error');
- if(data && data.responseText){
- try {
- var json = $.parseJSON(data.responseText);
- error += json.message;
- } catch (err) {}
- }
- App.showAlertPopup(Em.I18n.t('services.service.actions.run.executeCustomCommand.error'), error);
- },
- /**
- * Call callback after loading service metrics
- * @param callback
- */
- isServiceMetricsLoaded: function(callback) {
- App.router.get('mainController').isLoading.call(App.router.get('clusterController'), 'isServiceContentFullyLoaded').done(callback);
- }
- });
|