step8_controller.js 68 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719
  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. var stringUtils = require('utils/string_utils');
  20. App.WizardStep8Controller = Em.Controller.extend({
  21. name: 'wizardStep8Controller',
  22. rawContent: require('data/review_configs'),
  23. totalHosts: [],
  24. clusterInfo: [],
  25. services: [],
  26. configs: [],
  27. globals: [],
  28. ajaxQueue: [],
  29. configMapping: function(){
  30. return App.config.get('configMapping').all();
  31. }.property('App.config.configMapping'),
  32. slaveComponentConfig: null,
  33. isSubmitDisabled: false,
  34. hasErrorOccurred: false,
  35. servicesInstalled: false,
  36. securityEnabled: false,
  37. /**
  38. * During page save time, we set the host overrides to the server.
  39. * The new host -> site:tag map is stored below. This will be
  40. * useful during save, to update the host's host components. Also,
  41. * it will be useful in deletion of overrides.
  42. *
  43. * Example:
  44. * {
  45. * 'hostname1': {
  46. * 'global': {
  47. * 'tagName': 'tag3187261938_hostname1',
  48. * 'map': {
  49. * 'hadoop_heapsize': '2048m'
  50. * }
  51. * }
  52. * }
  53. * }
  54. *
  55. * @see loadedHostToOverrideSiteToTagMap
  56. */
  57. savedHostToOverrideSiteToTagMap: {},
  58. selectedServices: function () {
  59. return this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false);
  60. }.property('content.services').cacheable(),
  61. clearStep: function () {
  62. this.get('services').clear();
  63. this.get('configs').clear();
  64. this.get('globals').clear();
  65. this.get('clusterInfo').clear();
  66. this.set('servicesInstalled', false);
  67. },
  68. loadStep: function () {
  69. console.log("TRACE: Loading step8: Review Page");
  70. if (this.get('content.controllerName') != 'installerController') {
  71. this.set('securityEnabled', App.router.get('mainAdminSecurityController').getUpdatedSecurityStatus());
  72. }
  73. this.clearStep();
  74. this.formatDirectories();
  75. this.loadGlobals();
  76. this.loadConfigs();
  77. this.loadClusterInfo();
  78. this.loadServices();
  79. this.set('isSubmitDisabled', false);
  80. },
  81. /**
  82. * replace whitespace character with coma between directories
  83. */
  84. formatDirectories: function(){
  85. this.get('content.serviceConfigProperties').forEach(function(_configProperty){
  86. _configProperty.value = App.config.trimProperty(_configProperty,false);
  87. });
  88. },
  89. loadGlobals: function () {
  90. var globals = this.get('content.serviceConfigProperties').filterProperty('id', 'puppet var');
  91. if (globals.someProperty('name', 'hive_database')) {
  92. var hiveDb = globals.findProperty('name', 'hive_database');
  93. var hiveDbType = {name: 'hive_database_type', value: 'mysql'};
  94. var hiveJdbcDriver = {name: 'hive_jdbc_driver'};
  95. if (hiveDb.value === 'New MySQL Database') {
  96. if (globals.someProperty('name', 'hive_ambari_host')) {
  97. globals.findProperty('name', 'hive_hostname').value = globals.findProperty('name', 'hive_ambari_host').value;
  98. hiveDbType.value = 'mysql';
  99. hiveJdbcDriver.value = 'com.mysql.jdbc.Driver';
  100. }
  101. globals = globals.without(globals.findProperty('name', 'hive_existing_mysql_host'));
  102. globals = globals.without(globals.findProperty('name', 'hive_existing_mysql_database'));
  103. globals = globals.without(globals.findProperty('name', 'hive_existing_oracle_host'));
  104. globals = globals.without(globals.findProperty('name', 'hive_existing_oracle_database'));
  105. } else if (hiveDb.value === 'Existing MySQL Database'){
  106. globals.findProperty('name', 'hive_hostname').value = globals.findProperty('name', 'hive_existing_mysql_host').value;
  107. hiveDbType.value = 'mysql';
  108. hiveJdbcDriver.value = 'com.mysql.jdbc.Driver';
  109. globals = globals.without(globals.findProperty('name', 'hive_ambari_host'));
  110. globals = globals.without(globals.findProperty('name', 'hive_ambari_database'));
  111. globals = globals.without(globals.findProperty('name', 'hive_existing_oracle_host'));
  112. globals = globals.without(globals.findProperty('name', 'hive_existing_oracle_database'));
  113. } else { //existing oracle database
  114. globals.findProperty('name', 'hive_hostname').value = globals.findProperty('name', 'hive_existing_oracle_host').value;
  115. hiveDbType.value = 'oracle';
  116. hiveJdbcDriver.value = 'oracle.jdbc.driver.OracleDriver';
  117. globals = globals.without(globals.findProperty('name', 'hive_ambari_host'));
  118. globals = globals.without(globals.findProperty('name', 'hive_ambari_database'));
  119. globals = globals.without(globals.findProperty('name', 'hive_existing_mysql_host'));
  120. globals = globals.without(globals.findProperty('name', 'hive_existing_mysql_database'));
  121. }
  122. globals.push(hiveDbType);
  123. globals.push(hiveJdbcDriver);
  124. }
  125. if (globals.someProperty('name', 'oozie_database')) {
  126. var oozieDb = globals.findProperty('name', 'oozie_database');
  127. var oozieDbType = {name:'oozie_database_type'};
  128. var oozieJdbcDriver = {name: 'oozie_jdbc_driver'};
  129. if (oozieDb.value === 'New Derby Database') {
  130. globals.findProperty('name', 'oozie_hostname').value = globals.findProperty('name', 'oozie_ambari_host').value;
  131. oozieDbType.value = 'derby';
  132. oozieJdbcDriver.value = 'org.apache.derby.jdbc.EmbeddedDriver';
  133. globals = globals.without(globals.findProperty('name', 'oozie_ambari_host'));
  134. globals = globals.without(globals.findProperty('name', 'oozie_ambari_database'));
  135. globals = globals.without(globals.findProperty('name', 'oozie_existing_mysql_host'));
  136. globals = globals.without(globals.findProperty('name', 'oozie_existing_mysql_database'));
  137. globals = globals.without(globals.findProperty('name', 'oozie_existing_oracle_host'));
  138. globals = globals.without(globals.findProperty('name', 'oozie_existing_oracle_database'));
  139. } else if (oozieDb.value === 'Existing MySQL Database') {
  140. globals.findProperty('name', 'oozie_hostname').value = globals.findProperty('name', 'oozie_existing_mysql_host').value;
  141. oozieDbType.value = 'mysql';
  142. oozieJdbcDriver.value = 'com.mysql.jdbc.Driver';
  143. globals = globals.without(globals.findProperty('name', 'oozie_ambari_host'));
  144. globals = globals.without(globals.findProperty('name', 'oozie_ambari_database'));
  145. globals = globals.without(globals.findProperty('name', 'oozie_existing_oracle_host'));
  146. globals = globals.without(globals.findProperty('name', 'oozie_existing_oracle_database'));
  147. globals = globals.without(globals.findProperty('name', 'oozie_derby_database'));
  148. } else { // existing oracle database
  149. globals.findProperty('name', 'oozie_hostname').value = globals.findProperty('name', 'oozie_existing_oracle_host').value;
  150. oozieDbType.value = 'oracle';
  151. oozieJdbcDriver.value = 'oracle.jdbc.driver.OracleDriver';
  152. globals = globals.without(globals.findProperty('name', 'oozie_ambari_host'));
  153. globals = globals.without(globals.findProperty('name', 'oozie_ambari_database'));
  154. globals = globals.without(globals.findProperty('name', 'oozie_existing_mysql_host'));
  155. globals = globals.without(globals.findProperty('name', 'oozie_existing_mysql_database'));
  156. globals = globals.without(globals.findProperty('name', 'oozie_derby_database'));
  157. }
  158. globals.push(oozieDbType);
  159. globals.push(oozieJdbcDriver);
  160. }
  161. this.set('globals', globals);
  162. },
  163. loadConfigs: function () {
  164. //storedConfigs contains custom configs as well
  165. var serviceConfigProperties = this.get('content.serviceConfigProperties').filterProperty('id', 'site property');
  166. serviceConfigProperties.forEach(function(_config){
  167. _config.value = (typeof _config.value === "boolean") ? _config.value.toString() : _config.value;
  168. });
  169. var storedConfigs = serviceConfigProperties.filterProperty('value');
  170. var uiConfigs = this.loadUiSideConfigs();
  171. this.set('configs', storedConfigs.concat(uiConfigs));
  172. },
  173. loadUiSideConfigs: function () {
  174. var uiConfig = [];
  175. var configs = this.get('configMapping').filterProperty('foreignKey', null);
  176. this.addDynamicProperties(configs);
  177. configs.forEach(function (_config) {
  178. var valueWithOverrides = this.getGlobConfigValueWithOverrides(_config.templateName, _config.value, _config.name);
  179. uiConfig.pushObject({
  180. "id": "site property",
  181. "name": _config.name,
  182. "value": valueWithOverrides.value,
  183. "filename": _config.filename,
  184. "overrides": valueWithOverrides.overrides
  185. });
  186. }, this);
  187. var dependentConfig = $.extend(true, [], this.get('configMapping').filterProperty('foreignKey'));
  188. dependentConfig.forEach(function (_config) {
  189. App.config.setConfigValue(uiConfig, this.get('content.serviceConfigProperties'), _config, this.get('globals'));
  190. uiConfig.pushObject({
  191. "id": "site property",
  192. "name": _config._name || _config.name,
  193. "value": _config.value,
  194. "filename": _config.filename
  195. });
  196. }, this);
  197. return uiConfig;
  198. },
  199. addDynamicProperties: function(configs) {
  200. var templetonHiveProperty = this.get('content.serviceConfigProperties').someProperty('name', 'templeton.hive.properties');
  201. if (!templetonHiveProperty) {
  202. configs.pushObject({
  203. "name": "templeton.hive.properties",
  204. "templateName": ["hivemetastore_host"],
  205. "foreignKey": null,
  206. "value": "hive.metastore.local=false,hive.metastore.uris=thrift://<templateName[0]>:9083,hive.metastore.sasl.enabled=yes,hive.metastore.execute.setugi=true,hive.metastore.warehouse.dir=/apps/hive/warehouse",
  207. "filename": "webhcat-site.xml"
  208. });
  209. }
  210. },
  211. getRegisteredHosts: function () {
  212. var allHosts = this.get('content.hosts');
  213. var hosts = [];
  214. for (var hostName in allHosts) {
  215. if (allHosts[hostName].bootStatus == 'REGISTERED') {
  216. allHosts[hostName].hostName = allHosts[hostName].name;
  217. hosts.pushObject(allHosts[hostName]);
  218. }
  219. }
  220. return hosts;
  221. },
  222. /**
  223. * Set all site property that are derived from other puppet-variable
  224. * @return {
  225. * value: '...',
  226. * overrides: {
  227. * 'value1': [h1, h2],
  228. * 'value2': [h3]
  229. * }
  230. * }
  231. */
  232. getGlobConfigValueWithOverrides: function (templateName, expression, name) {
  233. var express = expression.match(/<(.*?)>/g);
  234. var value = expression;
  235. if (express == null) {
  236. return { value : expression, overrides: []}; // if site property do not map any global property then return the value
  237. }
  238. var overrideHostToValue = {};
  239. express.forEach(function (_express) {
  240. //console.log("The value of template is: " + _express);
  241. var index = parseInt(_express.match(/\[([\d]*)(?=\])/)[1]);
  242. if (this.get('globals').someProperty('name', templateName[index])) {
  243. //console.log("The name of the variable is: " + this.get('content.serviceConfigProperties').findProperty('name', templateName[index]).name);
  244. var globalObj = this.get('globals').findProperty('name', templateName[index]);
  245. var globValue = globalObj.value;
  246. // Hack for templeton.zookeeper.hosts
  247. var preReplaceValue = null;
  248. 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
  249. preReplaceValue = value;
  250. value = this._replaceConfigValues(name, _express, value, globValue);
  251. }
  252. if(globalObj.overrides!=null){
  253. globalObj.overrides.forEach(function(override){
  254. var ov = override.value;
  255. var hostsArray = override.hosts;
  256. hostsArray.forEach(function(host){
  257. if(!(host in overrideHostToValue)){
  258. overrideHostToValue[host] = this._replaceConfigValues(name, _express, preReplaceValue, ov);
  259. }else{
  260. overrideHostToValue[host] = this._replaceConfigValues(name, _express, overrideHostToValue[host], ov);
  261. }
  262. }, this);
  263. }, this);
  264. }
  265. } else {
  266. /*
  267. console.log("ERROR: The variable name is: " + templateName[index]);
  268. console.log("ERROR: mapped config from configMapping file has no corresponding variable in " +
  269. "content.serviceConfigProperties. Two possible reasons for the error could be: 1) The service is not selected. " +
  270. "and/OR 2) The service_config metadata file has no corresponding global var for the site property variable");
  271. */
  272. value = null;
  273. }
  274. }, this);
  275. var valueWithOverrides = {
  276. value: value,
  277. overrides: []
  278. };
  279. var overrideValueToHostMap = {};
  280. if(!jQuery.isEmptyObject(overrideHostToValue)){
  281. for(var host in overrideHostToValue){
  282. var hostVal = overrideHostToValue[host];
  283. if(!(hostVal in overrideValueToHostMap)){
  284. overrideValueToHostMap[hostVal] = [];
  285. }
  286. overrideValueToHostMap[hostVal].push(host);
  287. }
  288. }
  289. for(var val in overrideValueToHostMap){
  290. valueWithOverrides.overrides.push({
  291. value: val,
  292. hosts: overrideValueToHostMap[val]
  293. });
  294. }
  295. return valueWithOverrides;
  296. },
  297. _replaceConfigValues: function (name, express, value, globValue) {
  298. if (name === "templeton.zookeeper.hosts" || name === 'hbase.zookeeper.quorum') {
  299. // globValue is an array of ZooKeeper Server hosts
  300. var zooKeeperPort = '2181';
  301. if (name === "templeton.zookeeper.hosts") {
  302. var zooKeeperServers = globValue.map(function (item) {
  303. return item + ':' + zooKeeperPort;
  304. }).join(',');
  305. value = value.replace(express, zooKeeperServers);
  306. } else {
  307. value = value.replace(express, globValue.join(','));
  308. }
  309. } else {
  310. value = value.replace(express, globValue);
  311. }
  312. return value;
  313. },
  314. /**
  315. * Load all info about cluster to <code>clusterInfo</code> variable
  316. */
  317. loadClusterInfo: function () {
  318. //Admin name
  319. var admin = this.rawContent.findProperty('config_name', 'Admin');
  320. admin.config_value = App.db.getLoginName();
  321. console.log("STEP8: the value of content cluster name: " + App.db.getLoginName());
  322. if (admin.config_value) {
  323. this.get('clusterInfo').pushObject(Ember.Object.create(admin));
  324. }
  325. // cluster name
  326. var cluster = this.rawContent.findProperty('config_name', 'cluster');
  327. cluster.config_value = this.get('content.cluster.name');
  328. console.log("STEP8: the value of content cluster name: " + this.get('content.cluster.name'));
  329. this.get('clusterInfo').pushObject(Ember.Object.create(cluster));
  330. //hosts
  331. var masterHosts = this.get('content.masterComponentHosts').mapProperty('hostName').uniq();
  332. var slaveHosts = this.get('content.slaveComponentHosts');
  333. var hostObj = [];
  334. slaveHosts.forEach(function (_hosts) {
  335. hostObj = hostObj.concat(_hosts.hosts);
  336. }, this);
  337. slaveHosts = hostObj.mapProperty('hostName').uniq();
  338. var componentHosts = masterHosts.concat(slaveHosts).uniq();
  339. var totalHosts = App.Host.find().mapProperty('hostName').concat(componentHosts).uniq();
  340. var newHostsCount = totalHosts.length - App.Host.find().content.length;
  341. this.set('totalHosts', totalHosts);
  342. var totalHostsObj = this.rawContent.findProperty('config_name', 'hosts');
  343. totalHostsObj.config_value = totalHosts.length + ' (' + newHostsCount + ' new)';
  344. this.get('clusterInfo').pushObject(Ember.Object.create(totalHostsObj));
  345. //repo
  346. var repoOption = this.get('content.installOptions.localRepo');
  347. var repoObj = this.rawContent.findProperty('config_name', 'Repo');
  348. if (repoOption) {
  349. repoObj.config_value = 'Yes';
  350. } else {
  351. repoObj.config_value = 'No';
  352. }
  353. this.get('clusterInfo').pushObject(Ember.Object.create(repoObj));
  354. },
  355. /**
  356. * Load all info about services to <code>services</code> variable
  357. */
  358. loadServices: function () {
  359. var selectedServices = this.get('selectedServices');
  360. this.set('services', selectedServices.mapProperty('serviceName'));
  361. selectedServices.forEach(function (_service) {
  362. console.log('INFO: step8: Name of the service from getService function: ' + _service.serviceName);
  363. var reviewService = this.rawContent.findProperty('config_name', 'services');
  364. var serviceObj = reviewService.config_value.findProperty('service_name', _service.serviceName);
  365. if (serviceObj) {
  366. switch (serviceObj.service_name) {
  367. case 'HDFS':
  368. this.loadHDFS(serviceObj);
  369. break;
  370. case 'HCFS':
  371. this.loadHCFS(serviceObj);
  372. break;
  373. case 'MAPREDUCE':
  374. this.loadMapReduce(serviceObj);
  375. break;
  376. case 'MAPREDUCE2':
  377. this.loadMapReduce2(serviceObj);
  378. break;
  379. case 'YARN':
  380. this.loadYARN(serviceObj);
  381. break;
  382. case 'HIVE':
  383. this.loadHive(serviceObj);
  384. break;
  385. case 'HBASE':
  386. this.loadHbase(serviceObj);
  387. break;
  388. case 'ZOOKEEPER':
  389. this.loadZk(serviceObj);
  390. break;
  391. case 'OOZIE':
  392. this.loadOozie(serviceObj);
  393. break;
  394. case 'NAGIOS':
  395. this.loadNagios(serviceObj);
  396. break;
  397. case 'GANGLIA':
  398. this.loadGanglia(serviceObj);
  399. break;
  400. case 'HUE':
  401. this.loadHue(serviceObj);
  402. break;
  403. /* case 'TEZ':
  404. break;
  405. case 'PIG':
  406. this.loadPig(serviceObj);
  407. break;
  408. case 'SQOOP':
  409. this.loadSqoop(serviceObj);
  410. break;
  411. */
  412. case 'HCATALOG':
  413. break;
  414. default:
  415. }
  416. }
  417. }, this);
  418. },
  419. /**
  420. * load all info about HDFS service
  421. * @param hdfsObj
  422. */
  423. loadHDFS: function (hdfsObj) {
  424. hdfsObj.get('service_components').forEach(function (_component) {
  425. switch (_component.get('display_name')) {
  426. case 'NameNode':
  427. this.loadNnValue(_component);
  428. break;
  429. case 'SecondaryNameNode':
  430. this.loadSnnValue(_component);
  431. break;
  432. case 'DataNodes':
  433. this.loadDnValue(_component);
  434. break;
  435. default:
  436. }
  437. }, this);
  438. //var
  439. this.get('services').pushObject(hdfsObj);
  440. },
  441. /**
  442. * load all info about HCFS service
  443. * @param hcfsObj
  444. */
  445. loadHCFS: function (hcfsObj) {
  446. hcfsObj.get('service_components').forEach(function (_component) {
  447. switch (_component.get('display_name')) {
  448. case 'HCFS Client':
  449. this.loadHCFSClientValue(_component);
  450. break;
  451. default:
  452. }
  453. }, this);
  454. this.get('services').pushObject(hcfsObj);
  455. },
  456. loadHCFSClientValue: function (hcfsComponent) {
  457. var hcfsClientHosts = this.get('content.slaveComponentHosts').findProperty('displayName', 'Client');
  458. var totalHCFSHosts = hcfsClientHosts.hosts.length;
  459. hcfsComponent.set('component_value', totalHCFSHosts + ' hosts');
  460. },
  461. loadNnValue: function (nnComponent) {
  462. var nnHostName = this.get('content.masterComponentHosts').findProperty('display_name', nnComponent.display_name);
  463. nnComponent.set('component_value', nnHostName.hostName);
  464. },
  465. loadSnnValue: function (snnComponent) {
  466. var snnHostName = this.get('content.masterComponentHosts').findProperty('display_name', 'SNameNode');
  467. snnComponent.set('component_value', snnHostName.hostName);
  468. },
  469. loadDnValue: function (dnComponent) {
  470. var dnHosts = this.get('content.slaveComponentHosts').findProperty('displayName', 'DataNode');
  471. var totalDnHosts = dnHosts.hosts.length;
  472. /* var totalGroups = this.get('slaveComponentConfig.components').findProperty('componentName', 'DATANODE').groups.length;
  473. var groupLabel;
  474. if (totalGroups == 1) {
  475. groupLabel = 'group';
  476. } else {
  477. groupLabel = 'groups';
  478. }
  479. */
  480. dnComponent.set('component_value', totalDnHosts + Em.I18n.t('installer.step8.hosts'));
  481. },
  482. /**
  483. * Load all info about mapReduce service
  484. * @param mrObj
  485. */
  486. loadMapReduce: function (mrObj) {
  487. mrObj.get('service_components').forEach(function (_component) {
  488. switch (_component.get('display_name')) {
  489. case 'JobTracker':
  490. this.loadJtValue(_component);
  491. break;
  492. case 'TaskTrackers':
  493. this.loadTtValue(_component);
  494. break;
  495. default:
  496. }
  497. }, this);
  498. this.get('services').pushObject(mrObj);
  499. },
  500. loadMapReduce2: function(mrObj){
  501. mrObj.get('service_components').forEach(function (_component) {
  502. switch (_component.get('display_name')) {
  503. case 'History Server':
  504. _component.set('component_value', this.get('content.masterComponentHosts').findProperty('component', 'HISTORYSERVER').hostName);
  505. break;
  506. }
  507. }, this);
  508. this.get('services').pushObject(mrObj);
  509. },
  510. loadYARN: function(mrObj){
  511. mrObj.get('service_components').forEach(function (_component) {
  512. switch (_component.get('display_name')) {
  513. case 'NodeManager':
  514. this.loadNMValue(_component);
  515. break;
  516. case 'ResourceManager':
  517. _component.set('component_value', this.get('content.masterComponentHosts').findProperty('component', 'RESOURCEMANAGER').hostName);
  518. break;
  519. case 'History Server':
  520. _component.set('component_value', this.get('content.masterComponentHosts').findProperty('component', 'HISTORYSERVER').hostName);
  521. break;
  522. }
  523. }, this);
  524. this.get('services').pushObject(mrObj);
  525. },
  526. loadNMValue: function (nmComponent) {
  527. var nmHosts = this.get('content.slaveComponentHosts').findProperty('componentName', 'NODEMANAGER');
  528. nmComponent.set('component_value', nmHosts.hosts.length + Em.I18n.t('installer.step8.hosts'));
  529. },
  530. loadJtValue: function (jtComponent) {
  531. var jtHostName = this.get('content.masterComponentHosts').findProperty('display_name', jtComponent.display_name);
  532. jtComponent.set('component_value', jtHostName.hostName);
  533. },
  534. loadTtValue: function (ttComponent) {
  535. var ttHosts = this.get('content.slaveComponentHosts').findProperty('displayName', 'TaskTracker');
  536. var totalTtHosts = ttHosts.hosts.length;
  537. ttComponent.set('component_value', totalTtHosts + Em.I18n.t('installer.step8.hosts'));
  538. },
  539. /**
  540. * Load all info about Hive service
  541. * @param hiveObj
  542. */
  543. loadHive: function (hiveObj) {
  544. hiveObj.get('service_components').forEach(function (_component) {
  545. switch (_component.get('display_name')) {
  546. case 'Hive Metastore':
  547. this.loadHiveMetaStoreValue(_component);
  548. break;
  549. case 'Database':
  550. this.loadHiveDbValue(_component);
  551. break;
  552. default:
  553. }
  554. }, this);
  555. this.get('services').pushObject(hiveObj);
  556. },
  557. loadHiveMetaStoreValue: function (metaStoreComponent) {
  558. var hiveHostName = this.get('content.masterComponentHosts').findProperty('display_name', 'HiveServer2');
  559. metaStoreComponent.set('component_value', hiveHostName.hostName);
  560. },
  561. loadHiveDbValue: function (dbComponent) {
  562. var hiveDb = App.db.getServiceConfigProperties().findProperty('name', 'hive_database');
  563. if (hiveDb.value === 'New MySQL Database') {
  564. dbComponent.set('component_value', 'MySQL (New Database)');
  565. } else if(hiveDb.value === 'Existing MySQL Database'){
  566. var db = App.db.getServiceConfigProperties().findProperty('name', 'hive_existing_mysql_database');
  567. dbComponent.set('component_value', db.value + ' (' + hiveDb.value + ')');
  568. } else { // existing oracle database
  569. var db = App.db.getServiceConfigProperties().findProperty('name', 'hive_existing_oracle_database');
  570. dbComponent.set('component_value', db.value + ' (' + hiveDb.value + ')');
  571. }
  572. },
  573. /**
  574. * Load all info about Hbase
  575. * @param hbaseObj
  576. */
  577. loadHbase: function (hbaseObj) {
  578. hbaseObj.service_components.forEach(function (_component) {
  579. switch (_component.display_name) {
  580. case 'Master':
  581. this.loadMasterValue(_component);
  582. break;
  583. case 'RegionServers':
  584. this.loadRegionServerValue(_component);
  585. break;
  586. default:
  587. }
  588. }, this);
  589. this.get('services').pushObject(hbaseObj);
  590. },
  591. loadMasterValue: function (hbaseMaster) {
  592. var hbaseHostName = this.get('content.masterComponentHosts').filterProperty('display_name', 'HBase Master');
  593. if (hbaseHostName.length == 1) {
  594. hbaseMaster.set('component_value', hbaseHostName[0].hostName);
  595. } else {
  596. hbaseMaster.set('component_value', hbaseHostName[0].hostName + Em.I18n.t('installer.step8.other').format(hbaseHostName.length - 1));
  597. }
  598. },
  599. loadRegionServerValue: function (rsComponent) {
  600. var rsHosts = this.get('content.slaveComponentHosts').findProperty('displayName', 'RegionServer');
  601. var totalRsHosts = rsHosts.hosts.length;
  602. /* var totalGroups = this.get('slaveComponentConfig.components').findProperty('componentName', 'HBASE_REGIONSERVER').groups.length;
  603. var groupLabel;
  604. if (totalGroups == 1) {
  605. groupLabel = 'group';
  606. } else {
  607. groupLabel = 'groups';
  608. } */
  609. rsComponent.set('component_value', totalRsHosts + Em.I18n.t('installer.step8.hosts'));
  610. },
  611. /**
  612. * Load all info about ZooKeeper service
  613. * @param zkObj
  614. */
  615. loadZk: function (zkObj) {
  616. zkObj.get('service_components').forEach(function (_component) {
  617. switch (_component.get('display_name')) {
  618. case 'Servers':
  619. this.loadZkServerValue(_component);
  620. break;
  621. default:
  622. }
  623. }, this);
  624. this.get('services').pushObject(zkObj);
  625. },
  626. loadZkServerValue: function (serverComponent) {
  627. var zkHostNames = this.get('content.masterComponentHosts').filterProperty('display_name', 'ZooKeeper').length;
  628. var hostSuffix;
  629. if (zkHostNames === 1) {
  630. hostSuffix = Em.I18n.t('installer.step8.host');
  631. } else {
  632. hostSuffix = Em.I18n.t('installer.step8.hosts');
  633. }
  634. serverComponent.set('component_value', zkHostNames + ' ' + hostSuffix);
  635. },
  636. /**
  637. * Load all info about Hue services
  638. * @param hueObj
  639. */
  640. loadHue: function (hueObj) {
  641. hueObj.get('service_components').forEach(function (_component) {
  642. switch (_component.get('display_name')) {
  643. case 'Server':
  644. this.loadHueServerValue(_component);
  645. break;
  646. default:
  647. }
  648. }, this);
  649. this.get('services').pushObject(hueObj);
  650. },
  651. loadHueServerValue: function (hueServer) {
  652. var hueServerName = this.get('content.masterComponentHosts').findProperty('display_name', 'Hue Server');
  653. hueServer.set('component_value', hueServerName.hostName);
  654. },
  655. /**
  656. * Load all info about Oozie services
  657. * @param oozieObj
  658. */
  659. loadOozie: function (oozieObj) {
  660. oozieObj.get('service_components').forEach(function (_component) {
  661. switch (_component.get('display_name')) {
  662. case 'Server':
  663. this.loadOozieServerValue(_component);
  664. break;
  665. case 'Database':
  666. // TODO: uncomment when ready to integrate with Oozie Database other than Derby
  667. this.loadOozieDbValue(_component);
  668. break;
  669. default:
  670. }
  671. }, this);
  672. this.get('services').pushObject(oozieObj);
  673. },
  674. loadOozieServerValue: function (oozieServer) {
  675. var oozieServerName = this.get('content.masterComponentHosts').findProperty('display_name', 'Oozie Server');
  676. oozieServer.set('component_value', oozieServerName.hostName);
  677. },
  678. loadOozieDbValue: function (dbComponent) {
  679. var oozieDb = App.db.getServiceConfigProperties().findProperty('name', 'oozie_database');
  680. if (oozieDb.value === 'New Derby Database'){
  681. var db = App.db.getServiceConfigProperties().findProperty('name', 'oozie_derby_database');
  682. dbComponent.set('component_value', db.value + ' (' + oozieDb.value + ')');
  683. }/* else if (oozieDb.value === 'New MySQL Database') {
  684. dbComponent.set('component_value', 'MySQL (New Database)');
  685. } */else if(oozieDb.value === 'Existing MySQL Database'){
  686. var db = App.db.getServiceConfigProperties().findProperty('name', 'oozie_existing_mysql_database');
  687. dbComponent.set('component_value', db.value + ' (' + oozieDb.value + ')');
  688. } else { // existing oracle database
  689. var db = App.db.getServiceConfigProperties().findProperty('name', 'oozie_existing_oracle_database');
  690. dbComponent.set('component_value', db.value + ' (' + oozieDb.value + ')');
  691. }
  692. },
  693. /**
  694. * Load all info about Nagios service
  695. * @param nagiosObj
  696. */
  697. loadNagios: function (nagiosObj) {
  698. nagiosObj.service_components.forEach(function (_component) {
  699. switch (_component.display_name) {
  700. case 'Server':
  701. this.loadNagiosServerValue(_component);
  702. break;
  703. case 'Administrator':
  704. this.loadNagiosAdminValue(_component);
  705. break;
  706. default:
  707. }
  708. }, this);
  709. this.get('services').pushObject(nagiosObj);
  710. },
  711. loadNagiosServerValue: function (nagiosServer) {
  712. var nagiosServerName = this.get('content.masterComponentHosts').findProperty('display_name', 'Nagios Server');
  713. nagiosServer.set('component_value', nagiosServerName.hostName);
  714. },
  715. loadNagiosAdminValue: function (nagiosAdmin) {
  716. var config = this.get('content.serviceConfigProperties');
  717. var adminLoginName = config.findProperty('name', 'nagios_web_login');
  718. var adminEmail = config.findProperty('name', 'nagios_contact');
  719. nagiosAdmin.set('component_value', adminLoginName.value + ' / (' + adminEmail.value + ')');
  720. },
  721. /**
  722. * Load all info about ganglia
  723. * @param gangliaObj
  724. */
  725. loadGanglia: function (gangliaObj) {
  726. gangliaObj.get('service_components').forEach(function (_component) {
  727. switch (_component.get('display_name')) {
  728. case 'Server':
  729. this.loadGangliaServerValue(_component);
  730. break;
  731. default:
  732. }
  733. }, this);
  734. this.get('services').pushObject(gangliaObj);
  735. },
  736. loadGangliaServerValue: function (gangliaServer) {
  737. var gangliaServerName = this.get('content.masterComponentHosts').findProperty('display_name', 'Ganglia Collector');
  738. gangliaServer.set('component_value', gangliaServerName.hostName);
  739. },
  740. loadSqoop: function (sqoopObj) {
  741. this.get('services').pushObject(sqoopObj);
  742. },
  743. loadPig: function (pigObj) {
  744. this.get('services').pushObject(pigObj);
  745. },
  746. /**
  747. * Onclick handler for <code>next</code> button
  748. */
  749. submit: function () {
  750. if (this.get('isSubmitDisabled')) {
  751. return;
  752. }
  753. if ((this.get('content.controllerName') == 'addHostController') && this.get('securityEnabled')) {
  754. var self = this;
  755. App.showConfirmationPopup(function() {
  756. self.submitProceed();
  757. }, Em.I18n.t('installer.step8.securityConfirmationPopupBody'));
  758. }
  759. else {
  760. this.submitProceed();
  761. }
  762. },
  763. submitProceed: function() {
  764. this.set('isSubmitDisabled', true);
  765. // checkpoint the cluster status on the server so that the user can resume from where they left off
  766. switch (this.get('content.controllerName')) {
  767. case 'installerController':
  768. App.clusterStatus.setClusterStatus({
  769. clusterName: this.get('clusterName'),
  770. clusterState: 'CLUSTER_DEPLOY_PREP_2',
  771. wizardControllerName: this.get('content.controllerName'),
  772. localdb: App.db.data
  773. });
  774. break;
  775. case 'addHostController':
  776. App.clusterStatus.setClusterStatus({
  777. clusterName: this.get('clusterName'),
  778. clusterState: 'ADD_HOSTS_DEPLOY_PREP_2',
  779. wizardControllerName: this.get('content.controllerName'),
  780. localdb: App.db.data
  781. });
  782. break;
  783. case 'addServiceController':
  784. App.clusterStatus.setClusterStatus({
  785. clusterName: this.get('clusterName'),
  786. clusterState: 'ADD_SERVICES_DEPLOY_PREP_2',
  787. wizardControllerName: this.get('content.controllerName'),
  788. localdb: App.db.data
  789. });
  790. break;
  791. default:
  792. break;
  793. }
  794. // delete any existing clusters to start from a clean slate
  795. // before creating a new cluster in install wizard
  796. // TODO: modify for multi-cluster support
  797. if (this.get('content.controllerName') == 'installerController' && (!App.testMode)) {
  798. var clusterNames = this.getExistingClusterNames();
  799. this.deleteClusters(clusterNames);
  800. }
  801. this.setLocalRepositories();
  802. this.createCluster();
  803. this.createSelectedServices();
  804. this.createConfigurations();
  805. this.createComponents();
  806. this.registerHostsToCluster();
  807. this.createAllHostComponents();
  808. this.createHostOverrideConfigurations();
  809. this.ajaxQueueFinished = function () {
  810. console.log('everything is loaded');
  811. App.router.send('next');
  812. };
  813. this.doNextAjaxCall();
  814. },
  815. /**
  816. * Used in progress bar
  817. */
  818. ajaxQueueLength: function () {
  819. return this.get('ajaxQueue').length;
  820. }.property('ajaxQueue.length'),
  821. /**
  822. * Used in progress bar
  823. */
  824. ajaxQueueLeft: 0,
  825. setAmbariUIDb: function () {
  826. var dbContent = this.get('content.slaveGroupProperties');
  827. var slaveComponentConfig = this.get("slaveComponentConfig");
  828. this.persistKeyValues(slaveComponentConfig.version, dbContent);
  829. this.persistKeyValues('current_version', slaveComponentConfig.version);
  830. },
  831. persistKeyValues: function (key, value) {
  832. var str = "{ '" + key + "' : '" + JSON.stringify(value) + "'}";
  833. var obj = eval("(" + str + ")");
  834. this.ajax({
  835. type: "POST",
  836. url: App.apiPrefix + '/persist',
  837. data: JSON.stringify(obj),
  838. beforeSend: function () {
  839. console.log('BeforeSend: persistKeyValues', obj);
  840. }
  841. });
  842. },
  843. clusterName: function () {
  844. return this.get('content.cluster.name');
  845. }.property('content.cluster.name'),
  846. clusterNames: [],
  847. // returns an array of existing cluster names.
  848. // returns an empty array if there are no existing clusters.
  849. getExistingClusterNames: function () {
  850. var url = App.apiPrefix + '/clusters';
  851. App.ajax.send({
  852. name: 'wizard.step8.existing_cluster_names',
  853. sender: this,
  854. success: 'getExistingClusterNamesSuccessCallBack',
  855. error: 'getExistingClusterNamesErrorCallback'
  856. });
  857. return this.get('clusterNames');
  858. },
  859. getExistingClusterNamesSuccessCallBack: function (data) {
  860. var clusterNames = data.items.mapProperty('Clusters.cluster_name');
  861. console.log("Got existing cluster names: " + clusterNames);
  862. this.set('clusterNames', clusterNames);
  863. },
  864. getExistingClusterNamesErrorCallback: function () {
  865. console.log("Failed to get existing cluster names");
  866. this.set('clusterNames', []);
  867. },
  868. deleteClusters: function (clusterNames) {
  869. clusterNames.forEach(function (clusterName) {
  870. App.ajax.send({
  871. name: 'wizard.step8.delete_cluster',
  872. sender: this,
  873. data: {
  874. name: clusterName
  875. },
  876. success: 'deleteClustersSuccessCallback',
  877. error: 'deleteClustersErrorCallback'
  878. });
  879. }, this);
  880. },
  881. deleteClustersSuccessCallback: function(data, opt, params) {
  882. console.log('DELETE cluster ' + params.name + ' succeeded');
  883. },
  884. deleteClustersErrorCallback: function(request, ajaxOptions, error, opt) {
  885. console.log('DELETE cluster failed');
  886. },
  887. /**
  888. * Updates local repositories for the Ambari server.
  889. */
  890. setLocalRepositories: function () {
  891. if (this.get('content.controllerName') !== 'installerController' || !App.supports.localRepositories) {
  892. return false;
  893. }
  894. var self = this;
  895. var apiUrl = App.get('stack2VersionURL');
  896. var stacks = this.get('content.stacks');
  897. stacks.forEach(function (stack) {
  898. stack.operatingSystems.forEach(function (os) {
  899. if (os.baseUrl !== os.originalBaseUrl) {
  900. console.log("Updating local repository URL from " + os.originalBaseUrl + " -> " + os.baseUrl + ". ", os);
  901. var url = App.apiPrefix + apiUrl + "/operatingSystems/" + os.osType + "/repositories/" + stack.name;
  902. self.ajax({
  903. type: 'PUT',
  904. url: url,
  905. data: JSON.stringify({
  906. "Repositories": {
  907. "base_url": os.baseUrl
  908. }
  909. }),
  910. beforeSend: function () {
  911. console.log("BeforeSend: setLocalRepositories PUT to ", url);
  912. }
  913. });
  914. }
  915. });
  916. });
  917. },
  918. /**
  919. * The following create* functions are called upon submitting Step 8.
  920. */
  921. createCluster: function () {
  922. if (this.get('content.controllerName') !== 'installerController') {
  923. return false;
  924. }
  925. var clusterName = this.get('clusterName');
  926. var url = App.apiPrefix + '/clusters/' + clusterName;
  927. var stackVersion = (this.get('content.installOptions.localRepo')) ? App.defaultLocalStackVersion : App.currentStackVersion;
  928. this.ajax({
  929. type: 'POST',
  930. url: url,
  931. data: JSON.stringify({ "Clusters": {"version": stackVersion }}),
  932. beforeSend: function () {
  933. console.log("BeforeSend: createCluster for " + clusterName);
  934. }
  935. });
  936. },
  937. createSelectedServices: function () {
  938. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/services';
  939. var data = this.createServiceData();
  940. var httpMethod = 'POST';
  941. if (!data.length) {
  942. return;
  943. }
  944. this.ajax({
  945. type: httpMethod,
  946. url: url,
  947. data: JSON.stringify(data),
  948. beforeSend: function () {
  949. console.log('BeforeSend: createSelectedServices ', data);
  950. }
  951. });
  952. },
  953. createServiceData: function () {
  954. var services = this.get('selectedServices').mapProperty('serviceName');
  955. var data = [];
  956. services.forEach(function (_service) {
  957. data.pushObject({"ServiceInfo": { "service_name": _service }});
  958. }, this);
  959. return data;
  960. },
  961. createComponents: function () {
  962. var serviceComponents = require('data/service_components');
  963. var services = this.get('selectedServices').mapProperty('serviceName');
  964. services.forEach(function (_service) {
  965. var components = serviceComponents.filterProperty('service_name', _service);
  966. var componentsData = components.map(function (_component) {
  967. return { "ServiceComponentInfo": { "component_name": _component.component_name } };
  968. });
  969. // Service must be specified in terms of a query for creating multiple components at the same time.
  970. // See AMBARI-1018.
  971. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/services?ServiceInfo/service_name=' + _service;
  972. var data = {
  973. "components": componentsData
  974. }
  975. this.ajax({
  976. type: 'POST',
  977. url: url,
  978. data: JSON.stringify(data),
  979. beforeSend: function () {
  980. console.log('BeforeSend: createComponents for ' + _service, componentsData);
  981. }
  982. });
  983. }, this);
  984. },
  985. registerHostsToCluster: function () {
  986. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/hosts';
  987. var data = this.createRegisterHostData();
  988. if (data.length == 0) {
  989. return;
  990. }
  991. this.ajax({
  992. type: 'POST',
  993. url: url,
  994. data: JSON.stringify(data),
  995. beforeSend: function () {
  996. console.log('BeforeSend: registerHostsToCluster', data);
  997. }
  998. });
  999. },
  1000. createRegisterHostData: function () {
  1001. var hosts = this.getRegisteredHosts().filterProperty('isInstalled', false);
  1002. if (!hosts.length) {
  1003. return [];
  1004. }
  1005. return hosts.map(function (host) {
  1006. return {"Hosts": { "host_name": host.hostName}};
  1007. });
  1008. },
  1009. // TODO: review the code for add hosts / add services scenarios...
  1010. createAllHostComponents: function () {
  1011. var masterHosts = this.get('content.masterComponentHosts');
  1012. var slaveHosts = this.get('content.slaveComponentHosts');
  1013. var clients = this.get('content.clients');
  1014. // note: masterHosts has 'component' vs slaveHosts has 'componentName'
  1015. var masterComponents = masterHosts.mapProperty('component').uniq();
  1016. masterComponents.forEach(function (component) {
  1017. var hostNames = masterHosts.filterProperty('component', component).filterProperty('isInstalled', false).mapProperty('hostName');
  1018. this.registerHostsToComponent(hostNames, component);
  1019. }, this);
  1020. slaveHosts.forEach(function (_slave) {
  1021. if (_slave.componentName !== 'CLIENT') {
  1022. var hostNames = _slave.hosts.filterProperty('isInstalled', false).mapProperty('hostName');
  1023. this.registerHostsToComponent(hostNames, _slave.componentName);
  1024. } else {
  1025. clients.forEach(function (_client) {
  1026. var hostNames = _slave.hosts.mapProperty('hostName');
  1027. switch (_client.component_name) {
  1028. case 'HDFS_CLIENT':
  1029. // install HDFS_CLIENT on HBASE_MASTER, HBASE_REGIONSERVER, WEBHCAT_SERVER, and HISTORYSERVER hosts
  1030. masterHosts.filterProperty('component', 'HBASE_MASTER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1031. hostNames.pushObject(_masterHost.hostName);
  1032. }, this);
  1033. masterHosts.filterProperty('component', 'HBASE_REGIONSERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1034. hostNames.pushObject(_masterHost.hostName);
  1035. }, this);
  1036. masterHosts.filterProperty('component', 'WEBHCAT_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1037. hostNames.pushObject(_masterHost.hostName);
  1038. }, this);
  1039. masterHosts.filterProperty('component', 'HISTORYSERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1040. hostNames.pushObject(_masterHost.hostName);
  1041. }, this);
  1042. break;
  1043. case 'MAPREDUCE_CLIENT':
  1044. // install MAPREDUCE_CLIENT on HIVE_SERVER, OOZIE_SERVER, NAGIOS_SERVER, and WEBHCAT_SERVER hosts
  1045. masterHosts.filterProperty('component', 'HIVE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1046. hostNames.pushObject(_masterHost.hostName);
  1047. }, this);
  1048. masterHosts.filterProperty('component', 'OOZIE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1049. hostNames.pushObject(_masterHost.hostName);
  1050. }, this);
  1051. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1052. hostNames.pushObject(_masterHost.hostName);
  1053. }, this);
  1054. masterHosts.filterProperty('component', 'WEBHCAT_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1055. hostNames.pushObject(_masterHost.hostName);
  1056. }, this);
  1057. break;
  1058. case 'OOZIE_CLIENT':
  1059. // install OOZIE_CLIENT on NAGIOS_SERVER host
  1060. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1061. hostNames.pushObject(_masterHost.hostName);
  1062. }, this);
  1063. break;
  1064. case 'ZOOKEEPER_CLIENT':
  1065. // install ZOOKEEPER_CLIENT on WEBHCAT_SERVER host
  1066. masterHosts.filterProperty('component', 'WEBHCAT_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1067. hostNames.pushObject(_masterHost.hostName);
  1068. }, this);
  1069. break;
  1070. case 'HIVE_CLIENT':
  1071. //install HIVE client on NAGIOS_SERVER host
  1072. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1073. hostNames.pushObject(_masterHost.hostName);
  1074. }, this);
  1075. masterHosts.filterProperty('component', 'HIVE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1076. hostNames.pushObject(_masterHost.hostName);
  1077. }, this);
  1078. break;
  1079. case 'HCAT':
  1080. // install HCAT (client) on NAGIOS_SERVER host
  1081. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1082. hostNames.pushObject(_masterHost.hostName);
  1083. }, this);
  1084. break;
  1085. case 'YARN_CLIENT':
  1086. // install YARN_CLIENT on NAGIOS_SERVER host
  1087. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1088. hostNames.pushObject(_masterHost.hostName);
  1089. }, this);
  1090. break;
  1091. }
  1092. hostNames = hostNames.uniq();
  1093. if (_client.isInstalled) {
  1094. //check whether clients are already installed on selected master hosts!!!
  1095. var installedHosts = _slave.hosts.filterProperty('isInstalled', true).mapProperty('hostName');
  1096. installedHosts.forEach(function (host) {
  1097. if (hostNames.contains(host)) {
  1098. hostNames.splice(hostNames.indexOf(host), 1);
  1099. }
  1100. }, this);
  1101. }
  1102. this.registerHostsToComponent(hostNames, _client.component_name);
  1103. }, this);
  1104. }
  1105. }, this);
  1106. // add Ganglia Monitor (Slave) to all hosts if Ganglia service is selected
  1107. var gangliaService = this.get('content.services').filterProperty('isSelected', true).findProperty('serviceName', 'GANGLIA');
  1108. if (gangliaService) {
  1109. var hosts = this.getRegisteredHosts();
  1110. if (gangliaService.get('isInstalled')) {
  1111. hosts = hosts.filterProperty('isInstalled', false);
  1112. }
  1113. if (hosts.length) {
  1114. this.registerHostsToComponent(hosts.mapProperty('hostName'), 'GANGLIA_MONITOR');
  1115. }
  1116. }
  1117. // add MySQL Server if Hive is selected
  1118. var hiveService = this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false).findProperty('serviceName', 'HIVE');
  1119. if (hiveService) {
  1120. var hiveDb = this.get('content.serviceConfigProperties').findProperty('name', 'hive_database');
  1121. if(hiveDb.value == "New MySQL Database") {
  1122. this.registerHostsToComponent(masterHosts.filterProperty('component', 'HIVE_SERVER').mapProperty('hostName'), 'MYSQL_SERVER');
  1123. }
  1124. }
  1125. },
  1126. registerHostsToComponent: function (hostNames, componentName) {
  1127. if (hostNames.length == 0) {
  1128. return;
  1129. }
  1130. console.log('registering ' + componentName + ' to ' + JSON.stringify(hostNames));
  1131. // currently we are specifying the predicate as a query string.
  1132. // this can hit a ~4000-character limit in Jetty server.
  1133. // chunk to multiple calls if needed
  1134. // var hostsPredicate = hostNames.map(function (hostName) {
  1135. // return 'Hosts/host_name=' + hostName;
  1136. // }).join('|');
  1137. var queryStrArr = [];
  1138. var queryStr = '';
  1139. hostNames.forEach(function (hostName) {
  1140. queryStr += 'Hosts/host_name=' + hostName + '|';
  1141. if (queryStr.length > 3500) {
  1142. queryStrArr.push(queryStr.slice(0, -1));
  1143. queryStr = '';
  1144. }
  1145. });
  1146. if (queryStr.length > 0) {
  1147. queryStrArr.push(queryStr.slice(0, -1));
  1148. }
  1149. queryStrArr.forEach(function (queryStr) {
  1150. // console.log('creating host components for ' + queryStr);
  1151. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/hosts?' + queryStr;
  1152. var data = {
  1153. "host_components": [
  1154. {
  1155. "HostRoles": {
  1156. "component_name": componentName
  1157. }
  1158. }
  1159. ]
  1160. };
  1161. this.ajax({
  1162. type: 'POST',
  1163. url: url,
  1164. data: JSON.stringify(data),
  1165. beforeSend: function () {
  1166. console.log('BeforeSend: registerHostsToComponent for ' + queryStr + ' and component ' + componentName);
  1167. }
  1168. });
  1169. }, this);
  1170. },
  1171. createConfigurations: function () {
  1172. var selectedServices = this.get('selectedServices');
  1173. if (this.get('content.controllerName') == 'installerController') {
  1174. this.applyConfigurationToSite(this.createGlobalSiteObj());
  1175. this.applyConfigurationToSite(this.createCoreSiteObj());
  1176. this.applyConfigurationToSite(this.createHdfsSiteObj());
  1177. }
  1178. if (selectedServices.someProperty('serviceName', 'MAPREDUCE')) {
  1179. this.applyConfigurationToSite(this.createMrSiteObj());
  1180. if (App.supports.capacitySchedulerUi) {
  1181. this.applyConfigurationToSite(this.createCapacityScheduler());
  1182. this.applyConfigurationToSite(this.createMapredQueueAcls());
  1183. }
  1184. }
  1185. if (selectedServices.someProperty('serviceName', 'MAPREDUCE2')) {
  1186. this.applyConfigurationToSite(this.createMrSiteObj());
  1187. this.applyConfigurationToSite(this.createMapredQueueAcls());
  1188. }
  1189. if (selectedServices.someProperty('serviceName', 'YARN')) {
  1190. this.applyConfigurationToSite(this.createYarnSiteObj());
  1191. this.applyConfigurationToSite(this.createCapacityScheduler());
  1192. }
  1193. if (selectedServices.someProperty('serviceName', 'HBASE')) {
  1194. this.applyConfigurationToSite(this.createHbaseSiteObj());
  1195. }
  1196. if (selectedServices.someProperty('serviceName', 'OOZIE')) {
  1197. this.applyConfigurationToSite(this.createOozieSiteObj('OOZIE'));
  1198. }
  1199. if (selectedServices.someProperty('serviceName', 'HIVE')) {
  1200. this.applyConfigurationToSite(this.createHiveSiteObj('HIVE'));
  1201. }
  1202. if (selectedServices.someProperty('serviceName', 'WEBHCAT')) {
  1203. this.applyConfigurationToSite(this.createWebHCatSiteObj('WEBHCAT'));
  1204. }
  1205. if (selectedServices.someProperty('serviceName', 'HUE')) {
  1206. this.applyConfigurationToSite(this.createHueSiteObj('HUE'));
  1207. }
  1208. },
  1209. applyConfigurationToSite: function (data) {
  1210. console.log("Inside applyConfigurationToSite");
  1211. var clusterUrl = App.apiPrefix + '/clusters/' + this.get('clusterName');
  1212. var clusterData = {
  1213. Clusters: {
  1214. desired_configs: data
  1215. }
  1216. };
  1217. console.debug("applyConfigurationToSite(Step8): Applying to URL", clusterUrl, " Data:", clusterData);
  1218. this.ajax({
  1219. type: 'PUT',
  1220. url: clusterUrl,
  1221. data: JSON.stringify(clusterData),
  1222. beforeSend: function () {
  1223. console.log("BeforeSend: Updating cluster config for " + clusterData.type);
  1224. }
  1225. });
  1226. },
  1227. createGlobalSiteObj: function () {
  1228. var globalSiteProperties = {};
  1229. var globalSiteObj = this.get('globals');
  1230. var isHCFSSelected = this.get('selectedServices').someProperty('serviceName', 'HCFS');
  1231. // screen out the HCFS-specific global config entries when they are not required
  1232. if (!isHCFSSelected) {
  1233. globalSiteObj = globalSiteObj.filter(function(_config) {
  1234. return _config.name.indexOf("fs_glusterfs") < 0;
  1235. });
  1236. }
  1237. globalSiteObj.forEach(function (_globalSiteObj) {
  1238. var heapsizeException = ['hadoop_heapsize','yarn_heapsize','nodemanager_heapsize','resourcemanager_heapsize'];
  1239. // do not pass any globals whose name ends with _host or _hosts
  1240. if (!/_hosts?$/.test(_globalSiteObj.name)) {
  1241. // append "m" to JVM memory options except for hadoop_heapsize
  1242. if (/_heapsize|_newsize|_maxnewsize$/.test(_globalSiteObj.name) && !heapsizeException.contains(_globalSiteObj.name)) {
  1243. globalSiteProperties[_globalSiteObj.name] = _globalSiteObj.value + "m";
  1244. } else {
  1245. globalSiteProperties[_globalSiteObj.name] = App.config.escapeXMLCharacters(_globalSiteObj.value);
  1246. }
  1247. console.log("STEP8: name of the global property is: " + _globalSiteObj.name);
  1248. console.log("STEP8: value of the global property is: " + _globalSiteObj.value);
  1249. }
  1250. if (_globalSiteObj.name == 'java64_home') {
  1251. globalSiteProperties['java64_home'] = this.get('content.installOptions.javaHome');
  1252. }
  1253. this._recordHostOverrideFromObj(_globalSiteObj, 'global', 'version1', this);
  1254. }, this);
  1255. // we don't expose gmond_user to the user; it needs to be the same as gmetad_user
  1256. globalSiteProperties['gmond_user'] = globalSiteProperties['gmetad_user'];
  1257. return {"type": "global", "tag": "version1", "properties": globalSiteProperties};
  1258. },
  1259. createCoreSiteObj: function () {
  1260. var coreSiteObj = this.get('configs').filterProperty('filename', 'core-site.xml');
  1261. var coreSiteProperties = {};
  1262. // hadoop.proxyuser.oozie.hosts needs to be skipped if oozie is not selected
  1263. var isOozieSelected = this.get('selectedServices').someProperty('serviceName', 'OOZIE');
  1264. var oozieUser = this.get('globals').someProperty('name', 'oozie_user') ? this.get('globals').findProperty('name', 'oozie_user').value : null;
  1265. var isHiveSelected = this.get('selectedServices').someProperty('serviceName', 'HIVE');
  1266. var hiveUser = this.get('globals').someProperty('name', 'hive_user') ? this.get('globals').findProperty('name', 'hive_user').value : null;
  1267. var isHcatSelected = this.get('selectedServices').someProperty('serviceName', 'WEBHCAT');
  1268. var hcatUser = this.get('globals').someProperty('name', 'hcat_user') ? this.get('globals').findProperty('name', 'hcat_user').value : null;
  1269. var isHCFSSelected = this.get('selectedServices').someProperty('serviceName', 'HCFS');
  1270. // screen out the HCFS-specific core-site.xml entries when they are not needed
  1271. if (!isHCFSSelected) {
  1272. coreSiteObj = coreSiteObj.filter(function(_config) {
  1273. return _config.name.indexOf("fs.glusterfs") < 0;
  1274. });
  1275. }
  1276. coreSiteObj.forEach(function (_coreSiteObj) {
  1277. if ((isOozieSelected || (_coreSiteObj.name != 'hadoop.proxyuser.' + oozieUser + '.hosts' && _coreSiteObj.name != 'hadoop.proxyuser.' + oozieUser + '.groups')) && (isHiveSelected || (_coreSiteObj.name != 'hadoop.proxyuser.' + hiveUser + '.hosts' && _coreSiteObj.name != 'hadoop.proxyuser.' + hiveUser + '.groups')) && (isHcatSelected || (_coreSiteObj.name != 'hadoop.proxyuser.' + hcatUser + '.hosts' && _coreSiteObj.name != 'hadoop.proxyuser.' + hcatUser + '.groups'))) {
  1278. coreSiteProperties[_coreSiteObj.name] = App.config.escapeXMLCharacters(_coreSiteObj.value);
  1279. this._recordHostOverrideFromObj(_coreSiteObj, 'core-site', 'version1', this);
  1280. }
  1281. if (isHCFSSelected && _coreSiteObj.name == "fs.default.name") {
  1282. coreSiteProperties[_coreSiteObj.name] = this.get('globals').someProperty('name', 'fs_glusterfs_default_name') ? App.config.escapeXMLCharacters(this.get('globals').findProperty('name', 'fs_glusterfs_default_name').value) : null;
  1283. }
  1284. console.log("STEP*: name of the property is: " + _coreSiteObj.name);
  1285. console.log("STEP8: value of the property is: " + _coreSiteObj.value);
  1286. }, this);
  1287. return {"type": "core-site", "tag": "version1", "properties": coreSiteProperties};
  1288. },
  1289. createHdfsSiteObj: function () {
  1290. var hdfsSiteObj = this.get('configs').filterProperty('filename', 'hdfs-site.xml');
  1291. var hdfsProperties = {};
  1292. hdfsSiteObj.forEach(function (_configProperty) {
  1293. hdfsProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1294. this._recordHostOverrideFromObj(_configProperty, 'hdfs-site', 'version1', this);
  1295. console.log("STEP*: name of the property is: " + _configProperty.name);
  1296. console.log("STEP8: value of the property is: " + _configProperty.value);
  1297. }, this);
  1298. return {"type": "hdfs-site", "tag": "version1", "properties": hdfsProperties };
  1299. },
  1300. createHueSiteObj: function () {
  1301. var hueSiteObj = this.get('configs').filterProperty('filename', 'hue-site.xml');
  1302. var hueProperties = {};
  1303. hueSiteObj.forEach(function (_configProperty) {
  1304. hueProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1305. this._recordHostOverrideFromObj(_configProperty, 'hue-site', 'version1', this);
  1306. console.log("STEP*: name of the property is: " + _configProperty.name);
  1307. console.log("STEP8: value of the property is: " + _configProperty.value);
  1308. }, this);
  1309. return {"type": "hue-site", "tag": "version1", "properties": hueProperties };
  1310. },
  1311. createMrSiteObj: function () {
  1312. var configs = this.get('configs').filterProperty('filename', 'mapred-site.xml');
  1313. var mrProperties = {};
  1314. configs.forEach(function (_configProperty) {
  1315. mrProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1316. this._recordHostOverrideFromObj(_configProperty, 'mapred-site', 'version1', this);
  1317. console.log("STEP*: name of the property is: " + _configProperty.name);
  1318. console.log("STEP8: value of the property is: " + _configProperty.value);
  1319. }, this);
  1320. return {type: 'mapred-site', tag: 'version1', properties: mrProperties};
  1321. },
  1322. createYarnSiteObj: function () {
  1323. var configs = this.get('configs').filterProperty('filename', 'yarn-site.xml');
  1324. var mrProperties = {};
  1325. configs.forEach(function (_configProperty) {
  1326. mrProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1327. this._recordHostOverrideFromObj(_configProperty, 'yarn-site', 'version1', this);
  1328. console.log("STEP*: name of the property is: " + _configProperty.name);
  1329. console.log("STEP8: value of the property is: " + _configProperty.value);
  1330. }, this);
  1331. return {type: 'yarn-site', tag: 'version1', properties: mrProperties};
  1332. },
  1333. createCapacityScheduler: function () {
  1334. var configs = this.get('configs').filterProperty('filename', 'capacity-scheduler.xml');
  1335. var csProperties = {};
  1336. configs.forEach(function (_configProperty) {
  1337. csProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1338. this._recordHostOverrideFromObj(_configProperty, 'capacity-scheduler', 'version1', this);
  1339. console.log("STEP*: name of the property is: " + _configProperty.name);
  1340. console.log("STEP8: value of the property is: " + _configProperty.value);
  1341. }, this);
  1342. return {type: 'capacity-scheduler', tag: 'version1', properties: csProperties};
  1343. },
  1344. createMapredQueueAcls: function () {
  1345. var configs = this.get('configs').filterProperty('filename', 'mapred-queue-acls.xml');
  1346. var mqProperties = {};
  1347. configs.forEach(function (_configProperty) {
  1348. mqProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1349. this._recordHostOverrideFromObj(_configProperty, 'mapred-queue-acls', 'version1', this);
  1350. console.log("STEP*: name of the property is: " + _configProperty.name);
  1351. console.log("STEP8: value of the property is: " + _configProperty.value);
  1352. }, this);
  1353. return {type: 'mapred-queue-acls', tag: 'version1', properties: mqProperties};
  1354. },
  1355. createHbaseSiteObj: function () {
  1356. var configs = this.get('configs').filterProperty('filename', 'hbase-site.xml');
  1357. var hbaseProperties = {};
  1358. configs.forEach(function (_configProperty) {
  1359. hbaseProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1360. this._recordHostOverrideFromObj(_configProperty, 'hbase-site', 'version1', this);
  1361. }, this);
  1362. return {type: 'hbase-site', tag: 'version1', properties: hbaseProperties};
  1363. },
  1364. createOozieSiteObj: function (serviceName) {
  1365. var configs = this.get('configs').filterProperty('filename', 'oozie-site.xml');
  1366. var oozieProperties = {};
  1367. configs.forEach(function (_configProperty) {
  1368. oozieProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1369. this._recordHostOverrideFromObj(_configProperty, 'oozie-site', 'version1', this);
  1370. }, this);
  1371. var globals = this.get('content.serviceConfigProperties').filterProperty('id', 'puppet var');
  1372. if (globals.someProperty('name', 'oozie_database')) {
  1373. var oozieDb = globals.findProperty('name', 'oozie_database');
  1374. var oozieHost = globals.findProperty('name', 'oozie_hostname').value;
  1375. var oozieDbName = globals.findProperty('name', 'oozie_database_name').value;
  1376. if (oozieDb.value === 'New Derby Database') {
  1377. // oozieProperties["oozie.service.JPAService.jdbc.url"] = "jdbc:derby:${oozie.data.dir}/${oozie.db.schema.name}-db;create=true";
  1378. oozieProperties["oozie.service.JPAService.jdbc.driver"] = "org.apache.derby.jdbc.EmbeddedDriver";
  1379. } else if (oozieDb.value === 'Existing MySQL Database') {
  1380. // oozieProperties["oozie.service.JPAService.jdbc.url"] = "jdbc:mysql://" + oozieHost + "/" + oozieDbName;
  1381. oozieProperties["oozie.service.JPAService.jdbc.driver"] = "com.mysql.jdbc.Driver";
  1382. } else { //existing oracle database
  1383. // oozieProperties["oozie.service.JPAService.jdbc.url"] = "jdbc:oracle:thin:@//" + oozieHost + ":1521/" + oozieDbName;
  1384. oozieProperties["oozie.service.JPAService.jdbc.driver"] = "oracle.jdbc.driver.OracleDriver";
  1385. }
  1386. //set oozie username and password
  1387. oozieProperties["oozie.service.JPAService.jdbc.username"] = globals.findProperty('name', 'oozie_metastore_user_name').value;
  1388. oozieProperties["oozie.service.JPAService.jdbc.password"] = globals.findProperty('name', 'oozie_metastore_user_passwd').value;
  1389. }
  1390. return {type: 'oozie-site', tag: 'version1', properties: oozieProperties};
  1391. },
  1392. createHiveSiteObj: function (serviceName) {
  1393. var configs = this.get('configs').filterProperty('filename', 'hive-site.xml');
  1394. var hiveProperties = {};
  1395. configs.forEach(function (_configProperty) {
  1396. hiveProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1397. this._recordHostOverrideFromObj(_configProperty, 'hive-site', 'version1', this);
  1398. }, this);
  1399. var globals = this.get('content.serviceConfigProperties').filterProperty('id', 'puppet var');
  1400. if (globals.someProperty('name', 'hive_database')) {
  1401. var hiveDb = globals.findProperty('name', 'hive_database');
  1402. var hiveHost = globals.findProperty('name', 'hive_hostname').value;
  1403. var hiveDbName = globals.findProperty('name', 'hive_database_name').value;
  1404. if (hiveDb.value === 'New MySQL Database') {
  1405. // hiveProperties["javax.jdo.option.ConnectionURL"] = "jdbc:mysql://"+ hiveHost + "/" + hiveDbName + "?createDatabaseIfNotExist=true";
  1406. hiveProperties["javax.jdo.option.ConnectionDriverName"] = "com.mysql.jdbc.Driver";
  1407. } else if (hiveDb.value === 'Existing MySQL Database'){
  1408. // hiveProperties["javax.jdo.option.ConnectionURL"] = "jdbc:mysql://"+ hiveHost + "/" + hiveDbName + "?createDatabaseIfNotExist=true";
  1409. hiveProperties["javax.jdo.option.ConnectionDriverName"] = "com.mysql.jdbc.Driver";
  1410. } else { //existing oracle database
  1411. // hiveProperties["javax.jdo.option.ConnectionURL"] = "jdbc:oracle:thin:@//"+ hiveHost + ":1521/" + hiveDbName;
  1412. hiveProperties["javax.jdo.option.ConnectionDriverName"] = "oracle.jdbc.driver.OracleDriver";
  1413. }
  1414. }
  1415. return {type: 'hive-site', tag: 'version1', properties: hiveProperties};
  1416. },
  1417. createWebHCatSiteObj: function (serviceName) {
  1418. var configs = this.get('configs').filterProperty('filename', 'webhcat-site.xml');
  1419. var webHCatProperties = {};
  1420. configs.forEach(function (_configProperty) {
  1421. webHCatProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1422. this._recordHostOverrideFromObj(_configProperty, 'webhcat-site', 'version1', this);
  1423. }, this);
  1424. return {type: 'webhcat-site', tag: 'version1', properties: webHCatProperties};
  1425. },
  1426. ajaxQueueFinished: function () {
  1427. //do something
  1428. },
  1429. doNextAjaxCall: function () {
  1430. if (this.get('ajaxBusy')) {
  1431. return;
  1432. }
  1433. var queue = this.get('ajaxQueue');
  1434. if (!queue.length) {
  1435. this.ajaxQueueFinished();
  1436. return;
  1437. }
  1438. var first = queue[0];
  1439. this.set('ajaxQueue', queue.slice(1));
  1440. this.set('ajaxQueueLeft', this.get('ajaxQueue').length);
  1441. this.set('ajaxBusy', true);
  1442. console.log('AJAX send ' + first.url);
  1443. $.ajax(first);
  1444. },
  1445. /**
  1446. * Records all the host overrides per site/tag
  1447. */
  1448. _recordHostOverrideFromObj: function(serviceConfigObj, siteName, tagName, self){
  1449. var overrides = serviceConfigObj.overrides;
  1450. if(overrides && overrides.length>0){
  1451. overrides.forEach(function(override){
  1452. override.hosts.forEach(function(host){
  1453. if(!(host in self.savedHostToOverrideSiteToTagMap)){
  1454. self.savedHostToOverrideSiteToTagMap[host] = {};
  1455. }
  1456. if(!(siteName in self.savedHostToOverrideSiteToTagMap[host])){
  1457. self.savedHostToOverrideSiteToTagMap[host][siteName] = {};
  1458. self.savedHostToOverrideSiteToTagMap[host][siteName].map = {};
  1459. }
  1460. var finalTag = tagName + '_' + host;
  1461. console.log("recordHostOverride(): Saving host override for host="+host+", site="+siteName+", tag="+finalTag+", (key,value)=("+serviceConfigObj.name+","+override.value+")");
  1462. self.savedHostToOverrideSiteToTagMap[host][siteName].tagName = finalTag;
  1463. self.savedHostToOverrideSiteToTagMap[host][siteName].map[serviceConfigObj.name] = override.value;
  1464. });
  1465. });
  1466. }
  1467. },
  1468. /**
  1469. * Creates host level overrides for service configuration.
  1470. *
  1471. */
  1472. createHostOverrideConfigurations: function () {
  1473. var singlePUTHostData = [];
  1474. var savedHostSiteArray = [];
  1475. for ( var host in this.savedHostToOverrideSiteToTagMap) {
  1476. for ( var siteName in this.savedHostToOverrideSiteToTagMap[host]) {
  1477. var tagName = this.savedHostToOverrideSiteToTagMap[host][siteName].tagName;
  1478. var map = this.savedHostToOverrideSiteToTagMap[host][siteName].map;
  1479. savedHostSiteArray.push(host + "///" + siteName);
  1480. singlePUTHostData.push({
  1481. RequestInfo: {
  1482. query: 'Hosts/host_name='+host
  1483. },
  1484. Body: {
  1485. Hosts: {
  1486. desired_config: {
  1487. type: siteName,
  1488. tag: tagName,
  1489. properties: map
  1490. }
  1491. }
  1492. }
  1493. });
  1494. }
  1495. }
  1496. console.log("createHostOverrideConfigSites(): PUTting host-overrides. Data=", singlePUTHostData);
  1497. if(singlePUTHostData.length>0){
  1498. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/hosts';
  1499. this.ajax({
  1500. type: 'PUT',
  1501. url: url,
  1502. data: JSON.stringify(singlePUTHostData),
  1503. dataType: 'text',
  1504. beforeSend: function () {
  1505. console.log("createHostOverrideConfigSites() PUT override=", singlePUTHostData);
  1506. }
  1507. });
  1508. }
  1509. },
  1510. /**
  1511. * We need to do a lot of ajax calls async in special order. To do this,
  1512. * generate array of ajax objects and then send requests step by step. All
  1513. * ajax objects are stored in <code>ajaxQueue</code>
  1514. *
  1515. * @param params
  1516. */
  1517. ajax: function (params) {
  1518. if (App.testMode) return;
  1519. var self = this;
  1520. params = jQuery.extend({
  1521. async: true,
  1522. dataType: 'text',
  1523. statusCode: require('data/statusCodes'),
  1524. timeout: App.timeout,
  1525. error: function (request, ajaxOptions, error) {
  1526. console.log('Step8: In Error ');
  1527. // console.log('Step8: Error message is: ' + request.responseText);
  1528. },
  1529. success: function (data) {
  1530. var jsonData = jQuery.parseJSON(data);
  1531. console.log("TRACE: STep8 -> In success function");
  1532. console.log("TRACE: STep8 -> value of the url is: " + params.url);
  1533. console.log("TRACE: STep8 -> value of the received data is: " + jsonData);
  1534. }
  1535. }, params);
  1536. var success = params.success;
  1537. var error = params.error;
  1538. params.success = function () {
  1539. if (success) {
  1540. success();
  1541. }
  1542. self.set('ajaxBusy', false);
  1543. self.doNextAjaxCall();
  1544. }
  1545. params.error = function (xhr, status, error) {
  1546. var responseText = JSON.parse(xhr.responseText);
  1547. var controller = App.router.get(App.clusterStatus.wizardControllerName);
  1548. controller.registerErrPopup(Em.I18n.t('common.error'), responseText.message);
  1549. self.set('hasErrorOccurred', true);
  1550. // an error will break the ajax call chain and allow submission again
  1551. self.set('isSubmitDisabled', false);
  1552. self.get('ajaxQueue').clear();
  1553. self.set('ajaxBusy', false);
  1554. }
  1555. this.get('ajaxQueue').pushObject(params);
  1556. }
  1557. });