service_config.js 44 KB

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