in ambari-web/app/controllers/main/service/reassign/step4_controller.js [196:304]
onLoadConfigs: function (data) {
var isHadoop2Stack = App.get('isHadoop2Stack');
var securityEnabled = this.get('content.securityEnabled');
var componentName = this.get('content.reassign.component_name');
var targetHostName = this.get('content.reassignHosts.target');
var sourceHostName = this.get('content.reassignHosts.source');
var configs = {};
var componentDir = '';
var secureConfigs = [];
this.set('configsSitesNumber', data.items.length);
this.set('configsSitesCount', 0);
data.items.forEach(function (item) {
configs[item.type] = item.properties;
}, this);
switch (componentName) {
case 'NAMENODE':
if (isHadoop2Stack) {
if (!App.HostComponent.find().someProperty('componentName', 'SECONDARY_NAMENODE')) {
var nameServices = configs['hdfs-site']['dfs.nameservices'];
if (configs['hdfs-site']['dfs.namenode.http-address.' + nameServices + '.nn1'] === sourceHostName + ':50070') {
configs['hdfs-site']['dfs.namenode.http-address.' + nameServices + '.nn1'] = targetHostName + ':50070';
configs['hdfs-site']['dfs.namenode.https-address.' + nameServices + '.nn1'] = targetHostName + ':50470';
configs['hdfs-site']['dfs.namenode.rpc-address.' + nameServices + '.nn1'] = targetHostName + ':8020';
} else {
configs['hdfs-site']['dfs.namenode.http-address.' + nameServices + '.nn2'] = targetHostName + ':50070';
configs['hdfs-site']['dfs.namenode.https-address.' + nameServices + '.nn2'] = targetHostName + ':50470';
configs['hdfs-site']['dfs.namenode.rpc-address.' + nameServices + '.nn2'] = targetHostName + ':8020';
}
} else {
configs['hdfs-site']['dfs.namenode.http-address'] = targetHostName + ':50070';
configs['hdfs-site']['dfs.namenode.https-address'] = targetHostName + ':50470';
configs['core-site']['fs.defaultFS'] = 'hdfs://' + targetHostName + ':8020';
}
componentDir = configs['hdfs-site']['dfs.namenode.name.dir'];
} else {
componentDir = configs['hdfs-site']['dfs.name.dir'];
configs['hdfs-site']['dfs.http.address'] = targetHostName + ':50070';
configs['hdfs-site']['dfs.https.address'] = targetHostName + ':50470';
configs['core-site']['fs.default.name'] = 'hdfs://' + targetHostName + ':8020';
}
if (App.HostComponent.find().someProperty('componentName', 'SECONDARY_NAMENODE')) {
if (App.Service.find().someProperty('serviceName', 'HBASE')) {
configs['hbase-site']['hbase.rootdir'] = configs['hbase-site']['hbase.rootdir'].replace(/\/\/[^\/]*/, '//' + targetHostName);
}
}
if (securityEnabled) {
secureConfigs.push({keytab: configs['hdfs-site']['dfs.namenode.keytab.file'], principal: configs['hdfs-site']['dfs.namenode.kerberos.principal']});
secureConfigs.push({keytab: configs['hdfs-site']['dfs.web.authentication.kerberos.keytab'], principal: configs['hdfs-site']['dfs.web.authentication.kerberos.principal']});
}
break;
case 'SECONDARY_NAMENODE':
if (isHadoop2Stack) {
componentDir = configs['hdfs-site']['dfs.namenode.checkpoint.dir'];
configs['hdfs-site']['dfs.namenode.secondary.http-address'] = targetHostName + ':50090';
} else {
componentDir = configs['core-site']['fs.checkpoint.dir'];
configs['hdfs-site']['dfs.secondary.http.address'] = targetHostName + ':50090';
}
if (securityEnabled) {
secureConfigs.push({keytab: configs['hdfs-site']['dfs.secondary.namenode.keytab.file'], principal: configs['hdfs-site']['dfs.secondary.namenode.kerberos.principal']});
secureConfigs.push({keytab: configs['hdfs-site']['dfs.web.authentication.kerberos.keytab'], principal: configs['hdfs-site']['dfs.web.authentication.kerberos.principal']});
}
break;
case 'JOBTRACKER':
configs['mapred-site']['mapreduce.history.server.http.address'] = targetHostName + ':51111';
configs['mapred-site']['mapred.job.tracker.http.address'] = targetHostName + ':50030';
configs['mapred-site']['mapred.job.tracker'] = targetHostName + ':50300';
if (securityEnabled) {
secureConfigs.push({keytab: configs['mapred-site']['mapreduce.jobtracker.keytab.file'], principal: configs['mapred-site']['mapreduce.jobtracker.kerberos.principal']});
}
break;
case 'RESOURCEMANAGER':
configs['yarn-site']['yarn.resourcemanager.address'] = targetHostName + ':8050';
configs['yarn-site']['yarn.resourcemanager.admin.address'] = targetHostName + ':8141';
configs['yarn-site']['yarn.resourcemanager.resource-tracker.address'] = targetHostName + ':8025';
configs['yarn-site']['yarn.resourcemanager.scheduler.address'] = targetHostName + ':8030';
configs['yarn-site']['yarn.resourcemanager.webapp.address'] = targetHostName + ':8088';
configs['yarn-site']['yarn.resourcemanager.hostname'] = targetHostName;
if (securityEnabled) {
secureConfigs.push({keytab: configs['yarn-site']['yarn.resourcemanager.keytab'], principal: configs['yarn-site']['yarn.resourcemanager.principal']});
secureConfigs.push({keytab: configs['yarn-site']['yarn.resourcemanager.webapp.spnego-keytab-file'], principal: configs['yarn-site']['yarn.resourcemanager.webapp.spnego-principal']});
}
break;
}
if (componentDir || secureConfigs.length) {
App.router.get(this.get('content.controllerName')).saveComponentDir(componentDir);
App.router.get(this.get('content.controllerName')).saveSecureConfigs(secureConfigs);
App.clusterStatus.setClusterStatus({
clusterName: this.get('content.cluster.name'),
clusterState: this.get('clusterDeployState'),
wizardControllerName: this.get('content.controllerName'),
localdb: App.db.data
});
}
for (var site in configs) {
if (!configs.hasOwnProperty(site)) continue;
App.ajax.send({
name: 'reassign.save_configs',
sender: this,
data: {
siteName: site,
properties: configs[site]
},
success: 'onSaveConfigs',
error: 'onTaskError'
});
}
},