step8_controller.js 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033
  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. configMapping: require('data/config_mapping'),
  28. selectedServices: function () {
  29. return this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false);
  30. }.property('content.services').cacheable(),
  31. clearStep: function () {
  32. this.get('services').clear();
  33. this.get('configs').clear();
  34. this.get('globals').clear();
  35. this.get('clusterInfo').clear();
  36. },
  37. loadStep: function () {
  38. console.log("TRACE: Loading step8: Review Page");
  39. this.clearStep();
  40. this.loadGlobals();
  41. this.loadConfigs();
  42. this.setCustomConfigs();
  43. this.loadClusterInfo();
  44. this.loadServices();
  45. },
  46. loadGlobals: function () {
  47. var globals = this.get('content.serviceConfigProperties').filterProperty('id', 'puppet var');
  48. if (globals.someProperty('name', 'hive_database')) {
  49. //TODO: Hive host depends on the type of db selected. Change puppet variable name if postgress is not the default db
  50. var hiveDb = globals.findProperty('name', 'hive_database');
  51. if (hiveDb.value === 'New PostgreSQL Database') {
  52. globals.findProperty('name', 'hive_ambari_host').name = 'hive_mysql_host';
  53. globals = globals.without(globals.findProperty('name', 'hive_existing_host'));
  54. globals = globals.without(globals.findProperty('name', 'hive_existing_database'));
  55. } else {
  56. globals.findProperty('name', 'hive_existing_host').name = 'hive_mysql_host';
  57. globals = globals.without(globals.findProperty('name', 'hive_ambari_host'));
  58. globals = globals.without(globals.findProperty('name', 'hive_ambari_database'));
  59. }
  60. }
  61. this.set('globals', globals);
  62. },
  63. loadConfigs: function () {
  64. var storedConfigs = this.get('content.serviceConfigProperties').filterProperty('id', 'site property').filterProperty('value');
  65. var uiConfigs = this.loadUiSideConfigs();
  66. this.set('configs', storedConfigs.concat(uiConfigs));
  67. },
  68. loadUiSideConfigs: function () {
  69. var uiConfig = [];
  70. var configs = this.get('configMapping').filterProperty('foreignKey', null);
  71. configs.forEach(function (_config) {
  72. var value = this.getGlobConfigValue(_config.templateName, _config.value);
  73. uiConfig.pushObject({
  74. "id": "site property",
  75. "name": _config.name,
  76. "value": value,
  77. "filename": _config.filename
  78. });
  79. }, this);
  80. var dependentConfig = this.get('configMapping').filterProperty('foreignKey');
  81. dependentConfig.forEach(function (_config) {
  82. this.setConfigValue(uiConfig, _config);
  83. uiConfig.pushObject({
  84. "id": "site property",
  85. "name": _config.name,
  86. "value": _config.value,
  87. "filename": _config.filename
  88. });
  89. }, this);
  90. return uiConfig;
  91. },
  92. /**
  93. * Set all site property that are derived from other puppet-variable
  94. */
  95. getGlobConfigValue: function (templateName, expression) {
  96. var express = expression.match(/<(.*?)>/g);
  97. var value = expression;
  98. if (express == null) {
  99. return expression;
  100. }
  101. express.forEach(function (_express) {
  102. //console.log("The value of template is: " + _express);
  103. var index = parseInt(_express.match(/\[([\d]*)(?=\])/)[1]);
  104. if (this.get('globals').someProperty('name', templateName[index])) {
  105. //console.log("The name of the variable is: " + this.get('content.serviceConfigProperties').findProperty('name', templateName[index]).name);
  106. var globValue = this.get('globals').findProperty('name', templateName[index]).value;
  107. value = value.replace(_express, globValue);
  108. } else {
  109. /*
  110. console.log("ERROR: The variable name is: " + templateName[index]);
  111. console.log("ERROR: mapped config from configMapping file has no corresponding variable in " +
  112. "content.serviceConfigProperties. Two possible reasons for the error could be: 1) The service is not selected. " +
  113. "and/OR 2) The service_config metadata file has no corresponding global var for the site property variable");
  114. */
  115. value = null;
  116. }
  117. }, this);
  118. return value;
  119. },
  120. /**
  121. * Set all site property that are derived from other site-properties
  122. */
  123. setConfigValue: function (uiConfig, config) {
  124. var fkValue = config.value.match(/<(foreignKey.*?)>/g);
  125. if (fkValue) {
  126. fkValue.forEach(function (_fkValue) {
  127. var index = parseInt(_fkValue.match(/\[([\d]*)(?=\])/)[1]);
  128. if (uiConfig.someProperty('name', config.foreignKey[index])) {
  129. var globalValue = uiConfig.findProperty('name', config.foreignKey[index]).value;
  130. config.value = config.value.replace(_fkValue, globalValue);
  131. } else if (this.get('content.serviceConfigProperties').someProperty('name', config.foreignKey[index])) {
  132. var globalValue;
  133. if (this.get('content.serviceConfigProperties').findProperty('name', config.foreignKey[index]).value === '') {
  134. globalValue = this.get('content.serviceConfigProperties').findProperty('name', config.foreignKey[index]).defaultValue;
  135. } else {
  136. globalValue = this.get('content.serviceConfigProperties').findProperty('name', config.foreignKey[index]).value;
  137. }
  138. config.value = config.value.replace(_fkValue, globalValue);
  139. }
  140. }, this);
  141. }
  142. if (fkValue = config.name.match(/<(foreignKey.*?)>/g)) {
  143. fkValue.forEach(function (_fkValue) {
  144. var index = parseInt(_fkValue.match(/\[([\d]*)(?=\])/)[1]);
  145. if (uiConfig.someProperty('name', config.foreignKey[index])) {
  146. var globalValue = uiConfig.findProperty('name', config.foreignKey[index]).value;
  147. config.name = config.name.replace(_fkValue, globalValue);
  148. } else if (this.get('content.serviceConfigProperties').someProperty('name', config.foreignKey[index])) {
  149. var globalValue;
  150. if (this.get('content.serviceConfigProperties').findProperty('name', config.foreignKey[index]).value === '') {
  151. globalValue = this.get('content.serviceConfigProperties').findProperty('name', config.foreignKey[index]).defaultValue;
  152. } else {
  153. globalValue = this.get('content.serviceConfigProperties').findProperty('name', config.foreignKey[index]).value;
  154. }
  155. config.name = config.name.replace(_fkValue, globalValue);
  156. }
  157. }, this);
  158. }
  159. //For properties in the configMapping file having foreignKey and templateName properties.
  160. var templateValue = config.value.match(/<(templateName.*?)>/g);
  161. if (templateValue) {
  162. templateValue.forEach(function (_value) {
  163. var index = parseInt(_value.match(/\[([\d]*)(?=\])/)[1]);
  164. if (this.get('globals').someProperty('name', config.templateName[index])) {
  165. var globalValue = this.get('globals').findProperty('name', config.templateName[index]).value;
  166. config.value = config.value.replace(_value, globalValue);
  167. }
  168. }, this);
  169. }
  170. },
  171. /**
  172. * override site properties with the entered key-value pair in *-site.xml
  173. */
  174. setCustomConfigs: function () {
  175. var site = this.get('content.serviceConfigProperties').filterProperty('id', 'conf-site');
  176. site.forEach(function (_site) {
  177. var keyValue = _site.value.split(/\n+/);
  178. if (keyValue) {
  179. keyValue.forEach(function (_keyValue) {
  180. console.log("The value of the keyValue is: " + _keyValue.trim());
  181. _keyValue = _keyValue.trim();
  182. var key = _keyValue.match(/(.+)=/);
  183. var value = _keyValue.match(/=(.*)/);
  184. if (key) {
  185. this.setSiteProperty(key[1], value[1],_site.filename);
  186. }
  187. }, this);
  188. }
  189. }, this);
  190. },
  191. /**
  192. * Set property of the site variable
  193. */
  194. setSiteProperty: function(key,value,filename) {
  195. if(this.get('configs').someProperty('name',key)) {
  196. this.get('configs').findProperty('name',key).value = value;
  197. } else {
  198. this.get('configs').pushObject({
  199. "id": "site property",
  200. "name": key,
  201. "value": value,
  202. "filename": filename
  203. });
  204. }
  205. },
  206. /**
  207. * Load all info about cluster to <code>clusterInfo</code> variable
  208. */
  209. loadClusterInfo: function () {
  210. // cluster name
  211. var cluster = this.rawContent.findProperty('config_name', 'cluster');
  212. cluster.config_value = this.get('content.cluster.name');
  213. console.log("STEP8: the value of content cluster name: " + this.get('content.cluster.name'));
  214. this.get('clusterInfo').pushObject(Ember.Object.create(cluster));
  215. //hosts
  216. var masterHosts = this.get('content.masterComponentHosts').mapProperty('hostName').uniq();
  217. var slaveHosts = this.get('content.slaveComponentHosts');
  218. var hostObj = [];
  219. slaveHosts.forEach(function (_hosts) {
  220. hostObj = hostObj.concat(_hosts.hosts);
  221. }, this);
  222. slaveHosts = hostObj.mapProperty('hostName').uniq();
  223. var totalHosts = masterHosts.concat(slaveHosts).uniq();
  224. this.set('totalHosts', totalHosts);
  225. var totalHostsObj = this.rawContent.findProperty('config_name', 'hosts');
  226. totalHostsObj.config_value = totalHosts.length;
  227. this.get('clusterInfo').pushObject(Ember.Object.create(totalHostsObj));
  228. //repo
  229. var repoOption = this.get('content.hosts.localRepo');
  230. var repoObj = this.rawContent.findProperty('config_name', 'Repo');
  231. if (repoOption) {
  232. repoObj.config_value = 'Yes';
  233. } else {
  234. repoObj.config_value = 'No';
  235. }
  236. this.get('clusterInfo').pushObject(Ember.Object.create(repoObj));
  237. },
  238. /**
  239. * Load all info about services to <code>services</code> variable
  240. */
  241. loadServices: function () {
  242. var selectedServices = this.get('selectedServices');
  243. this.set('services', selectedServices.mapProperty('serviceName'));
  244. selectedServices.forEach(function (_service) {
  245. console.log('INFO: step8: Name of the service from getService function: ' + _service.serviceName);
  246. var reviewService = this.rawContent.findProperty('config_name', 'services');
  247. var serviceObj = reviewService.config_value.findProperty('service_name', _service.serviceName);
  248. if (serviceObj) {
  249. switch (serviceObj.service_name) {
  250. case 'HDFS':
  251. this.loadHDFS(serviceObj);
  252. break;
  253. case 'MAPREDUCE':
  254. this.loadMapReduce(serviceObj);
  255. break;
  256. case 'HIVE':
  257. this.loadHive(serviceObj);
  258. break;
  259. case 'HBASE':
  260. this.loadHbase(serviceObj);
  261. break;
  262. case 'ZOOKEEPER':
  263. this.loadZk(serviceObj);
  264. break;
  265. case 'OOZIE':
  266. this.loadOozie(serviceObj);
  267. break;
  268. case 'NAGIOS':
  269. this.loadNagios(serviceObj);
  270. break;
  271. case 'GANGLIA':
  272. this.loadGanglia(serviceObj);
  273. break;
  274. case 'HCATALOG':
  275. break;
  276. default:
  277. }
  278. }
  279. }, this);
  280. },
  281. /**
  282. * load all info about HDFS service
  283. * @param hdfsObj
  284. */
  285. loadHDFS: function (hdfsObj) {
  286. hdfsObj.get('service_components').forEach(function (_component) {
  287. switch (_component.get('display_name')) {
  288. case 'NameNode':
  289. this.loadNnValue(_component);
  290. break;
  291. case 'SecondaryNameNode':
  292. this.loadSnnValue(_component);
  293. break;
  294. case 'DataNodes':
  295. this.loadDnValue(_component);
  296. break;
  297. default:
  298. }
  299. }, this);
  300. //var
  301. this.get('services').pushObject(hdfsObj);
  302. },
  303. loadNnValue: function (nnComponent) {
  304. var nnHostName = this.get('content.masterComponentHosts').findProperty('display_name', nnComponent.display_name);
  305. nnComponent.set('component_value', nnHostName.hostName);
  306. },
  307. loadSnnValue: function (snnComponent) {
  308. var snnHostName = this.get('content.masterComponentHosts').findProperty('display_name', 'SNameNode');
  309. snnComponent.set('component_value', snnHostName.hostName);
  310. },
  311. loadDnValue: function (dnComponent) {
  312. var dnHosts = this.get('content.slaveComponentHosts').findProperty('displayName', 'DataNode');
  313. var totalDnHosts = dnHosts.hosts.length;
  314. var dnHostGroups = [];
  315. dnHosts.hosts.forEach(function (_dnHost) {
  316. dnHostGroups.push(_dnHost.group);
  317. }, this);
  318. var totalGroups = dnHostGroups.uniq().length;
  319. var groupLabel;
  320. if (totalGroups == 1) {
  321. groupLabel = 'group';
  322. } else {
  323. groupLabel = 'groups';
  324. }
  325. dnComponent.set('component_value', totalDnHosts + ' hosts ' + '(' + totalGroups + ' ' + groupLabel + ')');
  326. },
  327. /**
  328. * Load all info about mapReduce service
  329. * @param mrObj
  330. */
  331. loadMapReduce: function (mrObj) {
  332. mrObj.get('service_components').forEach(function (_component) {
  333. switch (_component.get('display_name')) {
  334. case 'JobTracker':
  335. this.loadJtValue(_component);
  336. break;
  337. case 'TaskTrackers':
  338. this.loadTtValue(_component);
  339. break;
  340. default:
  341. }
  342. }, this);
  343. this.get('services').pushObject(mrObj);
  344. },
  345. loadJtValue: function (jtComponent) {
  346. var jtHostName = this.get('content.masterComponentHosts').findProperty('display_name', jtComponent.display_name);
  347. jtComponent.set('component_value', jtHostName.hostName);
  348. },
  349. loadTtValue: function (ttComponent) {
  350. var ttHosts = this.get('content.slaveComponentHosts').findProperty('displayName', 'TaskTracker');
  351. var totalTtHosts = ttHosts.hosts.length;
  352. var ttHostGroups = [];
  353. ttHosts.hosts.forEach(function (_ttHost) {
  354. ttHostGroups.push(_ttHost.group);
  355. }, this);
  356. var totalGroups = ttHostGroups.uniq().length;
  357. var groupLabel;
  358. if (totalGroups == 1) {
  359. groupLabel = 'group';
  360. } else {
  361. groupLabel = 'groups';
  362. }
  363. ttComponent.set('component_value', totalTtHosts + ' hosts ' + '(' + totalGroups + ' ' + groupLabel + ')');
  364. },
  365. /**
  366. * Load all info about Hive service
  367. * @param hiveObj
  368. */
  369. loadHive: function (hiveObj) {
  370. hiveObj.get('service_components').forEach(function (_component) {
  371. switch (_component.get('display_name')) {
  372. case 'Hive Metastore Server':
  373. this.loadHiveMetaStoreValue(_component);
  374. break;
  375. case 'Database':
  376. this.loadHiveDbValue(_component);
  377. break;
  378. default:
  379. }
  380. }, this);
  381. this.get('services').pushObject(hiveObj);
  382. },
  383. loadHiveMetaStoreValue: function (metaStoreComponent) {
  384. var hiveHostName = this.get('content.masterComponentHosts').findProperty('display_name', 'Hive Metastore');
  385. metaStoreComponent.set('component_value', hiveHostName.hostName);
  386. },
  387. loadHiveDbValue: function (dbComponent) {
  388. var hiveDb = App.db.getServiceConfigProperties().findProperty('name', 'hive_database');
  389. if (hiveDb.value === 'New PostgreSQL Database') {
  390. dbComponent.set('component_value', 'PostgreSQL (New Database)');
  391. } else {
  392. var db = App.db.getServiceConfigProperties().findProperty('name', 'hive_existing_database');
  393. dbComponent.set('component_value', db.value + ' (' + hiveDb.value + ')');
  394. }
  395. },
  396. /**
  397. * Load all info about Hbase
  398. * @param hbaseObj
  399. */
  400. loadHbase: function (hbaseObj) {
  401. hbaseObj.service_components.forEach(function (_component) {
  402. switch (_component.display_name) {
  403. case 'Master':
  404. this.loadMasterValue(_component);
  405. break;
  406. case 'Region Servers':
  407. this.loadRegionServerValue(_component);
  408. break;
  409. default:
  410. }
  411. }, this);
  412. this.get('services').pushObject(hbaseObj);
  413. },
  414. loadMasterValue: function (hbaseMaster) {
  415. var hbaseHostName = this.get('content.masterComponentHosts').findProperty('display_name', 'HBase Master');
  416. hbaseMaster.set('component_value', hbaseHostName.hostName);
  417. },
  418. loadRegionServerValue: function (rsComponent) {
  419. var rsHosts = this.get('content.slaveComponentHosts').findProperty('displayName', 'RegionServer');
  420. var totalRsHosts = rsHosts.hosts.length;
  421. var rsHostGroups = [];
  422. rsHosts.hosts.forEach(function (_ttHost) {
  423. rsHostGroups.push(_ttHost.group);
  424. }, this);
  425. var totalGroups = rsHostGroups.uniq().length;
  426. var groupLabel;
  427. if (totalGroups == 1) {
  428. groupLabel = 'group';
  429. } else {
  430. groupLabel = 'groups';
  431. }
  432. rsComponent.set('component_value', totalRsHosts + ' hosts ' + '(' + totalGroups + ' ' + groupLabel + ')');
  433. },
  434. /**
  435. * Load all info about ZooKeeper service
  436. * @param zkObj
  437. */
  438. loadZk: function (zkObj) {
  439. zkObj.get('service_components').forEach(function (_component) {
  440. switch (_component.get('display_name')) {
  441. case 'Servers':
  442. this.loadZkServerValue(_component);
  443. break;
  444. default:
  445. }
  446. }, this);
  447. this.get('services').pushObject(zkObj);
  448. },
  449. loadZkServerValue: function (serverComponent) {
  450. var zkHostNames = this.get('content.masterComponentHosts').filterProperty('display_name', 'ZooKeeper').length;
  451. var hostSuffix;
  452. if (zkHostNames === 1) {
  453. hostSuffix = 'host';
  454. } else {
  455. hostSuffix = 'hosts';
  456. }
  457. serverComponent.set('component_value', zkHostNames + ' ' + hostSuffix);
  458. },
  459. /**
  460. * Load all info about Oozie services
  461. * @param oozieObj
  462. */
  463. loadOozie: function (oozieObj) {
  464. oozieObj.get('service_components').forEach(function (_component) {
  465. switch (_component.get('display_name')) {
  466. case 'Server':
  467. this.loadOozieServerValue(_component);
  468. break;
  469. case 'Database':
  470. // TODO: uncomment when ready to integrate with Oozie Database other than Derby
  471. // this.loadOozieDbValue(_component);
  472. break;
  473. default:
  474. }
  475. }, this);
  476. this.get('services').pushObject(oozieObj);
  477. },
  478. loadOozieServerValue: function (oozieServer) {
  479. var oozieServerName = this.get('content.masterComponentHosts').findProperty('display_name', 'Oozie Server');
  480. oozieServer.set('component_value', oozieServerName.hostName);
  481. },
  482. loadOozieDbValue: function (dbComponent) {
  483. var oozieDb = App.db.getServiceConfigProperties().findProperty('name', 'oozie_database');
  484. if (oozieDb.value === 'New PostgreSQL Database') {
  485. dbComponent.set('component_value', 'PostgreSQL (New Database)');
  486. } else {
  487. var db = App.db.getServiceConfigProperties().findProperty('name', 'oozie_existing_database');
  488. dbComponent.set('component_value', db.value + ' (' + oozieDb.value + ')');
  489. }
  490. },
  491. /**
  492. * Load all info about Nagios service
  493. * @param nagiosObj
  494. */
  495. loadNagios: function (nagiosObj) {
  496. nagiosObj.service_components.forEach(function (_component) {
  497. switch (_component.display_name) {
  498. case 'Server':
  499. this.loadNagiosServerValue(_component);
  500. break;
  501. case 'Administrator':
  502. this.loadNagiosAdminValue(_component);
  503. break;
  504. default:
  505. }
  506. }, this);
  507. this.get('services').pushObject(nagiosObj);
  508. },
  509. loadNagiosServerValue: function (nagiosServer) {
  510. var nagiosServerName = this.get('content.masterComponentHosts').findProperty('display_name', 'Nagios Server');
  511. nagiosServer.set('component_value', nagiosServerName.hostName);
  512. },
  513. loadNagiosAdminValue: function (nagiosAdmin) {
  514. var config = this.get('content.serviceConfigProperties');
  515. var adminLoginName = config.findProperty('name', 'nagios_web_login');
  516. var adminEmail = config.findProperty('name', 'nagios_contact');
  517. nagiosAdmin.set('component_value', adminLoginName.value + ' / (' + adminEmail.value + ')');
  518. },
  519. /**
  520. * Load all info about ganglia
  521. * @param gangliaObj
  522. */
  523. loadGanglia: function (gangliaObj) {
  524. gangliaObj.get('service_components').forEach(function (_component) {
  525. switch (_component.get('display_name')) {
  526. case 'Server':
  527. this.loadGangliaServerValue(_component);
  528. break;
  529. default:
  530. }
  531. }, this);
  532. this.get('services').pushObject(gangliaObj);
  533. },
  534. loadGangliaServerValue: function (gangliaServer) {
  535. var gangliaServerName = this.get('content.masterComponentHosts').findProperty('display_name', 'Ganglia Collector');
  536. gangliaServer.set('component_value', gangliaServerName.hostName);
  537. },
  538. /**
  539. * Onclick handler for <code>next</code> button
  540. */
  541. submit: function () {
  542. if (App.testMode) {
  543. // App.router.send('next');
  544. //return;
  545. }
  546. if(!this.get('content.cluster.requestId')){
  547. this.createCluster();
  548. this.createSelectedServices();
  549. this.createConfigurations();
  550. this.applyCreatedConfToServices();
  551. this.createComponents();
  552. this.registerHostsToCluster();
  553. this.createHostComponents();
  554. }
  555. App.router.send('next');
  556. },
  557. /* Following create* functions are called on submitting step8 */
  558. createCluster: function () {
  559. if (this.get('content.isWizard')){
  560. return false;
  561. }
  562. var clusterName = this.get('clusterInfo').findProperty('config_name', 'cluster').config_value;
  563. var url = App.apiPrefix + '/clusters/' + clusterName;
  564. $.ajax({
  565. type: 'POST',
  566. url: url,
  567. async: false,
  568. //accepts: 'text',
  569. dataType: 'text',
  570. data: '{"Clusters": {"version" : "HDP-1.2.0"}}',
  571. timeout: App.timeout,
  572. success: function (data) {
  573. var jsonData = jQuery.parseJSON(data);
  574. console.log("TRACE: STep8 -> In success function for createCluster call");
  575. console.log("TRACE: STep8 -> value of the received data is: " + jsonData);
  576. },
  577. error: function (request, ajaxOptions, error) {
  578. console.log('Step8: In Error ');
  579. console.log('Step8: Error message is: ' + request.responseText);
  580. },
  581. statusCode: require('data/statusCodes')
  582. });
  583. console.log("Exiting createCluster");
  584. },
  585. createSelectedServices: function () {
  586. var services = this.get('selectedServices').mapProperty('serviceName');
  587. services.forEach(function (_service) {
  588. this.createService(_service, 'POST');
  589. }, this);
  590. },
  591. createService: function (service, httpMethod) {
  592. var clusterName = this.get('clusterInfo').findProperty('config_name', 'cluster').config_value;
  593. var url = App.apiPrefix + '/clusters/' + clusterName + '/services/' + service;
  594. $.ajax({
  595. type: httpMethod,
  596. url: url,
  597. async: false,
  598. dataType: 'text',
  599. timeout: App.timeout,
  600. success: function (data) {
  601. var jsonData = jQuery.parseJSON(data);
  602. console.log("TRACE: STep8 -> In success function for the createService call");
  603. console.log("TRACE: STep8 -> value of the url is: " + url);
  604. console.log("TRACE: STep8 -> value of the received data is: " + jsonData);
  605. },
  606. error: function (request, ajaxOptions, error) {
  607. console.log('Step8: In Error ');
  608. console.log('Step8: Error message is: ' + request.responseText);
  609. },
  610. statusCode: require('data/statusCodes')
  611. });
  612. },
  613. createComponents: function () {
  614. var serviceComponents = require('data/service_components');
  615. var services = this.get('selectedServices').mapProperty('serviceName');
  616. services.forEach(function (_service) {
  617. var components = serviceComponents.filterProperty('service_name', _service);
  618. components.forEach(function (_component) {
  619. this.createComponent(_service, _component.component_name);
  620. }, this);
  621. }, this);
  622. },
  623. createComponent: function (service, component) {
  624. var clusterName = this.get('clusterInfo').findProperty('config_name', 'cluster').config_value;
  625. var url = App.apiPrefix + '/clusters/' + clusterName + '/services/' + service + '/components/' + component;
  626. $.ajax({
  627. type: 'POST',
  628. url: url,
  629. async: false,
  630. dataType: 'text',
  631. timeout: App.timeout,
  632. success: function (data) {
  633. var jsonData = jQuery.parseJSON(data);
  634. console.log("TRACE: STep8 -> In success function for createComponent");
  635. console.log("TRACE: STep8 -> value of the url is: " + url);
  636. console.log("TRACE: STep8 -> value of the received data is: " + jsonData);
  637. },
  638. error: function (request, ajaxOptions, error) {
  639. console.log('Step8: In Error ');
  640. console.log('Step8: Error message is: ' + request.responseText);
  641. },
  642. statusCode: require('data/statusCodes')
  643. });
  644. },
  645. registerHostsToCluster: function() {
  646. var allHosts = this.get('content.hostsInfo');
  647. for(var hostName in allHosts){
  648. if(!allHosts[hostName].isInstalled){
  649. this.registerHostToCluster(hostName);
  650. }
  651. }
  652. },
  653. registerHostToCluster: function (hostName) {
  654. var clusterName = this.get('clusterInfo').findProperty('config_name', 'cluster').config_value;
  655. var url = App.apiPrefix + '/clusters/' + clusterName + '/hosts/' + hostName;
  656. $.ajax({
  657. type: 'POST',
  658. url: url,
  659. async: false,
  660. dataType: 'text',
  661. timeout: App.timeout,
  662. success: function (data) {
  663. var jsonData = jQuery.parseJSON(data);
  664. console.log("TRACE: STep8 -> In success function for registerHostToCluster");
  665. console.log("TRACE: STep8 -> value of the url is: " + url);
  666. console.log("TRACE: STep8 -> value of the received data is: " + jsonData);
  667. },
  668. error: function (request, ajaxOptions, error) {
  669. console.log('Step8: In Error ');
  670. console.log('Step8: Error message is: ' + request.responseText);
  671. },
  672. statusCode: require('data/statusCodes')
  673. });
  674. },
  675. createHostComponents: function () {
  676. //TODO: Uncomment following after hooking up with all services.
  677. var masterHosts = this.get('content.masterComponentHosts');
  678. var slaveHosts = this.get('content.slaveComponentHosts');
  679. var clients = this.get('content.clients');
  680. var allHosts = this.get('content.hostsInfo');
  681. masterHosts.forEach(function (_masterHost) {
  682. this.createHostComponent(_masterHost);
  683. }, this);
  684. slaveHosts.forEach(function (_slaveHosts) {
  685. var slaveObj = {};
  686. if (_slaveHosts.componentName !== 'CLIENT') {
  687. slaveObj.component = _slaveHosts.componentName;
  688. _slaveHosts.hosts.forEach(function (_slaveHost) {
  689. slaveObj.hostName = _slaveHost.hostName;
  690. slaveObj.isInstalled = _slaveHost.isInstalled;
  691. this.createHostComponent(slaveObj);
  692. }, this);
  693. } else {
  694. //: todo
  695. this.get('content.clients').forEach(function (_client) {
  696. slaveObj.component = _client.component_name;
  697. _slaveHosts.hosts.forEach(function (_slaveHost) {
  698. slaveObj.hostName = _slaveHost.hostName;
  699. slaveObj.isInstalled = _slaveHost.isInstalled && _client.isInstalled;
  700. this.createHostComponent(slaveObj);
  701. }, this);
  702. }, this);
  703. }
  704. }, this);
  705. // add Ganglia Monitor (Slave) to all hosts if Ganglia is selected
  706. if (this.get('selectedServices').someProperty('serviceName', 'GANGLIA')) {
  707. for (var hostName in allHosts) {
  708. // TODO: filter for only confirmed hosts?
  709. this.createHostComponent({ hostName: hostName, component: 'GANGLIA_MONITOR'});
  710. }
  711. }
  712. },
  713. createHostComponent: function (hostComponent) {
  714. console.log('try to install', hostComponent.component, 'on host', hostComponent.hostName, 'isInstalled', hostComponent.isInstalled);
  715. if (hostComponent.isInstalled) {
  716. return false;
  717. }
  718. var clusterName = this.get('clusterInfo').findProperty('config_name', 'cluster').config_value;
  719. var url = App.apiPrefix + '/clusters/' + clusterName + '/hosts/' + hostComponent.hostName + '/host_components/' + hostComponent.component;
  720. $.ajax({
  721. type: 'POST',
  722. url: url,
  723. async: false,
  724. dataType: 'text',
  725. timeout: App.timeout,
  726. success: function (data) {
  727. var jsonData = jQuery.parseJSON(data);
  728. console.log("TRACE: STep8 -> In success function for the createComponent with new host call");
  729. console.log("TRACE: STep8 -> value of the url is: " + url);
  730. console.log("TRACE: STep8 -> value of the received data is: " + jsonData);
  731. },
  732. error: function (request, ajaxOptions, error) {
  733. console.log('Step8: In Error ');
  734. console.log('Step8: Error message is: ' + request.responseText);
  735. },
  736. statusCode: require('data/statusCodes')
  737. });
  738. },
  739. createConfigurations: function () {
  740. var selectedServices = this.get('selectedServices');
  741. if (!this.get('content.isWizard')){
  742. this.createConfigSite(this.createGlobalSiteObj());
  743. this.createConfigSite(this.createCoreSiteObj());
  744. this.createConfigSite(this.createHdfsSiteObj('HDFS'));
  745. }
  746. if (selectedServices.someProperty('serviceName', 'MAPREDUCE')) {
  747. this.createConfigSite(this.createMrSiteObj('MAPREDUCE'));
  748. }
  749. if (selectedServices.someProperty('serviceName', 'HBASE')) {
  750. this.createConfigSite(this.createHbaseSiteObj('HBASE'));
  751. }
  752. if (selectedServices.someProperty('serviceName', 'OOZIE')) {
  753. this.createConfigSite(this.createOozieSiteObj('OOZIE'));
  754. }
  755. if (selectedServices.someProperty('serviceName', 'HIVE')) {
  756. // TODO
  757. // this.createConfigSite(this.createHiveSiteObj('HIVE'));
  758. }
  759. },
  760. createConfigSite: function (data) {
  761. console.log("Inside createConfigSite");
  762. var clusterName = this.get('clusterInfo').findProperty('config_name', 'cluster').config_value;
  763. var url = App.apiPrefix + '/clusters/' + clusterName + '/configurations';
  764. $.ajax({
  765. type: 'POST',
  766. url: url,
  767. data: JSON.stringify(data),
  768. async: false,
  769. dataType: 'text',
  770. timeout: App.timeout,
  771. success: function (data) {
  772. var jsonData = jQuery.parseJSON(data);
  773. console.log("TRACE: STep8 -> In success function for the createConfigSite");
  774. console.log("TRACE: STep8 -> value of the url is: " + url);
  775. console.log("TRACE: STep8 -> value of the received data is: " + jsonData);
  776. },
  777. error: function (request, ajaxOptions, error) {
  778. console.log('Step8: In Error ');
  779. console.log('Step8: Error message is: ' + request.responseText);
  780. console.log("TRACE: STep8 -> value of the url is: " + url);
  781. },
  782. statusCode: require('data/statusCodes')
  783. });
  784. console.log("Exiting createConfigSite");
  785. },
  786. createGlobalSiteObj: function () {
  787. var globalSiteProperties = {};
  788. this.get('globals').forEach(function (_globalSiteObj) {
  789. // do not pass any globals whose name ends with _host or _hosts
  790. if (!/_hosts?$/.test(_globalSiteObj.name)) {
  791. // append "m" to JVM memory options
  792. if (/_heapsize|_newsize|_maxnewsize$/.test(_globalSiteObj.name)) {
  793. _globalSiteObj.value += "m";
  794. }
  795. globalSiteProperties[_globalSiteObj.name] = _globalSiteObj.value;
  796. console.log("STEP8: name of the global property is: " + _globalSiteObj.name);
  797. console.log("STEP8: value of the global property is: " + _globalSiteObj.value);
  798. }
  799. }, this);
  800. return {"type": "global", "tag": "version1", "properties": globalSiteProperties};
  801. },
  802. createCoreSiteObj: function () {
  803. var coreSiteObj = this.get('configs').filterProperty('filename', 'core-site.xml');
  804. var coreSiteProperties = {};
  805. // hadoop.proxyuser.oozie.hosts needs to be skipped if oozie is not selected
  806. var isOozieSelected = this.get('selectedServices').someProperty('serviceName', 'OOZIE');
  807. coreSiteObj.forEach(function (_coreSiteObj) {
  808. if (isOozieSelected || _coreSiteObj.name != 'hadoop.proxyuser.oozie.hosts') {
  809. coreSiteProperties[_coreSiteObj.name] = _coreSiteObj.value;
  810. }
  811. console.log("STEP*: name of the property is: " + _coreSiteObj.name);
  812. console.log("STEP8: value of the property is: " + _coreSiteObj.value);
  813. }, this);
  814. return {"type": "core-site", "tag": "version1", "properties": coreSiteProperties};
  815. },
  816. createHdfsSiteObj: function (serviceName) {
  817. var hdfsSiteObj = this.get('configs').filterProperty('filename', 'hdfs-site.xml');
  818. var hdfsProperties = {};
  819. hdfsSiteObj.forEach(function (_configProperty) {
  820. hdfsProperties[_configProperty.name] = _configProperty.value;
  821. console.log("STEP*: name of the property is: " + _configProperty.name);
  822. console.log("STEP8: value of the property is: " + _configProperty.value);
  823. }, this);
  824. return {"type": "hdfs-site", "tag": "version1", "properties": hdfsProperties };
  825. },
  826. createMrSiteObj: function (serviceName) {
  827. var configs = this.get('configs').filterProperty('filename', 'mapred-site.xml');
  828. var mrProperties = {};
  829. configs.forEach(function (_configProperty) {
  830. mrProperties[_configProperty.name] = _configProperty.value;
  831. console.log("STEP*: name of the property is: " + _configProperty.name);
  832. console.log("STEP8: value of the property is: " + _configProperty.value);
  833. }, this);
  834. return {type: 'mapred-site', tag: 'version1', properties: mrProperties};
  835. },
  836. createHbaseSiteObj: function (serviceName) {
  837. var configs = this.get('configs').filterProperty('filename', 'hbase-site.xml');
  838. var hbaseProperties = {};
  839. configs.forEach(function (_configProperty) {
  840. hbaseProperties[_configProperty.name] = _configProperty.value;
  841. }, this);
  842. var masterHosts = App.db.getMasterComponentHosts();
  843. // TODO: should filter on "component" but that gives unexpected results
  844. var zkServers = masterHosts.filterProperty('display_name', 'ZooKeeper').mapProperty('hostName');
  845. hbaseProperties['hbase.zookeeper.quorum'] = zkServers.join(',');
  846. return {type: 'hbase-site', tag: 'version1', properties: hbaseProperties};
  847. },
  848. createOozieSiteObj: function (serviceName) {
  849. var configs = this.get('configs').filterProperty('filename', 'oozie-site.xml');
  850. var oozieProperties = {};
  851. configs.forEach(function (_configProperty) {
  852. oozieProperties[_configProperty.name] = _configProperty.value;
  853. }, this);
  854. var baseUrl = oozieProperties['oozie.base.url'];
  855. oozieProperties = {
  856. "oozie.service.JPAService.jdbc.password" : " ", "oozie.db.schema.name" : "oozie", "oozie.service.JPAService.jdbc.url" : "jdbc:derby:/var/data/oozie/oozie-db;create=true", "oozie.service.JPAService.jdbc.driver" : "org.apache.derby.jdbc.EmbeddedDriver", "oozie.service.WorkflowAppService.system.libpath" : "/user/oozie/share/lib", "oozie.service.JPAService.jdbc.username" : "sa", "oozie.service.SchemaService.wf.ext.schemas" : "shell-action-0.1.xsd,email-action-0.1.xsd,hive-action-0.2.xsd,sqoop-action-0.2.xsd,ssh-action-0.1.xsd,distcp-action-0.1.xsd", "oozie.service.JPAService.create.db.schema" : "false", "use.system.libpath.for.mapreduce.and.pig.jobs" : "false", "oozie.service.ActionService.executor.ext.classes" : "org.apache.oozie.action.email.EmailActionExecutor,org.apache.oozie.action.hadoop.HiveActionExecutor,org.apache.oozie.action.hadoop.ShellActionExecutor,org.apache.oozie.action.hadoop.SqoopActionExecutor,org.apache.oozie.action.hadoop.DistcpActionExecutor", "oozie.service.HadoopAccessorService.hadoop.configurations" : "*=/etc/hadoop/conf"
  857. };
  858. oozieProperties['oozie.base.url'] = baseUrl;
  859. return {type: 'oozie-site', tag: 'version1', properties: oozieProperties};
  860. },
  861. createHiveSiteObj: function (serviceName) {
  862. var configs = this.get('configs').filterProperty('filename', 'hive-site.xml');
  863. var hiveProperties = {};
  864. configs.forEach(function (_configProperty) {
  865. hiveProperties[_configProperty.name] = _configProperty.value;
  866. }, this);
  867. return {type: 'hbase-site', tag: 'version1', properties: hiveProperties};
  868. },
  869. applyCreatedConfToServices: function () {
  870. var services = this.get('selectedServices').mapProperty('serviceName');
  871. services.forEach(function (_service) {
  872. var data = this.getConfigForService(_service);
  873. this.applyCreatedConfToService(_service, 'PUT', data);
  874. }, this);
  875. },
  876. applyCreatedConfToService: function (service, httpMethod, data) {
  877. console.log("Inside applyCreatedConfToService");
  878. var clusterName = this.get('clusterInfo').findProperty('config_name', 'cluster').config_value;
  879. var url = App.apiPrefix + '/clusters/' + clusterName + '/services/' + service;
  880. $.ajax({
  881. type: httpMethod,
  882. url: url,
  883. async: false,
  884. dataType: 'text',
  885. data: JSON.stringify(data),
  886. timeout: App.timeout,
  887. success: function (data) {
  888. var jsonData = jQuery.parseJSON(data);
  889. console.log("TRACE: STep8 -> In success function for the applyCreatedConfToService call");
  890. console.log("TRACE: STep8 -> value of the url is: " + url);
  891. console.log("TRACE: STep8 -> value of the received data is: " + jsonData);
  892. },
  893. error: function (request, ajaxOptions, error) {
  894. console.log('Step8: In Error ');
  895. console.log('Step8: Error message is: ' + request.responseText);
  896. },
  897. statusCode: require('data/statusCodes')
  898. });
  899. console.log("Exiting applyCreatedConfToService");
  900. },
  901. getConfigForService: function (serviceName) {
  902. switch (serviceName) {
  903. case 'HDFS':
  904. return {config: {'global': 'version1', 'core-site': 'version1', 'hdfs-site': 'version1'}};
  905. case 'MAPREDUCE':
  906. return {config: {'global': 'version1', 'core-site': 'version1', 'mapred-site': 'version1'}};
  907. case 'HBASE':
  908. return {config: {'global': 'version1', 'core-site': 'version1', 'hbase-site': 'version1'}};
  909. case 'OOZIE':
  910. return {config: {'global': 'version1', 'core-site': 'version1', 'oozie-site': 'version1'}};
  911. }
  912. }
  913. })