step8_controller.js 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569
  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. // returns an array of existing cluster names.
  805. // returns an empty array if there are no existing clusters.
  806. getExistingClusterNames: function () {
  807. var url = App.apiPrefix + '/clusters';
  808. var clusterNames = [];
  809. $.ajax({
  810. type: 'GET',
  811. url: url,
  812. async: false,
  813. success: function (data) {
  814. var jsonData = jQuery.parseJSON(data);
  815. clusterNames = jsonData.items.mapProperty('Clusters.cluster_name');
  816. console.log("Got existing cluster names: " + clusterNames);
  817. },
  818. error: function () {
  819. console.log("Failed to get existing cluster names");
  820. }
  821. });
  822. return clusterNames;
  823. },
  824. deleteClusters: function (clusterNames) {
  825. clusterNames.forEach(function (clusterName) {
  826. var url = App.apiPrefix + '/clusters/' + clusterName;
  827. $.ajax({
  828. type: 'DELETE',
  829. url: url,
  830. async: false,
  831. success: function () {
  832. console.log('DELETE cluster ' + clusterName + ' succeeded');
  833. },
  834. error: function () {
  835. console.log('DELETE cluster ' + clusterName + ' failed');
  836. }
  837. });
  838. });
  839. },
  840. /**
  841. * The following create* functions are called upon submitting Step 8.
  842. */
  843. createCluster: function () {
  844. if (this.get('content.controllerName') !== 'installerController') {
  845. return false;
  846. }
  847. var clusterName = this.get('clusterName');
  848. var url = App.apiPrefix + '/clusters/' + clusterName;
  849. var stackVersion = (this.get('content.installOptions.localRepo')) ? App.defaultLocalStackVersion : App.defaultStackVersion;
  850. this.ajax({
  851. type: 'POST',
  852. url: url,
  853. data: JSON.stringify({ "Clusters": {"version": stackVersion }}),
  854. beforeSend: function () {
  855. console.log("BeforeSend: createCluster for " + clusterName);
  856. }
  857. });
  858. },
  859. createSelectedServices: function () {
  860. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/services';
  861. var data = this.createServiceData();
  862. var httpMethod = 'POST';
  863. if (!data.length) {
  864. return;
  865. }
  866. this.ajax({
  867. type: httpMethod,
  868. url: url,
  869. data: JSON.stringify(data),
  870. beforeSend: function () {
  871. console.log('BeforeSend: createSelectedServices ', data);
  872. }
  873. });
  874. },
  875. createServiceData: function () {
  876. var services = this.get('selectedServices').mapProperty('serviceName');
  877. var data = [];
  878. services.forEach(function (_service) {
  879. data.pushObject({"ServiceInfo": { "service_name": _service }});
  880. }, this);
  881. return data;
  882. },
  883. createComponents: function () {
  884. var serviceComponents = require('data/service_components');
  885. var services = this.get('selectedServices').mapProperty('serviceName');
  886. services.forEach(function (_service) {
  887. var components = serviceComponents.filterProperty('service_name', _service);
  888. var componentsData = components.map(function (_component) {
  889. return { "ServiceComponentInfo": { "component_name": _component.component_name } };
  890. });
  891. // Service must be specified in terms of a query for creating multiple components at the same time.
  892. // See AMBARI-1018.
  893. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/services?ServiceInfo/service_name=' + _service;
  894. var data = {
  895. "components": componentsData
  896. }
  897. this.ajax({
  898. type: 'POST',
  899. url: url,
  900. data: JSON.stringify(data),
  901. beforeSend: function () {
  902. console.log('BeforeSend: createComponents for ' + _service, componentsData);
  903. }
  904. });
  905. }, this);
  906. },
  907. registerHostsToCluster: function () {
  908. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/hosts';
  909. var data = this.createRegisterHostData();
  910. if (data.length == 0) {
  911. return;
  912. }
  913. this.ajax({
  914. type: 'POST',
  915. url: url,
  916. data: JSON.stringify(data),
  917. beforeSend: function () {
  918. console.log('BeforeSend: registerHostsToCluster', data);
  919. }
  920. });
  921. },
  922. createRegisterHostData: function () {
  923. var hosts = this.getRegisteredHosts().filterProperty('isInstalled', false);
  924. if (!hosts.length) {
  925. return [];
  926. }
  927. return hosts.map(function (host) {
  928. return {"Hosts": { "host_name": host.hostName}};
  929. });
  930. },
  931. // TODO: review the code for add hosts / add services scenarios...
  932. createAllHostComponents: function () {
  933. var masterHosts = this.get('content.masterComponentHosts');
  934. var slaveHosts = this.get('content.slaveComponentHosts');
  935. var clients = this.get('content.clients');
  936. // note: masterHosts has 'component' vs slaveHosts has 'componentName'
  937. var masterComponents = masterHosts.mapProperty('component').uniq();
  938. masterComponents.forEach(function (component) {
  939. var hostNames = masterHosts.filterProperty('component', component).filterProperty('isInstalled', false).mapProperty('hostName');
  940. this.registerHostsToComponent(hostNames, component);
  941. }, this);
  942. slaveHosts.forEach(function (_slave) {
  943. if (_slave.componentName !== 'CLIENT') {
  944. var hostNames = _slave.hosts.filterProperty('isInstalled', false).mapProperty('hostName');
  945. this.registerHostsToComponent(hostNames, _slave.componentName);
  946. } else {
  947. clients.forEach(function (_client) {
  948. var hostNames = _slave.hosts.mapProperty('hostName');
  949. switch (_client.component_name) {
  950. case 'HDFS_CLIENT':
  951. // install HDFS_CLIENT on HBASE_MASTER, HBASE_REGIONSERVER, and WEBHCAT_SERVER hosts
  952. masterHosts.filterProperty('component', 'HBASE_MASTER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  953. hostNames.pushObject(_masterHost.hostName);
  954. }, this);
  955. masterHosts.filterProperty('component', 'HBASE_REGIONSERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  956. hostNames.pushObject(_masterHost.hostName);
  957. }, this);
  958. masterHosts.filterProperty('component', 'WEBHCAT_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  959. hostNames.pushObject(_masterHost.hostName);
  960. }, this);
  961. break;
  962. case 'MAPREDUCE_CLIENT':
  963. // install MAPREDUCE_CLIENT on HIVE_SERVER, OOZIE_SERVER, NAGIOS_SERVER, and WEBHCAT_SERVER hosts
  964. masterHosts.filterProperty('component', 'HIVE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  965. hostNames.pushObject(_masterHost.hostName);
  966. }, this);
  967. masterHosts.filterProperty('component', 'OOZIE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  968. hostNames.pushObject(_masterHost.hostName);
  969. }, this);
  970. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  971. hostNames.pushObject(_masterHost.hostName);
  972. }, this);
  973. masterHosts.filterProperty('component', 'WEBHCAT_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  974. hostNames.pushObject(_masterHost.hostName);
  975. }, this);
  976. break;
  977. case 'OOZIE_CLIENT':
  978. // install OOZIE_CLIENT on NAGIOS_SERVER host
  979. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  980. hostNames.pushObject(_masterHost.hostName);
  981. }, this);
  982. break;
  983. case 'ZOOKEEPER_CLIENT':
  984. // install ZOOKEEPER_CLIENT on WEBHCAT_SERVER host
  985. masterHosts.filterProperty('component', 'WEBHCAT_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  986. hostNames.pushObject(_masterHost.hostName);
  987. }, this);
  988. break;
  989. case 'HIVE_CLIENT':
  990. //install HIVE client on NAGIOS_SERVER host
  991. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  992. hostNames.pushObject(_masterHost.hostName);
  993. }, this);
  994. masterHosts.filterProperty('component', 'HIVE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  995. hostNames.pushObject(_masterHost.hostName);
  996. }, this);
  997. break;
  998. case 'HCAT':
  999. // install HCAT (client) on NAGIOS_SERVER host
  1000. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1001. hostNames.pushObject(_masterHost.hostName);
  1002. }, this);
  1003. break;
  1004. }
  1005. hostNames = hostNames.uniq();
  1006. if (_client.isInstalled) {
  1007. //check whether clients are already installed on selected master hosts!!!
  1008. var installedHosts = _slave.hosts.filterProperty('isInstalled', true).mapProperty('hostName');
  1009. installedHosts.forEach(function (host) {
  1010. if (hostNames.contains(host)) {
  1011. hostNames.splice(hostNames.indexOf(host), 1);
  1012. }
  1013. }, this);
  1014. }
  1015. this.registerHostsToComponent(hostNames, _client.component_name);
  1016. }, this);
  1017. }
  1018. }, this);
  1019. // add Ganglia Monitor (Slave) to all hosts if Ganglia service is selected
  1020. var gangliaService = this.get('content.services').filterProperty('isSelected', true).findProperty('serviceName', 'GANGLIA');
  1021. if (gangliaService) {
  1022. var hosts = this.getRegisteredHosts();
  1023. if (gangliaService.get('isInstalled')) {
  1024. hosts = hosts.filterProperty('isInstalled', false);
  1025. }
  1026. if (hosts.length) {
  1027. this.registerHostsToComponent(hosts.mapProperty('hostName'), 'GANGLIA_MONITOR');
  1028. }
  1029. }
  1030. // add MySQL Server if Hive is selected
  1031. var hiveService = this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false).findProperty('serviceName', 'HIVE');
  1032. if (hiveService) {
  1033. this.registerHostsToComponent(masterHosts.filterProperty('component', 'HIVE_SERVER').mapProperty('hostName'), 'MYSQL_SERVER');
  1034. }
  1035. },
  1036. registerHostsToComponent: function (hostNames, componentName) {
  1037. if (hostNames.length == 0) {
  1038. return;
  1039. }
  1040. console.log('registering ' + componentName + ' to ' + JSON.stringify(hostNames));
  1041. // currently we are specifying the predicate as a query string.
  1042. // this can hit a ~4000-character limit in Jetty server.
  1043. // chunk to multiple calls if needed
  1044. // var hostsPredicate = hostNames.map(function (hostName) {
  1045. // return 'Hosts/host_name=' + hostName;
  1046. // }).join('|');
  1047. var queryStrArr = [];
  1048. var queryStr = '';
  1049. hostNames.forEach(function (hostName) {
  1050. queryStr += 'Hosts/host_name=' + hostName + '|';
  1051. if (queryStr.length > 3500) {
  1052. queryStrArr.push(queryStr.slice(0, -1));
  1053. queryStr = '';
  1054. }
  1055. });
  1056. if (queryStr.length > 0) {
  1057. queryStrArr.push(queryStr.slice(0, -1));
  1058. }
  1059. queryStrArr.forEach(function (queryStr) {
  1060. // console.log('creating host components for ' + queryStr);
  1061. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/hosts?' + queryStr;
  1062. var data = {
  1063. "host_components": [
  1064. {
  1065. "HostRoles": {
  1066. "component_name": componentName
  1067. }
  1068. }
  1069. ]
  1070. };
  1071. this.ajax({
  1072. type: 'POST',
  1073. url: url,
  1074. data: JSON.stringify(data),
  1075. beforeSend: function () {
  1076. console.log('BeforeSend: registerHostsToComponent for ' + queryStr + ' and component ' + componentName);
  1077. }
  1078. });
  1079. }, this);
  1080. },
  1081. createConfigurations: function () {
  1082. var selectedServices = this.get('selectedServices');
  1083. if (this.get('content.controllerName') == 'installerController') {
  1084. this.applyConfigurationToSite(this.createGlobalSiteObj());
  1085. this.applyConfigurationToSite(this.createCoreSiteObj());
  1086. this.applyConfigurationToSite(this.createHdfsSiteObj());
  1087. }
  1088. if (selectedServices.someProperty('serviceName', 'MAPREDUCE')) {
  1089. this.applyConfigurationToSite(this.createMrSiteObj());
  1090. this.applyConfigurationToSite(this.createCapacityScheduler());
  1091. this.applyConfigurationToSite(this.createMapredQueueAcls());
  1092. }
  1093. if (selectedServices.someProperty('serviceName', 'HBASE')) {
  1094. this.applyConfigurationToSite(this.createHbaseSiteObj());
  1095. }
  1096. if (selectedServices.someProperty('serviceName', 'OOZIE')) {
  1097. this.applyConfigurationToSite(this.createOozieSiteObj('OOZIE'));
  1098. }
  1099. if (selectedServices.someProperty('serviceName', 'HIVE')) {
  1100. this.applyConfigurationToSite(this.createHiveSiteObj('HIVE'));
  1101. }
  1102. if (selectedServices.someProperty('serviceName', 'WEBHCAT')) {
  1103. this.applyConfigurationToSite(this.createWebHCatSiteObj('WEBHCAT'));
  1104. }
  1105. if (selectedServices.someProperty('serviceName', 'HUE')) {
  1106. this.applyConfigurationToSite(this.createHueSiteObj('HUE'));
  1107. }
  1108. },
  1109. applyConfigurationToSite: function (data) {
  1110. console.log("Inside applyConfigurationToSite");
  1111. var clusterUrl = App.apiPrefix + '/clusters/' + this.get('clusterName');
  1112. var clusterData = {
  1113. Clusters: {
  1114. desired_configs: data
  1115. }
  1116. };
  1117. console.debug("applyConfigurationToSite(Step8): Applying to URL", clusterUrl, " Data:", clusterData);
  1118. this.ajax({
  1119. type: 'PUT',
  1120. url: clusterUrl,
  1121. data: JSON.stringify(clusterData),
  1122. beforeSend: function () {
  1123. console.log("BeforeSend: Updating cluster config for " + clusterData.type);
  1124. }
  1125. });
  1126. },
  1127. createGlobalSiteObj: function () {
  1128. var globalSiteProperties = {};
  1129. //this.get('globals').filterProperty('domain', 'global').forEach(function (_globalSiteObj) {
  1130. this.get('globals').forEach(function (_globalSiteObj) {
  1131. // do not pass any globals whose name ends with _host or _hosts
  1132. if (!/_hosts?$/.test(_globalSiteObj.name)) {
  1133. // append "m" to JVM memory options except for hadoop_heapsize
  1134. if (/_heapsize|_newsize|_maxnewsize$/.test(_globalSiteObj.name) && _globalSiteObj.name !== 'hadoop_heapsize') {
  1135. globalSiteProperties[_globalSiteObj.name] = _globalSiteObj.value + "m";
  1136. } else {
  1137. globalSiteProperties[_globalSiteObj.name] = _globalSiteObj.value;
  1138. }
  1139. console.log("STEP8: name of the global property is: " + _globalSiteObj.name);
  1140. console.log("STEP8: value of the global property is: " + _globalSiteObj.value);
  1141. }
  1142. if (_globalSiteObj.name == 'java64_home') {
  1143. globalSiteProperties['java64_home'] = this.get('content.installOptions.javaHome');
  1144. }
  1145. this._recordHostOverrideFromObj(_globalSiteObj, 'global', 'version1', this);
  1146. }, this);
  1147. return {"type": "global", "tag": "version1", "properties": globalSiteProperties};
  1148. },
  1149. createCoreSiteObj: function () {
  1150. var coreSiteObj = this.get('configs').filterProperty('filename', 'core-site.xml');
  1151. var coreSiteProperties = {};
  1152. // hadoop.proxyuser.oozie.hosts needs to be skipped if oozie is not selected
  1153. var isOozieSelected = this.get('selectedServices').someProperty('serviceName', 'OOZIE');
  1154. var oozieUser = this.get('globals').someProperty('name', 'oozie_user') ? this.get('globals').findProperty('name', 'oozie_user').value : null;
  1155. var isHiveSelected = this.get('selectedServices').someProperty('serviceName', 'HIVE');
  1156. var hiveUser = this.get('globals').someProperty('name', 'hive_user') ? this.get('globals').findProperty('name', 'hive_user').value : null;
  1157. var isHcatSelected = this.get('selectedServices').someProperty('serviceName', 'WEBHCAT');
  1158. var hcatUser = this.get('globals').someProperty('name', 'hcat_user') ? this.get('globals').findProperty('name', 'hcat_user').value : null;
  1159. coreSiteObj.forEach(function (_coreSiteObj) {
  1160. 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'))) {
  1161. coreSiteProperties[_coreSiteObj.name] = _coreSiteObj.value;
  1162. this._recordHostOverrideFromObj(_coreSiteObj, 'core-site', 'version1', this);
  1163. }
  1164. console.log("STEP*: name of the property is: " + _coreSiteObj.name);
  1165. console.log("STEP8: value of the property is: " + _coreSiteObj.value);
  1166. }, this);
  1167. return {"type": "core-site", "tag": "version1", "properties": coreSiteProperties};
  1168. },
  1169. createHdfsSiteObj: function () {
  1170. var hdfsSiteObj = this.get('configs').filterProperty('filename', 'hdfs-site.xml');
  1171. var hdfsProperties = {};
  1172. hdfsSiteObj.forEach(function (_configProperty) {
  1173. hdfsProperties[_configProperty.name] = _configProperty.value;
  1174. this._recordHostOverrideFromObj(_configProperty, 'hdfs-site', 'version1', this);
  1175. console.log("STEP*: name of the property is: " + _configProperty.name);
  1176. console.log("STEP8: value of the property is: " + _configProperty.value);
  1177. }, this);
  1178. return {"type": "hdfs-site", "tag": "version1", "properties": hdfsProperties };
  1179. },
  1180. createHueSiteObj: function () {
  1181. var hueSiteObj = this.get('configs').filterProperty('filename', 'hue-site.xml');
  1182. var hueProperties = {};
  1183. hueSiteObj.forEach(function (_configProperty) {
  1184. hueProperties[_configProperty.name] = _configProperty.value;
  1185. this._recordHostOverrideFromObj(_configProperty, 'hue-site', 'version1', this);
  1186. console.log("STEP*: name of the property is: " + _configProperty.name);
  1187. console.log("STEP8: value of the property is: " + _configProperty.value);
  1188. }, this);
  1189. return {"type": "hue-site", "tag": "version1", "properties": hueProperties };
  1190. },
  1191. createMrSiteObj: function () {
  1192. var configs = this.get('configs').filterProperty('filename', 'mapred-site.xml');
  1193. var mrProperties = {};
  1194. configs.forEach(function (_configProperty) {
  1195. mrProperties[_configProperty.name] = _configProperty.value;
  1196. this._recordHostOverrideFromObj(_configProperty, 'mapred-site', 'version1', this);
  1197. console.log("STEP*: name of the property is: " + _configProperty.name);
  1198. console.log("STEP8: value of the property is: " + _configProperty.value);
  1199. }, this);
  1200. return {type: 'mapred-site', tag: 'version1', properties: mrProperties};
  1201. },
  1202. createCapacityScheduler: function () {
  1203. var configs = this.get('configs').filterProperty('filename', 'capacity-scheduler.xml');
  1204. var csProperties = {};
  1205. configs.forEach(function (_configProperty) {
  1206. csProperties[_configProperty.name] = _configProperty.value;
  1207. this._recordHostOverrideFromObj(_configProperty, 'capacity-scheduler', 'version1', this);
  1208. console.log("STEP*: name of the property is: " + _configProperty.name);
  1209. console.log("STEP8: value of the property is: " + _configProperty.value);
  1210. }, this);
  1211. return {type: 'capacity-scheduler', tag: 'version1', properties: csProperties};
  1212. },
  1213. createMapredQueueAcls: function () {
  1214. var configs = this.get('configs').filterProperty('filename', 'mapred-queue-acls.xml');
  1215. var mqProperties = {};
  1216. configs.forEach(function (_configProperty) {
  1217. mqProperties[_configProperty.name] = _configProperty.value;
  1218. this._recordHostOverrideFromObj(_configProperty, 'mapred-queue-acls', 'version1', this);
  1219. console.log("STEP*: name of the property is: " + _configProperty.name);
  1220. console.log("STEP8: value of the property is: " + _configProperty.value);
  1221. }, this);
  1222. return {type: 'mapred-queue-acls', tag: 'version1', properties: mqProperties};
  1223. },
  1224. createHbaseSiteObj: function () {
  1225. var configs = this.get('configs').filterProperty('filename', 'hbase-site.xml');
  1226. var hbaseProperties = {};
  1227. configs.forEach(function (_configProperty) {
  1228. hbaseProperties[_configProperty.name] = _configProperty.value;
  1229. this._recordHostOverrideFromObj(_configProperty, 'hbase-site', 'version1', this);
  1230. }, this);
  1231. return {type: 'hbase-site', tag: 'version1', properties: hbaseProperties};
  1232. },
  1233. createOozieSiteObj: function (serviceName) {
  1234. var configs = this.get('configs').filterProperty('filename', 'oozie-site.xml');
  1235. var oozieProperties = {};
  1236. configs.forEach(function (_configProperty) {
  1237. oozieProperties[_configProperty.name] = _configProperty.value;
  1238. this._recordHostOverrideFromObj(_configProperty, 'oozie-site', 'version1', this);
  1239. }, this);
  1240. return {type: 'oozie-site', tag: 'version1', properties: oozieProperties};
  1241. },
  1242. createHiveSiteObj: function (serviceName) {
  1243. var configs = this.get('configs').filterProperty('filename', 'hive-site.xml');
  1244. var hiveProperties = {};
  1245. configs.forEach(function (_configProperty) {
  1246. hiveProperties[_configProperty.name] = _configProperty.value;
  1247. this._recordHostOverrideFromObj(_configProperty, 'hive-site', 'version1', this);
  1248. }, this);
  1249. return {type: 'hive-site', tag: 'version1', properties: hiveProperties};
  1250. },
  1251. createWebHCatSiteObj: function (serviceName) {
  1252. var configs = this.get('configs').filterProperty('filename', 'webhcat-site.xml');
  1253. var webHCatProperties = {};
  1254. configs.forEach(function (_configProperty) {
  1255. webHCatProperties[_configProperty.name] = _configProperty.value;
  1256. this._recordHostOverrideFromObj(_configProperty, 'webhcat-site', 'version1', this);
  1257. }, this);
  1258. return {type: 'webhcat-site', tag: 'version1', properties: webHCatProperties};
  1259. },
  1260. getConfigForService: function (serviceName) {
  1261. switch (serviceName) {
  1262. case 'HDFS':
  1263. return {config: {'global': 'version1', 'core-site': 'version1', 'hdfs-site': 'version1'}};
  1264. case 'MAPREDUCE':
  1265. return {config: {'global': 'version1', 'core-site': 'version1', 'mapred-site': 'version1', 'capacity-scheduler': 'version1', 'mapred-queue-acls': 'version1'}};
  1266. case 'HBASE':
  1267. return {config: {'global': 'version1', 'hbase-site': 'version1'}};
  1268. case 'OOZIE':
  1269. return {config: {'global': 'version1', 'oozie-site': 'version1'}};
  1270. case 'HIVE':
  1271. return {config: {'global': 'version1', 'hive-site': 'version1'}};
  1272. case 'WEBHCAT':
  1273. return {config: {'global': 'version1', 'webhcat-site': 'version1'}};
  1274. case 'HUE':
  1275. return {config: {'global': 'version1', 'hue-site': 'version1'}};
  1276. default:
  1277. return {config: {'global': 'version1'}};
  1278. }
  1279. },
  1280. ajaxQueueFinished: function () {
  1281. //do something
  1282. },
  1283. doNextAjaxCall: function () {
  1284. if (this.get('ajaxBusy')) {
  1285. return;
  1286. }
  1287. var queue = this.get('ajaxQueue');
  1288. if (!queue.length) {
  1289. this.ajaxQueueFinished();
  1290. return;
  1291. }
  1292. var first = queue[0];
  1293. this.set('ajaxQueue', queue.slice(1));
  1294. this.set('ajaxQueueLeft', this.get('ajaxQueue').length);
  1295. this.set('ajaxBusy', true);
  1296. console.log('AJAX send ' + first.url);
  1297. $.ajax(first);
  1298. },
  1299. /**
  1300. * Records all the host overrides per site/tag
  1301. */
  1302. _recordHostOverrideFromObj: function(serviceConfigObj, siteName, tagName, self){
  1303. var overrides = serviceConfigObj.overrides;
  1304. if(overrides && overrides.length>0){
  1305. overrides.forEach(function(override){
  1306. override.hosts.forEach(function(host){
  1307. if(!(host in self.savedHostToOverrideSiteToTagMap)){
  1308. self.savedHostToOverrideSiteToTagMap[host] = {};
  1309. }
  1310. if(!(siteName in self.savedHostToOverrideSiteToTagMap[host])){
  1311. self.savedHostToOverrideSiteToTagMap[host][siteName] = {};
  1312. self.savedHostToOverrideSiteToTagMap[host][siteName].map = {};
  1313. }
  1314. var finalTag = tagName + '_' + host;
  1315. console.log("recordHostOverride(): Saving host override for host="+host+", site="+siteName+", tag="+finalTag+", (key,value)=("+serviceConfigObj.name+","+override.value+")");
  1316. self.savedHostToOverrideSiteToTagMap[host][siteName].tagName = finalTag;
  1317. self.savedHostToOverrideSiteToTagMap[host][siteName].map[serviceConfigObj.name] = override.value;
  1318. });
  1319. });
  1320. }
  1321. },
  1322. /**
  1323. * Creates host level overrides for service configuration.
  1324. *
  1325. */
  1326. createHostOverrideConfigurations: function () {
  1327. var singlePUTHostData = [];
  1328. var savedHostSiteArray = [];
  1329. for ( var host in this.savedHostToOverrideSiteToTagMap) {
  1330. for ( var siteName in this.savedHostToOverrideSiteToTagMap[host]) {
  1331. var tagName = this.savedHostToOverrideSiteToTagMap[host][siteName].tagName;
  1332. var map = this.savedHostToOverrideSiteToTagMap[host][siteName].map;
  1333. savedHostSiteArray.push(host + "///" + siteName);
  1334. singlePUTHostData.push({
  1335. RequestInfo: {
  1336. query: 'Hosts/host_name='+host
  1337. },
  1338. Body: {
  1339. Hosts: {
  1340. desired_config: {
  1341. type: siteName,
  1342. tag: tagName,
  1343. properties: map
  1344. }
  1345. }
  1346. }
  1347. });
  1348. }
  1349. }
  1350. console.log("createHostOverrideConfigSites(): PUTting host-overrides. Data=", singlePUTHostData);
  1351. if(singlePUTHostData.length>0){
  1352. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/hosts';
  1353. this.ajax({
  1354. type: 'PUT',
  1355. url: url,
  1356. data: JSON.stringify(singlePUTHostData),
  1357. dataType: 'text',
  1358. beforeSend: function () {
  1359. console.log("createHostOverrideConfigSites() PUT override=", singlePUTHostData);
  1360. }
  1361. });
  1362. }
  1363. },
  1364. /**
  1365. * We need to do a lot of ajax calls async in special order. To do this,
  1366. * generate array of ajax objects and then send requests step by step. All
  1367. * ajax objects are stored in <code>ajaxQueue</code>
  1368. *
  1369. * @param params
  1370. */
  1371. ajax: function (params) {
  1372. if (App.testMode) return;
  1373. var self = this;
  1374. params = jQuery.extend({
  1375. async: true,
  1376. dataType: 'text',
  1377. statusCode: require('data/statusCodes'),
  1378. timeout: App.timeout,
  1379. error: function (request, ajaxOptions, error) {
  1380. console.log('Step8: In Error ');
  1381. // console.log('Step8: Error message is: ' + request.responseText);
  1382. },
  1383. success: function (data) {
  1384. var jsonData = jQuery.parseJSON(data);
  1385. console.log("TRACE: STep8 -> In success function");
  1386. console.log("TRACE: STep8 -> value of the url is: " + params.url);
  1387. console.log("TRACE: STep8 -> value of the received data is: " + jsonData);
  1388. }
  1389. }, params);
  1390. var success = params.success;
  1391. var error = params.error;
  1392. params.success = function () {
  1393. if (success) {
  1394. success();
  1395. }
  1396. self.set('ajaxBusy', false);
  1397. self.doNextAjaxCall();
  1398. }
  1399. params.error = function (xhr, status, error) {
  1400. var responseText = JSON.parse(xhr.responseText);
  1401. var controller = App.router.get(App.clusterStatus.wizardControllerName);
  1402. controller.registerErrPopup(Em.I18n.t('common.error'), responseText.message);
  1403. self.set('hasErrorOccurred', true);
  1404. // an error will break the ajax call chain and allow submission again
  1405. self.set('isSubmitDisabled', false);
  1406. self.get('ajaxQueue').clear();
  1407. self.set('ajaxBusy', false);
  1408. }
  1409. this.get('ajaxQueue').pushObject(params);
  1410. }
  1411. });