step8_controller.js 67 KB

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