step8_controller.js 67 KB

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