step8_controller.js 69 KB

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