onLoadConfigs: function (data) { var hdfsSiteProperties = data.items.findProperty('type', 'hdfs-site').properties; var coreSiteProperties = data.items.findProperty('type', 'core-site').properties; var currentNameNodeHost = this.get('content.masterComponentHosts').findProperty('isCurNameNode').hostName; var newNameNodeHost = this.get('content.masterComponentHosts').findProperty('isAddNameNode').hostName; var journalNodeHosts = this.get('content.masterComponentHosts').filterProperty('component', 'JOURNALNODE').mapProperty('hostName'); var zooKeeperHosts = this.get('content.masterComponentHosts').filterProperty('component', 'ZOOKEEPER_SERVER').mapProperty('hostName'); var nameServiceId = this.get('content.nameServiceId'); //hdfs-site configs changes hdfsSiteProperties['dfs.nameservices'] = nameServiceId; hdfsSiteProperties['dfs.ha.namenodes.' + nameServiceId] = 'nn1,nn2'; hdfsSiteProperties['dfs.namenode.rpc-address.' + nameServiceId + '.nn1'] = currentNameNodeHost + ':8020'; hdfsSiteProperties['dfs.namenode.rpc-address.' + nameServiceId + '.nn2'] = newNameNodeHost + ':8020'; hdfsSiteProperties['dfs.namenode.http-address.' + nameServiceId + '.nn1'] = currentNameNodeHost + ':50070'; hdfsSiteProperties['dfs.namenode.http-address.' + nameServiceId + '.nn2'] = newNameNodeHost + ':50070'; hdfsSiteProperties['dfs.namenode.shared.edits.dir'] = 'qjournal://' + journalNodeHosts[0] + ':8485;' + journalNodeHosts[1] + ':8485;' + journalNodeHosts[2] + ':8485/' + nameServiceId; hdfsSiteProperties['dfs.client.failover.proxy.provider.' + nameServiceId] = 'org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider'; hdfsSiteProperties['dfs.ha.fencing.methods'] = 'shell(/bin/true)'; hdfsSiteProperties['dfs.journalnode.edits.dir'] = '/grid/0/hdfs/journal'; hdfsSiteProperties['dfs.ha.automatic-failover.enabled'] = 'true'; //core-site configs changes coreSiteProperties['ha.zookeeper.quorum'] = zooKeeperHosts[0] + ':2181,' + zooKeeperHosts[1] + ':2181,' + zooKeeperHosts[2] + ':2181'; coreSiteProperties['fs.defaultFS'] = 'hdfs://' + nameServiceId; this.set('configsSaved', false); App.ajax.send({ name: 'admin.high_availability.save_configs', sender: this, data: { siteName: 'hdfs-site', properties: hdfsSiteProperties }, success: 'installHDFSClients', error: 'onTaskError' }); App.ajax.send({ name: 'admin.high_availability.save_configs', sender: this, data: { siteName: 'core-site', properties: coreSiteProperties }, success: 'installHDFSClients', error: 'onTaskError' }); },
installServices: function (isRetry, callback) { // clear requests since we are installing services // and we don't want to get tasks for previous install attempts this.set('content.cluster.oldRequestsId', []); var data; callback = callback || Em.K; if (isRetry) { data = { context: Em.I18n.t('requestInfo.installComponents'), HostRoles: {"state": "INSTALLED"}, urlParams: "HostRoles/desired_state=INSTALLED" }; } else { data = { context: Em.I18n.t('requestInfo.installServices'), ServiceInfo: {"state": "INSTALLED"}, urlParams: "ServiceInfo/state=INIT" }; } var clusterStatus = { status: 'PENDING' }; this.saveClusterStatus(clusterStatus); App.ajax.send({ name: isRetry ? 'common.host_components.update' : 'common.services.update', sender: this, data: data, success: 'installServicesSuccessCallback', error: 'installServicesErrorCallback' }).then(callback, callback); },
doBootstrap: function () { if (this.get('stopBootstrap')) { return null; } this.incrementProperty('numPolls'); return App.ajax.send({ name: 'wizard.step3.bootstrap', sender: this, data: { bootRequestId: this.get('content.installOptions.bootRequestId'), numPolls: this.get('numPolls') }, success: 'doBootstrapSuccessCallback' }). retry({ times: App.maxRetries, timeout: App.timeout }). then( null, function () { App.showReloadPopup(); console.log('Bootstrap failed'); } ); },
validate: function(blueprint, callback) { var self = this; var selectedServices = App.StackService.find().filterProperty('isSelected').mapProperty('serviceName'); var installedServices = App.StackService.find().filterProperty('isInstalled').mapProperty('serviceName'); var services = installedServices.concat(selectedServices).uniq(); var hostNames = self.get('hosts').mapProperty('host_name'); App.ajax.send({ name: 'config.validations', sender: self, data: { stackVersionUrl: App.get('stackVersionURL'), hosts: hostNames, services: services, validate: 'host_groups', recommendations: blueprint }, success: 'updateValidationsSuccessCallback', error: 'updateValidationsErrorCallback' }).then(function() { if (callback) { callback(); } } ); },
onLoadConfigsTags: function (data) { var componentName = this.get('content.reassign.component_name'); var urlParams = []; switch (componentName) { case 'NAMENODE': urlParams.push('(type=hdfs-site&tag=' + data.Clusters.desired_configs['hdfs-site'].tag + ')'); urlParams.push('(type=core-site&tag=' + data.Clusters.desired_configs['core-site'].tag + ')'); if (App.Service.find().someProperty('serviceName', 'HBASE')) { urlParams.push('(type=hbase-site&tag=' + data.Clusters.desired_configs['hbase-site'].tag + ')'); } break; case 'SECONDARY_NAMENODE': urlParams.push('(type=hdfs-site&tag=' + data.Clusters.desired_configs['hdfs-site'].tag + ')'); urlParams.push('(type=core-site&tag=' + data.Clusters.desired_configs['core-site'].tag + ')'); break; case 'JOBTRACKER': urlParams.push('(type=mapred-site&tag=' + data.Clusters.desired_configs['mapred-site'].tag + ')'); break; case 'RESOURCEMANAGER': urlParams.push('(type=yarn-site&tag=' + data.Clusters.desired_configs['yarn-site'].tag + ')'); break; } App.ajax.send({ name: 'reassign.load_configs', sender: this, data: { urlParams: urlParams.join('|') }, success: 'onLoadConfigs', error: 'onTaskError' }); },
applyConfigurationsToCluster: function () { var configData = []; this.get('serviceConfigTags').forEach(function (_serviceConfig) { var Clusters = { Clusters: { desired_config: { type: _serviceConfig.siteName, tag: _serviceConfig.newTagName, properties: _serviceConfig.configs } } }; configData.pushObject(JSON.stringify(Clusters)); }, this); var data = { configData: '[' + configData.toString() + ']' }; App.ajax.send({ name: 'admin.security.apply_configurations', sender: this, data: data, success: 'applyConfigurationToClusterSuccessCallback', error: 'applyConfigurationToClusterErrorCallback' }); },
os.get('repositories').forEach(function (repo) { repo.setProperties({ errorTitle: '', errorContent: '', validation: App.Repository.validation['INPROGRESS'] }); this.set('content.isCheckInProgress', true); App.ajax.send({ name: 'wizard.advanced_repositories.valid_url', sender: this, data: { stackName: stackName, stackVersion: stackVersion, repoId: repo.get('repoId'), osType: os.get('osType'), osId: os.get('id'), dfd: dfd, data: { 'Repositories': { 'base_url': repo.get('baseUrl'), "verify_base_url": verifyBaseUrl } } }, success: 'checkRepoURLSuccessCallback', error: 'checkRepoURLErrorCallback' }); }, this);
renderConfigs: function () { var configs = $.extend(true, {}, require('data/HDP2/rm_ha_properties').haConfig); var serviceConfig = App.ServiceConfig.create({ serviceName: configs.serviceName, displayName: configs.displayName, configCategories: [], showConfig: true, configs: [] }); configs.configCategories.forEach(function (configCategory) { if (App.Service.find().someProperty('serviceName', configCategory.name)) { serviceConfig.configCategories.pushObject(configCategory); } }, this); this.renderConfigProperties(configs, serviceConfig); App.ajax.send({ name: 'config.tags', sender: this, success: 'loadConfigTagsSuccessCallback', error: 'loadConfigsErrorCallback', data: { serviceConfig: serviceConfig } }); },
}, function (data) { if (data.items.length) { var hostsWithComponentInProperState = data.items.mapProperty('Hosts.host_name'); App.ajax.send({ name: 'common.host_components.update', sender: self, data: { HostRoles: { state: operationData.action }, query: 'HostRoles/component_name=' + operationData.componentName + '&HostRoles/host_name.in(' + hostsWithComponentInProperState.join(',') + ')&HostRoles/maintenance_state=OFF', context: operationData.message + ' ' + operationData.componentNameFormatted, level: 'SERVICE', noOpsMessage: operationData.componentNameFormatted }, success: 'bulkOperationForHostComponentsSuccessCallback' }); } else { App.ModalPopup.show({ header: Em.I18n.t('rolling.nothingToDo.header'), body: Em.I18n.t('rolling.nothingToDo.body').format(operationData.componentNameFormatted), secondary: false }); } });
}, function (data) { var hostNames = []; data.items.forEach(function (host) { if (host.Hosts.maintenance_state !== operationData.state) { hostNames.push(host.Hosts.host_name); } }); if (hostNames.length) { App.ajax.send({ name: 'bulk_request.hosts.passive_state', sender: self, data: { hostNames: hostNames.join(','), passive_state: operationData.state, requestInfo: operationData.message }, success: 'updateHostPassiveState' }); } else { App.ModalPopup.show({ header: Em.I18n.t('rolling.nothingToDo.header'), body: Em.I18n.t('hosts.bulkOperation.passiveState.nothingToDo.body'), secondary: false }); } });
pullNnCheckPointTime: function () { return App.ajax.send({ name: 'common.service.hdfs.getNnCheckPointTime', sender: this, success: 'parseNnCheckPointTime' }); },
logOff: function (context) { $('title').text('Ambari'); var hash = window.btoa(this.get('loginController.loginName') + ":" + this.get('loginController.password')); App.router.get('mainController').stopPolling(); // App.db.cleanUp() must be called before router.clearAllSteps(). // otherwise, this.set('installerController.currentStep, 0) would have no effect // since it's a computed property but we are not setting it as a dependent of App.db. App.db.cleanUp(); App.set('isAdmin', false); this.set('loggedIn', false); this.clearAllSteps(); console.log("Log off: " + App.router.getClusterName()); this.set('loginController.loginName', ''); this.set('loginController.password', ''); // When logOff is called by Sign Out button, context contains event object. As it is only case we should send logoff request, we are checking context below. if (!App.testMode && context) { App.ajax.send({ name: 'router.logoff', sender: this, data: { auth: "Basic " + hash }, beforeSend: 'authBeforeSend', success: 'logOffSuccessCallback', error:'logOffErrorCallback' }); } this.transitionTo('login', context); },
loginSuccessCallback: function(data, opt, params) { console.log('login success'); var d = data; var isAdmin = data.Users.roles.indexOf('admin') >= 0; if (isAdmin) { App.set('isAdmin', true); var controller = this.get('loginController'); this.setAuthenticated(true); this.setLoginName(params.loginName); App.usersMapper.map({"items": [data]}); this.setUser(App.User.find().findProperty('id', params.loginName)); this.transitionTo(this.getSection()); controller.postLogin(true,true); } else { App.ajax.send({ name: 'router.login2', sender: this, data: { loginName: params.loginName, loginData: data }, success: 'login2SuccessCallback', error: 'login2ErrorCallback' }); } },
loadSelectedVersion: function (version, switchToGroup) { this.set('isCompareMode', false); this.set('versionLoaded', false); version = version || this.get('currentDefaultVersion'); if (version === this.get('currentDefaultVersion') && (!switchToGroup || switchToGroup.get('isDefault'))) { this.set('selectedVersion', this.get('currentDefaultVersion')); this.loadCurrentVersions(); } else { //version of non-default group require properties from current version of default group to correctly display page var versions = (this.isVersionDefault(version)) ? [version] : [this.get('currentDefaultVersion'), version]; switchToGroup = (this.isVersionDefault(version) && !switchToGroup) ? this.get('configGroups').findProperty('isDefault') : switchToGroup; if (this.get('dataIsLoaded') && switchToGroup) { this.set('selectedConfigGroup', switchToGroup); } var selectedVersion = versions.length > 1 ? versions[1] : versions[0]; this.set('selectedVersion', selectedVersion); this.trackRequest(App.ajax.send({ name: 'service.serviceConfigVersions.get.multiple', sender: this, data: { serviceName: this.get('content.serviceName'), serviceConfigVersions: versions, additionalParams: this.get('dependentServiceNames.length') ? '|service_name.in(' + this.get('dependentServiceNames') + ')&is_current=true' : '' }, success: 'loadSelectedVersionsSuccess' })); } },
getJDKName: function () { return App.ajax.send({ name: 'ambari.service.load_jdk_name', sender: this, success: 'getJDKNameSuccessCallback' }); },
login: function () { var controller = this.get('loginController'); var loginName = controller.get('loginName').toLowerCase(); controller.set('loginName', loginName); var hash = window.btoa(loginName + ":" + controller.get('password')); var usr = ''; if (App.testMode) { if (loginName === "admin" && controller.get('password') === 'admin') { usr = '******'; } else if (loginName === 'user' && controller.get('password') === 'user') { usr = '******'; } } App.ajax.send({ name: 'router.login', sender: this, data: { auth: "Basic " + hash, usr: usr, loginName: loginName }, beforeSend: 'authBeforeSend', success: 'loginSuccessCallback', error: 'loginErrorCallback' }); },
getHostNameResolution: function () { var hosts = this.get('bootHosts').getEach('name').join(","); var jdk_location = App.router.get('clusterController.ambariProperties.jdk_location'); var RequestInfo = { "action": "check_host", "context": "Check host", "parameters": { "check_execute_list": "host_resolution_check", "jdk_location" : jdk_location, "hosts": hosts, "threshold": "20" } }; var resource_filters = { "hosts": hosts }; if (App.testMode) { this.getHostNameResolutionSuccess(); } else { return App.ajax.send({ name: 'preinstalled.checks', sender: this, data: { RequestInfo: RequestInfo, resource_filters: resource_filters }, success: 'getHostNameResolutionSuccess', error: 'getHostNameResolutionError' }); } },
getAllRegisteredHosts: function () { return App.ajax.send({ name: 'wizard.step3.is_hosts_registered', sender: this, success: 'getAllRegisteredHostsCallback' }); }.observes('bootHosts'),
this.loadDefaultFS(function (defaultFS) { var clusterName = App.get('clusterName'); var sourceCluster = Ember.Object.create({ name: clusterName, execute: App.HostComponent.find().findProperty('componentName', 'RESOURCEMANAGER').get('hostName') + ':8050', readonly: 'hftp://' + App.HostComponent.find().findProperty('componentName', 'NAMENODE').get('hostName') + ':50070', workflow: 'http://' + App.HostComponent.find().findProperty('componentName', 'OOZIE_SERVER').get('hostName') + ':11000/oozie', write: defaultFS, staging: '/apps/falcon/' + clusterName + '/staging', working: '/apps/falcon/' + clusterName + '/working', temp: '/tmp' }); var sourceClusterData = App.router.get('mainMirroringManageClustersController').formatClusterXML(sourceCluster); App.ajax.send({ name: 'mirroring.submit_entity', sender: this, data: { type: 'cluster', entity: sourceClusterData, falconServer: App.get('falconServerURL') }, success: 'onSourceClusterCreateSuccess', error: 'onSourceClusterCreateError' }); clustersData.items.push(sourceCluster); });
restartMySqlServer: function() { var context = "Restart MySql Server"; var resource_filters = { component_name: "MYSQL_SERVER", hosts: App.HostComponent.find().filterProperty('componentName', 'MYSQL_SERVER').get('firstObject.hostName'), service_name: "HIVE" }; var operation_level = { level: "HOST_COMPONENT", cluster_name: this.get('content.cluster.name'), service_name: "HIVE", hostcomponent_name: "MYSQL_SERVER" }; App.ajax.send({ name: 'restart.hostComponents', sender: this, data: { context: context, resource_filters: [resource_filters], operation_level: operation_level }, success: 'startPolling', error: 'onTaskError' }); },
prepareDBCheckAction: function() { var params = this.get('preparedDBProperties'); var ambariProperties = App.router.get('clusterController.ambariProperties'); params['db_name'] = this.get('dbType'); params['jdk_location'] = ambariProperties['jdk_location']; params['jdk_name'] = ambariProperties['jdk.name']; params['java_home'] = ambariProperties['java.home']; params['threshold'] = 60; params['ambari_server_host'] = location.hostname; params['check_execute_list'] = "db_connection_check"; App.ajax.send({ name: 'cluster.custom_action.create', sender: this, data: { requestInfo: { "context": "Check host", "action": "check_host", "parameters": params }, filteredHosts: [this.get('content.reassignHosts.target')] }, success: 'onCreateActionSuccess', error: 'onTaskError' }); },
createUserWidgetLayout: function (defaultWidgetLayoutData) { var layout = defaultWidgetLayoutData.items[0].WidgetLayoutInfo; var layoutName = this.get('userLayoutName'); var data = { "WidgetLayoutInfo": { "display_name": layout.display_name, "layout_name": layoutName, "scope": "USER", "section_name": layout.section_name, "user_name": App.router.get('loginName'), "widgets": layout.widgets.map(function (widget) { return { "id": widget.WidgetInfo.id } }) } }; return App.ajax.send({ name: 'widget.layout.create', sender: this, data: { data: data } }); },
saveWidgetLayout: function (widgets, widgetLayout) { var activeLayout = widgetLayout || this.get('activeWidgetLayout'); var data = { "WidgetLayoutInfo": { "display_name": activeLayout.get("displayName"), "id": activeLayout.get("id"), "layout_name": activeLayout.get("layoutName"), "scope": activeLayout.get("scope"), "section_name": activeLayout.get("sectionName"), "widgets": widgets.map(function (widget) { return { "id": widget.get('id') } }) } }; return App.ajax.send({ name: 'widget.layout.edit', sender: this, data: { layoutId: activeLayout.get("id"), data: data } }); },
startPolling: function () { if (!this.get('requestId')) return false; var self = this; this.pollTaskLog(); App.ajax.send({ name: 'background_operations.get_by_request', sender: this, data: { requestId: this.get('requestId') }, success: 'startPollingSuccessCallback', error: 'startPollingErrorCallback' }) .retry({times: App.maxRetries, timeout: App.timeout}) .then( function () { self.closeReloadPopup(); }, function () { self.showReloadPopup(); console.log('Install services all retries failed'); } ); return true; },
error: function (xhr, textStatus, errorThrown) { console.log('Error deleting host component'); console.log(textStatus); console.log(errorThrown); dialogSelf.hide(); xhr.responseText = "{\"message\": \"" + xhr.statusText + "\"}"; App.ajax.defaultErrorHandler(xhr, url, 'DELETE', xhr.status); },
loadConfigsTags: function () { App.ajax.send({ name: 'config.tags', sender: this, success: 'onLoadConfigsTags', error: 'onTaskError' }); },
installJournalNodes: function () { App.ajax.send({ name: 'admin.high_availability.create_journalnode', sender: this, success: 'onJournalNodeCreate', error: 'onJournalNodeCreate' }); },
stopAllServices: function () { App.ajax.send({ name: 'admin.high_availability.stop_all_services', sender: this, success: 'startPolling', error: 'onTaskError' }); },
setAmbariStacks: function () { App.ajax.send({ name: 'router.set_ambari_stacks', sender: this, success: 'setAmbariStacksSuccessCallback', error: 'setAmbariStacksErrorCallback' }); },
loadClusterConfigs: function () { App.ajax.send({ name: 'admin.security.add.cluster_configs', sender: this, success: 'loadClusterConfigsSuccessCallback', error: 'loadClusterConfigsErrorCallback' }); },