configs.js 67 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var App = require('app');
  19. require('controllers/wizard/slave_component_groups_controller');
  20. App.MainServiceInfoConfigsController = Em.Controller.extend({
  21. name: 'mainServiceInfoConfigsController',
  22. dataIsLoaded: false,
  23. stepConfigs: [], //contains all field properties that are viewed in this service
  24. selectedService: null,
  25. serviceConfigTags: null,
  26. globalConfigs: [],
  27. uiConfigs: [],
  28. customConfig: [],
  29. isApplyingChanges: false,
  30. serviceConfigs: function(){
  31. return App.config.get('preDefinedServiceConfigs');
  32. }.property('App.config.preDefinedServiceConfigs'),
  33. customConfigs: function(){
  34. return App.config.get('preDefinedCustomConfigs');
  35. }.property('App.config.preDefinedCustomConfigs'),
  36. configMapping: function(){
  37. return App.config.get('configMapping');
  38. }.property('App.config.configMapping'),
  39. configs: function() {
  40. return App.config.get('preDefinedConfigProperties');
  41. }.property('App.config.preDefinedConfigProperties'),
  42. secureConfigs: require('data/secure_mapping'),
  43. /**
  44. * During page load time, we get the host overrides from the server.
  45. * The current host -> site:tag map is stored below. This will be
  46. * useful during save, so that removals can also be determined.
  47. *
  48. * Example:
  49. * {
  50. * 'hostname1':{
  51. * 'global': 'version1',
  52. * 'core-site': 'version1',
  53. * 'hdfs-site', 'tag3187261938'
  54. * }
  55. * }
  56. *
  57. * @see savedHostToOverrideSiteToTagMap
  58. */
  59. loadedHostToOverrideSiteToTagMap: {},
  60. /**
  61. * During page load time the cluster level site to tag
  62. * mapping is stored here.
  63. *
  64. * Example:
  65. * {
  66. * 'global': 'version1',
  67. * 'hdfs-site': 'version1',
  68. * 'core-site': 'version1'
  69. * }
  70. */
  71. loadedClusterSiteToTagMap: {},
  72. /**
  73. * During page save time, we set the host overrides to the server.
  74. * The new host -> site:tag map is stored below. This will be
  75. * useful during save, to update the host's host components. Also,
  76. * it will be useful in deletion of overrides.
  77. *
  78. * Example:
  79. * {
  80. * 'hostname1': {
  81. * 'global': {
  82. * 'tagName': 'tag3187261938_hostname1',
  83. * 'map': {
  84. * 'hadoop_heapsize': '2048m'
  85. * }
  86. * }
  87. * }
  88. * }
  89. *
  90. * @see loadedHostToOverrideSiteToTagMap
  91. */
  92. savedHostToOverrideSiteToTagMap: {},
  93. /**
  94. * Holds the actual base service-config server data uploaded.
  95. * This is used by the host-override mechanism to update host
  96. * specific values.
  97. */
  98. savedSiteNameToServerServiceConfigDataMap: {},
  99. isSubmitDisabled: function () {
  100. return (!(this.stepConfigs.everyProperty('errorCount', 0)) || this.get('isApplyingChanges'));
  101. }.property('stepConfigs.@each.errorCount', 'isApplyingChanges'),
  102. slaveComponentGroups: null,
  103. /**
  104. * Filter text will be located here
  105. */
  106. filter: '',
  107. /**
  108. * Dropdown menu items in filter compbobox
  109. */
  110. filterColumns: function(){
  111. var result = [];
  112. for(var i = 1; i<4; i++){
  113. result.push(Ember.Object.create({
  114. name: this.t('common.combobox.dropdown.' + i),
  115. selected: false
  116. }));
  117. }
  118. return result;
  119. }.property(),
  120. /**
  121. * clear and set properties to default value
  122. */
  123. clearStep: function () {
  124. this.set('dataIsLoaded', false);
  125. this.set('filter', '');
  126. this.get('filterColumns').setEach('selected', false);
  127. this.get('stepConfigs').clear();
  128. this.get('globalConfigs').clear();
  129. this.get('uiConfigs').clear();
  130. this.get('customConfig').clear();
  131. this.set('loadedHostToOverrideSiteToTagMap', {});
  132. this.set('savedHostToOverrideSiteToTagMap', {});
  133. this.set('savedSiteNameToServerServiceConfigDataMap', {});
  134. if (this.get('serviceConfigTags')) {
  135. this.set('serviceConfigTags', null);
  136. }
  137. },
  138. serviceConfigProperties: function () {
  139. return App.db.getServiceConfigProperties();
  140. }.property('content'),
  141. /**
  142. * On load function
  143. */
  144. loadStep: function () {
  145. console.log("TRACE: Loading configure for service");
  146. this.clearStep();
  147. this.loadServiceConfigs();
  148. },
  149. /**
  150. * Loads the actual configuration of all host components.
  151. * This helps in determining which services need a restart, and also
  152. * in showing which properties are actually applied or not.
  153. * This method also compares the actual_configs with the desired_configs
  154. * and builds a diff structure.
  155. *
  156. * Internall it calculates an array of host-components which need restart.
  157. * Example:
  158. * [
  159. * {
  160. * componentName: 'DATANODE',
  161. * serviceName: 'HDFS',
  162. * host: 'host.name',
  163. * type: 'core-site',
  164. * desiredConfigTags: {tag:'version1'},
  165. * actualConfigTags: {tag:'version4'. host_override:'version2'}
  166. * },
  167. * ...
  168. * ]
  169. *
  170. * From there it return the following restart-data for this service.
  171. * It represents the hosts, whose components need restart, and the
  172. * properties which require restart.
  173. *
  174. * {
  175. * hostAndHostComponents: {
  176. * 'hostname1': {
  177. * 'DATANODE': {
  178. * 'property1': 'value1',
  179. * 'property2': 'value2'
  180. * },
  181. * 'TASKTRACKER': {
  182. * 'prop1': 'val1'
  183. * }
  184. * },
  185. * 'hostname6': {
  186. * 'ZOOKEEPER': {
  187. * 'property1': 'value3'
  188. * }
  189. * }
  190. * },
  191. * propertyToHostAndComponent: {
  192. * 'property1': {
  193. * 'hostname1': ['DATANODE'],
  194. * 'hostname6': ['ZOOKEEPER']
  195. * },
  196. * 'property2': {
  197. * 'hostname1': ['DATANODE']
  198. * },
  199. * 'prop1': {
  200. * 'hostname1': ['TASKTRACKER']
  201. * }
  202. * }
  203. * }
  204. */
  205. loadActualConfigsAndCalculateRestarts: function () {
  206. var currentService = this.get('content.serviceName');
  207. var restartData = {
  208. hostAndHostComponents: {},
  209. propertyToHostAndComponent: {}
  210. };
  211. var self = this;
  212. var actualConfigsUrl = this.getUrl('/data/services/host_component_actual_configs.json', '/services?fields=components/host_components/HostRoles/actual_configs');
  213. $.ajax({
  214. type: 'GET',
  215. url: actualConfigsUrl,
  216. async: false,
  217. timeout: 10000,
  218. dataType: 'json',
  219. success: function (data) {
  220. var diffHostComponents = [];
  221. console.debug("loadActualConfigs(" + actualConfigsUrl + "): Data=", data);
  222. var configsToDownload = [];
  223. data.items.forEach(function (service) {
  224. // For current service, do any of the host_components differ in
  225. // configuration?
  226. if (currentService === service.ServiceInfo.service_name) {
  227. service.components.forEach(function (serviceComponent) {
  228. serviceComponent.host_components.forEach(function (hostComponent) {
  229. if (hostComponent.HostRoles.actual_configs) {
  230. for ( var site in hostComponent.HostRoles.actual_configs) {
  231. var actualConfigsTags = hostComponent.HostRoles.actual_configs[site];
  232. var desiredConfigTags = self.getDesiredConfigTag(site, hostComponent.HostRoles.host_name);
  233. if (desiredConfigTags.tag !== actualConfigsTags.tag ||
  234. (desiredConfigTags.host_override != null &&
  235. actualConfigsTags.host_override != null &&
  236. desiredConfigTags.host_override !== actualConfigsTags.host_override)) {
  237. // Restart may be necessary for this host-component
  238. diffHostComponents.push({
  239. componentName: hostComponent.HostRoles.component_name,
  240. serviceName: serviceComponent.ServiceComponentInfo.service_name,
  241. host: hostComponent.HostRoles.host_name,
  242. type: site,
  243. desiredConfigTags: desiredConfigTags,
  244. actualConfigTags: actualConfigsTags
  245. });
  246. self.addConfigDownloadParam(site, actualConfigsTags.tag, configsToDownload);
  247. self.addConfigDownloadParam(site, actualConfigsTags.host_override, configsToDownload);
  248. self.addConfigDownloadParam(site, desiredConfigTags.tag, configsToDownload);
  249. self.addConfigDownloadParam(site, desiredConfigTags.host_override, configsToDownload);
  250. }
  251. }
  252. }
  253. });
  254. });
  255. }
  256. });
  257. if (configsToDownload.length > 0) {
  258. var url = self.getUrl('/data/configurations/cluster_level_actual_configs.json?' + configsToDownload.join('|'), '/configurations?' + configsToDownload.join('|'));
  259. $.ajax({
  260. type: 'GET',
  261. url: url,
  262. async: false,
  263. timeout: 10000,
  264. dataType: 'json',
  265. success: function (data) {
  266. console.log("configsToDownload(): In success for ", url);
  267. if (data.items) {
  268. data.items.forEach(function (item) {
  269. App.config.loadedConfigurationsCache[item.type + "_" + item.tag] = item.properties;
  270. });
  271. }
  272. },
  273. error: function (request, ajaxOptions, error) {
  274. console.log("TRACE: In error function for the configsToDownload call");
  275. console.log("TRACE: value of the url is: " + url);
  276. console.log("TRACE: error code status is: " + request.status);
  277. },
  278. statusCode: require('data/statusCodes')
  279. });
  280. }
  281. // Now all the configurations are loaded.
  282. // Find the diff in properties
  283. if (diffHostComponents.length > 0) {
  284. diffHostComponents.forEach(function (diffHostComponent) {
  285. var actualConfigs = App.config.loadedConfigurationsCache[diffHostComponent.type + "_" + diffHostComponent.actualConfigTags.tag];
  286. var desiredConfigs = App.config.loadedConfigurationsCache[diffHostComponent.type + "_" + diffHostComponent.desiredConfigTags.tag];
  287. var diffs = self.getConfigDifferences(actualConfigs, desiredConfigs);
  288. if (!jQuery.isEmptyObject(diffs)) {
  289. var skip = false;
  290. if (diffHostComponent.type == 'global') {
  291. if(!App.config.isServiceEffectedByGlobalChange(
  292. diffHostComponent.serviceName,
  293. diffHostComponent.desiredConfigTags.tag,
  294. diffHostComponent.actualConfigTags.tag)){
  295. skip = true;
  296. }
  297. }
  298. if(!skip){
  299. // Populate restartData.hostAndHostComponents
  300. if (!(diffHostComponent.host in restartData.hostAndHostComponents)) {
  301. restartData.hostAndHostComponents[diffHostComponent.host] = {};
  302. }
  303. if (!(diffHostComponent.componentName in restartData.hostAndHostComponents[diffHostComponent.host])) {
  304. restartData.hostAndHostComponents[diffHostComponent.host][diffHostComponent.componentName] = {};
  305. }
  306. jQuery.extend(restartData.hostAndHostComponents[diffHostComponent.host][diffHostComponent.componentName], diffs);
  307. // Populate restartData.propertyToHostAndComponent
  308. for ( var diff in diffs) {
  309. if (!(diff in restartData.propertyToHostAndComponent)) {
  310. restartData.propertyToHostAndComponent[diff] = {};
  311. }
  312. if (!(diffHostComponent.host in restartData.propertyToHostAndComponent[diff])) {
  313. restartData.propertyToHostAndComponent[diff][diffHostComponent.host] = [];
  314. }
  315. if (!(restartData.propertyToHostAndComponent[diff][diffHostComponent.host].contains(diffHostComponent.componentName))) {
  316. restartData.propertyToHostAndComponent[diff][diffHostComponent.host].push(diffHostComponent.componentName);
  317. }
  318. }
  319. }
  320. }
  321. });
  322. }
  323. console.log("loadActualConfigs(): Finished loading. Restart host components = ", diffHostComponents);
  324. },
  325. error: function (request, ajaxOptions, error) {
  326. console.log("loadActualConfigs(): URL:" + actualConfigsUrl + ". Status:", request.status, ", Error:", error);
  327. },
  328. statusCode: require('data/statusCodes')
  329. });
  330. console.log("loadActualConfigsAndCalculateRestarts(): Restart data = ", restartData);
  331. return restartData;
  332. },
  333. /**
  334. * Determines the differences between desired and actual configs and returns
  335. * them as an object. The key is the property, and value is actual_config.
  336. */
  337. getConfigDifferences: function (actualConfigs, desiredConfigs) {
  338. var differences = {};
  339. if (actualConfigs != null && desiredConfigs != null) {
  340. for(var desiredProp in desiredConfigs){
  341. if(desiredConfigs[desiredProp] !== actualConfigs[desiredProp]){
  342. differences[desiredProp] = actualConfigs[desiredProp];
  343. }
  344. }
  345. }
  346. return differences;
  347. },
  348. addConfigDownloadParam: function(site, tag, configsToDownload){
  349. if(tag!=null && !(site+"_"+tag in App.config.loadedConfigurationsCache)){
  350. var configParam = "(type="+site+"&tag="+tag+")";
  351. if(!configsToDownload.contains(configParam)){
  352. configsToDownload.push(configParam);
  353. }
  354. }
  355. },
  356. getDesiredConfigTag: function(site, hostName){
  357. var tag = {tag: this.loadedClusterSiteToTagMap[site], host_override: null};
  358. if(hostName in this.loadedHostToOverrideSiteToTagMap){
  359. var map = this.loadedHostToOverrideSiteToTagMap[hostName];
  360. if(site in map){
  361. tag.host_overrides = map[site];
  362. }
  363. }
  364. return tag;
  365. },
  366. /**
  367. * Loads service configurations
  368. */
  369. loadServiceConfigs: function () {
  370. App.ajax.send({
  371. name: 'config.tags',
  372. sender: this,
  373. data: {
  374. serviceName: this.get('content.serviceName'),
  375. serviceConfigsDef: this.get('serviceConfigs').findProperty('serviceName', this.get('content.serviceName'))
  376. },
  377. success: 'loadServiceTagsSuccess'
  378. });
  379. },
  380. loadServiceTagsSuccess: function(data, opt, params){
  381. var serviceConfigsDef = params.serviceConfigsDef;
  382. var serviceName = this.get('content.serviceName');
  383. console.debug("loadServiceConfigs(): data=", data);
  384. this.loadedClusterSiteToTagMap = {};
  385. //STEP 1: handle tags from JSON data
  386. for ( var site in data.Clusters.desired_configs) {
  387. if (serviceConfigsDef.sites.indexOf(site) > -1) {
  388. this.loadedClusterSiteToTagMap[site] = data.Clusters.desired_configs[site]['tag'];
  389. var overrides = data.Clusters.desired_configs[site].host_overrides;
  390. if (overrides) {
  391. overrides.forEach(function (override) {
  392. var hostname = override.host_name;
  393. var tag = override.tag;
  394. if(!this.loadedHostToOverrideSiteToTagMap[hostname]){
  395. this.loadedHostToOverrideSiteToTagMap[hostname] = {};
  396. }
  397. this.loadedHostToOverrideSiteToTagMap[hostname][site] = tag;
  398. }, this);
  399. }
  400. }
  401. }
  402. //STEP 2: Create an array of objects defining tag names to be polled and new tag names to be set after submit
  403. this.setServiceConfigTags(this.loadedClusterSiteToTagMap);
  404. //STEP 3: Load advanced configs from server
  405. var advancedConfigs = App.config.loadAdvancedConfig(serviceName) || [];
  406. //STEP 4: Load on-site config by service from server
  407. var configGroups = App.config.loadConfigsByTags(this.get('serviceConfigTags'));
  408. //STEP 5: Merge global and on-site configs with pre-defined
  409. var configSet = App.config.mergePreDefinedWithLoaded(configGroups, advancedConfigs, this.get('serviceConfigTags'), serviceName);
  410. //var serviceConfigs = this.getSitesConfigProperties(advancedConfigs);
  411. var configs = configSet.configs;
  412. //put global configs into globalConfigs to save them separately
  413. this.set('globalConfigs', configSet.globalConfigs);
  414. //STEP 6: add advanced configs
  415. //App.config.addAdvancedConfigs(configs, advancedConfigs, serviceName);
  416. //STEP 7: add custom configs
  417. App.config.addCustomConfigs(configs);
  418. //put properties from capacity-scheduler.xml into one config with textarea view
  419. if(this.get('content.serviceName') === 'YARN' && !App.supports.capacitySchedulerUi){
  420. configs = App.config.fileConfigsIntoTextarea(configs, 'capacity-scheduler.xml');
  421. }
  422. //STEP 8: add configs as names of host components
  423. this.addHostNamesToGlobalConfig();
  424. var allConfigs = this.get('globalConfigs').concat(configs);
  425. //this.loadServiceConfigHostsOverrides(serviceConfigs, this.loadedHostToOverrideSiteToTagMap);
  426. //STEP 9: Load and add host override configs
  427. App.config.loadServiceConfigHostsOverrides(allConfigs, this.loadedHostToOverrideSiteToTagMap);
  428. var restartData = this.loadActualConfigsAndCalculateRestarts();
  429. //STEP 10: creation of serviceConfig object which contains configs for current service
  430. var serviceConfig = App.config.createServiceConfig(serviceName);
  431. this.checkForRestart(serviceConfig, restartData);
  432. if (serviceName || serviceConfig.serviceName === 'MISC') {
  433. //STEP 11: render configs and wrap each in ServiceConfigProperty object
  434. this.loadComponentConfigs(allConfigs, serviceConfig, restartData);
  435. this.get('stepConfigs').pushObject(serviceConfig);
  436. }
  437. this.set('selectedService', this.get('stepConfigs').objectAt(0));
  438. this.checkForSecureConfig( this.get('selectedService'));
  439. this.set('dataIsLoaded', true);
  440. },
  441. /**
  442. * Changes format from Object to Array
  443. *
  444. * {
  445. * 'core-site': 'version1',
  446. * 'hdfs-site': 'version1',
  447. * 'global': 'version2',
  448. * ...
  449. * }
  450. *
  451. * to
  452. *
  453. * [
  454. * {
  455. * siteName: 'core-site',
  456. * tagName: 'version1',
  457. * newTageName: null
  458. * },
  459. * ...
  460. * ]
  461. *
  462. * set tagnames for configuration of the *-site.xml
  463. */
  464. setServiceConfigTags: function (desiredConfigsSiteTags) {
  465. console.debug("setServiceConfigTags(): Trying to set ", desiredConfigsSiteTags);
  466. var newServiceConfigTags = [];
  467. for (var index in desiredConfigsSiteTags) {
  468. newServiceConfigTags.pushObject({
  469. siteName: index,
  470. tagName: desiredConfigsSiteTags[index],
  471. newTagName: null
  472. }, this);
  473. }
  474. console.debug("setServiceConfigTags(): Setting 'serviceConfigTags' to ", newServiceConfigTags);
  475. this.set('serviceConfigTags', newServiceConfigTags);
  476. },
  477. /**
  478. * check whether host component must be restarted
  479. * @param serviceConfig
  480. * @param restartData
  481. */
  482. checkForRestart: function(serviceConfig, restartData){
  483. var hostsCount = 0;
  484. var hostComponentCount = 0;
  485. var restartHosts = Ember.A([]);
  486. if(restartData != null && restartData.hostAndHostComponents != null && !jQuery.isEmptyObject(restartData.hostAndHostComponents)){
  487. serviceConfig.set('restartRequired', true);
  488. for(var host in restartData.hostAndHostComponents) {
  489. hostsCount++;
  490. var componentsArray = Ember.A([]);
  491. for(var component in restartData.hostAndHostComponents[host]){
  492. componentsArray.push(Ember.Object.create({name: App.format.role(component)}));
  493. hostComponentCount++;
  494. }
  495. var hostObj = App.Host.find(host);
  496. restartHosts.push(Ember.Object.create({hostData: hostObj, components: componentsArray}))
  497. }
  498. serviceConfig.set('restartRequiredHostsAndComponents', restartHosts);
  499. serviceConfig.set('restartRequiredMessage', 'Service needs '+hostComponentCount+' components on ' + hostsCount +' hosts to be restarted.')
  500. }
  501. },
  502. /**
  503. * check whether the config property is a security related knob
  504. * @param serviceConfig
  505. */
  506. checkForSecureConfig: function(serviceConfig) {
  507. serviceConfig.get('configs').forEach(function(_config){
  508. this.get('secureConfigs').forEach(function(_secureConfig){
  509. if(_config.get('name')=== _secureConfig.name) {
  510. _config.set('isSecureConfig',true);
  511. }
  512. },this)
  513. },this)
  514. },
  515. /**
  516. * Load child components to service config object
  517. * @param configs
  518. * @param componentConfig
  519. * @param restartData
  520. */
  521. loadComponentConfigs: function (configs, componentConfig, restartData) {
  522. configs.forEach(function (_serviceConfigProperty) {
  523. console.log("config", _serviceConfigProperty);
  524. if (!_serviceConfigProperty) return;
  525. var overrides = _serviceConfigProperty.overrides;
  526. // we will populate the override properties below
  527. _serviceConfigProperty.overrides = null;
  528. if (_serviceConfigProperty.isOverridable === undefined) {
  529. _serviceConfigProperty.isOverridable = true;
  530. }
  531. var serviceConfigProperty = App.ServiceConfigProperty.create(_serviceConfigProperty);
  532. var propertyName = serviceConfigProperty.get('name');
  533. if (restartData != null && propertyName in restartData.propertyToHostAndComponent) {
  534. serviceConfigProperty.set('isRestartRequired', true);
  535. var message = '<ul>';
  536. for(var host in restartData.propertyToHostAndComponent[propertyName]){
  537. var appHost = App.Host.find(host);
  538. message += "<li>"+appHost.get('publicHostName');
  539. message += "<ul>";
  540. restartData.propertyToHostAndComponent[propertyName][host].forEach(function(comp){
  541. message += "<li>"+App.format.role(comp)+"</li>"
  542. });
  543. message += "</ul></li>";
  544. }
  545. message += "</ul>";
  546. serviceConfigProperty.set('restartRequiredMessage', message);
  547. }
  548. if (serviceConfigProperty.get('serviceName') === this.get('content.serviceName')) {
  549. // serviceConfigProperty.serviceConfig = componentConfig;
  550. if (App.get('isAdmin')) {
  551. serviceConfigProperty.set('isEditable', serviceConfigProperty.get('isReconfigurable'));
  552. } else {
  553. serviceConfigProperty.set('isEditable', false);
  554. }
  555. console.log("config result", serviceConfigProperty);
  556. } else {
  557. serviceConfigProperty.set('isVisible', false);
  558. }
  559. if (overrides != null) {
  560. for(var overridenValue in overrides){
  561. var hostsArray = overrides[overridenValue];
  562. var newSCP = App.ServiceConfigProperty.create(_serviceConfigProperty);
  563. newSCP.set('value', overridenValue);
  564. newSCP.set('isOriginalSCP', false); // indicated this is overridden value,
  565. newSCP.set('parentSCP', serviceConfigProperty);
  566. newSCP.set('selectedHostOptions', Ember.A(hostsArray));
  567. var parentOverridesArray = serviceConfigProperty.get('overrides');
  568. if(parentOverridesArray == null){
  569. parentOverridesArray = Ember.A([]);
  570. serviceConfigProperty.set('overrides', parentOverridesArray);
  571. }
  572. parentOverridesArray.pushObject(newSCP);
  573. console.debug("createOverrideProperty(): Added:", newSCP, " to main-property:", serviceConfigProperty)
  574. }
  575. }
  576. componentConfig.configs.pushObject(serviceConfigProperty);
  577. serviceConfigProperty.validate();
  578. }, this);
  579. },
  580. /**
  581. * Determines which host components are running on each host.
  582. * @param status 'running' or 'unknown'
  583. * @return Returned in the following format:
  584. * {
  585. * runningHosts: {
  586. * 'hostname1': 'NameNode, DataNode, JobTracker',
  587. * 'hostname2': 'DataNode',
  588. * },
  589. * runningComponentCount: 5
  590. * }
  591. */
  592. getHostComponentsByStatus: function (services, status) {
  593. var hosts = [];
  594. var componentCount = 0;
  595. var hostToIndexMap = {};
  596. services.forEach(function (service) {
  597. var hostComponents = (status == App.HostComponentStatus.started) ? service.get('runningHostComponents') : service.get('unknownHostComponents');
  598. if (hostComponents != null) {
  599. hostComponents.forEach(function (hc) {
  600. var hostName = hc.get('host.publicHostName');
  601. var componentName = hc.get('displayName');
  602. componentCount++;
  603. if (!(hostName in hostToIndexMap)) {
  604. hosts.push({
  605. name: hostName,
  606. components: ""
  607. });
  608. hostToIndexMap[hostName] = hosts.length - 1;
  609. }
  610. var hostObj = hosts[hostToIndexMap[hostName]];
  611. if (hostObj.components.length > 0)
  612. hostObj.components += ", " + componentName;
  613. else
  614. hostObj.components += componentName;
  615. });
  616. hosts.sort(function (a, b) {
  617. return a.name.localeCompare(b.name);
  618. });
  619. }
  620. });
  621. return {
  622. hosts: hosts,
  623. componentCount: componentCount
  624. };
  625. },
  626. /**
  627. * open popup with appropriate message
  628. */
  629. restartServicePopup: function (event) {
  630. if(this.get("isSubmitDisabled")){
  631. return;
  632. }
  633. var header;
  634. var message;
  635. var messageClass;
  636. var hasUnknown = false;
  637. var value;
  638. var flag = false;
  639. var runningHosts = null;
  640. var runningComponentCount = 0;
  641. var unknownHosts = null;
  642. var unknownComponentCount = 0;
  643. var dfd = $.Deferred();
  644. var self = this;
  645. var serviceName = this.get('content.serviceName');
  646. var displayName = this.get('content.displayName');
  647. if (App.supports.hostOverrides ||
  648. (serviceName !== 'HDFS' && this.get('content.isStopped') === true) ||
  649. ((serviceName === 'HDFS') && this.get('content.isStopped') === true && (!App.Service.find().someProperty('id', 'MAPREDUCE') || App.Service.find('MAPREDUCE').get('isStopped')))) {
  650. // warn the user if any service directories are being changed
  651. var dirChanged = false;
  652. if (serviceName === 'HDFS') {
  653. var hdfsConfigs = self.get('stepConfigs').findProperty('serviceName', 'HDFS').get('configs');
  654. if (
  655. hdfsConfigs.findProperty('name', 'dfs_name_dir').get('isNotDefaultValue') ||
  656. hdfsConfigs.findProperty('name', 'fs_checkpoint_dir').get('isNotDefaultValue') ||
  657. hdfsConfigs.findProperty('name', 'dfs_data_dir').get('isNotDefaultValue')
  658. ) {
  659. dirChanged = true;
  660. }
  661. } else if (serviceName === 'MAPREDUCE') {
  662. var mapredConfigs = self.get('stepConfigs').findProperty('serviceName', 'MAPREDUCE').get('configs');
  663. if (
  664. mapredConfigs.findProperty('name', 'mapred_local_dir').get('isNotDefaultValue') ||
  665. mapredConfigs.findProperty('name', 'mapred_system_dir').get('isNotDefaultValue')
  666. ) {
  667. dirChanged = true;
  668. }
  669. }
  670. if (dirChanged) {
  671. App.showConfirmationPopup(function() {
  672. dfd.resolve();
  673. }, Em.I18n.t('services.service.config.confirmDirectoryChange').format(displayName));
  674. } else {
  675. dfd.resolve();
  676. }
  677. dfd.done(function() {
  678. var result = self.saveServiceConfigProperties();
  679. App.router.get('clusterController').updateClusterData();
  680. flag = result.flag;
  681. if (result.flag === true) {
  682. header = Em.I18n.t('services.service.config.saved');
  683. message = Em.I18n.t('services.service.config.saved.message');
  684. messageClass = 'alert alert-success';
  685. // warn the user if any of the components are in UNKNOWN state
  686. var uhc;
  687. if (self.get('content.serviceName') !== 'HDFS' || (self.get('content.serviceName') === 'HDFS' && !App.Service.find().someProperty('id', 'MAPREDUCE'))) {
  688. uhc = self.getHostComponentsByStatus([self.get('content')], App.HostComponentStatus.unknown);
  689. } else {
  690. uhc = self.getHostComponentsByStatus([self.get('content'), App.Service.find('MAPREDUCE')], App.HostComponentStatus.unknown);
  691. }
  692. unknownHosts = uhc.hosts;
  693. unknownComponentCount = uhc.componentCount;
  694. } else {
  695. header = Em.I18n.t('common.failure');
  696. message = result.message;
  697. messageClass = 'alert alert-error';
  698. value = result.value;
  699. }
  700. });
  701. } else {
  702. var rhc;
  703. if (this.get('content.serviceName') !== 'HDFS' || (this.get('content.serviceName') === 'HDFS' && !App.Service.find().someProperty('id', 'MAPREDUCE'))) {
  704. rhc = this.getHostComponentsByStatus([this.get('content')], App.HostComponentStatus.started);
  705. header = Em.I18n.t('services.service.config.notSaved');
  706. message = Em.I18n.t('services.service.config.msgServiceStop');
  707. } else {
  708. rhc = this.getHostComponentsByStatus([this.get('content'), App.Service.find('MAPREDUCE')], App.HostComponentStatus.started);
  709. header = Em.I18n.t('services.service.config.notSaved');
  710. message = Em.I18n.t('services.service.config.msgHDFSMapRServiceStop');
  711. }
  712. messageClass = 'alert alert-error';
  713. runningHosts = rhc.hosts;
  714. runningComponentCount = rhc.componentCount;
  715. dfd.resolve();
  716. }
  717. dfd.done(function () {
  718. App.ModalPopup.show({
  719. header: header,
  720. primary: Em.I18n.t('ok'),
  721. secondary: null,
  722. onPrimary: function () {
  723. this.hide();
  724. if (flag) {
  725. self.loadStep();
  726. }
  727. },
  728. bodyClass: Ember.View.extend({
  729. flag: flag,
  730. message: message,
  731. messageClass: messageClass,
  732. runningHosts: runningHosts,
  733. runningComponentCount: runningComponentCount,
  734. unknownHosts: unknownHosts,
  735. unknownComponentCount: unknownComponentCount,
  736. siteProperties: value,
  737. getDisplayMessage: function () {
  738. var displayMsg = [];
  739. var siteProperties = this.get('siteProperties');
  740. if (siteProperties) {
  741. siteProperties.forEach(function (_siteProperty) {
  742. var displayProperty = _siteProperty.siteProperty;
  743. var displayNames = _siteProperty.displayNames;
  744. /////////
  745. if (displayNames && displayNames.length) {
  746. if (displayNames.length === 1) {
  747. displayMsg.push(displayProperty + Em.I18n.t('as') + displayNames[0]);
  748. } else {
  749. var name;
  750. displayNames.forEach(function (_name, index) {
  751. if (index === 0) {
  752. name = _name;
  753. } else if (index === siteProperties.length - 1) {
  754. name = name + Em.I18n.t('and') + _name;
  755. } else {
  756. name = name + ', ' + _name;
  757. }
  758. }, this);
  759. displayMsg.push(displayProperty + Em.I18n.t('as') + name);
  760. }
  761. } else {
  762. displayMsg.push(displayProperty);
  763. }
  764. }, this);
  765. }
  766. return displayMsg;
  767. }.property('siteProperties'),
  768. runningHostsMessage: function () {
  769. return Em.I18n.t('services.service.config.stopService.runningHostComponents').format(this.get('runningComponentCount'), this.get('runningHosts.length'));
  770. }.property('runningComponentCount', 'runningHosts.length'),
  771. unknownHostsMessage: function () {
  772. return Em.I18n.t('services.service.config.stopService.unknownHostComponents').format(this.get('unknownComponentCount'), this.get('unknownHosts.length'));
  773. }.property('unknownComponentCount', 'unknownHosts.length'),
  774. templateName: require('templates/main/service/info/configs_save_popup')
  775. })
  776. })
  777. });
  778. },
  779. /**
  780. * Save config properties
  781. */
  782. saveServiceConfigProperties: function () {
  783. var result = {
  784. flag: false,
  785. message: null,
  786. value: null
  787. };
  788. this.savedHostToOverrideSiteToTagMap = {};
  789. var configs = this.get('stepConfigs').findProperty('serviceName', this.get('content.serviceName')).get('configs');
  790. this.saveGlobalConfigs(configs);
  791. if(this.get('content.serviceName') === 'YARN' && !App.supports.capacitySchedulerUi){
  792. configs = App.config.textareaIntoFileConfigs(configs, 'capacity-scheduler.xml');
  793. }
  794. this.saveSiteConfigs(configs);
  795. /**
  796. * First we put cluster configurations, which automatically creates /configurations
  797. * resources. Next we update host level overrides.
  798. */
  799. result.flag = this.doPUTClusterConfigurations();
  800. if (!result.flag) {
  801. result.message = Em.I18n.t('services.service.config.failSaveConfig');
  802. }else{
  803. result.flag = result.flag && this.doPUTHostOverridesConfigurationSites();
  804. if (!result.flag) {
  805. result.message = Em.I18n.t('services.service.config.failSaveConfigHostExceptions');
  806. }
  807. }
  808. console.log("The result from applyCreatdConfToService is: " + result);
  809. return result;
  810. },
  811. /**
  812. * save new or change exist configs in global configs
  813. * @param configs
  814. */
  815. saveGlobalConfigs: function (configs) {
  816. var globalConfigs = this.get('globalConfigs');
  817. configs.filterProperty('id', 'puppet var').forEach(function (uiConfigProperty) {
  818. var displayType = uiConfigProperty.get('displayType');
  819. if (displayType == 'directories' || displayType === 'directory') {
  820. var value = uiConfigProperty.get('value').replace(/,/g,' ').trim().split(/\s+/g).join(',');
  821. uiConfigProperty.set('value', value);
  822. }
  823. if (globalConfigs.someProperty('name', uiConfigProperty.name)) {
  824. var modelGlobalConfig = globalConfigs.findProperty('name', uiConfigProperty.name);
  825. modelGlobalConfig.value = uiConfigProperty.value;
  826. var uiOverrides = uiConfigProperty.get('overrides');
  827. if(uiOverrides!=null && uiOverrides.get('length')>0){
  828. modelGlobalConfig.overrides = {};
  829. uiOverrides.forEach(function(uiOverride){
  830. var value = uiOverride.get('value');
  831. modelGlobalConfig.overrides[value] = [];
  832. uiOverride.get('selectedHostOptions').forEach(function(host){
  833. modelGlobalConfig.overrides[value].push(host);
  834. });
  835. });
  836. }
  837. } else {
  838. globalConfigs.pushObject({
  839. name: uiConfigProperty.name,
  840. value: uiConfigProperty.value
  841. });
  842. }
  843. }, this);
  844. this.setHiveHostName(globalConfigs);
  845. this.setOozieHostName(globalConfigs);
  846. this.set('globalConfigs', globalConfigs);
  847. },
  848. /**
  849. * set hive hostnames in global configs
  850. * @param globals
  851. */
  852. setHiveHostName: function (globals) {
  853. if (globals.someProperty('name', 'hive_database')) {
  854. var hiveDb = globals.findProperty('name', 'hive_database');
  855. if (hiveDb.value === 'New MySQL Database') {
  856. var ambariHost = globals.findProperty('name', 'hive_ambari_host');
  857. if (ambariHost) {
  858. ambariHost.name = 'hive_hostname';
  859. }
  860. globals = globals.without(globals.findProperty('name', 'hive_existing_mysql_host'));
  861. globals = globals.without(globals.findProperty('name', 'hive_existing_mysql_database'));
  862. globals = globals.without(globals.findProperty('name', 'hive_existing_oracle_host'));
  863. globals = globals.without(globals.findProperty('name', 'hive_existing_oracle_database'));
  864. } else if (hiveDb.value === 'Existing MySQL Database'){
  865. var existingMySqlHost = globals.findProperty('name', 'hive_existing_mysql_host');
  866. if (existingMySqlHost) {
  867. existingMySqlHost.name = 'hive_hostname';
  868. }
  869. globals = globals.without(globals.findProperty('name', 'hive_ambari_host'));
  870. globals = globals.without(globals.findProperty('name', 'hive_ambari_database'));
  871. globals = globals.without(globals.findProperty('name', 'hive_existing_oracle_host'));
  872. globals = globals.without(globals.findProperty('name', 'hive_existing_oracle_database'));
  873. } else { //existing oracle database
  874. var existingOracleHost = globals.findProperty('name', 'hive_existing_oracle_host');
  875. if (existingOracleHost) {
  876. existingOracleHost.name = 'hive_hostname';
  877. }
  878. globals = globals.without(globals.findProperty('name', 'hive_ambari_host'));
  879. globals = globals.without(globals.findProperty('name', 'hive_ambari_database'));
  880. globals = globals.without(globals.findProperty('name', 'hive_existing_mysql_host'));
  881. globals = globals.without(globals.findProperty('name', 'hive_existing_mysql_database'));
  882. }
  883. }
  884. },
  885. /**
  886. * set oozie hostnames in global configs
  887. * @param globals
  888. */
  889. setOozieHostName: function (globals) {
  890. if (globals.someProperty('name', 'oozie_database')) {
  891. var oozieDb = globals.findProperty('name', 'oozie_database');
  892. if (oozieDb.value === 'New Derby Database'){
  893. globals = globals.without(globals.findProperty('name', 'oozie_ambari_host'));
  894. globals = globals.without(globals.findProperty('name', 'oozie_ambari_database'));
  895. globals = globals.without(globals.findProperty('name', 'oozie_existing_mysql_host'));
  896. globals = globals.without(globals.findProperty('name', 'oozie_existing_mysql_database'));
  897. globals = globals.without(globals.findProperty('name', 'oozie_existing_oracle_host'));
  898. globals = globals.without(globals.findProperty('name', 'oozie_existing_oracle_database'));
  899. } else if (oozieDb.value === 'New MySQL Database') {
  900. var ambariHost = globals.findProperty('name', 'oozie_ambari_host');
  901. if (ambariHost) {
  902. ambariHost.name = 'oozie_hostname';
  903. }
  904. globals = globals.without(globals.findProperty('name', 'oozie_existing_mysql_host'));
  905. globals = globals.without(globals.findProperty('name', 'oozie_existing_mysql_database'));
  906. globals = globals.without(globals.findProperty('name', 'oozie_existing_oracle_host'));
  907. globals = globals.without(globals.findProperty('name', 'oozie_existing_oracle_database'));
  908. globals = globals.without(globals.findProperty('name', 'oozie_derby_database'));
  909. } else if (oozieDb.value === 'Existing MySQL Database') {
  910. var existingMySqlHost = globals.findProperty('name', 'oozie_existing_mysql_host');
  911. if (existingMySqlHost) {
  912. existingMySqlHost.name = 'oozie_hostname';
  913. }
  914. globals = globals.without(globals.findProperty('name', 'oozie_ambari_host'));
  915. globals = globals.without(globals.findProperty('name', 'oozie_ambari_database'));
  916. globals = globals.without(globals.findProperty('name', 'oozie_existing_oracle_host'));
  917. globals = globals.without(globals.findProperty('name', 'oozie_existing_oracle_database'));
  918. globals = globals.without(globals.findProperty('name', 'oozie_derby_database'));
  919. } else{ //existing oracle database
  920. var existingOracleHost = globals.findProperty('name', 'oozie_existing_oracle_host');
  921. if (existingOracleHost) {
  922. existingOracleHost.name = 'oozie_hostname';
  923. }
  924. globals = globals.without(globals.findProperty('name', 'oozie_ambari_host'));
  925. globals = globals.without(globals.findProperty('name', 'oozie_ambari_database'));
  926. globals = globals.without(globals.findProperty('name', 'oozie_existing_mysql_host'));
  927. globals = globals.without(globals.findProperty('name', 'oozie_existing_mysql_database'));
  928. globals = globals.without(globals.findProperty('name', 'oozie_derby_database'));
  929. }
  930. }
  931. },
  932. /**
  933. * save site configs
  934. * @param configs
  935. */
  936. saveSiteConfigs: function (configs) {
  937. //storedConfigs contains custom configs as well
  938. var serviceConfigProperties = configs.filterProperty('id', 'site property');
  939. serviceConfigProperties.forEach(function(_config){
  940. if(typeof _config.get('value') === "boolean") _config.set('value', _config.value.toString());
  941. });
  942. var storedConfigs = serviceConfigProperties.filterProperty('value');
  943. var allUiConfigs = this.loadUiSideConfigs(this.get('configMapping').all());
  944. this.set('uiConfigs', storedConfigs.concat(allUiConfigs));
  945. },
  946. /**
  947. * return configs from the UI side
  948. * @param configMapping array with configs
  949. * @return {Array}
  950. */
  951. loadUiSideConfigs: function (configMapping) {
  952. var uiConfig = [];
  953. var configs = configMapping.filterProperty('foreignKey', null);
  954. this.addDynamicProperties(configs);
  955. configs.forEach(function (_config) {
  956. var valueWithOverrides = this.getGlobConfigValueWithOverrides(_config.templateName, _config.value, _config.name);
  957. if (valueWithOverrides !== null) {
  958. uiConfig.pushObject({
  959. "id": "site property",
  960. "name": _config.name,
  961. "value": valueWithOverrides.value,
  962. "filename": _config.filename,
  963. "overrides": valueWithOverrides.overrides
  964. });
  965. }
  966. }, this);
  967. return uiConfig;
  968. },
  969. addDynamicProperties: function(configs) {
  970. var allConfigs = this.get('stepConfigs').findProperty('serviceName', this.get('content.serviceName')).get('configs');
  971. var templetonHiveProperty = allConfigs.someProperty('name', 'templeton.hive.properties');
  972. if (!templetonHiveProperty && this.get('content.serviceName') === 'WEBHCAT') {
  973. configs.pushObject({
  974. "name": "templeton.hive.properties",
  975. "templateName": ["hivemetastore_host"],
  976. "foreignKey": null,
  977. "value": "hive.metastore.local=false,hive.metastore.uris=thrift://<templateName[0]>:9083,hive.metastore.sasl.enabled=yes,hive.metastore.execute.setugi=true",
  978. "filename": "webhcat-site.xml"
  979. });
  980. }
  981. },
  982. /**
  983. * return global config value
  984. * @param templateName
  985. * @param expression
  986. * @param name
  987. * @return {
  988. * value: '...',
  989. * overrides: {
  990. * 'value1': [h1, h2],
  991. * 'value2': [h3]
  992. * }
  993. * }
  994. */
  995. getGlobConfigValueWithOverrides: function (templateName, expression, name) {
  996. var express = expression.match(/<(.*?)>/g);
  997. var value = expression;
  998. if (express == null) {
  999. return { value : expression, overrides: {}}; // if site property do not map any global property then return the value
  1000. }
  1001. var overrideHostToValue = {};
  1002. express.forEach(function (_express) {
  1003. //console.log("The value of template is: " + _express);
  1004. var index = parseInt(_express.match(/\[([\d]*)(?=\])/)[1]);
  1005. if (this.get('globalConfigs').someProperty('name', templateName[index])) {
  1006. //console.log("The name of the variable is: " + this.get('content.serviceConfigProperties').findProperty('name', templateName[index]).name);
  1007. var globalObj = this.get('globalConfigs').findProperty('name', templateName[index]);
  1008. var globValue = globalObj.value;
  1009. // Hack for templeton.zookeeper.hosts
  1010. var preReplaceValue = null;
  1011. if (value !== null) { // if the property depends on more than one template name like <templateName[0]>/<templateName[1]> then don't proceed to the next if the prior is null or not found in the global configs
  1012. preReplaceValue = value;
  1013. value = this._replaceConfigValues(name, _express, value, globValue);
  1014. }
  1015. if(globalObj.overrides!=null){
  1016. for(var ov in globalObj.overrides){
  1017. var hostsArray = globalObj.overrides[ov];
  1018. hostsArray.forEach(function(host){
  1019. if(!(host in overrideHostToValue)){
  1020. overrideHostToValue[host] = this._replaceConfigValues(name, _express, preReplaceValue, ov);
  1021. }else{
  1022. overrideHostToValue[host] = this._replaceConfigValues(name, _express, overrideHostToValue[host], ov);
  1023. }
  1024. }, this);
  1025. }
  1026. }
  1027. } else {
  1028. /*
  1029. console.log("ERROR: The variable name is: " + templateName[index]);
  1030. console.log("ERROR: mapped config from configMapping file has no corresponding variable in " +
  1031. "content.serviceConfigProperties. Two possible reasons for the error could be: 1) The service is not selected. " +
  1032. "and/OR 2) The service_config metadata file has no corresponding global var for the site property variable");
  1033. */
  1034. value = null;
  1035. }
  1036. }, this);
  1037. var valueWithOverrides = {
  1038. value: value,
  1039. overrides: {}
  1040. };
  1041. if(!jQuery.isEmptyObject(overrideHostToValue)){
  1042. for(var host in overrideHostToValue){
  1043. var hostVal = overrideHostToValue[host];
  1044. if(!(hostVal in valueWithOverrides.overrides)){
  1045. valueWithOverrides.overrides[hostVal] = [];
  1046. }
  1047. valueWithOverrides.overrides[hostVal].push(host);
  1048. }
  1049. }
  1050. return valueWithOverrides;
  1051. },
  1052. _replaceConfigValues: function (name, express, value, globValue) {
  1053. if (name === "templeton.zookeeper.hosts" || name === 'hbase.zookeeper.quorum') {
  1054. var zooKeeperPort = '2181';
  1055. if (typeof globValue === 'string') {
  1056. var temp = [];
  1057. temp.push(globValue);
  1058. globValue = temp;
  1059. }
  1060. if (name === "templeton.zookeeper.hosts") {
  1061. var temp = [];
  1062. globValue.forEach(function (_host, index) {
  1063. temp.push(globValue[index] + ':' + zooKeeperPort);
  1064. }, this);
  1065. globValue = temp;
  1066. }
  1067. value = value.replace(express, globValue.toString());
  1068. } else {
  1069. value = value.replace(express, globValue);
  1070. }
  1071. return value;
  1072. },
  1073. /**
  1074. * Saves cluster level configurations for all necessary sites.
  1075. * PUT calls are made to /api/v1/clusters/clusterName for each site.
  1076. *
  1077. * @return {Boolean}
  1078. */
  1079. doPUTClusterConfigurations: function () {
  1080. var result = true;
  1081. var serviceConfigTags = this.get('serviceConfigTags');
  1082. this.setNewTagNames(serviceConfigTags);
  1083. var siteNameToServerDataMap = {};
  1084. serviceConfigTags.forEach(function (_serviceTags) {
  1085. if (_serviceTags.siteName === 'global') {
  1086. console.log("TRACE: Inside global");
  1087. var serverGlobalConfigs = this.createGlobalSiteObj(_serviceTags.newTagName);
  1088. siteNameToServerDataMap['global'] = serverGlobalConfigs;
  1089. if(this.isConfigChanged(App.config.loadedConfigurationsCache['global_'+this.loadedClusterSiteToTagMap['global']], serverGlobalConfigs.properties)){
  1090. result = result && this.doPUTClusterConfigurationSite(serverGlobalConfigs);
  1091. }
  1092. } else if (_serviceTags.siteName === 'core-site') {
  1093. console.log("TRACE: Inside core-site");
  1094. if (this.get('content.serviceName') === 'HDFS' || this.get('content.serviceName') === 'HCFS') {
  1095. var coreSiteConfigs = this.createCoreSiteObj(_serviceTags.newTagName);
  1096. siteNameToServerDataMap['core-site'] = coreSiteConfigs;
  1097. if(this.isConfigChanged(App.config.loadedConfigurationsCache['core-site_'+this.loadedClusterSiteToTagMap['core-site']], coreSiteConfigs.properties)){
  1098. result = result && this.doPUTClusterConfigurationSite(coreSiteConfigs);
  1099. }
  1100. }
  1101. } else {
  1102. var serverConfigs = this.createSiteObj(_serviceTags.siteName, _serviceTags.newTagName);
  1103. siteNameToServerDataMap[_serviceTags.siteName] = serverConfigs;
  1104. if(this.isConfigChanged(App.config.loadedConfigurationsCache[_serviceTags.siteName+'_'+this.loadedClusterSiteToTagMap[_serviceTags.siteName]], serverConfigs.properties)){
  1105. result = result && this.doPUTClusterConfigurationSite(serverConfigs);
  1106. }
  1107. }
  1108. }, this);
  1109. this.savedSiteNameToServerServiceConfigDataMap = siteNameToServerDataMap;
  1110. return result;
  1111. },
  1112. /**
  1113. * Compares the loaded config values with the saving config values.
  1114. */
  1115. isConfigChanged: function (loadedConfig, savingConfig) {
  1116. var changed = false;
  1117. if (loadedConfig != null && savingConfig != null) {
  1118. var seenLoadKeys = [];
  1119. for ( var loadKey in loadedConfig) {
  1120. seenLoadKeys.push(loadKey);
  1121. var loadValue = loadedConfig[loadKey];
  1122. var saveValue = savingConfig[loadKey];
  1123. if("boolean" == typeof(saveValue)){
  1124. saveValue = saveValue.toString();
  1125. }
  1126. if(saveValue==null){
  1127. saveValue = "null";
  1128. }
  1129. if (loadValue !== saveValue) {
  1130. changed = true;
  1131. break;
  1132. }
  1133. }
  1134. for ( var saveKey in savingConfig) {
  1135. if (seenLoadKeys.indexOf(saveKey) < 0) {
  1136. changed = true;
  1137. break;
  1138. }
  1139. }
  1140. }
  1141. return changed;
  1142. },
  1143. /**
  1144. * Saves configuration of a particular site. The provided data
  1145. * contains the site name and tag to be used.
  1146. */
  1147. doPUTClusterConfigurationSite: function (data) {
  1148. var result;
  1149. var url = this.getUrl('', '');
  1150. var clusterData = {
  1151. Clusters: {
  1152. desired_config: data
  1153. }
  1154. };
  1155. console.log("applyClusterConfigurationToSite(): PUTting data:", clusterData);
  1156. $.ajax({
  1157. type: 'PUT',
  1158. url: url,
  1159. async: false,
  1160. dataType: 'text',
  1161. data: JSON.stringify(clusterData),
  1162. timeout: 5000,
  1163. success: function (data) {
  1164. console.log("applyClusterConfigurationToSite(): In success for data:", data);
  1165. result = true;
  1166. },
  1167. error: function (request, ajaxOptions, error) {
  1168. console.log('applyClusterConfigurationToSite(): ERROR:', request.responseText, ", error=", error);
  1169. result = false;
  1170. },
  1171. statusCode: require('data/statusCodes')
  1172. });
  1173. console.log("applyClusterConfigurationToSite(): Exiting with result=" + result);
  1174. return result;
  1175. },
  1176. /**
  1177. * Creates host level overrides for service configuration.
  1178. *
  1179. */
  1180. doPUTHostOverridesConfigurationSites: function(){
  1181. var singlePUTHostData = [];
  1182. var savedHostSiteArray = [];
  1183. for ( var host in this.savedHostToOverrideSiteToTagMap) {
  1184. for ( var siteName in this.savedHostToOverrideSiteToTagMap[host]) {
  1185. var tagName = this.savedHostToOverrideSiteToTagMap[host][siteName].tagName;
  1186. var map = this.savedHostToOverrideSiteToTagMap[host][siteName].map;
  1187. savedHostSiteArray.push(host+"///"+siteName);
  1188. singlePUTHostData.push({
  1189. RequestInfo: {
  1190. query: 'Hosts/host_name='+host
  1191. },
  1192. Body: {
  1193. Hosts: {
  1194. desired_config: {
  1195. type: siteName,
  1196. tag: tagName,
  1197. properties: map
  1198. }
  1199. }
  1200. }
  1201. });
  1202. }
  1203. }
  1204. // Now cleanup removed overrides
  1205. for ( var loadedHost in this.loadedHostToOverrideSiteToTagMap) {
  1206. for ( var loadedSiteName in this.loadedHostToOverrideSiteToTagMap[loadedHost]) {
  1207. if (!(savedHostSiteArray.contains(loadedHost + "///" + loadedSiteName))) {
  1208. // This host-site combination was loaded, but not saved.
  1209. // Meaning it is not needed anymore. Hence send a DELETE command.
  1210. singlePUTHostData.push({
  1211. RequestInfo: {
  1212. query: 'Hosts/host_name='+loadedHost
  1213. },
  1214. Body: {
  1215. Hosts: {
  1216. desired_config: {
  1217. type: loadedSiteName,
  1218. tag: this.loadedHostToOverrideSiteToTagMap[loadedHost][loadedSiteName],
  1219. selected: false
  1220. }
  1221. }
  1222. }
  1223. });
  1224. }
  1225. }
  1226. }
  1227. console.debug("createHostOverrideConfigSites(): PUTting host-overrides. Data=",singlePUTHostData);
  1228. if(singlePUTHostData.length>0){
  1229. var url = this.getUrl('', '/hosts');
  1230. var hostOverrideResult = true;
  1231. $.ajax({
  1232. type: 'PUT',
  1233. url: url,
  1234. data: JSON.stringify(singlePUTHostData),
  1235. async: false,
  1236. dataType: 'text',
  1237. timeout: 5000,
  1238. success: function (data) {
  1239. var jsonData = jQuery.parseJSON(data);
  1240. hostOverrideResult = true;
  1241. console.log("createHostOverrideConfigSites(): SUCCESS:", url, ". RESPONSE:",jsonData);
  1242. },
  1243. error: function (request, ajaxOptions, error) {
  1244. hostOverrideResult = false;
  1245. console.log("createHostOverrideConfigSites(): ERROR:", url, ". RESPONSE:",request.responseText);
  1246. },
  1247. statusCode: require('data/statusCodes')
  1248. });
  1249. return hostOverrideResult;
  1250. }
  1251. return true;
  1252. },
  1253. /**
  1254. * add newTagName property to each config in serviceConfigs
  1255. * @param serviceConfigs
  1256. */
  1257. setNewTagNames: function (serviceConfigs) {
  1258. var time = (new Date).getTime();
  1259. serviceConfigs.forEach(function (_serviceConfigs) {
  1260. _serviceConfigs.newTagName = 'version' + time;
  1261. }, this);
  1262. },
  1263. /**
  1264. * create global site object
  1265. * @param tagName
  1266. * @return {Object}
  1267. */
  1268. createGlobalSiteObj: function (tagName) {
  1269. var globalSiteProperties = {};
  1270. this.get('globalConfigs').forEach(function (_globalSiteObj) {
  1271. // do not pass any globalConfigs whose name ends with _host or _hosts
  1272. if (!/_hosts?$/.test(_globalSiteObj.name)) {
  1273. // append "m" to JVM memory options except for hadoop_heapsize
  1274. if (/_heapsize|_newsize|_maxnewsize$/.test(_globalSiteObj.name) && _globalSiteObj.name !== 'hadoop_heapsize') {
  1275. _globalSiteObj.value += "m";
  1276. }
  1277. globalSiteProperties[_globalSiteObj.name] = _globalSiteObj.value;
  1278. this.recordHostOverride(_globalSiteObj, 'global', tagName, this);
  1279. //console.log("TRACE: name of the global property is: " + _globalSiteObj.name);
  1280. //console.log("TRACE: value of the global property is: " + _globalSiteObj.value);
  1281. }
  1282. }, this);
  1283. return {"type": "global", "tag": tagName, "properties": globalSiteProperties};
  1284. },
  1285. recordHostOverride: function(serviceConfigObj, siteName, tagName, self){
  1286. if('get' in serviceConfigObj){
  1287. return this._recordHostOverrideFromEmberObj(serviceConfigObj, siteName, tagName, self);
  1288. }else{
  1289. return this._recordHostOverrideFromObj(serviceConfigObj, siteName, tagName, self);
  1290. }
  1291. },
  1292. /**
  1293. * Records all the host overrides per site/tag
  1294. */
  1295. _recordHostOverrideFromObj: function(serviceConfigObj, siteName, tagName, self){
  1296. var overrides = serviceConfigObj.overrides;
  1297. if(overrides){
  1298. for(var value in overrides){
  1299. overrides[value].forEach(function(host){
  1300. if(!(host in self.savedHostToOverrideSiteToTagMap)){
  1301. self.savedHostToOverrideSiteToTagMap[host] = {};
  1302. }
  1303. if(!(siteName in self.savedHostToOverrideSiteToTagMap[host])){
  1304. self.savedHostToOverrideSiteToTagMap[host][siteName] = {};
  1305. self.savedHostToOverrideSiteToTagMap[host][siteName].map = {};
  1306. }
  1307. var finalTag = tagName + '_' + host;
  1308. console.log("recordHostOverride(): Saving host override for host="+host+", site="+siteName+", tag="+finalTag+", (key,value)=("+serviceConfigObj.name+","+value+")");
  1309. self.savedHostToOverrideSiteToTagMap[host][siteName].tagName = finalTag;
  1310. self.savedHostToOverrideSiteToTagMap[host][siteName].map[serviceConfigObj.name] = value;
  1311. });
  1312. }
  1313. }
  1314. },
  1315. /**
  1316. * Records all the host overrides per site/tag
  1317. */
  1318. _recordHostOverrideFromEmberObj: function(serviceConfigObj, siteName, tagName, self){
  1319. var overrides = serviceConfigObj.get('overrides');
  1320. if(overrides){
  1321. overrides.forEach(function(override){
  1322. override.get('selectedHostOptions').forEach(function(host){
  1323. if(!(host in self.savedHostToOverrideSiteToTagMap)){
  1324. self.savedHostToOverrideSiteToTagMap[host] = {};
  1325. }
  1326. if(!(siteName in self.savedHostToOverrideSiteToTagMap[host])){
  1327. self.savedHostToOverrideSiteToTagMap[host][siteName] = {};
  1328. self.savedHostToOverrideSiteToTagMap[host][siteName].map = {};
  1329. }
  1330. var finalTag = tagName + '_' + host;
  1331. console.log("recordHostOverride(): Saving host override for host="+host+", site="+siteName+", tag="+finalTag+", (key,value)=("+serviceConfigObj.name+","+override.get('value')+")");
  1332. self.savedHostToOverrideSiteToTagMap[host][siteName].tagName = finalTag;
  1333. self.savedHostToOverrideSiteToTagMap[host][siteName].map[serviceConfigObj.name] = override.get('value');
  1334. });
  1335. });
  1336. }
  1337. },
  1338. /**
  1339. * create core site object
  1340. * @param tagName
  1341. * @return {Object}
  1342. */
  1343. createCoreSiteObj: function (tagName) {
  1344. var coreSiteObj = this.get('uiConfigs').filterProperty('filename', 'core-site.xml');
  1345. var coreSiteProperties = {};
  1346. coreSiteObj.forEach(function (_coreSiteObj) {
  1347. coreSiteProperties[_coreSiteObj.name] = _coreSiteObj.value;
  1348. this.recordHostOverride(_coreSiteObj, 'core-site', tagName, this);
  1349. }, this);
  1350. return {"type": "core-site", "tag": tagName, "properties": coreSiteProperties};
  1351. },
  1352. /**
  1353. * create site object
  1354. * @param siteName
  1355. * @param tagName
  1356. * @return {Object}
  1357. */
  1358. createSiteObj: function (siteName, tagName) {
  1359. var siteObj = this.get('uiConfigs').filterProperty('filename', siteName + '.xml');
  1360. var siteProperties = {};
  1361. if (siteName == 'oozie-site') {
  1362. siteObj = this.getOozieSiteObj(siteObj);
  1363. } else if (siteName == 'hive-site') {
  1364. siteObj = this.getHiveSiteObj(siteObj);
  1365. }
  1366. siteObj.forEach(function (_siteObj) {
  1367. siteProperties[_siteObj.name] = _siteObj.value;
  1368. this.recordHostOverride(_siteObj, siteName, tagName, this);
  1369. }, this);
  1370. return {"type": siteName, "tag": tagName, "properties": siteProperties};
  1371. },
  1372. /**
  1373. * create site object for Oozie
  1374. * @param siteObj
  1375. * @return {Object}
  1376. */
  1377. getOozieSiteObj: function (siteObj) {
  1378. var jdbcUrl = siteObj.findProperty('name', 'oozie.service.JPAService.jdbc.url');
  1379. var jdbcDriver = siteObj.findProperty('name', 'oozie.service.JPAService.jdbc.driver');
  1380. var oozieDb = this.get('globalConfigs').findProperty('name', 'oozie_database').value;
  1381. // oozieHost is undefined if the database is derby
  1382. var oozieHost = (oozieDb == 'New Derby Database') ? '' : this.get('globalConfigs').findProperty('name', 'oozie_hostname').value;
  1383. var oozieDbName = this.get('globalConfigs').findProperty('name', 'oozie_database_name').value;
  1384. var defaultJdbcUrl;
  1385. switch (oozieDb) {
  1386. case 'New Derby Database':
  1387. defaultJdbcUrl = "jdbc:derby:${oozie.data.dir}/${oozie.db.schema.name}-db;create=true";
  1388. jdbcDriver.value = "org.apache.derby.jdbc.EmbeddedDriver";
  1389. break;
  1390. case 'Existing MySQL Database':
  1391. defaultJdbcUrl = "jdbc:mysql://" + oozieHost + "/" + oozieDbName;
  1392. jdbcDriver.value = "com.mysql.jdbc.Driver";
  1393. break;
  1394. case 'Existing Oracle Database':
  1395. defaultJdbcUrl = "jdbc:oracle:thin:@//" + oozieHost + ":1521/" + oozieDbName;
  1396. jdbcDriver.value = "oracle.jdbc.driver.OracleDriver";
  1397. break;
  1398. }
  1399. // in case the user upgraded from Ambari version <= 1.2.3, they will not have oozie_jdbc_connection_url global
  1400. var jdbcUrlInGlobal = this.get('globalConfigs').findProperty('name', 'oozie_jdbc_connection_url');
  1401. jdbcUrl.value = jdbcUrlInGlobal ? jdbcUrlInGlobal.value : defaultJdbcUrl;
  1402. return siteObj;
  1403. },
  1404. /**
  1405. * create site object for Hive
  1406. * @param siteObj
  1407. * @return {Object}
  1408. */
  1409. getHiveSiteObj: function (siteObj) {
  1410. var jdbcUrl = siteObj.findProperty('name', 'javax.jdo.option.ConnectionURL');
  1411. var jdbcDriver = siteObj.findProperty('name', 'javax.jdo.option.ConnectionDriverName');
  1412. var hiveDb = this.get('globalConfigs').findProperty('name', 'hive_database').value;
  1413. var hiveHost = this.get('globalConfigs').findProperty('name', 'hive_hostname').value;
  1414. var hiveDbName = this.get('globalConfigs').findProperty('name', 'hive_database_name').value;
  1415. var defaultJdbcUrl;
  1416. switch (hiveDb) {
  1417. case 'New MySQL Database':
  1418. defaultJdbcUrl = "jdbc:mysql://"+ hiveHost + "/" + hiveDbName + "?createDatabaseIfNotExist=true";
  1419. jdbcDriver.value = "com.mysql.jdbc.Driver";
  1420. break;
  1421. case 'Existing MySQL Database':
  1422. defaultJdbcUrl = "jdbc:mysql://"+ hiveHost + "/" + hiveDbName + "?createDatabaseIfNotExist=true";
  1423. jdbcDriver.value = "com.mysql.jdbc.Driver";
  1424. break;
  1425. case 'Existing Oracle Database':
  1426. defaultJdbcUrl = "jdbc:oracle:thin:@//"+ hiveHost + ":1521/" + hiveDbName;
  1427. jdbcDriver.value = "oracle.jdbc.driver.OracleDriver";
  1428. break;
  1429. }
  1430. // in case the user upgraded from Ambari <= 1.2.3, they will not have hive_jdbc_connection_url global
  1431. var jdbcUrlInGlobal = this.get('globalConfigs').findProperty('name', 'hive_jdbc_connection_url');
  1432. jdbcUrl.value = jdbcUrlInGlobal ? jdbcUrlInGlobal.value : defaultJdbcUrl;
  1433. return siteObj;
  1434. },
  1435. /**
  1436. * Set display names of the property from the puppet/global names
  1437. * @param: displayNames: a field to be set with displayNames
  1438. * @param names: array of property puppet/global names
  1439. */
  1440. setPropertyDisplayNames: function (displayNames, names) {
  1441. var stepConfigs = this.get('stepConfigs').findProperty('serviceName', this.get('content.serviceName')).configs;
  1442. names.forEach(function (_name, index) {
  1443. if (stepConfigs.someProperty('name', _name)) {
  1444. displayNames.push(stepConfigs.findProperty('name', _name).displayName);
  1445. }
  1446. }, this);
  1447. },
  1448. /**
  1449. * Set property of the site variable
  1450. */
  1451. setSiteProperty: function (key, value, filename) {
  1452. if (filename === 'core-site.xml' && this.get('uiConfigs').filterProperty('filename', 'core-site.xml').someProperty('name', key)) {
  1453. this.get('uiConfigs').filterProperty('filename', 'core-site.xml').findProperty('name', key).value = value;
  1454. return;
  1455. }
  1456. this.get('uiConfigs').pushObject({
  1457. "id": "site property",
  1458. "name": key,
  1459. "value": value,
  1460. "filename": filename
  1461. });
  1462. },
  1463. /**
  1464. * return either specific url for request if testMode is false or testUrl
  1465. * @param testUrl
  1466. * @param url
  1467. * @return {*}
  1468. */
  1469. getUrl: function (testUrl, url) {
  1470. return (App.testMode) ? testUrl : App.apiPrefix + '/clusters/' + App.router.getClusterName() + url;
  1471. },
  1472. /**
  1473. * Adds host name of master component to global config;
  1474. */
  1475. addHostNamesToGlobalConfig: function () {
  1476. var serviceName = this.get('content.serviceName');
  1477. var globalConfigs = this.get('globalConfigs');
  1478. var serviceConfigs = this.get('serviceConfigs').findProperty('serviceName', serviceName).configs;
  1479. //namenode_host is required to derive "fs.default.name" a property of core-site
  1480. var nameNodeHost = this.get('serviceConfigs').findProperty('serviceName', 'HDFS').configs.findProperty('name', 'namenode_host');
  1481. try {
  1482. nameNodeHost.defaultValue = App.Service.find('HDFS').get('hostComponents').findProperty('componentName', 'NAMENODE').get('host.hostName');
  1483. globalConfigs.push(nameNodeHost);
  1484. } catch (err) {
  1485. console.log("No NameNode Host available. This is expected if you're using HCFS rather than HDFS.");
  1486. }
  1487. //zooKeeperserver_host
  1488. var zooKeperHost = this.get('serviceConfigs').findProperty('serviceName', 'ZOOKEEPER').configs.findProperty('name', 'zookeeperserver_hosts');
  1489. if (serviceName === 'ZOOKEEPER' || serviceName === 'HBASE' || serviceName === 'WEBHCAT') {
  1490. zooKeperHost.defaultValue = App.Service.find('ZOOKEEPER').get('hostComponents').filterProperty('componentName', 'ZOOKEEPER_SERVER').mapProperty('host.hostName');
  1491. globalConfigs.push(zooKeperHost);
  1492. }
  1493. switch (serviceName) {
  1494. case 'HDFS':
  1495. var sNameNodeHost = serviceConfigs.findProperty('name', 'snamenode_host');
  1496. sNameNodeHost.defaultValue = this.get('content.hostComponents').findProperty('componentName', 'SECONDARY_NAMENODE').get('host.hostName');
  1497. globalConfigs.push(sNameNodeHost);
  1498. break;
  1499. case 'MAPREDUCE':
  1500. var jobTrackerHost = serviceConfigs.findProperty('name', 'jobtracker_host');
  1501. jobTrackerHost.defaultValue = this.get('content.hostComponents').findProperty('componentName', 'JOBTRACKER').get('host.hostName');
  1502. globalConfigs.push(jobTrackerHost);
  1503. break;
  1504. case 'MAPREDUCE2':
  1505. var historyServerHost = serviceConfigs.findProperty('name', 'hs_host');
  1506. historyServerHost.defaultValue = this.get('content.hostComponents').findProperty('componentName', 'HISTORYSERVER').get('host.hostName');
  1507. globalConfigs.push(historyServerHost);
  1508. break;
  1509. case 'YARN':
  1510. var resourceManagerHost = serviceConfigs.findProperty('name', 'rm_host');
  1511. resourceManagerHost.defaultValue = this.get('content.hostComponents').findProperty('componentName', 'RESOURCEMANAGER').get('host.hostName');
  1512. globalConfigs.push(resourceManagerHost);
  1513. //yarn.log.server.url config dependent on HistoryServer host
  1514. if(App.HostComponent.find().someProperty('componentName', 'HISTORYSERVER')){
  1515. historyServerHost = this.get('serviceConfigs').findProperty('serviceName', 'MAPREDUCE2').configs.findProperty('name', 'hs_host');
  1516. historyServerHost.defaultValue = App.HostComponent.find().findProperty('componentName', 'HISTORYSERVER').get('host.hostName');
  1517. globalConfigs.push(historyServerHost);
  1518. }
  1519. break;
  1520. case 'HIVE':
  1521. var hiveMetastoreHost = serviceConfigs.findProperty('name', 'hivemetastore_host');
  1522. hiveMetastoreHost.defaultValue = this.get('content.hostComponents').findProperty('componentName', 'HIVE_SERVER').get('host.hostName');
  1523. globalConfigs.push(hiveMetastoreHost);
  1524. var hiveDb = globalConfigs.findProperty('name', 'hive_database').value;
  1525. if (['Existing MySQL Database', 'Existing Oracle Database'].contains(hiveDb)) {
  1526. globalConfigs.findProperty('name', 'hive_hostname').isVisible = true;
  1527. }
  1528. break;
  1529. case 'OOZIE':
  1530. var oozieServerHost = serviceConfigs.findProperty('name', 'oozieserver_host');
  1531. oozieServerHost.defaultValue = this.get('content.hostComponents').findProperty('componentName', 'OOZIE_SERVER').get('host.hostName');
  1532. globalConfigs.push(oozieServerHost);
  1533. var oozieDb = globalConfigs.findProperty('name', 'oozie_database').value;
  1534. if (['Existing MySQL Database', 'Existing Oracle Database'].contains(oozieDb)) {
  1535. globalConfigs.findProperty('name', 'oozie_hostname').isVisible = true;
  1536. }
  1537. break;
  1538. case 'HBASE':
  1539. var hbaseMasterHost = serviceConfigs.findProperty('name', 'hbasemaster_host');
  1540. hbaseMasterHost.defaultValue = this.get('content.hostComponents').filterProperty('componentName', 'HBASE_MASTER').mapProperty('host.hostName');
  1541. globalConfigs.push(hbaseMasterHost);
  1542. break;
  1543. case 'HUE':
  1544. var hueServerHost = serviceConfigs.findProperty('name', 'hueserver_host');
  1545. hueServerHost.defaultValue = this.get('content.hostComponents').findProperty('componentName', 'HUE_SERVER').get('host.hostName');
  1546. globalConfigs.push(hueServerHost);
  1547. break;
  1548. case 'WEBHCAT':
  1549. var webhcatMasterHost = serviceConfigs.findProperty('name', 'webhcatserver_host');
  1550. webhcatMasterHost.defaultValue = this.get('content.hostComponents').filterProperty('componentName', 'WEBHCAT_SERVER').mapProperty('host.hostName');
  1551. globalConfigs.push(webhcatMasterHost);
  1552. var hiveMetastoreHost = this.get('serviceConfigs').findProperty('serviceName', 'HIVE').configs.findProperty('name', 'hivemetastore_host');
  1553. hiveMetastoreHost.defaultValue = App.Service.find('HIVE').get('hostComponents').findProperty('componentName', 'HIVE_SERVER').get('host.hostName');
  1554. globalConfigs.push(hiveMetastoreHost);
  1555. break;
  1556. }
  1557. },
  1558. /**
  1559. * Provides service component name and display-name information for
  1560. * the current selected service.
  1561. */
  1562. getCurrentServiceComponents: function () {
  1563. var service = this.get('content');
  1564. var components = service.get('hostComponents');
  1565. var validComponents = Ember.A([]);
  1566. var seenComponents = {};
  1567. components.forEach(function(component){
  1568. var cn = component.get('componentName');
  1569. var cdn = component.get('displayName');
  1570. if(!seenComponents[cn]){
  1571. validComponents.push(Ember.Object.create({
  1572. componentName: cn,
  1573. displayName: cdn,
  1574. selected: false
  1575. }));
  1576. seenComponents[cn] = cn;
  1577. }
  1578. });
  1579. return validComponents;
  1580. }.property('content'),
  1581. getAllHosts: function () {
  1582. return App.router.get('mainHostController.content');
  1583. }.property('App.router.mainHostController.content'),
  1584. doCancel: function () {
  1585. this.loadStep();
  1586. }
  1587. });