step8_controller.js 79 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010
  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: function(){
  30. return App.config.get('configMapping').all(true);
  31. }.property('App.config.configMapping'),
  32. slaveComponentConfig: null,
  33. isSubmitDisabled: false,
  34. isBackBtnDisabled: false,
  35. hasErrorOccurred: false,
  36. servicesInstalled: false,
  37. serviceConfigTags: [],
  38. securityEnabled: function() {
  39. return App.router.get('mainAdminSecurityController.securityEnabled');
  40. }.property('App.router.mainAdminSecurityController.securityEnabled'),
  41. /**
  42. * During page save time, we set the host overrides to the server.
  43. * The new host -> site:tag map is stored below. This will be
  44. * useful during save, to update the host's host components. Also,
  45. * it will be useful in deletion of overrides.
  46. *
  47. * Example:
  48. * {
  49. * 'hostname1': {
  50. * 'global': {
  51. * 'tagName': 'tag3187261938_hostname1',
  52. * 'map': {
  53. * 'hadoop_heapsize': '2048m'
  54. * }
  55. * }
  56. * }
  57. * }
  58. *
  59. * @see loadedHostToOverrideSiteToTagMap
  60. */
  61. savedHostToOverrideSiteToTagMap: {},
  62. selectedConfigGroup: null,
  63. configGroups: [],
  64. selectedServices: function () {
  65. return this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false);
  66. }.property('content.services').cacheable(),
  67. clearStep: function () {
  68. this.get('services').clear();
  69. this.get('configs').clear();
  70. this.get('globals').clear();
  71. this.get('clusterInfo').clear();
  72. this.get('serviceConfigTags').clear();
  73. this.set('servicesInstalled', false);
  74. },
  75. loadStep: function () {
  76. console.log("TRACE: Loading step8: Review Page");
  77. if (this.get('content.controllerName') != 'installerController') {
  78. App.router.get('mainAdminSecurityController').setSecurityStatus();
  79. }
  80. this.clearStep();
  81. if (this.get('content.serviceConfigProperties')) {
  82. this.formatProperties();
  83. this.loadGlobals();
  84. this.loadConfigs();
  85. }
  86. this.loadClusterInfo();
  87. this.loadServices();
  88. this.set('isSubmitDisabled', false);
  89. this.set('isBackBtnDisabled', false);
  90. },
  91. /**
  92. * replace whitespace character with coma between directories
  93. */
  94. formatProperties: function(){
  95. this.get('content.serviceConfigProperties').forEach(function(_configProperty){
  96. _configProperty.value = App.config.trimProperty(_configProperty,false);
  97. });
  98. },
  99. loadGlobals: function () {
  100. var globals = this.get('content.serviceConfigProperties').filterProperty('id', 'puppet var');
  101. if (globals.someProperty('name', 'hive_database')) {
  102. var hiveDb = globals.findProperty('name', 'hive_database');
  103. var hiveDbType = {name: 'hive_database_type', value: 'mysql'};
  104. var hiveJdbcDriver = {name: 'hive_jdbc_driver'};
  105. if (hiveDb.value === 'New MySQL Database') {
  106. if (globals.someProperty('name', 'hive_ambari_host')) {
  107. globals.findProperty('name', 'hive_hostname').value = globals.findProperty('name', 'hive_ambari_host').value;
  108. hiveDbType.value = 'mysql';
  109. hiveJdbcDriver.value = 'com.mysql.jdbc.Driver';
  110. }
  111. globals = globals.without(globals.findProperty('name', 'hive_existing_mysql_host'));
  112. globals = globals.without(globals.findProperty('name', 'hive_existing_mysql_database'));
  113. globals = globals.without(globals.findProperty('name', 'hive_existing_oracle_host'));
  114. globals = globals.without(globals.findProperty('name', 'hive_existing_oracle_database'));
  115. } else if (hiveDb.value === 'Existing MySQL Database'){
  116. globals.findProperty('name', 'hive_hostname').value = globals.findProperty('name', 'hive_existing_mysql_host').value;
  117. hiveDbType.value = 'mysql';
  118. hiveJdbcDriver.value = 'com.mysql.jdbc.Driver';
  119. globals = globals.without(globals.findProperty('name', 'hive_ambari_host'));
  120. globals = globals.without(globals.findProperty('name', 'hive_ambari_database'));
  121. globals = globals.without(globals.findProperty('name', 'hive_existing_oracle_host'));
  122. globals = globals.without(globals.findProperty('name', 'hive_existing_oracle_database'));
  123. } else { //existing oracle database
  124. globals.findProperty('name', 'hive_hostname').value = globals.findProperty('name', 'hive_existing_oracle_host').value;
  125. hiveDbType.value = 'oracle';
  126. hiveJdbcDriver.value = 'oracle.jdbc.driver.OracleDriver';
  127. globals = globals.without(globals.findProperty('name', 'hive_ambari_host'));
  128. globals = globals.without(globals.findProperty('name', 'hive_ambari_database'));
  129. globals = globals.without(globals.findProperty('name', 'hive_existing_mysql_host'));
  130. globals = globals.without(globals.findProperty('name', 'hive_existing_mysql_database'));
  131. }
  132. globals.push(hiveDbType);
  133. globals.push(hiveJdbcDriver);
  134. }
  135. if (globals.someProperty('name', 'oozie_database')) {
  136. var oozieDb = globals.findProperty('name', 'oozie_database');
  137. var oozieDbType = {name:'oozie_database_type'};
  138. var oozieJdbcDriver = {name: 'oozie_jdbc_driver'};
  139. if (oozieDb.value === 'New Derby Database') {
  140. globals.findProperty('name', 'oozie_hostname').value = globals.findProperty('name', 'oozie_ambari_host').value;
  141. oozieDbType.value = 'derby';
  142. oozieJdbcDriver.value = 'org.apache.derby.jdbc.EmbeddedDriver';
  143. globals = globals.without(globals.findProperty('name', 'oozie_ambari_host'));
  144. globals = globals.without(globals.findProperty('name', 'oozie_ambari_database'));
  145. globals = globals.without(globals.findProperty('name', 'oozie_existing_mysql_host'));
  146. globals = globals.without(globals.findProperty('name', 'oozie_existing_mysql_database'));
  147. globals = globals.without(globals.findProperty('name', 'oozie_existing_oracle_host'));
  148. globals = globals.without(globals.findProperty('name', 'oozie_existing_oracle_database'));
  149. } else if (oozieDb.value === 'Existing MySQL Database') {
  150. globals.findProperty('name', 'oozie_hostname').value = globals.findProperty('name', 'oozie_existing_mysql_host').value;
  151. oozieDbType.value = 'mysql';
  152. oozieJdbcDriver.value = 'com.mysql.jdbc.Driver';
  153. globals = globals.without(globals.findProperty('name', 'oozie_ambari_host'));
  154. globals = globals.without(globals.findProperty('name', 'oozie_ambari_database'));
  155. globals = globals.without(globals.findProperty('name', 'oozie_existing_oracle_host'));
  156. globals = globals.without(globals.findProperty('name', 'oozie_existing_oracle_database'));
  157. globals = globals.without(globals.findProperty('name', 'oozie_derby_database'));
  158. } else { // existing oracle database
  159. globals.findProperty('name', 'oozie_hostname').value = globals.findProperty('name', 'oozie_existing_oracle_host').value;
  160. oozieDbType.value = 'oracle';
  161. oozieJdbcDriver.value = 'oracle.jdbc.driver.OracleDriver';
  162. globals = globals.without(globals.findProperty('name', 'oozie_ambari_host'));
  163. globals = globals.without(globals.findProperty('name', 'oozie_ambari_database'));
  164. globals = globals.without(globals.findProperty('name', 'oozie_existing_mysql_host'));
  165. globals = globals.without(globals.findProperty('name', 'oozie_existing_mysql_database'));
  166. globals = globals.without(globals.findProperty('name', 'oozie_derby_database'));
  167. }
  168. globals.push(oozieDbType);
  169. globals.push(oozieJdbcDriver);
  170. }
  171. this.set('globals', globals);
  172. },
  173. loadConfigs: function () {
  174. //storedConfigs contains custom configs as well
  175. var serviceConfigProperties = this.get('content.serviceConfigProperties').filterProperty('id', 'site property');
  176. serviceConfigProperties.forEach(function(_config){
  177. _config.value = (typeof _config.value === "boolean") ? _config.value.toString() : _config.value;
  178. });
  179. var storedConfigs = serviceConfigProperties.filterProperty('value');
  180. var uiConfigs = this.loadUiSideConfigs();
  181. this.set('configs', storedConfigs.concat(uiConfigs));
  182. },
  183. loadUiSideConfigs: function () {
  184. var uiConfig = [];
  185. var configs = this.get('configMapping').filterProperty('foreignKey', null);
  186. this.addDynamicProperties(configs);
  187. configs.forEach(function (_config) {
  188. var valueWithOverrides = this.getGlobConfigValueWithOverrides(_config.templateName, _config.value, _config.name);
  189. uiConfig.pushObject({
  190. "id": "site property",
  191. "name": _config.name,
  192. "value": valueWithOverrides.value,
  193. "filename": _config.filename,
  194. "overrides": valueWithOverrides.overrides
  195. });
  196. }, this);
  197. var dependentConfig = $.extend(true, [], this.get('configMapping').filterProperty('foreignKey'));
  198. dependentConfig.forEach(function (_config) {
  199. App.config.setConfigValue(uiConfig, this.get('content.serviceConfigProperties'), _config, this.get('globals'));
  200. uiConfig.pushObject({
  201. "id": "site property",
  202. "name": _config._name || _config.name,
  203. "value": _config.value,
  204. "filename": _config.filename
  205. });
  206. }, this);
  207. return uiConfig;
  208. },
  209. addDynamicProperties: function(configs) {
  210. var templetonHiveProperty = this.get('content.serviceConfigProperties').someProperty('name', 'templeton.hive.properties');
  211. if (!templetonHiveProperty) {
  212. configs.pushObject({
  213. "name": "templeton.hive.properties",
  214. "templateName": ["hivemetastore_host"],
  215. "foreignKey": null,
  216. "value": "hive.metastore.local=false,hive.metastore.uris=thrift://<templateName[0]>:9083,hive.metastore.sasl.enabled=yes,hive.metastore.execute.setugi=true,hive.metastore.warehouse.dir=/apps/hive/warehouse",
  217. "filename": "webhcat-site.xml"
  218. });
  219. }
  220. },
  221. getRegisteredHosts: function () {
  222. var allHosts = this.get('content.hosts');
  223. var hosts = [];
  224. for (var hostName in allHosts) {
  225. if (allHosts[hostName].bootStatus == 'REGISTERED') {
  226. allHosts[hostName].hostName = allHosts[hostName].name;
  227. hosts.pushObject(allHosts[hostName]);
  228. }
  229. }
  230. return hosts;
  231. },
  232. /**
  233. * Set all site property that are derived from other puppet-variable
  234. * @return {
  235. * value: '...',
  236. * overrides: {
  237. * 'value1': [h1, h2],
  238. * 'value2': [h3]
  239. * }
  240. * }
  241. */
  242. getGlobConfigValueWithOverrides: function (templateName, expression, name) {
  243. var express = expression.match(/<(.*?)>/g);
  244. var value = expression;
  245. if (express == null) {
  246. return { value : expression, overrides: []}; // if site property do not map any global property then return the value
  247. }
  248. var overrideHostToValue = {};
  249. express.forEach(function (_express) {
  250. //console.log("The value of template is: " + _express);
  251. var index = parseInt(_express.match(/\[([\d]*)(?=\])/)[1]);
  252. if (this.get('globals').someProperty('name', templateName[index])) {
  253. //console.log("The name of the variable is: " + this.get('content.serviceConfigProperties').findProperty('name', templateName[index]).name);
  254. var globalObj = this.get('globals').findProperty('name', templateName[index]);
  255. var globValue = globalObj.value;
  256. // Hack for templeton.zookeeper.hosts
  257. var preReplaceValue = null;
  258. 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
  259. preReplaceValue = value;
  260. value = this._replaceConfigValues(name, _express, value, globValue);
  261. }
  262. if(globalObj.overrides!=null){
  263. globalObj.overrides.forEach(function(override){
  264. var ov = override.value;
  265. var hostsArray = override.hosts;
  266. hostsArray.forEach(function(host){
  267. if(!(host in overrideHostToValue)){
  268. overrideHostToValue[host] = this._replaceConfigValues(name, _express, preReplaceValue, ov);
  269. }else{
  270. overrideHostToValue[host] = this._replaceConfigValues(name, _express, overrideHostToValue[host], ov);
  271. }
  272. }, this);
  273. }, this);
  274. }
  275. } else {
  276. /*
  277. console.log("ERROR: The variable name is: " + templateName[index]);
  278. console.log("ERROR: mapped config from configMapping file has no corresponding variable in " +
  279. "content.serviceConfigProperties. Two possible reasons for the error could be: 1) The service is not selected. " +
  280. "and/OR 2) The service_config metadata file has no corresponding global var for the site property variable");
  281. */
  282. value = null;
  283. }
  284. }, this);
  285. var valueWithOverrides = {
  286. value: value,
  287. overrides: []
  288. };
  289. var overrideValueToHostMap = {};
  290. if(!jQuery.isEmptyObject(overrideHostToValue)){
  291. for(var host in overrideHostToValue){
  292. var hostVal = overrideHostToValue[host];
  293. if(!(hostVal in overrideValueToHostMap)){
  294. overrideValueToHostMap[hostVal] = [];
  295. }
  296. overrideValueToHostMap[hostVal].push(host);
  297. }
  298. }
  299. for(var val in overrideValueToHostMap){
  300. valueWithOverrides.overrides.push({
  301. value: val,
  302. hosts: overrideValueToHostMap[val]
  303. });
  304. }
  305. return valueWithOverrides;
  306. },
  307. _replaceConfigValues: function (name, express, value, globValue) {
  308. return value.replace(express, globValue);
  309. },
  310. /**
  311. * Load all info about cluster to <code>clusterInfo</code> variable
  312. */
  313. loadClusterInfo: function () {
  314. //Admin name
  315. var admin = this.rawContent.findProperty('config_name', 'Admin');
  316. admin.config_value = App.db.getLoginName();
  317. console.log("STEP8: the value of content cluster name: " + App.db.getLoginName());
  318. if (admin.config_value) {
  319. this.get('clusterInfo').pushObject(Ember.Object.create(admin));
  320. }
  321. // cluster name
  322. var cluster = this.rawContent.findProperty('config_name', 'cluster');
  323. cluster.config_value = this.get('content.cluster.name');
  324. console.log("STEP8: the value of content cluster name: " + this.get('content.cluster.name'));
  325. this.get('clusterInfo').pushObject(Ember.Object.create(cluster));
  326. //hosts
  327. var masterHosts = this.get('content.masterComponentHosts').mapProperty('hostName').uniq();
  328. var slaveHosts = this.get('content.slaveComponentHosts');
  329. var hostObj = [];
  330. slaveHosts.forEach(function (_hosts) {
  331. hostObj = hostObj.concat(_hosts.hosts);
  332. }, this);
  333. slaveHosts = hostObj.mapProperty('hostName').uniq();
  334. var componentHosts = masterHosts.concat(slaveHosts).uniq();
  335. var totalHosts = App.Host.find().mapProperty('hostName').concat(componentHosts).uniq();
  336. var newHostsCount = totalHosts.length - App.Host.find().content.length;
  337. this.set('totalHosts', totalHosts);
  338. var totalHostsObj = this.rawContent.findProperty('config_name', 'hosts');
  339. totalHostsObj.config_value = totalHosts.length + ' (' + newHostsCount + ' new)';
  340. this.get('clusterInfo').pushObject(Ember.Object.create(totalHostsObj));
  341. //repo
  342. if (['addHostController', 'addServiceController'].contains(this.get('content.controllerName'))) {
  343. this.loadRepoInfo();
  344. } else { // from install wizard
  345. var selectedStack = this.get('content.stacks').findProperty('isSelected', true);
  346. var allRepos = [];
  347. if (selectedStack && selectedStack.operatingSystems) {
  348. selectedStack.operatingSystems.forEach (function(os){
  349. if (os.selected) {
  350. switch (os.osType) {
  351. case 'redhat6':
  352. var repo = Em.Object.create({
  353. base_url: os.baseUrl,
  354. os_type: Em.I18n.t("installer.step8.repoInfo.osType.redhat6")
  355. });
  356. allRepos.push(repo);
  357. break;
  358. case 'redhat5':
  359. var repo = Em.Object.create({
  360. base_url: os.baseUrl,
  361. os_type: Em.I18n.t("installer.step8.repoInfo.osType.redhat5")
  362. });
  363. allRepos.push(repo);
  364. break;
  365. case 'sles11':
  366. var repo = Em.Object.create({
  367. base_url: os.baseUrl,
  368. os_type: Em.I18n.t("installer.step8.repoInfo.osType.sles11")
  369. });
  370. allRepos.push(repo);
  371. break;
  372. }
  373. }
  374. }, this);
  375. }
  376. allRepos.set('display_name', Em.I18n.t("installer.step8.repoInfo.displayName"));
  377. this.get('clusterInfo').set('repoInfo', allRepos);
  378. }
  379. },
  380. /**
  381. * get the repositories info of HDP from server. Used only in addHost controller.
  382. */
  383. loadRepoInfo: function(){
  384. var nameVersionCombo = App.get('currentStackVersion');
  385. var stackName = nameVersionCombo.split('-')[0];
  386. var stackVersion = nameVersionCombo.split('-')[1];
  387. App.ajax.send({
  388. name: 'cluster.load_repositories',
  389. sender: this,
  390. data: {
  391. stackName: stackName,
  392. stackVersion: stackVersion
  393. },
  394. success: 'loadRepoInfoSuccessCallback',
  395. error: 'loadRepositoriesErrorCallback'
  396. });
  397. },
  398. loadRepoInfoSuccessCallback: function (data) {
  399. var allRepos = [];
  400. data.items.forEach(function(item) {
  401. var os = item.repositories[0].Repositories;
  402. switch (os.os_type) {
  403. case 'redhat6':
  404. var repo = Em.Object.create({
  405. base_url: os.base_url,
  406. os_type: Em.I18n.t("installer.step8.repoInfo.osType.redhat6")
  407. });
  408. allRepos.push(repo);
  409. break;
  410. case 'redhat5':
  411. var repo = Em.Object.create({
  412. base_url: os.base_url,
  413. os_type: Em.I18n.t("installer.step8.repoInfo.osType.redhat5")
  414. });
  415. allRepos.push(repo);
  416. break;
  417. case 'sles11':
  418. var repo = Em.Object.create({
  419. base_url: os.base_url,
  420. os_type: Em.I18n.t("installer.step8.repoInfo.osType.sles11")
  421. });
  422. allRepos.push(repo);
  423. break;
  424. }
  425. }, this);
  426. allRepos.set('display_name', Em.I18n.t("installer.step8.repoInfo.displayName"));
  427. this.get('clusterInfo').set('repoInfo', allRepos);
  428. },
  429. loadRepoInfoErrorCallback: function(request, ajaxOptions, error) {
  430. console.log('Error message is: ' + request.responseText);
  431. var allRepos = [];
  432. allRepos.set('display_name', Em.I18n.t("installer.step8.repoInfo.displayName"));
  433. this.get('clusterInfo').set('repoInfo', allRepos);
  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 'GLUSTERFS':
  451. this.loadGLUSTERFS(serviceObj);
  452. break;
  453. case 'MAPREDUCE':
  454. this.loadMapReduce(serviceObj);
  455. break;
  456. case 'MAPREDUCE2':
  457. this.loadMapReduce2(serviceObj);
  458. break;
  459. case 'YARN':
  460. this.loadYARN(serviceObj);
  461. break;
  462. case 'HIVE':
  463. this.loadHive(serviceObj);
  464. break;
  465. case 'HBASE':
  466. this.loadHbase(serviceObj);
  467. break;
  468. case 'ZOOKEEPER':
  469. this.loadZk(serviceObj);
  470. break;
  471. case 'OOZIE':
  472. this.loadOozie(serviceObj);
  473. break;
  474. case 'NAGIOS':
  475. this.loadNagios(serviceObj);
  476. break;
  477. case 'GANGLIA':
  478. this.loadGanglia(serviceObj);
  479. break;
  480. case 'HUE':
  481. this.loadHue(serviceObj);
  482. break;
  483. case 'FALCON':
  484. this.loadFalcon(serviceObj);
  485. break;
  486. /* case 'TEZ':
  487. break;
  488. case 'PIG':
  489. this.loadPig(serviceObj);
  490. break;
  491. case 'SQOOP':
  492. this.loadSqoop(serviceObj);
  493. break;
  494. */
  495. case 'STORM':
  496. this.loadSTORM(serviceObj);
  497. case 'HCATALOG':
  498. break;
  499. default:
  500. }
  501. }
  502. }, this);
  503. },
  504. /**
  505. * load all info about HDFS service
  506. * @param hdfsObj
  507. */
  508. loadHDFS: function (hdfsObj) {
  509. hdfsObj.get('service_components').forEach(function (_component) {
  510. switch (_component.get('display_name')) {
  511. case 'NameNode':
  512. this.loadNnValue(_component);
  513. break;
  514. case 'SecondaryNameNode':
  515. this.loadSnnValue(_component);
  516. break;
  517. case 'DataNodes':
  518. this.loadDnValue(_component);
  519. break;
  520. default:
  521. }
  522. }, this);
  523. //var
  524. this.get('services').pushObject(hdfsObj);
  525. },
  526. /**
  527. * load all info about GLUSTERFS service
  528. * @param glusterfsObj
  529. */
  530. loadGLUSTERFS: function (glusterfsObj) {
  531. glusterfsObj.get('service_components').forEach(function (_component) {
  532. switch (_component.get('display_name')) {
  533. case 'GLUSTERFS Client':
  534. this.loadGLUSTERFSClientValue(_component);
  535. break;
  536. default:
  537. }
  538. }, this);
  539. this.get('services').pushObject(glusterfsObj);
  540. },
  541. loadGLUSTERFSClientValue: function (glusterfsComponent) {
  542. var glusterfsClientHosts = this.get('content.slaveComponentHosts').findProperty('displayName', 'Client');
  543. var totalGLUSTERFSHosts = glusterfsClientHosts.hosts.length;
  544. glusterfsComponent.set('component_value', totalGLUSTERFSHosts + ' hosts');
  545. },
  546. loadNnValue: function (nnComponent) {
  547. var nnHostName = this.get('content.masterComponentHosts').findProperty('display_name', nnComponent.display_name);
  548. nnComponent.set('component_value', nnHostName.hostName);
  549. },
  550. loadSnnValue: function (snnComponent) {
  551. var snnHostName = this.get('content.masterComponentHosts').findProperty('display_name', 'SNameNode');
  552. snnComponent.set('component_value', snnHostName.hostName);
  553. },
  554. loadDnValue: function (dnComponent) {
  555. var dnHosts = this.get('content.slaveComponentHosts').findProperty('displayName', 'DataNode');
  556. var totalDnHosts = dnHosts.hosts.length;
  557. /* var totalGroups = this.get('slaveComponentConfig.components').findProperty('componentName', 'DATANODE').groups.length;
  558. var groupLabel;
  559. if (totalGroups == 1) {
  560. groupLabel = 'group';
  561. } else {
  562. groupLabel = 'groups';
  563. }
  564. */
  565. dnComponent.set('component_value', totalDnHosts + Em.I18n.t('installer.step8.hosts'));
  566. },
  567. /**
  568. * Load all info about mapReduce service
  569. * @param mrObj
  570. */
  571. loadMapReduce: function (mrObj) {
  572. mrObj.get('service_components').forEach(function (_component) {
  573. switch (_component.get('display_name')) {
  574. case 'JobTracker':
  575. this.loadJtValue(_component);
  576. break;
  577. case 'TaskTrackers':
  578. this.loadTtValue(_component);
  579. break;
  580. default:
  581. }
  582. }, this);
  583. this.get('services').pushObject(mrObj);
  584. },
  585. loadMapReduce2: function(mrObj){
  586. mrObj.get('service_components').forEach(function (_component) {
  587. switch (_component.get('display_name')) {
  588. case 'History Server':
  589. _component.set('component_value', this.get('content.masterComponentHosts').findProperty('component', 'HISTORYSERVER').hostName);
  590. break;
  591. }
  592. }, this);
  593. this.get('services').pushObject(mrObj);
  594. },
  595. loadYARN: function(mrObj){
  596. var setComponentHost = function(component, componentName) {
  597. component.set('component_value', this.get('content.masterComponentHosts').findProperty('component', componentName).hostName);
  598. }.bind(this);
  599. mrObj.get('service_components').forEach(function (_component) {
  600. switch (_component.get('display_name')) {
  601. case 'NodeManager':
  602. this.loadNMValue(_component);
  603. break;
  604. case 'ResourceManager':
  605. setComponentHost(_component, 'RESOURCEMANAGER');
  606. break;
  607. case 'History Server':
  608. setComponentHost(_component, 'HISTORYSERVER');
  609. break;
  610. case 'App Timeline Server':
  611. setComponentHost(_component, 'APP_TIMELINE_SERVER');
  612. break;
  613. }
  614. }, this);
  615. this.get('services').pushObject(mrObj);
  616. },
  617. loadNMValue: function (nmComponent) {
  618. var nmHosts = this.get('content.slaveComponentHosts').findProperty('componentName', 'NODEMANAGER');
  619. nmComponent.set('component_value', nmHosts.hosts.length + Em.I18n.t('installer.step8.hosts'));
  620. },
  621. loadJtValue: function (jtComponent) {
  622. var jtHostName = this.get('content.masterComponentHosts').findProperty('display_name', jtComponent.display_name);
  623. jtComponent.set('component_value', jtHostName.hostName);
  624. },
  625. loadTtValue: function (ttComponent) {
  626. var ttHosts = this.get('content.slaveComponentHosts').findProperty('displayName', 'TaskTracker');
  627. var totalTtHosts = ttHosts.hosts.length;
  628. ttComponent.set('component_value', totalTtHosts + Em.I18n.t('installer.step8.hosts'));
  629. },
  630. /**
  631. * Load all info about Hive service
  632. * @param hiveObj
  633. */
  634. loadHive: function (hiveObj) {
  635. hiveObj.get('service_components').forEach(function (_component) {
  636. switch (_component.get('display_name')) {
  637. case 'Hive Metastore':
  638. this.loadHiveMetaStoreValue(_component);
  639. break;
  640. case 'Database':
  641. this.loadHiveDbValue(_component);
  642. break;
  643. default:
  644. }
  645. }, this);
  646. this.get('services').pushObject(hiveObj);
  647. },
  648. loadHiveMetaStoreValue: function (metaStoreComponent) {
  649. var hiveHostName = this.get('content.masterComponentHosts').findProperty('display_name', 'HiveServer2');
  650. metaStoreComponent.set('component_value', hiveHostName.hostName);
  651. },
  652. loadHiveDbValue: function (dbComponent) {
  653. var hiveDb = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'hive_database');
  654. if (hiveDb.value === 'New MySQL Database') {
  655. dbComponent.set('component_value', 'MySQL (New Database)');
  656. } else if(hiveDb.value === 'Existing MySQL Database'){
  657. var db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'hive_existing_mysql_database');
  658. dbComponent.set('component_value', db.value + ' (' + hiveDb.value + ')');
  659. } else { // existing oracle database
  660. var db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'hive_existing_oracle_database');
  661. dbComponent.set('component_value', db.value + ' (' + hiveDb.value + ')');
  662. }
  663. },
  664. /**
  665. * Load all info about Hbase
  666. * @param hbaseObj
  667. */
  668. loadHbase: function (hbaseObj) {
  669. hbaseObj.service_components.forEach(function (_component) {
  670. switch (_component.display_name) {
  671. case 'Master':
  672. this.loadMasterValue(_component);
  673. break;
  674. case 'RegionServers':
  675. this.loadRegionServerValue(_component);
  676. break;
  677. default:
  678. }
  679. }, this);
  680. this.get('services').pushObject(hbaseObj);
  681. },
  682. loadMasterValue: function (hbaseMaster) {
  683. var hbaseHostName = this.get('content.masterComponentHosts').filterProperty('display_name', 'HBase Master');
  684. if (hbaseHostName.length == 1) {
  685. hbaseMaster.set('component_value', hbaseHostName[0].hostName);
  686. } else {
  687. hbaseMaster.set('component_value', hbaseHostName[0].hostName + Em.I18n.t('installer.step8.other').format(hbaseHostName.length - 1));
  688. }
  689. },
  690. loadRegionServerValue: function (rsComponent) {
  691. var rsHosts = this.get('content.slaveComponentHosts').findProperty('displayName', 'RegionServer');
  692. var totalRsHosts = rsHosts.hosts.length;
  693. /* var totalGroups = this.get('slaveComponentConfig.components').findProperty('componentName', 'HBASE_REGIONSERVER').groups.length;
  694. var groupLabel;
  695. if (totalGroups == 1) {
  696. groupLabel = 'group';
  697. } else {
  698. groupLabel = 'groups';
  699. } */
  700. rsComponent.set('component_value', totalRsHosts + Em.I18n.t('installer.step8.hosts'));
  701. },
  702. /**
  703. * Load all info about ZooKeeper service
  704. * @param zkObj
  705. */
  706. loadZk: function (zkObj) {
  707. zkObj.get('service_components').forEach(function (_component) {
  708. switch (_component.get('display_name')) {
  709. case 'Servers':
  710. this.loadZkServerValue(_component);
  711. break;
  712. default:
  713. }
  714. }, this);
  715. this.get('services').pushObject(zkObj);
  716. },
  717. loadZkServerValue: function (serverComponent) {
  718. var zkHostNames = this.get('content.masterComponentHosts').filterProperty('display_name', 'ZooKeeper').length;
  719. var hostSuffix;
  720. if (zkHostNames === 1) {
  721. hostSuffix = Em.I18n.t('installer.step8.host');
  722. } else {
  723. hostSuffix = Em.I18n.t('installer.step8.hosts');
  724. }
  725. serverComponent.set('component_value', zkHostNames + ' ' + hostSuffix);
  726. },
  727. /**
  728. * Load all info about Hue services
  729. * @param hueObj
  730. */
  731. loadHue: function (hueObj) {
  732. hueObj.get('service_components').forEach(function (_component) {
  733. switch (_component.get('display_name')) {
  734. case 'Server':
  735. this.loadHueServerValue(_component);
  736. break;
  737. default:
  738. }
  739. }, this);
  740. this.get('services').pushObject(hueObj);
  741. },
  742. loadHueServerValue: function (hueServer) {
  743. var hueServerName = this.get('content.masterComponentHosts').findProperty('display_name', 'Hue Server');
  744. hueServer.set('component_value', hueServerName.hostName);
  745. },
  746. /**
  747. * Load all info about Oozie services
  748. * @param oozieObj
  749. */
  750. loadOozie: function (oozieObj) {
  751. oozieObj.get('service_components').forEach(function (_component) {
  752. switch (_component.get('display_name')) {
  753. case 'Server':
  754. this.loadOozieServerValue(_component);
  755. break;
  756. case 'Database':
  757. // TODO: uncomment when ready to integrate with Oozie Database other than Derby
  758. this.loadOozieDbValue(_component);
  759. break;
  760. default:
  761. }
  762. }, this);
  763. this.get('services').pushObject(oozieObj);
  764. },
  765. loadOozieServerValue: function (oozieServer) {
  766. var oozieServerName = this.get('content.masterComponentHosts').findProperty('display_name', 'Oozie Server');
  767. oozieServer.set('component_value', oozieServerName.hostName);
  768. },
  769. loadOozieDbValue: function (dbComponent) {
  770. var oozieDb = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_database');
  771. if (oozieDb.value === 'New Derby Database'){
  772. var db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_derby_database');
  773. dbComponent.set('component_value', db.value + ' (' + oozieDb.value + ')');
  774. }/* else if (oozieDb.value === 'New MySQL Database') {
  775. dbComponent.set('component_value', 'MySQL (New Database)');
  776. } */else if(oozieDb.value === 'Existing MySQL Database'){
  777. var db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_mysql_database');
  778. dbComponent.set('component_value', db.value + ' (' + oozieDb.value + ')');
  779. } else { // existing oracle database
  780. var db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_oracle_database');
  781. dbComponent.set('component_value', db.value + ' (' + oozieDb.value + ')');
  782. }
  783. },
  784. /**
  785. * Load all info about Nagios service
  786. * @param nagiosObj
  787. */
  788. loadNagios: function (nagiosObj) {
  789. nagiosObj.service_components.forEach(function (_component) {
  790. switch (_component.display_name) {
  791. case 'Server':
  792. this.loadNagiosServerValue(_component);
  793. break;
  794. case 'Administrator':
  795. this.loadNagiosAdminValue(_component);
  796. break;
  797. default:
  798. }
  799. }, this);
  800. this.get('services').pushObject(nagiosObj);
  801. },
  802. loadNagiosServerValue: function (nagiosServer) {
  803. var nagiosServerName = this.get('content.masterComponentHosts').findProperty('display_name', 'Nagios Server');
  804. nagiosServer.set('component_value', nagiosServerName.hostName);
  805. },
  806. loadNagiosAdminValue: function (nagiosAdmin) {
  807. var config = this.get('content.serviceConfigProperties');
  808. var adminLoginName = config.findProperty('name', 'nagios_web_login');
  809. var adminEmail = config.findProperty('name', 'nagios_contact');
  810. nagiosAdmin.set('component_value', adminLoginName.value + ' / (' + adminEmail.value + ')');
  811. },
  812. /**
  813. * Load all info about ganglia
  814. * @param gangliaObj
  815. */
  816. loadGanglia: function (gangliaObj) {
  817. gangliaObj.get('service_components').forEach(function (_component) {
  818. switch (_component.get('display_name')) {
  819. case 'Server':
  820. this.loadGangliaServerValue(_component);
  821. break;
  822. default:
  823. }
  824. }, this);
  825. this.get('services').pushObject(gangliaObj);
  826. },
  827. loadGangliaServerValue: function (gangliaServer) {
  828. var gangliaServerName = this.get('content.masterComponentHosts').findProperty('display_name', 'Ganglia Server');
  829. gangliaServer.set('component_value', gangliaServerName.hostName);
  830. },
  831. loadSqoop: function (sqoopObj) {
  832. this.get('services').pushObject(sqoopObj);
  833. },
  834. loadPig: function (pigObj) {
  835. this.get('services').pushObject(pigObj);
  836. },
  837. loadFalcon: function (falconObj) {
  838. falconObj.get('service_components').forEach(function(component) {
  839. switch (component.get('display_name')) {
  840. case 'Server':
  841. this.loadFalconValue(component);
  842. break;
  843. }
  844. }, this);
  845. this.get('services').pushObject(falconObj);
  846. },
  847. loadFalconValue: function(component) {
  848. var falconHost = this.get('content.masterComponentHosts').filterProperty('display_name', 'Falcon Server');
  849. component.set('component_value', falconHost[0].hostName);
  850. },
  851. loadSTORM: function (stormObj) {
  852. stormObj.get('service_components').forEach(function(component) {
  853. switch (component.get('display_name')) {
  854. case 'Nimbus':
  855. case 'Logviewer Server':
  856. case 'Storm UI Server':
  857. case 'DRPC Server':
  858. this.loadMasterComponentHostValue(component);
  859. break;
  860. case 'SuperVisor':
  861. this.loadSuperVisorValue(component);
  862. break;
  863. default:
  864. }
  865. }, this);
  866. this.get('services').pushObject(stormObj);
  867. },
  868. /**
  869. * Load master component host value
  870. * @method loadMasterComponentHostValue
  871. * @param {Object} component - component object which value should be set
  872. * @param {String} componentName - (optional) display_name of component
  873. */
  874. loadMasterComponentHostValue: function(component, componentName) {
  875. var component_name = componentName || component.get('display_name');
  876. var masterHost = this.get('content.masterComponentHosts').findProperty('display_name', component_name);
  877. component.set('component_value', masterHost.hostName);
  878. },
  879. loadSuperVisorValue: function(component) {
  880. var hostsCount = this.get('content.slaveComponentHosts').findProperty('componentName', 'SUPERVISOR').hosts.length;
  881. var hostsText = hostsCount > 1 ? hostsCount + ' hosts' : hostsCount + ' host'
  882. component.set('component_value', hostsText);
  883. },
  884. /**
  885. * Onclick handler for <code>next</code> button
  886. */
  887. submit: function () {
  888. if (this.get('isSubmitDisabled')) {
  889. return;
  890. }
  891. if ((this.get('content.controllerName') == 'addHostController') && this.get('securityEnabled')) {
  892. var self = this;
  893. App.showConfirmationPopup(function() {
  894. self.submitProceed();
  895. }, Em.I18n.t('installer.step8.securityConfirmationPopupBody'));
  896. }
  897. else {
  898. this.submitProceed();
  899. }
  900. },
  901. submitProceed: function() {
  902. this.set('isSubmitDisabled', true);
  903. this.set('isBackBtnDisabled', true);
  904. if (this.get('content.controllerName') == 'addHostController') {
  905. App.router.get('addHostController').setLowerStepsDisable(4);
  906. }
  907. // checkpoint the cluster status on the server so that the user can resume from where they left off
  908. switch (this.get('content.controllerName')) {
  909. case 'installerController':
  910. App.clusterStatus.setClusterStatus({
  911. clusterName: this.get('clusterName'),
  912. clusterState: 'CLUSTER_DEPLOY_PREP_2',
  913. wizardControllerName: this.get('content.controllerName'),
  914. localdb: App.db.data
  915. });
  916. break;
  917. case 'addHostController':
  918. App.clusterStatus.setClusterStatus({
  919. clusterName: this.get('clusterName'),
  920. clusterState: 'ADD_HOSTS_DEPLOY_PREP_2',
  921. wizardControllerName: this.get('content.controllerName'),
  922. localdb: App.db.data
  923. });
  924. break;
  925. case 'addServiceController':
  926. App.clusterStatus.setClusterStatus({
  927. clusterName: this.get('clusterName'),
  928. clusterState: 'ADD_SERVICES_DEPLOY_PREP_2',
  929. wizardControllerName: this.get('content.controllerName'),
  930. localdb: App.db.data
  931. });
  932. break;
  933. default:
  934. break;
  935. }
  936. // delete any existing clusters to start from a clean slate
  937. // before creating a new cluster in install wizard
  938. // TODO: modify for multi-cluster support
  939. if (this.get('content.controllerName') == 'installerController' && (!App.testMode)) {
  940. var clusterNames = this.getExistingClusterNames();
  941. this.deleteClusters(clusterNames);
  942. }
  943. this.setLocalRepositories();
  944. this.createCluster();
  945. this.createSelectedServices();
  946. this.createConfigurations();
  947. this.createComponents();
  948. this.registerHostsToCluster();
  949. if (App.supports.hostOverridesInstaller) {
  950. this.createConfigurationGroups();
  951. }
  952. this.createAllHostComponents();
  953. this.createHostOverrideConfigurations();
  954. this.ajaxQueueFinished = function () {
  955. console.log('everything is loaded');
  956. App.router.send('next');
  957. };
  958. this.doNextAjaxCall();
  959. },
  960. /**
  961. * Used in progress bar
  962. */
  963. ajaxQueueLength: function () {
  964. return this.get('ajaxQueue').length;
  965. }.property('ajaxQueue.length'),
  966. /**
  967. * Used in progress bar
  968. */
  969. ajaxQueueLeft: 0,
  970. setAmbariUIDb: function () {
  971. var dbContent = this.get('content.slaveGroupProperties');
  972. var slaveComponentConfig = this.get("slaveComponentConfig");
  973. this.persistKeyValues(slaveComponentConfig.version, dbContent);
  974. this.persistKeyValues('current_version', slaveComponentConfig.version);
  975. },
  976. persistKeyValues: function (key, value) {
  977. var str = "{ '" + key + "' : '" + JSON.stringify(value) + "'}";
  978. var obj = eval("(" + str + ")");
  979. this.ajax({
  980. type: "POST",
  981. url: App.apiPrefix + '/persist',
  982. data: JSON.stringify(obj),
  983. beforeSend: function () {
  984. console.log('BeforeSend: persistKeyValues', obj);
  985. }
  986. });
  987. },
  988. clusterName: function () {
  989. return this.get('content.cluster.name');
  990. }.property('content.cluster.name'),
  991. clusterNames: [],
  992. // returns an array of existing cluster names.
  993. // returns an empty array if there are no existing clusters.
  994. getExistingClusterNames: function () {
  995. var url = App.apiPrefix + '/clusters';
  996. App.ajax.send({
  997. name: 'wizard.step8.existing_cluster_names',
  998. sender: this,
  999. success: 'getExistingClusterNamesSuccessCallBack',
  1000. error: 'getExistingClusterNamesErrorCallback'
  1001. });
  1002. return this.get('clusterNames');
  1003. },
  1004. getExistingClusterNamesSuccessCallBack: function (data) {
  1005. var clusterNames = data.items.mapProperty('Clusters.cluster_name');
  1006. console.log("Got existing cluster names: " + clusterNames);
  1007. this.set('clusterNames', clusterNames);
  1008. },
  1009. getExistingClusterNamesErrorCallback: function () {
  1010. console.log("Failed to get existing cluster names");
  1011. this.set('clusterNames', []);
  1012. },
  1013. deleteClusters: function (clusterNames) {
  1014. clusterNames.forEach(function (clusterName) {
  1015. App.ajax.send({
  1016. name: 'wizard.step8.delete_cluster',
  1017. sender: this,
  1018. data: {
  1019. name: clusterName
  1020. },
  1021. success: 'deleteClustersSuccessCallback',
  1022. error: 'deleteClustersErrorCallback'
  1023. });
  1024. }, this);
  1025. },
  1026. deleteClustersSuccessCallback: function(data, opt, params) {
  1027. console.log('DELETE cluster ' + params.name + ' succeeded');
  1028. },
  1029. deleteClustersErrorCallback: function(request, ajaxOptions, error, opt) {
  1030. console.log('DELETE cluster failed');
  1031. },
  1032. /**
  1033. * Updates local repositories for the Ambari server.
  1034. */
  1035. setLocalRepositories: function () {
  1036. if (this.get('content.controllerName') !== 'installerController' || !App.supports.localRepositories) {
  1037. return false;
  1038. }
  1039. var self = this;
  1040. var apiUrl = App.get('stack2VersionURL');
  1041. var stacks = this.get('content.stacks');
  1042. stacks.forEach(function (stack) {
  1043. stack.operatingSystems.forEach(function (os) {
  1044. if (os.baseUrl !== os.originalBaseUrl) {
  1045. console.log("Updating local repository URL from " + os.originalBaseUrl + " -> " + os.baseUrl + ". ", os);
  1046. var url = App.apiPrefix + apiUrl + "/operatingSystems/" + os.osType + "/repositories/" + stack.name;
  1047. self.ajax({
  1048. type: 'PUT',
  1049. url: url,
  1050. data: JSON.stringify({
  1051. "Repositories": {
  1052. "base_url": os.baseUrl
  1053. }
  1054. }),
  1055. beforeSend: function () {
  1056. console.log("BeforeSend: setLocalRepositories PUT to ", url);
  1057. }
  1058. });
  1059. }
  1060. });
  1061. });
  1062. },
  1063. /**
  1064. * The following create* functions are called upon submitting Step 8.
  1065. */
  1066. createCluster: function () {
  1067. if (this.get('content.controllerName') !== 'installerController') {
  1068. return false;
  1069. }
  1070. var clusterName = this.get('clusterName');
  1071. var url = App.apiPrefix + '/clusters/' + clusterName;
  1072. var stackVersion = (this.get('content.installOptions.localRepo')) ? App.currentStackVersion.replace(/(-\d+(\.\d)*)/ig, "Local$&") : App.currentStackVersion;
  1073. this.ajax({
  1074. type: 'POST',
  1075. url: url,
  1076. data: JSON.stringify({ "Clusters": {"version": stackVersion }}),
  1077. beforeSend: function () {
  1078. console.log("BeforeSend: createCluster for " + clusterName);
  1079. }
  1080. });
  1081. },
  1082. createSelectedServices: function () {
  1083. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/services';
  1084. var data = this.createServiceData();
  1085. var httpMethod = 'POST';
  1086. if (!data.length) {
  1087. return;
  1088. }
  1089. this.ajax({
  1090. type: httpMethod,
  1091. url: url,
  1092. data: JSON.stringify(data),
  1093. beforeSend: function () {
  1094. console.log('BeforeSend: createSelectedServices ', data);
  1095. }
  1096. });
  1097. },
  1098. createServiceData: function () {
  1099. var services = this.get('selectedServices').mapProperty('serviceName');
  1100. var data = [];
  1101. services.forEach(function (_service) {
  1102. data.pushObject({"ServiceInfo": { "service_name": _service }});
  1103. }, this);
  1104. return data;
  1105. },
  1106. createComponents: function () {
  1107. var serviceComponents = require('data/service_components');
  1108. var services = this.get('selectedServices').mapProperty('serviceName');
  1109. services.forEach(function (_service) {
  1110. var components = serviceComponents.filterProperty('service_name', _service);
  1111. var componentsData = components.map(function (_component) {
  1112. return { "ServiceComponentInfo": { "component_name": _component.component_name } };
  1113. });
  1114. // Service must be specified in terms of a query for creating multiple components at the same time.
  1115. // See AMBARI-1018.
  1116. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/services?ServiceInfo/service_name=' + _service;
  1117. var data = {
  1118. "components": componentsData
  1119. }
  1120. this.ajax({
  1121. type: 'POST',
  1122. url: url,
  1123. data: JSON.stringify(data),
  1124. beforeSend: function () {
  1125. console.log('BeforeSend: createComponents for ' + _service, componentsData);
  1126. }
  1127. });
  1128. }, this);
  1129. },
  1130. registerHostsToCluster: function () {
  1131. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/hosts';
  1132. var data = this.createRegisterHostData();
  1133. if (data.length == 0) {
  1134. return;
  1135. }
  1136. this.ajax({
  1137. type: 'POST',
  1138. url: url,
  1139. data: JSON.stringify(data),
  1140. beforeSend: function () {
  1141. console.log('BeforeSend: registerHostsToCluster', data);
  1142. }
  1143. });
  1144. },
  1145. createRegisterHostData: function () {
  1146. var hosts = this.getRegisteredHosts().filterProperty('isInstalled', false);
  1147. if (!hosts.length) {
  1148. return [];
  1149. }
  1150. return hosts.map(function (host) {
  1151. return {"Hosts": { "host_name": host.hostName}};
  1152. });
  1153. },
  1154. // TODO: review the code for add hosts / add services scenarios...
  1155. createAllHostComponents: function () {
  1156. var masterHosts = this.get('content.masterComponentHosts');
  1157. var slaveHosts = this.get('content.slaveComponentHosts');
  1158. var clients = this.get('content.clients');
  1159. // note: masterHosts has 'component' vs slaveHosts has 'componentName'
  1160. var masterComponents = masterHosts.mapProperty('component').uniq();
  1161. masterComponents.forEach(function (component) {
  1162. var hostNames = masterHosts.filterProperty('component', component).filterProperty('isInstalled', false).mapProperty('hostName');
  1163. this.registerHostsToComponent(hostNames, component);
  1164. }, this);
  1165. slaveHosts.forEach(function (_slave) {
  1166. if (_slave.componentName !== 'CLIENT') {
  1167. var hostNames = _slave.hosts.filterProperty('isInstalled', false).mapProperty('hostName');
  1168. this.registerHostsToComponent(hostNames, _slave.componentName);
  1169. } else {
  1170. clients.forEach(function (_client) {
  1171. var hostNames = _slave.hosts.mapProperty('hostName');
  1172. switch (_client.component_name) {
  1173. case 'HDFS_CLIENT':
  1174. // install HDFS_CLIENT on HBASE_MASTER, HBASE_REGIONSERVER, WEBHCAT_SERVER, HISTORYSERVER and OOZIE_SERVER hosts
  1175. masterHosts.filterProperty('component', 'HBASE_MASTER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1176. hostNames.pushObject(_masterHost.hostName);
  1177. }, this);
  1178. masterHosts.filterProperty('component', 'HBASE_REGIONSERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1179. hostNames.pushObject(_masterHost.hostName);
  1180. }, this);
  1181. masterHosts.filterProperty('component', 'WEBHCAT_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1182. hostNames.pushObject(_masterHost.hostName);
  1183. }, this);
  1184. masterHosts.filterProperty('component', 'HISTORYSERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1185. hostNames.pushObject(_masterHost.hostName);
  1186. }, this);
  1187. masterHosts.filterProperty('component', 'OOZIE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1188. hostNames.pushObject(_masterHost.hostName);
  1189. }, this);
  1190. break;
  1191. case 'MAPREDUCE_CLIENT':
  1192. // install MAPREDUCE_CLIENT on HIVE_SERVER, OOZIE_SERVER, NAGIOS_SERVER, and WEBHCAT_SERVER hosts
  1193. masterHosts.filterProperty('component', 'HIVE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1194. hostNames.pushObject(_masterHost.hostName);
  1195. }, this);
  1196. masterHosts.filterProperty('component', 'OOZIE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1197. hostNames.pushObject(_masterHost.hostName);
  1198. }, this);
  1199. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1200. hostNames.pushObject(_masterHost.hostName);
  1201. }, this);
  1202. masterHosts.filterProperty('component', 'WEBHCAT_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1203. hostNames.pushObject(_masterHost.hostName);
  1204. }, this);
  1205. break;
  1206. case 'OOZIE_CLIENT':
  1207. // install OOZIE_CLIENT on NAGIOS_SERVER host
  1208. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1209. hostNames.pushObject(_masterHost.hostName);
  1210. }, this);
  1211. break;
  1212. case 'ZOOKEEPER_CLIENT':
  1213. // install ZOOKEEPER_CLIENT on WEBHCAT_SERVER host
  1214. masterHosts.filterProperty('component', 'WEBHCAT_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1215. hostNames.pushObject(_masterHost.hostName);
  1216. }, this);
  1217. break;
  1218. case 'HIVE_CLIENT':
  1219. //install HIVE client on NAGIOS_SERVER host
  1220. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1221. hostNames.pushObject(_masterHost.hostName);
  1222. }, this);
  1223. masterHosts.filterProperty('component', 'HIVE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1224. hostNames.pushObject(_masterHost.hostName);
  1225. }, this);
  1226. break;
  1227. case 'HCAT':
  1228. // install HCAT (client) on NAGIOS_SERVER host
  1229. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1230. hostNames.pushObject(_masterHost.hostName);
  1231. }, this);
  1232. break;
  1233. case 'YARN_CLIENT':
  1234. // install YARN_CLIENT on NAGIOS_SERVER,HIVE_SERVER,OOZIE_SERVER,WEBHCAT_SERVER host
  1235. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1236. hostNames.pushObject(_masterHost.hostName);
  1237. }, this);
  1238. masterHosts.filterProperty('component', 'HIVE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1239. hostNames.pushObject(_masterHost.hostName);
  1240. }, this);
  1241. masterHosts.filterProperty('component', 'OOZIE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1242. hostNames.pushObject(_masterHost.hostName);
  1243. }, this);
  1244. masterHosts.filterProperty('component', 'WEBHCAT_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1245. hostNames.pushObject(_masterHost.hostName);
  1246. }, this);
  1247. break;
  1248. }
  1249. hostNames = hostNames.uniq();
  1250. if (_client.isInstalled) {
  1251. //check whether clients are already installed on selected master hosts!!!
  1252. var installedHosts = _slave.hosts.filterProperty('isInstalled', true).mapProperty('hostName');
  1253. installedHosts.forEach(function (host) {
  1254. if (hostNames.contains(host)) {
  1255. hostNames.splice(hostNames.indexOf(host), 1);
  1256. }
  1257. }, this);
  1258. }
  1259. this.registerHostsToComponent(hostNames, _client.component_name);
  1260. }, this);
  1261. }
  1262. }, this);
  1263. // add Ganglia Monitor (Slave) to all hosts if Ganglia service is selected
  1264. var gangliaService = this.get('content.services').filterProperty('isSelected', true).findProperty('serviceName', 'GANGLIA');
  1265. if (gangliaService) {
  1266. var hosts = this.getRegisteredHosts();
  1267. if (gangliaService.get('isInstalled')) {
  1268. hosts = hosts.filterProperty('isInstalled', false);
  1269. }
  1270. if (hosts.length) {
  1271. this.registerHostsToComponent(hosts.mapProperty('hostName'), 'GANGLIA_MONITOR');
  1272. }
  1273. }
  1274. // add MySQL Server if Hive is selected
  1275. var hiveService = this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false).findProperty('serviceName', 'HIVE');
  1276. if (hiveService) {
  1277. var hiveDb = this.get('content.serviceConfigProperties').findProperty('name', 'hive_database');
  1278. if(hiveDb.value == "New MySQL Database") {
  1279. this.registerHostsToComponent(masterHosts.filterProperty('component', 'HIVE_SERVER').mapProperty('hostName'), 'MYSQL_SERVER');
  1280. }
  1281. }
  1282. },
  1283. registerHostsToComponent: function (hostNames, componentName) {
  1284. if (hostNames.length == 0) {
  1285. return;
  1286. }
  1287. // currently we are specifying the predicate as a query string.
  1288. // this can hit a ~4000-character limit in Jetty server.
  1289. // chunk to multiple calls if needed
  1290. // var hostsPredicate = hostNames.map(function (hostName) {
  1291. // return 'Hosts/host_name=' + hostName;
  1292. // }).join('|');
  1293. var queryStrArr = [];
  1294. var queryStr = '';
  1295. hostNames.forEach(function (hostName) {
  1296. queryStr += 'Hosts/host_name=' + hostName + '|';
  1297. if (queryStr.length > 3500) {
  1298. queryStrArr.push(queryStr.slice(0, -1));
  1299. queryStr = '';
  1300. }
  1301. });
  1302. if (queryStr.length > 0) {
  1303. queryStrArr.push(queryStr.slice(0, -1));
  1304. }
  1305. queryStrArr.forEach(function (queryStr) {
  1306. // console.log('creating host components for ' + queryStr);
  1307. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/hosts?' + queryStr;
  1308. var data = {
  1309. "host_components": [
  1310. {
  1311. "HostRoles": {
  1312. "component_name": componentName
  1313. }
  1314. }
  1315. ]
  1316. };
  1317. this.ajax({
  1318. type: 'POST',
  1319. url: url,
  1320. data: JSON.stringify(data)
  1321. });
  1322. }, this);
  1323. },
  1324. createConfigurations: function () {
  1325. var selectedServices = this.get('selectedServices');
  1326. if (this.get('content.controllerName') == 'installerController') {
  1327. this.get('serviceConfigTags').pushObject(this.createCoreSiteObj());
  1328. this.get('serviceConfigTags').pushObject(this.createHdfsSiteObj());
  1329. this.get('serviceConfigTags').pushObject(this.createLog4jObj('HDFS'));
  1330. }
  1331. var globalSiteObj = this.createGlobalSiteObj();
  1332. if (this.get('content.controllerName') == 'addServiceController') {
  1333. globalSiteObj.tag = 'version' + (new Date).getTime();
  1334. }
  1335. this.get('serviceConfigTags').pushObject(globalSiteObj);
  1336. if (selectedServices.someProperty('serviceName', 'MAPREDUCE')) {
  1337. this.get('serviceConfigTags').pushObject(this.createMrSiteObj());
  1338. if (App.supports.capacitySchedulerUi) {
  1339. this.get('serviceConfigTags').pushObject(this.createCapacityScheduler());
  1340. this.get('serviceConfigTags').pushObject(this.createMapredQueueAcls());
  1341. }
  1342. this.get('serviceConfigTags').pushObject(this.createLog4jObj('MAPREDUCE'));
  1343. }
  1344. if (selectedServices.someProperty('serviceName', 'MAPREDUCE2')) {
  1345. this.get('serviceConfigTags').pushObject(this.createMrSiteObj());
  1346. this.get('serviceConfigTags').pushObject(this.createLog4jObj('MAPREDUCE2'));
  1347. }
  1348. if (selectedServices.someProperty('serviceName', 'YARN')) {
  1349. this.get('serviceConfigTags').pushObject(this.createYarnSiteObj());
  1350. this.get('serviceConfigTags').pushObject(this.createCapacityScheduler());
  1351. this.get('serviceConfigTags').pushObject(this.createLog4jObj('YARN'));
  1352. }
  1353. if (selectedServices.someProperty('serviceName', 'HBASE')) {
  1354. this.get('serviceConfigTags').pushObject(this.createHbaseSiteObj());
  1355. this.get('serviceConfigTags').pushObject(this.createLog4jObj('HBASE'));
  1356. }
  1357. if (selectedServices.someProperty('serviceName', 'OOZIE')) {
  1358. this.get('serviceConfigTags').pushObject(this.createOozieSiteObj('OOZIE'));
  1359. this.get('serviceConfigTags').pushObject(this.createLog4jObj('OOZIE'));
  1360. }
  1361. if (selectedServices.someProperty('serviceName', 'HIVE')) {
  1362. this.get('serviceConfigTags').pushObject(this.createHiveSiteObj('HIVE'));
  1363. this.get('serviceConfigTags').pushObject(this.createLog4jObj('HIVE'));
  1364. this.get('serviceConfigTags').pushObject(this.createLog4jObj('HIVE-EXEC'));
  1365. }
  1366. if (selectedServices.someProperty('serviceName', 'WEBHCAT')) {
  1367. this.get('serviceConfigTags').pushObject(this.createWebHCatSiteObj('WEBHCAT'));
  1368. }
  1369. if (selectedServices.someProperty('serviceName', 'HUE')) {
  1370. this.get('serviceConfigTags').pushObject(this.createHueSiteObj('HUE'));
  1371. }
  1372. if (selectedServices.someProperty('serviceName', 'PIG')) {
  1373. this.get('serviceConfigTags').pushObject(this.createLog4jObj('PIG'));
  1374. }
  1375. if (selectedServices.someProperty('serviceName', 'STORM')) {
  1376. this.get('serviceConfigTags').pushObject(this.createStormSiteObj('STORM'));
  1377. }
  1378. if (selectedServices.someProperty('serviceName', 'ZOOKEEPER')) {
  1379. this.get('serviceConfigTags').pushObject(this.createZooCfgObj());
  1380. this.get('serviceConfigTags').pushObject(this.createLog4jObj('ZOOKEEPER'));
  1381. }
  1382. this.applyConfigurationsToCluster();
  1383. },
  1384. applyConfigurationsToCluster: function() {
  1385. var clusterUrl = App.apiPrefix + '/clusters/' + this.get('clusterName');
  1386. var configData = [];
  1387. this.get('serviceConfigTags').forEach(function (_serviceConfig) {
  1388. var Clusters = {
  1389. Clusters: {
  1390. desired_config: {
  1391. type: _serviceConfig.type,
  1392. tag: _serviceConfig.tag,
  1393. properties: _serviceConfig.properties
  1394. }
  1395. }
  1396. };
  1397. configData.pushObject(JSON.stringify(Clusters));
  1398. }, this);
  1399. var data = {
  1400. configData: '[' + configData.toString() + ']'
  1401. };
  1402. console.debug("applyConfigurationsToCluster(Step8): Applying to URL", clusterUrl, " Data:", data.configData);
  1403. this.ajax({
  1404. type: 'PUT',
  1405. url: clusterUrl,
  1406. data: data.configData,
  1407. beforeSend: function () {
  1408. console.log("BeforeSend: Updating cluster config");
  1409. }
  1410. });
  1411. },
  1412. createConfigurationGroups: function () {
  1413. var configGroups = this.get('content.configGroups').filterProperty('isDefault', false);
  1414. var clusterName = this.get('clusterName');
  1415. var sendData = [];
  1416. var updateData = [];
  1417. var serviceConfigController = App.router.get('mainServiceInfoConfigsController');
  1418. var timeTag = (new Date).getTime();
  1419. var groupsToDelete = App.router.get(this.get('content.controllerName')).getDBProperty('groupsToDelete');
  1420. if (groupsToDelete && groupsToDelete.length > 0) {
  1421. this.removeInstalledServicesConfigurationGroups(groupsToDelete);
  1422. }
  1423. configGroups.forEach(function (configGroup) {
  1424. var groupConfigs = [];
  1425. var groupData = {
  1426. "cluster_name": clusterName,
  1427. "group_name": configGroup.name,
  1428. "tag": configGroup.service.id,
  1429. "description": configGroup.description,
  1430. "hosts": [],
  1431. "desired_configs": []
  1432. };
  1433. configGroup.hosts.forEach(function (hostName) {
  1434. groupData.hosts.push({"host_name": hostName});
  1435. });
  1436. //wrap properties into Em.Object to make them compatible with buildGroupDesiredConfigs method
  1437. configGroup.properties.forEach(function (property) {
  1438. groupConfigs.push(Em.Object.create(property));
  1439. });
  1440. groupData.desired_configs = serviceConfigController.buildGroupDesiredConfigs.call(serviceConfigController, groupConfigs, timeTag);
  1441. // check for group from installed service
  1442. if (configGroup.isForUpdate === true) {
  1443. // if group is a new one, create it
  1444. if (!configGroup.id) {
  1445. sendData.push({"ConfigGroup": groupData});
  1446. } else {
  1447. // update an existing group
  1448. groupData.id = configGroup.id;
  1449. updateData.push({"ConfigGroup": groupData});
  1450. }
  1451. } else {
  1452. sendData.push({"ConfigGroup": groupData});
  1453. }
  1454. //each group should have unique tag to prevent overriding configs from common sites
  1455. timeTag++;
  1456. }, this);
  1457. if (sendData.length > 0) {
  1458. this.applyConfigurationGroups(sendData);
  1459. }
  1460. if (updateData.length > 0) {
  1461. this.applyInstalledServicesConfigurationGroup(updateData);
  1462. }
  1463. },
  1464. applyConfigurationGroups: function (sendData) {
  1465. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/config_groups';
  1466. this.ajax({
  1467. type: 'POST',
  1468. url: url,
  1469. data: JSON.stringify(sendData)
  1470. });
  1471. },
  1472. applyInstalledServicesConfigurationGroup: function (updateData) {
  1473. updateData.forEach(function(item) {
  1474. App.router.get('mainServiceInfoConfigsController').putConfigGroupChanges(item);
  1475. });
  1476. },
  1477. removeInstalledServicesConfigurationGroups: function(groupsToDelete) {
  1478. groupsToDelete.forEach(function(item) {
  1479. App.config.deleteConfigGroup(Em.Object.create(item));
  1480. });
  1481. },
  1482. createGlobalSiteObj: function () {
  1483. var globalSiteProperties = {};
  1484. var globalSiteObj = this.get('globals');
  1485. var isGLUSTERFSSelected = this.get('selectedServices').someProperty('serviceName', 'GLUSTERFS');
  1486. // screen out the GLUSTERFS-specific global config entries when they are not required
  1487. if (!isGLUSTERFSSelected) {
  1488. globalSiteObj = globalSiteObj.filter(function(_config) {
  1489. return _config.name.indexOf("fs_glusterfs") < 0;
  1490. });
  1491. }
  1492. globalSiteObj.forEach(function (_globalSiteObj) {
  1493. var heapsizeException = ['hadoop_heapsize','yarn_heapsize','nodemanager_heapsize','resourcemanager_heapsize'];
  1494. // do not pass any globals whose name ends with _host or _hosts
  1495. if (_globalSiteObj.isRequiredByAgent !== false) {
  1496. // append "m" to JVM memory options except for hadoop_heapsize
  1497. if (/_heapsize|_newsize|_maxnewsize$/.test(_globalSiteObj.name) && !heapsizeException.contains(_globalSiteObj.name)) {
  1498. globalSiteProperties[_globalSiteObj.name] = _globalSiteObj.value + "m";
  1499. } else {
  1500. globalSiteProperties[_globalSiteObj.name] = App.config.escapeXMLCharacters(_globalSiteObj.value);
  1501. }
  1502. }
  1503. this._recordHostOverrideFromObj(_globalSiteObj, 'global', 'version1', this);
  1504. }, this);
  1505. // we don't expose gmond_user to the user; it needs to be the same as gmetad_user
  1506. globalSiteProperties['gmond_user'] = globalSiteProperties['gmetad_user'];
  1507. return {"type": "global", "tag": "version1", "properties": globalSiteProperties};
  1508. },
  1509. createCoreSiteObj: function () {
  1510. var coreSiteObj = this.get('configs').filterProperty('filename', 'core-site.xml');
  1511. var coreSiteProperties = {};
  1512. // hadoop.proxyuser.oozie.hosts needs to be skipped if oozie is not selected
  1513. var isOozieSelected = this.get('selectedServices').someProperty('serviceName', 'OOZIE');
  1514. var oozieUser = this.get('globals').someProperty('name', 'oozie_user') ? this.get('globals').findProperty('name', 'oozie_user').value : null;
  1515. var isHiveSelected = this.get('selectedServices').someProperty('serviceName', 'HIVE');
  1516. var hiveUser = this.get('globals').someProperty('name', 'hive_user') ? this.get('globals').findProperty('name', 'hive_user').value : null;
  1517. var isHcatSelected = this.get('selectedServices').someProperty('serviceName', 'WEBHCAT');
  1518. var hcatUser = this.get('globals').someProperty('name', 'hcat_user') ? this.get('globals').findProperty('name', 'hcat_user').value : null;
  1519. var isGLUSTERFSSelected = this.get('selectedServices').someProperty('serviceName', 'GLUSTERFS');
  1520. // screen out the GLUSTERFS-specific core-site.xml entries when they are not needed
  1521. if (!isGLUSTERFSSelected) {
  1522. coreSiteObj = coreSiteObj.filter(function(_config) {
  1523. return _config.name.indexOf("fs.glusterfs") < 0;
  1524. });
  1525. }
  1526. coreSiteObj.forEach(function (_coreSiteObj) {
  1527. 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'))) {
  1528. coreSiteProperties[_coreSiteObj.name] = App.config.escapeXMLCharacters(_coreSiteObj.value);
  1529. this._recordHostOverrideFromObj(_coreSiteObj, 'core-site', 'version1', this);
  1530. }
  1531. if (isGLUSTERFSSelected && _coreSiteObj.name == "fs.default.name") {
  1532. coreSiteProperties[_coreSiteObj.name] = this.get('globals').someProperty('name', 'fs_glusterfs_default_name') ? App.config.escapeXMLCharacters(this.get('globals').findProperty('name', 'fs_glusterfs_default_name').value) : null;
  1533. }
  1534. if (isGLUSTERFSSelected && _coreSiteObj.name == "fs.defaultFS") {
  1535. coreSiteProperties[_coreSiteObj.name] = this.get('globals').someProperty('name', 'glusterfs_defaultFS_name') ? App.config.escapeXMLCharacters(this.get('globals').findProperty('name', 'glusterfs_defaultFS_name').value) : null;
  1536. }
  1537. console.log("STEP*: name of the property is: " + _coreSiteObj.name);
  1538. console.log("STEP8: value of the property is: " + _coreSiteObj.value);
  1539. }, this);
  1540. return {"type": "core-site", "tag": "version1", "properties": coreSiteProperties};
  1541. },
  1542. createHdfsSiteObj: function () {
  1543. var hdfsSiteObj = this.get('configs').filterProperty('filename', 'hdfs-site.xml');
  1544. var hdfsProperties = {};
  1545. hdfsSiteObj.forEach(function (_configProperty) {
  1546. hdfsProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1547. this._recordHostOverrideFromObj(_configProperty, 'hdfs-site', 'version1', this);
  1548. console.log("STEP*: name of the property is: " + _configProperty.name);
  1549. console.log("STEP8: value of the property is: " + _configProperty.value);
  1550. }, this);
  1551. return {"type": "hdfs-site", "tag": "version1", "properties": hdfsProperties };
  1552. },
  1553. createLog4jObj: function (fileName) {
  1554. fileName = fileName.toLowerCase();
  1555. var Log4jObj = this.get('configs').filterProperty('filename', fileName + '-log4j.xml');
  1556. var Log4jProperties = {};
  1557. Log4jObj.forEach(function (_configProperty) {
  1558. Log4jProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1559. this._recordHostOverrideFromObj(_configProperty, fileName + '-log4j', 'version1', this);
  1560. console.log("STEP*: name of the property is: " + _configProperty.name);
  1561. console.log("STEP8: value of the property is: " + _configProperty.value);
  1562. }, this);
  1563. return {"type": fileName + "-log4j", "tag": "version1", "properties": Log4jProperties };
  1564. },
  1565. createHueSiteObj: function () {
  1566. var hueSiteObj = this.get('configs').filterProperty('filename', 'hue-site.xml');
  1567. var hueProperties = {};
  1568. hueSiteObj.forEach(function (_configProperty) {
  1569. hueProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1570. this._recordHostOverrideFromObj(_configProperty, 'hue-site', 'version1', this);
  1571. console.log("STEP*: name of the property is: " + _configProperty.name);
  1572. console.log("STEP8: value of the property is: " + _configProperty.value);
  1573. }, this);
  1574. return {"type": "hue-site", "tag": "version1", "properties": hueProperties };
  1575. },
  1576. createMrSiteObj: function () {
  1577. var configs = this.get('configs').filterProperty('filename', 'mapred-site.xml');
  1578. var mrProperties = {};
  1579. configs.forEach(function (_configProperty) {
  1580. mrProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1581. this._recordHostOverrideFromObj(_configProperty, 'mapred-site', 'version1', this);
  1582. console.log("STEP*: name of the property is: " + _configProperty.name);
  1583. console.log("STEP8: value of the property is: " + _configProperty.value);
  1584. }, this);
  1585. return {type: 'mapred-site', tag: 'version1', properties: mrProperties};
  1586. },
  1587. createYarnSiteObj: function () {
  1588. var configs = this.get('configs').filterProperty('filename', 'yarn-site.xml');
  1589. var mrProperties = {};
  1590. configs.forEach(function (_configProperty) {
  1591. mrProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1592. this._recordHostOverrideFromObj(_configProperty, 'yarn-site', 'version1', this);
  1593. console.log("STEP*: name of the property is: " + _configProperty.name);
  1594. console.log("STEP8: value of the property is: " + _configProperty.value);
  1595. }, this);
  1596. return {type: 'yarn-site', tag: 'version1', properties: mrProperties};
  1597. },
  1598. createCapacityScheduler: function () {
  1599. var configs = this.get('configs').filterProperty('filename', 'capacity-scheduler.xml');
  1600. var csProperties = {};
  1601. configs.forEach(function (_configProperty) {
  1602. csProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1603. this._recordHostOverrideFromObj(_configProperty, 'capacity-scheduler', 'version1', this);
  1604. console.log("STEP*: name of the property is: " + _configProperty.name);
  1605. console.log("STEP8: value of the property is: " + _configProperty.value);
  1606. }, this);
  1607. return {type: 'capacity-scheduler', tag: 'version1', properties: csProperties};
  1608. },
  1609. createMapredQueueAcls: function () {
  1610. var configs = this.get('configs').filterProperty('filename', 'mapred-queue-acls.xml');
  1611. var mqProperties = {};
  1612. configs.forEach(function (_configProperty) {
  1613. mqProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1614. this._recordHostOverrideFromObj(_configProperty, 'mapred-queue-acls', 'version1', this);
  1615. console.log("STEP*: name of the property is: " + _configProperty.name);
  1616. console.log("STEP8: value of the property is: " + _configProperty.value);
  1617. }, this);
  1618. return {type: 'mapred-queue-acls', tag: 'version1', properties: mqProperties};
  1619. },
  1620. createHbaseSiteObj: function () {
  1621. var configs = this.get('configs').filterProperty('filename', 'hbase-site.xml');
  1622. var hbaseProperties = {};
  1623. configs.forEach(function (_configProperty) {
  1624. hbaseProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1625. this._recordHostOverrideFromObj(_configProperty, 'hbase-site', 'version1', this);
  1626. }, this);
  1627. return {type: 'hbase-site', tag: 'version1', properties: hbaseProperties};
  1628. },
  1629. createOozieSiteObj: function (serviceName) {
  1630. var configs = this.get('configs').filterProperty('filename', 'oozie-site.xml');
  1631. var oozieProperties = {};
  1632. configs.forEach(function (_configProperty) {
  1633. oozieProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1634. this._recordHostOverrideFromObj(_configProperty, 'oozie-site', 'version1', this);
  1635. }, this);
  1636. var globals = this.get('content.serviceConfigProperties').filterProperty('id', 'puppet var');
  1637. if (globals.someProperty('name', 'oozie_database')) {
  1638. var oozieDb = globals.findProperty('name', 'oozie_database');
  1639. if (oozieDb.value === 'New Derby Database') {
  1640. // oozieProperties["oozie.service.JPAService.jdbc.url"] = "jdbc:derby:${oozie.data.dir}/${oozie.db.schema.name}-db;create=true";
  1641. oozieProperties["oozie.service.JPAService.jdbc.driver"] = "org.apache.derby.jdbc.EmbeddedDriver";
  1642. } else if (oozieDb.value === 'Existing MySQL Database') {
  1643. // oozieProperties["oozie.service.JPAService.jdbc.url"] = "jdbc:mysql://" + oozieHost + "/" + oozieDbName;
  1644. oozieProperties["oozie.service.JPAService.jdbc.driver"] = "com.mysql.jdbc.Driver";
  1645. } else { //existing oracle database
  1646. // oozieProperties["oozie.service.JPAService.jdbc.url"] = "jdbc:oracle:thin:@//" + oozieHost + ":1521/" + oozieDbName;
  1647. oozieProperties["oozie.service.JPAService.jdbc.driver"] = "oracle.jdbc.driver.OracleDriver";
  1648. }
  1649. }
  1650. return {type: 'oozie-site', tag: 'version1', properties: oozieProperties};
  1651. },
  1652. createHiveSiteObj: function (serviceName) {
  1653. var configs = this.get('configs').filterProperty('filename', 'hive-site.xml');
  1654. var hiveProperties = {};
  1655. configs.forEach(function (_configProperty) {
  1656. hiveProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1657. this._recordHostOverrideFromObj(_configProperty, 'hive-site', 'version1', this);
  1658. }, this);
  1659. var globals = this.get('content.serviceConfigProperties').filterProperty('id', 'puppet var');
  1660. if (globals.someProperty('name', 'hive_database')) {
  1661. var hiveDb = globals.findProperty('name', 'hive_database');
  1662. if (hiveDb.value === 'New MySQL Database') {
  1663. hiveProperties["javax.jdo.option.ConnectionDriverName"] = "com.mysql.jdbc.Driver";
  1664. } else if (hiveDb.value === 'Existing MySQL Database'){
  1665. hiveProperties["javax.jdo.option.ConnectionDriverName"] = "com.mysql.jdbc.Driver";
  1666. } else { //existing oracle database
  1667. hiveProperties["javax.jdo.option.ConnectionDriverName"] = "oracle.jdbc.driver.OracleDriver";
  1668. }
  1669. }
  1670. return {type: 'hive-site', tag: 'version1', properties: hiveProperties};
  1671. },
  1672. createWebHCatSiteObj: function (serviceName) {
  1673. var configs = this.get('configs').filterProperty('filename', 'webhcat-site.xml');
  1674. var webHCatProperties = {};
  1675. configs.forEach(function (_configProperty) {
  1676. webHCatProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1677. this._recordHostOverrideFromObj(_configProperty, 'webhcat-site', 'version1', this);
  1678. }, this);
  1679. return {type: 'webhcat-site', tag: 'version1', properties: webHCatProperties};
  1680. },
  1681. createZooCfgObj: function () {
  1682. var configs = this.get('configs').filterProperty('filename', 'zoo.cfg');
  1683. var csProperties = {};
  1684. configs.forEach(function (_configProperty) {
  1685. csProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1686. this._recordHostOverrideFromObj(_configProperty, 'zoo.cfg', 'version1', this);
  1687. }, this);
  1688. return {type: 'zoo.cfg', tag: 'version1', properties: csProperties};
  1689. },
  1690. createStormSiteObj: function (s) {
  1691. var configs = this.get('configs').filterProperty('filename', 'storm-site.xml');
  1692. var stormProperties = {};
  1693. configs.forEach(function (_configProperty) {
  1694. if (_configProperty.name == "storm.zookeeper.servers") {
  1695. stormProperties[_configProperty.name] = JSON.stringify(_configProperty.value).replace(/"/g, "'");
  1696. } else {
  1697. stormProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1698. }
  1699. this._recordHostOverrideFromObj(_configProperty, 'storm-site', 'version1', this);
  1700. }, this);
  1701. return {type: 'storm-site', tag: 'version1', properties: stormProperties};
  1702. },
  1703. ajaxQueueFinished: function () {
  1704. //do something
  1705. },
  1706. doNextAjaxCall: function () {
  1707. if (this.get('ajaxBusy')) {
  1708. return;
  1709. }
  1710. var queue = this.get('ajaxQueue');
  1711. if (!queue.length) {
  1712. this.ajaxQueueFinished();
  1713. return;
  1714. }
  1715. var first = queue[0];
  1716. this.set('ajaxQueue', queue.slice(1));
  1717. this.set('ajaxQueueLeft', this.get('ajaxQueue').length);
  1718. this.set('ajaxBusy', true);
  1719. $.ajax(first);
  1720. },
  1721. /**
  1722. * Records all the host overrides per site/tag
  1723. */
  1724. _recordHostOverrideFromObj: function(serviceConfigObj, siteName, tagName, self){
  1725. var overrides = serviceConfigObj.overrides;
  1726. if(overrides && overrides.length>0){
  1727. overrides.forEach(function(override){
  1728. override.hosts.forEach(function(host){
  1729. if(!(host in self.savedHostToOverrideSiteToTagMap)){
  1730. self.savedHostToOverrideSiteToTagMap[host] = {};
  1731. }
  1732. if(!(siteName in self.savedHostToOverrideSiteToTagMap[host])){
  1733. self.savedHostToOverrideSiteToTagMap[host][siteName] = {};
  1734. self.savedHostToOverrideSiteToTagMap[host][siteName].map = {};
  1735. }
  1736. var finalTag = tagName + '_' + host;
  1737. console.log("recordHostOverride(): Saving host override for host="+host+", site="+siteName+", tag="+finalTag+", (key,value)=("+serviceConfigObj.name+","+override.value+")");
  1738. self.savedHostToOverrideSiteToTagMap[host][siteName].tagName = finalTag;
  1739. self.savedHostToOverrideSiteToTagMap[host][siteName].map[serviceConfigObj.name] = override.value;
  1740. });
  1741. });
  1742. }
  1743. },
  1744. /**
  1745. * Creates host level overrides for service configuration.
  1746. *
  1747. */
  1748. createHostOverrideConfigurations: function () {
  1749. var singlePUTHostData = [];
  1750. var savedHostSiteArray = [];
  1751. for ( var host in this.savedHostToOverrideSiteToTagMap) {
  1752. for ( var siteName in this.savedHostToOverrideSiteToTagMap[host]) {
  1753. var tagName = this.savedHostToOverrideSiteToTagMap[host][siteName].tagName;
  1754. var map = this.savedHostToOverrideSiteToTagMap[host][siteName].map;
  1755. savedHostSiteArray.push(host + "///" + siteName);
  1756. singlePUTHostData.push({
  1757. RequestInfo: {
  1758. query: 'Hosts/host_name='+host
  1759. },
  1760. Body: {
  1761. Hosts: {
  1762. desired_config: {
  1763. type: siteName,
  1764. tag: tagName,
  1765. properties: map
  1766. }
  1767. }
  1768. }
  1769. });
  1770. }
  1771. }
  1772. console.log("createHostOverrideConfigSites(): PUTting host-overrides. Data=", singlePUTHostData);
  1773. if(singlePUTHostData.length>0){
  1774. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/hosts';
  1775. this.ajax({
  1776. type: 'PUT',
  1777. url: url,
  1778. data: JSON.stringify(singlePUTHostData),
  1779. dataType: 'text',
  1780. beforeSend: function () {
  1781. console.log("createHostOverrideConfigSites() PUT override=", singlePUTHostData);
  1782. }
  1783. });
  1784. }
  1785. },
  1786. /**
  1787. * We need to do a lot of ajax calls async in special order. To do this,
  1788. * generate array of ajax objects and then send requests step by step. All
  1789. * ajax objects are stored in <code>ajaxQueue</code>
  1790. *
  1791. * @param params
  1792. */
  1793. ajax: function (params) {
  1794. if (App.testMode) return;
  1795. var self = this;
  1796. params = jQuery.extend({
  1797. async: true,
  1798. dataType: 'text',
  1799. statusCode: require('data/statusCodes'),
  1800. timeout: App.timeout,
  1801. error: function (request, ajaxOptions, error) {
  1802. console.log('Step8: In Error ');
  1803. // console.log('Step8: Error message is: ' + request.responseText);
  1804. },
  1805. success: function (data) {
  1806. console.log("TRACE: STep8 -> In success function");
  1807. }
  1808. }, params);
  1809. var success = params.success;
  1810. var error = params.error;
  1811. params.success = function () {
  1812. if (success) {
  1813. success();
  1814. }
  1815. self.set('ajaxBusy', false);
  1816. self.doNextAjaxCall();
  1817. }
  1818. params.error = function (xhr, status, error) {
  1819. var responseText = JSON.parse(xhr.responseText);
  1820. var controller = App.router.get(App.clusterStatus.wizardControllerName);
  1821. controller.registerErrPopup(Em.I18n.t('common.error'), responseText.message);
  1822. self.set('hasErrorOccurred', true);
  1823. // an error will break the ajax call chain and allow submission again
  1824. self.set('isSubmitDisabled', false);
  1825. self.set('isBackBtnDisabled', false);
  1826. App.router.get(self.get('content.controllerName')).setStepsEnable();
  1827. self.get('ajaxQueue').clear();
  1828. self.set('ajaxBusy', false);
  1829. }
  1830. this.get('ajaxQueue').pushObject(params);
  1831. }
  1832. });