step8_controller.js 61 KB

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