service_config.js 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052
  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 validator = require('utils/validator');
  20. App.ServiceConfig = Ember.Object.extend({
  21. serviceName: '',
  22. configCategories: [],
  23. configs: null,
  24. restartRequired: false,
  25. restartRequiredMessage: '',
  26. restartRequiredHostsAndComponents: {},
  27. configGroups: [],
  28. initConfigsLength: 0, // configs length after initialization in order to watch changes
  29. errorCount: function () {
  30. var overrideErrors = 0;
  31. this.get('configs').filterProperty("overrides").forEach(function (e) {
  32. e.overrides.forEach(function (e) {
  33. if (e.error) {
  34. overrideErrors += 1;
  35. }
  36. })
  37. });
  38. var categoryNames = this.get('configCategories').mapProperty('name');
  39. var masterErrors = this.get('configs').filter(function (item) {
  40. return categoryNames.contains(item.get('category'));
  41. }).filterProperty('isValid', false).filterProperty('isVisible', true).get('length');
  42. var slaveErrors = 0;
  43. this.get('configCategories').forEach(function (_category) {
  44. slaveErrors += _category.get('slaveErrorCount');
  45. }, this);
  46. return masterErrors + slaveErrors + overrideErrors;
  47. }.property('configs.@each.isValid', 'configs.@each.isVisible', 'configCategories.@each.slaveErrorCount', 'configs.@each.overrideErrorTrigger'),
  48. isPropertiesChanged: function() {
  49. return this.get('configs').someProperty('isNotDefaultValue') ||
  50. this.get('configs').someProperty('isOverrideChanged') ||
  51. this.get('configs.length') !== this.get('initConfigsLength') ||
  52. (this.get('configs.length') === this.get('initConfigsLength') && this.get('configs').someProperty('defaultValue', null));
  53. }.property('configs.@each.isNotDefaultValue', 'configs.@each.isOverrideChanged', 'configs.length')
  54. });
  55. App.ServiceConfigCategory = Ember.Object.extend({
  56. name: null,
  57. /**
  58. * We cant have spaces in the name as this is being used as HTML element id while rendering. Hence we introduced 'displayName' where we can have spaces like 'Secondary Name Node' etc.
  59. */
  60. displayName: null,
  61. slaveConfigs: null,
  62. /**
  63. * check whether to show custom view in category instead of default
  64. */
  65. isCustomView: false,
  66. customView: null,
  67. /**
  68. * Each category might have a site-name associated (hdfs-site, core-site, etc.)
  69. * and this will be used when determining which category a particular property
  70. * ends up in, based on its site.
  71. */
  72. siteFileName: null,
  73. /**
  74. * Can this category add new properties. Used for custom configurations.
  75. */
  76. canAddProperty: false,
  77. primaryName: function () {
  78. switch (this.get('name')) {
  79. case 'DataNode':
  80. return 'DATANODE';
  81. break;
  82. case 'TaskTracker':
  83. return 'TASKTRACKER';
  84. break;
  85. case 'RegionServer':
  86. return 'HBASE_REGIONSERVER';
  87. }
  88. return null;
  89. }.property('name'),
  90. isForMasterComponent: function () {
  91. var masterServices = [ 'NameNode', 'SNameNode', 'JobTracker', 'HBase Master', 'Oozie Master',
  92. 'Hive Metastore', 'WebHCat Server', 'ZooKeeper Server', 'Nagios', 'Ganglia' ];
  93. return (masterServices.contains(this.get('name')));
  94. }.property('name'),
  95. isForSlaveComponent: function () {
  96. var slaveComponents = ['DataNode', 'TaskTracker', 'RegionServer'];
  97. return (slaveComponents.contains(this.get('name')));
  98. }.property('name'),
  99. slaveErrorCount: function () {
  100. var length = 0;
  101. if (this.get('slaveConfigs.groups')) {
  102. this.get('slaveConfigs.groups').forEach(function (_group) {
  103. length += _group.get('errorCount');
  104. }, this);
  105. }
  106. return length;
  107. }.property('slaveConfigs.groups.@each.errorCount'),
  108. isAdvanced : function(){
  109. var name = this.get('name');
  110. return name.indexOf("Advanced") !== -1 ;
  111. }.property('name')
  112. });
  113. App.SlaveConfigs = Ember.Object.extend({
  114. componentName: null,
  115. displayName: null,
  116. hosts: null,
  117. groups: null
  118. });
  119. App.Group = Ember.Object.extend({
  120. name: null,
  121. hostNames: null,
  122. properties: null,
  123. errorCount: function () {
  124. if (this.get('properties')) {
  125. return this.get('properties').filterProperty('isValid', false).filterProperty('isVisible', true).get('length');
  126. }
  127. }.property('properties.@each.isValid', 'properties.@each.isVisible')
  128. });
  129. App.ServiceConfigProperty = Em.Object.extend({
  130. id: '', //either 'puppet var' or 'site property'
  131. name: '',
  132. displayName: '',
  133. value: '',
  134. retypedPassword: '',
  135. defaultValue: '',
  136. defaultDirectory: '',
  137. description: '',
  138. displayType: 'string', // string, digits, number, directories, custom
  139. unit: '',
  140. category: 'General',
  141. isRequired: true, // by default a config property is required
  142. isReconfigurable: true, // by default a config property is reconfigurable
  143. isEditable: true, // by default a config property is editable
  144. isNotEditable: Ember.computed.not('isEditable'),
  145. isFinal: false,
  146. hideFinalIcon: function () {
  147. return (!this.get('isFinal'))&& this.get('isNotEditable');
  148. }.property('isFinal', 'isNotEditable'),
  149. defaultIsFinal: false,
  150. supportsFinal: false,
  151. isVisible: true,
  152. isMock: false, // mock config created created only to displaying
  153. isRequiredByAgent: true, // Setting it to true implies property will be stored in configuration
  154. isSecureConfig: false,
  155. errorMessage: '',
  156. warnMessage: '',
  157. serviceConfig: null, // points to the parent App.ServiceConfig object
  158. filename: '',
  159. isOriginalSCP : true, // if true, then this is original SCP instance and its value is not overridden value.
  160. parentSCP: null, // This is the main SCP which is overridden by this. Set only when isOriginalSCP is false.
  161. selectedHostOptions : null, // contain array of hosts configured with overridden value
  162. overrides : null,
  163. overrideValues: [],
  164. group: null, // Contain group related to this property. Set only when isOriginalSCP is false.
  165. isUserProperty: null, // This property was added by user. Hence they get removal actions etc.
  166. isOverridable: true,
  167. compareConfigs: [],
  168. isComparison: false,
  169. hasCompareDiffs: false,
  170. showLabel: true,
  171. error: false,
  172. warn: false,
  173. overrideErrorTrigger: 0, //Trigger for overrridable property error
  174. isRestartRequired: false,
  175. restartRequiredMessage: 'Restart required',
  176. index: null, //sequence number in category
  177. editDone: false, //Text field: on focusOut: true, on focusIn: false
  178. serviceValidator: null,
  179. isNotSaved: false, // user property was added but not saved
  180. hasInitialValue: false, //if true then property value is defined and saved to server
  181. isHiddenByFilter: false, //if true then hide this property (filtered out)
  182. rowStyleClass: null, // CSS-Class to be applied on the row showing this config
  183. /**
  184. * Usage example see on <code>App.ServiceConfigRadioButtons.handleDBConnectionProperty()</code>
  185. *
  186. * @property {Ember.View} additionalView - custom view related to property
  187. **/
  188. additionalView: null,
  189. /**
  190. * On Overridable property error message, change overrideErrorTrigger value to recount number of errors service have
  191. */
  192. observeErrors: function () {
  193. this.set("overrideErrorTrigger", this.get("overrideErrorTrigger") + 1);
  194. }.observes("overrides.@each.errorMessage"),
  195. /**
  196. * No override capabilities for fields which are not edtiable
  197. * and fields which represent master hosts.
  198. */
  199. isPropertyOverridable: function () {
  200. var overrideable = this.get('isOverridable');
  201. var editable = this.get('isEditable');
  202. var overrides = this.get('overrides');
  203. var dt = this.get('displayType');
  204. return overrideable && (editable || !overrides || !overrides.length) && ("masterHost" != dt);
  205. }.property('isEditable', 'displayType', 'isOverridable', 'overrides.length'),
  206. isOverridden: function() {
  207. var overrides = this.get('overrides');
  208. return (overrides != null && overrides.get('length')>0) || !this.get('isOriginalSCP');
  209. }.property('overrides', 'overrides.length', 'isOriginalSCP'),
  210. isOverrideChanged: function () {
  211. if (Em.isNone(this.get('overrides')) && this.get('overrideValues.length') === 0) return false;
  212. return JSON.stringify(this.get('overrides').mapProperty('isFinal')) !== JSON.stringify(this.get('overrideIsFinalValues'))
  213. || JSON.stringify(this.get('overrides').mapProperty('value')) !== JSON.stringify(this.get('overrideValues'));
  214. }.property('isOverridden', 'overrides.@each.isNotDefaultValue'),
  215. isRemovable: function() {
  216. var isOriginalSCP = this.get('isOriginalSCP');
  217. var isUserProperty = this.get('isUserProperty');
  218. var isEditable = this.get('isEditable');
  219. var hasOverrides = this.get('overrides.length') > 0;
  220. // Removable when this is a user property, or it is not an original property and it is editable
  221. return isEditable && !hasOverrides && (isUserProperty || !isOriginalSCP);
  222. }.property('isUserProperty', 'isOriginalSCP', 'overrides.length'),
  223. init: function () {
  224. if(this.get("displayType")=="password"){
  225. this.set('retypedPassword', this.get('value'));
  226. }
  227. if ((this.get('id') === 'puppet var') && this.get('value') == '') {
  228. this.set('value', this.get('defaultValue'));
  229. }
  230. // TODO: remove mock data
  231. },
  232. /**
  233. * Indicates when value is not the default value.
  234. * Returns false when there is no default value.
  235. */
  236. isNotDefaultValue: function () {
  237. var value = this.get('value');
  238. var defaultValue = this.get('defaultValue');
  239. var supportsFinal = this.get('supportsFinal');
  240. var isFinal = this.get('isFinal');
  241. var defaultIsFinal = this.get('defaultIsFinal');
  242. var isEditable = this.get('isEditable');
  243. return isEditable && ((defaultValue != null && value !== defaultValue) || (supportsFinal && isFinal !== defaultIsFinal));
  244. }.property('value', 'defaultValue', 'isEditable', 'isFinal', 'defaultIsFinal'),
  245. /**
  246. * Don't show "Undo" for hosts on Installer Step7
  247. */
  248. cantBeUndone: function() {
  249. var types = ["masterHost", "slaveHosts", "masterHosts", "slaveHost","radio button"];
  250. var displayType = this.get('displayType');
  251. var result = false;
  252. types.forEach(function(type) {
  253. if (type === displayType) {
  254. result = true;
  255. }
  256. });
  257. return result;
  258. }.property('displayType'),
  259. initialValue: function (localDB, hiveMetastoreUrisDefault) {
  260. var masterComponentHostsInDB = localDB.masterComponentHosts;
  261. //console.log("value in initialvalue: " + JSON.stringify(masterComponentHostsInDB));
  262. var hostsInfo = localDB.hosts; // which we are setting in installerController in step3.
  263. var slaveComponentHostsInDB = localDB.slaveComponentHosts;
  264. var isOnlyFirstOneNeeded = true;
  265. var hostWithPort = "([\\w|\\.]*)(?=:)";
  266. var hostWithPrefix = ":\/\/" + hostWithPort;
  267. switch (this.get('name')) {
  268. case 'namenode_host':
  269. this.set('value', masterComponentHostsInDB.filterProperty('component', 'NAMENODE').mapProperty('hostName'));
  270. break;
  271. case 'dfs.http.address':
  272. var nnHost = masterComponentHostsInDB.findProperty('component', 'NAMENODE').hostName;
  273. this.setDefaultValue(hostWithPort,nnHost);
  274. break;
  275. case 'dfs.namenode.http-address':
  276. var nnHost = masterComponentHostsInDB.findProperty('component', 'NAMENODE').hostName;
  277. this.setDefaultValue(hostWithPort,nnHost);
  278. break;
  279. case 'dfs.https.address':
  280. var nnHost = masterComponentHostsInDB.findProperty('component', 'NAMENODE').hostName;
  281. this.setDefaultValue(hostWithPort,nnHost);
  282. break;
  283. case 'dfs.namenode.https-address':
  284. var nnHost = masterComponentHostsInDB.findProperty('component', 'NAMENODE').hostName;
  285. this.setDefaultValue(hostWithPort,nnHost);
  286. break;
  287. case 'fs.default.name':
  288. var nnHost = masterComponentHostsInDB.filterProperty('component', 'NAMENODE').mapProperty('hostName');
  289. this.setDefaultValue(hostWithPrefix,'://' + nnHost);
  290. break;
  291. case 'fs.defaultFS':
  292. var nnHost = masterComponentHostsInDB.filterProperty('component', 'NAMENODE').mapProperty('hostName');
  293. this.setDefaultValue(hostWithPrefix,'://' + nnHost);
  294. break;
  295. case 'hbase.rootdir':
  296. var nnHost = masterComponentHostsInDB.filterProperty('component', 'NAMENODE').mapProperty('hostName');
  297. this.setDefaultValue(hostWithPrefix,'://' + nnHost);
  298. break;
  299. case 'snamenode_host':
  300. // Secondary NameNode does not exist when NameNode HA is enabled
  301. var snn = masterComponentHostsInDB.findProperty('component', 'SECONDARY_NAMENODE');
  302. if (snn) {
  303. this.set('value', snn.hostName);
  304. }
  305. break;
  306. case 'dfs.secondary.http.address':
  307. var snnHost = masterComponentHostsInDB.findProperty('component', 'SECONDARY_NAMENODE');
  308. if (snnHost) {
  309. this.setDefaultValue(hostWithPort,snnHost.hostName);
  310. }
  311. break;
  312. case 'dfs.namenode.secondary.http-address':
  313. var snnHost = masterComponentHostsInDB.findProperty('component', 'SECONDARY_NAMENODE');
  314. if (snnHost) {
  315. this.setDefaultValue(hostWithPort,snnHost.hostName);
  316. }
  317. break;
  318. case 'datanode_hosts':
  319. this.set('value', slaveComponentHostsInDB.findProperty('componentName', 'DATANODE').hosts.mapProperty('hostName'));
  320. break;
  321. case 'hs_host':
  322. this.set('value', masterComponentHostsInDB.filterProperty('component', 'HISTORYSERVER').mapProperty('hostName'));
  323. break;
  324. case 'yarn.log.server.url':
  325. var hsHost = masterComponentHostsInDB.filterProperty('component', 'HISTORYSERVER').mapProperty('hostName');
  326. this.setDefaultValue(hostWithPrefix,'://' + hsHost);
  327. break;
  328. case 'mapreduce.jobhistory.webapp.address':
  329. var hsHost = masterComponentHostsInDB.filterProperty('component', 'HISTORYSERVER').mapProperty('hostName');
  330. this.setDefaultValue(hostWithPort,hsHost);
  331. break;
  332. case 'mapreduce.jobhistory.address':
  333. var hsHost = masterComponentHostsInDB.filterProperty('component', 'HISTORYSERVER').mapProperty('hostName');
  334. this.setDefaultValue(hostWithPort,hsHost);
  335. break;
  336. case 'rm_host':
  337. this.set('value', masterComponentHostsInDB.findProperty('component', 'RESOURCEMANAGER').hostName);
  338. break;
  339. case 'ats_host':
  340. var atsHost = masterComponentHostsInDB.findProperty('component', 'APP_TIMELINE_SERVER');
  341. if (atsHost)
  342. this.set('value', atsHost.hostName);
  343. else
  344. this.set('value', 'false');
  345. break;
  346. case 'yarn.resourcemanager.hostname':
  347. var rmHost = masterComponentHostsInDB.findProperty('component', 'RESOURCEMANAGER').hostName;
  348. this.set('defaultValue',rmHost);
  349. this.set('value',this.get('defaultValue'));
  350. break;
  351. case 'yarn.resourcemanager.resource-tracker.address':
  352. var rmHost = masterComponentHostsInDB.findProperty('component', 'RESOURCEMANAGER').hostName;
  353. this.setDefaultValue(hostWithPort,rmHost);
  354. break;
  355. case 'yarn.resourcemanager.webapp.address':
  356. var rmHost = masterComponentHostsInDB.findProperty('component', 'RESOURCEMANAGER').hostName;
  357. this.setDefaultValue(hostWithPort,rmHost);
  358. break;
  359. case 'yarn.resourcemanager.scheduler.address':
  360. var rmHost = masterComponentHostsInDB.findProperty('component', 'RESOURCEMANAGER').hostName;
  361. this.setDefaultValue(hostWithPort,rmHost);
  362. break;
  363. case 'yarn.resourcemanager.address':
  364. var rmHost = masterComponentHostsInDB.findProperty('component', 'RESOURCEMANAGER').hostName;
  365. this.setDefaultValue(hostWithPort,rmHost);
  366. break;
  367. case 'yarn.resourcemanager.admin.address':
  368. var rmHost = masterComponentHostsInDB.findProperty('component', 'RESOURCEMANAGER').hostName;
  369. this.setDefaultValue(hostWithPort,rmHost);
  370. break;
  371. case 'yarn.timeline-service.webapp.address':
  372. var atsHost = masterComponentHostsInDB.findProperty('component', 'APP_TIMELINE_SERVER');
  373. if (atsHost && atsHost.hostName) {
  374. this.setDefaultValue(hostWithPort,atsHost.hostName);
  375. }
  376. break;
  377. case 'yarn.timeline-service.webapp.https.address':
  378. var atsHost = masterComponentHostsInDB.findProperty('component', 'APP_TIMELINE_SERVER');
  379. if (atsHost && atsHost.hostName) {
  380. this.setDefaultValue(hostWithPort,atsHost.hostName);
  381. }
  382. break;
  383. case 'yarn.timeline-service.address':
  384. var atsHost = masterComponentHostsInDB.findProperty('component', 'APP_TIMELINE_SERVER');
  385. if (atsHost && atsHost.hostName) {
  386. this.setDefaultValue(hostWithPort,atsHost.hostName);
  387. }
  388. break;
  389. case 'nm_hosts':
  390. this.set('value', slaveComponentHostsInDB.findProperty('componentName', 'NODEMANAGER').hosts.mapProperty('hostName'));
  391. break;
  392. case 'jobtracker_host':
  393. this.set('value', masterComponentHostsInDB.findProperty('component', 'JOBTRACKER').hostName);
  394. break;
  395. case 'mapred.job.tracker':
  396. var jtHost = masterComponentHostsInDB.findProperty('component', 'JOBTRACKER').hostName;
  397. this.setDefaultValue(hostWithPort,jtHost);
  398. break;
  399. case 'mapred.job.tracker.http.address':
  400. var jtHost = masterComponentHostsInDB.findProperty('component', 'JOBTRACKER').hostName;
  401. this.setDefaultValue(hostWithPort,jtHost);
  402. break;
  403. case 'mapreduce.history.server.http.address':
  404. var jtHost = masterComponentHostsInDB.findProperty('component', 'HISTORYSERVER').hostName;
  405. this.setDefaultValue(hostWithPort,jtHost);
  406. break;
  407. case 'tasktracker_hosts':
  408. this.set('value', slaveComponentHostsInDB.findProperty('componentName', 'TASKTRACKER').hosts.mapProperty('hostName'));
  409. break;
  410. case 'hbasemaster_host':
  411. this.set('value', masterComponentHostsInDB.filterProperty('component', 'HBASE_MASTER').mapProperty('hostName'));
  412. break;
  413. case 'regionserver_hosts':
  414. this.set('value', slaveComponentHostsInDB.findProperty('componentName', 'HBASE_REGIONSERVER').hosts.mapProperty('hostName'));
  415. break;
  416. case 'hivemetastore_host':
  417. this.set('value', masterComponentHostsInDB.filterProperty('component', 'HIVE_METASTORE').mapProperty('hostName'));
  418. break;
  419. case 'hive_ambari_host':
  420. this.set('value', masterComponentHostsInDB.findProperty('component', 'HIVE_SERVER').hostName);
  421. break;
  422. case 'hive_master_hosts':
  423. var hostNames = masterComponentHostsInDB.filter(function (masterComponent) {
  424. return ['HIVE_METASTORE', 'HIVE_SERVER'].contains(masterComponent.component);
  425. });
  426. this.set('value', hostNames.mapProperty('hostName').uniq().join(','));
  427. break;
  428. case 'hive_database':
  429. var newMySQLDBOption = this.get('options').findProperty('displayName', 'New MySQL Database');
  430. if (newMySQLDBOption) {
  431. var isNewMySQLDBOptionHidden = !App.get('supports.alwaysEnableManagedMySQLForHive') && App.get('router.currentState.name') != 'configs' &&
  432. !App.get('isManagedMySQLForHiveEnabled');
  433. if (isNewMySQLDBOptionHidden && this.get('value') == 'New MySQL Database') {
  434. this.set('value', 'Existing MySQL Database');
  435. }
  436. Em.set(newMySQLDBOption, 'hidden', isNewMySQLDBOptionHidden);
  437. }
  438. break;
  439. case 'oozieserver_host':
  440. this.set('value', masterComponentHostsInDB.findProperty('component', 'OOZIE_SERVER').hostName);
  441. break;
  442. case 'oozie.base.url':
  443. var oozieHost = masterComponentHostsInDB.findProperty('component', 'OOZIE_SERVER').hostName;
  444. this.setDefaultValue(hostWithPrefix,'://' + oozieHost);
  445. break;
  446. case 'webhcatserver_host':
  447. this.set('value', masterComponentHostsInDB.findProperty('component', 'WEBHCAT_SERVER').hostName);
  448. break;
  449. case 'oozie_ambari_host':
  450. this.set('value', masterComponentHostsInDB.findProperty('component', 'OOZIE_SERVER').hostName);
  451. break;
  452. case 'hadoop_host':
  453. this.set('value', masterComponentHostsInDB.filterProperty('component', 'NAMENODE').mapProperty('hostName'));
  454. break;
  455. case 'hive_existing_mysql_host':
  456. case 'hive_existing_postgresql_host':
  457. case 'hive_existing_oracle_host':
  458. case 'hive_existing_mssql_server_host':
  459. case 'hive_existing_mssql_server_2_host':
  460. var hiveServerHost = masterComponentHostsInDB.findProperty('component', 'HIVE_SERVER').hostName;
  461. this.set('value', hiveServerHost).set('defaultValue', hiveServerHost);
  462. break;
  463. case 'hive.metastore.uris':
  464. var hiveMSUris = this.getHiveMetastoreUris(masterComponentHostsInDB, hiveMetastoreUrisDefault);
  465. if (hiveMSUris) {
  466. this.setDefaultValue("(.*)", hiveMSUris);
  467. }
  468. break;
  469. case 'oozie_existing_mysql_host':
  470. case 'oozie_existing_postgresql_host':
  471. case 'oozie_existing_oracle_host':
  472. case 'oozie_existing_mssql_server_host':
  473. case 'oozie_existing_mssql_server_2_host':
  474. var oozieServerHost = masterComponentHostsInDB.findProperty('component', 'OOZIE_SERVER').hostName;
  475. this.set('value', oozieServerHost).set('defaultValue', oozieServerHost);
  476. break;
  477. case 'storm.zookeeper.servers':
  478. case 'zookeeperserver_hosts':
  479. this.set('value', masterComponentHostsInDB.filterProperty('component', 'ZOOKEEPER_SERVER').mapProperty('hostName'));
  480. break;
  481. case 'nimbus.host':
  482. this.set('value', masterComponentHostsInDB.findProperty('component', 'NIMBUS').hostName);
  483. break;
  484. case 'falconserver_host':
  485. this.set('value', masterComponentHostsInDB.findProperty('component', 'FALCON_SERVER').hostName);
  486. break;
  487. case 'drpcserver_host':
  488. var drpcHost = masterComponentHostsInDB.findProperty('component', 'DRPC_SERVER');
  489. if (drpcHost) {
  490. this.set('value', drpcHost.hostName);
  491. }
  492. break;
  493. case 'stormuiserver_host':
  494. this.set('value', masterComponentHostsInDB.findProperty('component', 'STORM_UI_SERVER').hostName);
  495. break;
  496. case 'storm_rest_api_host':
  497. var stormRresApiHost = masterComponentHostsInDB.findProperty('component', 'STORM_REST_API');
  498. if(stormRresApiHost) {
  499. this.set('value', stormRresApiHost.hostName);
  500. }
  501. break;
  502. case 'supervisor_hosts':
  503. this.set('value', slaveComponentHostsInDB.findProperty('componentName', 'SUPERVISOR').hosts.mapProperty('hostName'));
  504. break;
  505. case 'knox_gateway_host':
  506. this.set('value', masterComponentHostsInDB.findProperty('component', 'KNOX_GATEWAY').hostName);
  507. break;
  508. case 'kafka_broker_hosts':
  509. this.set('value', masterComponentHostsInDB.filterProperty('component', 'KAFKA_BROKER').mapProperty('hostName'));
  510. break;
  511. case 'kafka.ganglia.metrics.host':
  512. var gangliaHost = masterComponentHostsInDB.findProperty('component', 'GANGLIA_SERVER');
  513. if (gangliaHost) {
  514. this.set('value', gangliaHost.hostName);
  515. }
  516. break;
  517. case 'hbase.zookeeper.quorum':
  518. if (this.get('filename') == 'hbase-site.xml') {
  519. var zkHosts = masterComponentHostsInDB.filterProperty('component', 'ZOOKEEPER_SERVER').mapProperty('hostName');
  520. this.setDefaultValue("(\\w*)", zkHosts);
  521. }
  522. break;
  523. case 'zookeeper.connect':
  524. case 'hive.zookeeper.quorum':
  525. case 'templeton.zookeeper.hosts':
  526. case 'hadoop.registry.zk.quorum':
  527. case 'hive.cluster.delegation.token.store.zookeeper.connectString':
  528. var zkHosts = masterComponentHostsInDB.filterProperty('component', 'ZOOKEEPER_SERVER').mapProperty('hostName');
  529. var zkHostPort = zkHosts;
  530. var regex = "\\w*:(\\d+)"; //regex to fetch the port
  531. var portValue = this.get('defaultValue').match(new RegExp(regex));
  532. if (!portValue) return;
  533. if (portValue[1]) {
  534. for ( var i = 0; i < zkHosts.length; i++ ) {
  535. zkHostPort[i] = zkHosts[i] + ":" + portValue[1];
  536. }
  537. }
  538. this.setDefaultValue("(.*)", zkHostPort);
  539. break;
  540. case 'templeton.hive.properties':
  541. var hiveMSUris = this.getHiveMetastoreUris(masterComponentHostsInDB, hiveMetastoreUrisDefault).replace(',', '\\,');
  542. if (/\/\/localhost:/g.test(this.get('value'))) {
  543. this.set('defaultValue', this.get('value') + ',hive.metastore.execute.setugi=true');
  544. }
  545. this.setDefaultValue("(hive\\.metastore\\.uris=)([^\\,]+)", "$1" + hiveMSUris);
  546. break;
  547. case 'dfs.name.dir':
  548. case 'dfs.namenode.name.dir':
  549. case 'dfs.data.dir':
  550. case 'dfs.datanode.data.dir':
  551. case 'yarn.nodemanager.local-dirs':
  552. case 'yarn.nodemanager.log-dirs':
  553. case 'mapred.local.dir':
  554. case 'log.dirs': // for Kafka Broker
  555. this.unionAllMountPoints(!isOnlyFirstOneNeeded, localDB);
  556. break;
  557. case 'hbase.tmp.dir':
  558. if (this.get('filename') == 'hbase-site.xml') {
  559. this.unionAllMountPoints(isOnlyFirstOneNeeded, localDB);
  560. }
  561. break;
  562. case 'fs.checkpoint.dir':
  563. case 'dfs.namenode.checkpoint.dir':
  564. case 'yarn.timeline-service.leveldb-timeline-store.path':
  565. case 'dataDir':
  566. case 'oozie_data_dir':
  567. case 'storm.local.dir':
  568. case '*.falcon.graph.storage.directory':
  569. case '*.falcon.graph.serialize.path':
  570. this.unionAllMountPoints(isOnlyFirstOneNeeded, localDB);
  571. break;
  572. case '*.broker.url':
  573. var falconServerHost = masterComponentHostsInDB.findProperty('component', 'FALCON_SERVER').hostName;
  574. this.setDefaultValue('localhost', falconServerHost);
  575. break;
  576. }
  577. },
  578. /**
  579. * Get hive.metastore.uris initial value
  580. * @param hosts
  581. * @param defaultValue
  582. * @returns {string}
  583. */
  584. getHiveMetastoreUris: function (hosts, defaultValue) {
  585. var hiveMSHosts = hosts.filterProperty('component', 'HIVE_METASTORE').mapProperty('hostName'),
  586. hiveMSUris = hiveMSHosts,
  587. regex = "\\w*:(\\d+)",
  588. portValue = defaultValue && defaultValue.match(new RegExp(regex));
  589. if (!portValue) return '';
  590. if (portValue[1]) {
  591. for (var i = 0; i < hiveMSHosts.length; i++) {
  592. hiveMSUris[i] = "thrift://" + hiveMSHosts[i] + ":" + portValue[1];
  593. }
  594. }
  595. return hiveMSUris.join(',');
  596. },
  597. /**
  598. * @param regex : String
  599. * @param replaceWith : String
  600. */
  601. setDefaultValue: function(regex,replaceWith) {
  602. var defaultValue = this.get('defaultValue');
  603. var re = new RegExp(regex);
  604. defaultValue = defaultValue.replace(re,replaceWith);
  605. this.set('defaultValue',defaultValue);
  606. this.set('value',this.get('defaultValue'));
  607. },
  608. unionAllMountPoints: function (isOnlyFirstOneNeeded, localDB) {
  609. var hostname = '';
  610. var mountPointsPerHost = [];
  611. var mountPointAsRoot;
  612. var masterComponentHostsInDB = localDB.masterComponentHosts;
  613. var slaveComponentHostsInDB = localDB.slaveComponentHosts;
  614. var hostsInfo = localDB.hosts; // which we are setting in installerController in step3.
  615. //all hosts should be in local storage without using App.Host model
  616. App.Host.find().forEach(function(item){
  617. if(!hostsInfo[item.get('id')]){
  618. hostsInfo[item.get('id')] = {
  619. name: item.get('id'),
  620. cpu: item.get('cpu'),
  621. memory: item.get('memory'),
  622. disk_info: item.get('diskInfo'),
  623. bootStatus: "REGISTERED",
  624. isInstalled: true
  625. };
  626. }
  627. });
  628. var temp = '';
  629. var setOfHostNames = [];
  630. var components = [];
  631. switch (this.get('name')) {
  632. case 'dfs.namenode.name.dir':
  633. case 'dfs.name.dir':
  634. components = masterComponentHostsInDB.filterProperty('component', 'NAMENODE');
  635. components.forEach(function (component) {
  636. setOfHostNames.push(component.hostName);
  637. }, this);
  638. break;
  639. case 'fs.checkpoint.dir':
  640. case 'dfs.namenode.checkpoint.dir':
  641. components = masterComponentHostsInDB.filterProperty('component', 'SECONDARY_NAMENODE');
  642. components.forEach(function (component) {
  643. setOfHostNames.push(component.hostName);
  644. }, this);
  645. break;
  646. case 'dfs.data.dir':
  647. case 'dfs.datanode.data.dir':
  648. temp = slaveComponentHostsInDB.findProperty('componentName', 'DATANODE');
  649. temp.hosts.forEach(function (host) {
  650. setOfHostNames.push(host.hostName);
  651. }, this);
  652. break;
  653. case 'mapred.local.dir':
  654. temp = slaveComponentHostsInDB.findProperty('componentName', 'TASKTRACKER') || slaveComponentHostsInDB.findProperty('componentName', 'NODEMANAGER');
  655. temp.hosts.forEach(function (host) {
  656. setOfHostNames.push(host.hostName);
  657. }, this);
  658. break;
  659. case 'yarn.nodemanager.log-dirs':
  660. case 'yarn.nodemanager.local-dirs':
  661. temp = slaveComponentHostsInDB.findProperty('componentName', 'NODEMANAGER');
  662. temp.hosts.forEach(function (host) {
  663. setOfHostNames.push(host.hostName);
  664. }, this);
  665. break;
  666. case 'yarn.timeline-service.leveldb-timeline-store.path':
  667. components = masterComponentHostsInDB.filterProperty('component', 'APP_TIMELINE_SERVER');
  668. components.forEach(function (component) {
  669. setOfHostNames.push(component.hostName);
  670. }, this);
  671. break;
  672. case 'dataDir':
  673. components = masterComponentHostsInDB.filterProperty('component', 'ZOOKEEPER_SERVER');
  674. components.forEach(function (component) {
  675. setOfHostNames.push(component.hostName);
  676. }, this);
  677. break;
  678. case 'oozie_data_dir':
  679. components = masterComponentHostsInDB.filterProperty('component', 'OOZIE_SERVER');
  680. components.forEach(function (component) {
  681. setOfHostNames.push(component.hostName);
  682. }, this);
  683. break;
  684. case 'hbase.tmp.dir':
  685. temp = slaveComponentHostsInDB.findProperty('componentName', 'HBASE_REGIONSERVER');
  686. temp.hosts.forEach(function (host) {
  687. setOfHostNames.push(host.hostName);
  688. }, this);
  689. break;
  690. case 'storm.local.dir':
  691. temp = slaveComponentHostsInDB.findProperty('componentName', 'SUPERVISOR');
  692. temp.hosts.forEach(function (host) {
  693. setOfHostNames.push(host.hostName);
  694. }, this);
  695. components = masterComponentHostsInDB.filterProperty('component', 'NIMBUS');
  696. components.forEach(function (component) {
  697. setOfHostNames.push(component.hostName);
  698. }, this);
  699. break;
  700. case '*.falcon.graph.storage.directory':
  701. case '*.falcon.graph.serialize.path':
  702. components = masterComponentHostsInDB.filterProperty('component', 'FALCON_SERVER');
  703. components.forEach(function (component) {
  704. setOfHostNames.push(component.hostName);
  705. }, this);
  706. break;
  707. case 'log.dirs':
  708. components = masterComponentHostsInDB.filterProperty('component', 'KAFKA_BROKER');
  709. components.forEach(function (component) {
  710. setOfHostNames.push(component.hostName);
  711. }, this);
  712. break;
  713. }
  714. // In Add Host Wizard, if we did not select this slave component for any host, then we don't process any further.
  715. if (setOfHostNames.length === 0) {
  716. return;
  717. }
  718. var allMountPoints = [];
  719. for (var i = 0; i < setOfHostNames.length; i++) {
  720. hostname = setOfHostNames[i];
  721. mountPointsPerHost = hostsInfo[hostname].disk_info;
  722. mountPointAsRoot = mountPointsPerHost.findProperty('mountpoint', '/');
  723. // If Server does not send any host details information then atleast one mountpoint should be presumed as root
  724. // This happens in a single container Linux Docker environment.
  725. if (!mountPointAsRoot) {
  726. mountPointAsRoot = {mountpoint: '/'};
  727. }
  728. mountPointsPerHost = mountPointsPerHost.filter(function (mPoint) {
  729. return !(['/', '/home', '/boot'].contains(mPoint.mountpoint)
  730. || ['devtmpfs', 'tmpfs', 'vboxsf'].contains(mPoint.type)
  731. || mPoint.available == 0
  732. || mPoint.type == 'CDFS');
  733. });
  734. mountPointsPerHost.forEach(function (mPoint) {
  735. if( !allMountPoints.findProperty("mountpoint", mPoint.mountpoint)) {
  736. allMountPoints.push(mPoint);
  737. }
  738. }, this);
  739. }
  740. if (allMountPoints.length == 0) {
  741. allMountPoints.push(mountPointAsRoot);
  742. }
  743. this.set('value', '');
  744. var winRegex = /^([a-z]):\\?$/;
  745. if (!isOnlyFirstOneNeeded) {
  746. allMountPoints.forEach(function (eachDrive) {
  747. var mPoint = this.get('value');
  748. if (!mPoint) {
  749. mPoint = "";
  750. }
  751. if (eachDrive.mountpoint === "/") {
  752. mPoint += this.get('defaultDirectory') + "\n";
  753. } else if(winRegex.test(eachDrive.mountpoint.toLowerCase())) {
  754. switch (this.get('name')) {
  755. case 'dfs.datanode.data.dir':
  756. case 'dfs.name.dir':
  757. case 'dfs.namenode.name.dir':
  758. case 'dfs.data.dir':
  759. case 'dfs.datanode.data.dir':
  760. var winDriveUrl = eachDrive.mountpoint.toLowerCase().replace(winRegex, "file:///$1:");
  761. mPoint += winDriveUrl + this.get('defaultDirectory') + "\n";
  762. break;
  763. default:
  764. var winDrive = eachDrive.mountpoint.toLowerCase().replace(winRegex, "$1:");
  765. var winDir = this.get('defaultDirectory').replace(/\//g, "\\");
  766. mPoint += winDrive + winDir + "\n";
  767. }
  768. } else {
  769. mPoint += eachDrive.mountpoint + this.get('defaultDirectory') + "\n";
  770. }
  771. this.set('value', mPoint);
  772. this.set('defaultValue', mPoint);
  773. }, this);
  774. } else {
  775. var mPoint = allMountPoints[0].mountpoint;
  776. if (mPoint === "/") {
  777. mPoint = this.get('defaultDirectory');
  778. } else if(winRegex.test(mPoint.toLowerCase())) {
  779. switch (this.get('name')) {
  780. case 'fs.checkpoint.dir':
  781. case 'dfs.namenode.checkpoint.dir':
  782. var winDriveUrl = mPoint.toLowerCase().replace(winRegex, "file:///$1:");
  783. mPoint = winDriveUrl + this.get('defaultDirectory') + "\n";
  784. break;
  785. case 'zk_data_dir':
  786. var winDrive = mPoint.toLowerCase().replace(winRegex, "$1:");
  787. var winDir = this.get('defaultDirectory').replace(/\//g, "\\\\");
  788. mPoint = winDrive + winDir + "\n";
  789. break;
  790. default:
  791. var winDrive = mPoint.toLowerCase().replace(winRegex, "$1:");
  792. var winDir = this.get('defaultDirectory').replace(/\//g, "\\");
  793. mPoint = winDrive + winDir + "\n";
  794. }
  795. } else {
  796. mPoint = mPoint + this.get('defaultDirectory');
  797. }
  798. this.set('value', mPoint);
  799. this.set('defaultValue', mPoint);
  800. }
  801. },
  802. isValid: function () {
  803. return this.get('errorMessage') === '';
  804. }.property('errorMessage'),
  805. viewClass: function () {
  806. switch (this.get('displayType')) {
  807. case 'checkbox':
  808. return App.ServiceConfigCheckbox;
  809. case 'password':
  810. return App.ServiceConfigPasswordField;
  811. case 'combobox':
  812. return App.ServiceConfigComboBox;
  813. case 'radio button':
  814. return App.ServiceConfigRadioButtons;
  815. break;
  816. case 'directories':
  817. case 'datanodedirs':
  818. return App.ServiceConfigTextArea;
  819. break;
  820. case 'content':
  821. return App.ServiceConfigTextAreaContent;
  822. break;
  823. case 'multiLine':
  824. return App.ServiceConfigTextArea;
  825. break;
  826. case 'custom':
  827. return App.ServiceConfigBigTextArea;
  828. case 'masterHost':
  829. return App.ServiceConfigMasterHostView;
  830. case 'label':
  831. return App.ServiceConfigLabelView;
  832. case 'masterHosts':
  833. return App.ServiceConfigMasterHostsView;
  834. case 'slaveHosts':
  835. return App.ServiceConfigSlaveHostsView;
  836. case 'supportTextConnection':
  837. return App.checkConnectionView;
  838. default:
  839. if (this.get('unit')) {
  840. return App.ServiceConfigTextFieldWithUnit;
  841. } else {
  842. return App.ServiceConfigTextField;
  843. }
  844. }
  845. }.property('displayType'),
  846. validate: function () {
  847. var value = this.get('value');
  848. var supportsFinal = this.get('supportsFinal');
  849. var isFinal = this.get('isFinal');
  850. var valueRange = this.get('valueRange');
  851. var values = [];//value split by "," to check UNIX users, groups list
  852. var isError = false;
  853. var isWarn = false;
  854. if (typeof value === 'string' && value.length === 0) {
  855. if (this.get('isRequired')) {
  856. this.set('errorMessage', 'This is required');
  857. isError = true;
  858. } else {
  859. return;
  860. }
  861. }
  862. if (!isError) {
  863. switch (this.get('displayType')) {
  864. case 'int':
  865. if (!validator.isValidInt(value)) {
  866. this.set('errorMessage', 'Must contain digits only');
  867. isError = true;
  868. } else {
  869. if(valueRange){
  870. if(value < valueRange[0] || value > valueRange[1]){
  871. this.set('errorMessage', 'Must match the range');
  872. isError = true;
  873. }
  874. }
  875. }
  876. break;
  877. case 'float':
  878. if (!validator.isValidFloat(value)) {
  879. this.set('errorMessage', 'Must be a valid number');
  880. isError = true;
  881. }
  882. break;
  883. case 'UNIXList':
  884. if(value != '*'){
  885. values = value.split(',');
  886. for(var i = 0, l = values.length; i < l; i++){
  887. if(!validator.isValidUNIXUser(values[i])){
  888. if(this.get('type') == 'USERS'){
  889. this.set('errorMessage', 'Must be a valid list of user names');
  890. } else {
  891. this.set('errorMessage', 'Must be a valid list of group names');
  892. }
  893. isError = true;
  894. }
  895. }
  896. }
  897. break;
  898. case 'checkbox':
  899. break;
  900. case 'datanodedirs':
  901. if (!validator.isValidDataNodeDir(value)) {
  902. this.set('errorMessage', 'dir format is wrong, can be "[{storage type}]/{dir name}"');
  903. isError = true;
  904. }
  905. else {
  906. if (!validator.isAllowedDir(value)) {
  907. this.set('errorMessage', 'Cannot start with "home(s)"');
  908. isError = true;
  909. }
  910. }
  911. break;
  912. case 'directories':
  913. case 'directory':
  914. if (!validator.isValidDir(value)) {
  915. this.set('errorMessage', 'Must be a slash or drive at the start');
  916. isError = true;
  917. }
  918. else {
  919. if (!validator.isAllowedDir(value)) {
  920. this.set('errorMessage', 'Can\'t start with "home(s)"');
  921. isError = true;
  922. }
  923. }
  924. break;
  925. case 'custom':
  926. break;
  927. case 'email':
  928. if (!validator.isValidEmail(value)) {
  929. this.set('errorMessage', 'Must be a valid email address');
  930. isError = true;
  931. }
  932. break;
  933. case 'host':
  934. var hiveOozieHostNames = ['hive_hostname','hive_existing_mysql_host','hive_existing_oracle_host','hive_ambari_host',
  935. 'oozie_hostname','oozie_existing_mysql_host','oozie_existing_oracle_host','oozie_ambari_host'];
  936. if(hiveOozieHostNames.contains(this.get('name'))) {
  937. if (validator.hasSpaces(value)) {
  938. this.set('errorMessage', Em.I18n.t('host.spacesValidation'));
  939. isError = true;
  940. }
  941. } else {
  942. if (validator.isNotTrimmed(value)) {
  943. this.set('errorMessage', Em.I18n.t('host.trimspacesValidation'));
  944. isError = true;
  945. }
  946. }
  947. break;
  948. case 'advanced':
  949. if(this.get('name')=='javax.jdo.option.ConnectionURL' || this.get('name')=='oozie.service.JPAService.jdbc.url') {
  950. if (validator.isNotTrimmed(value)) {
  951. this.set('errorMessage', Em.I18n.t('host.trimspacesValidation'));
  952. isError = true;
  953. }
  954. }
  955. break;
  956. case 'password':
  957. // retypedPassword is set by the retypePasswordView child view of App.ServiceConfigPasswordField
  958. if (value !== this.get('retypedPassword')) {
  959. this.set('errorMessage', 'Passwords do not match');
  960. isError = true;
  961. }
  962. }
  963. }
  964. if (!isError) {
  965. // Check if this value is already in any of the overrides
  966. var self = this;
  967. var isOriginalSCP = this.get('isOriginalSCP');
  968. var parentSCP = this.get('parentSCP');
  969. if (!isOriginalSCP) {
  970. if (!isError && parentSCP != null) {
  971. if (value === parentSCP.get('value') && supportsFinal && isFinal === parentSCP.get('isFinal')) {
  972. this.set('errorMessage', 'Configuration overrides must have different value');
  973. isError = true;
  974. } else {
  975. var overrides = parentSCP.get('overrides');
  976. if (overrides) {
  977. overrides.forEach(function (override) {
  978. if (self != override && value === override.get('value') && supportsFinal && isFinal === parentSCP.get('isFinal')) {
  979. self.set('errorMessage', 'Multiple configuration overrides cannot have same value');
  980. isError = true;
  981. }
  982. });
  983. }
  984. }
  985. }
  986. }
  987. }
  988. if (!isWarn || isError) { // Errors get priority
  989. this.set('warnMessage', '');
  990. this.set('warn', false);
  991. } else {
  992. this.set('warn', true);
  993. }
  994. if (!isError) {
  995. this.set('errorMessage', '');
  996. this.set('error', false);
  997. } else {
  998. this.set('error', true);
  999. }
  1000. }.observes('value', 'isFinal', 'retypedPassword')
  1001. });
  1002. App.ConfigSiteTag = Ember.Object.extend({
  1003. site: DS.attr('string'),
  1004. tag: DS.attr('string'),
  1005. /**
  1006. * Object map of hostname->override-tag for overrides.
  1007. * <b>Creators should set new object here.<b>
  1008. */
  1009. hostOverrides: null
  1010. });