stack_service.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  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. require('utils/helper');
  20. require('models/configs/objects/service_config_category');
  21. /**
  22. * This model loads all services supported by the stack
  23. * The model maps to the http://hostname:8080/api/v1/stacks/HDP/versions/${versionNumber}/services?fields=StackServices/*,serviceComponents/*
  24. * @type {*}
  25. */
  26. App.StackService = DS.Model.extend({
  27. serviceName: DS.attr('string'),
  28. serviceType: DS.attr('string'),
  29. displayName: DS.attr('string'),
  30. comments: DS.attr('string'),
  31. configTypes: DS.attr('object'),
  32. serviceVersion: DS.attr('string'),
  33. serviceCheckSupported: DS.attr('boolean'),
  34. stackName: DS.attr('string'),
  35. stackVersion: DS.attr('string'),
  36. selection: DS.attr('string'),
  37. isMandatory: DS.attr('boolean', {defaultValue: false}),
  38. isSelected: DS.attr('boolean', {defaultValue: true}),
  39. isInstalled: DS.attr('boolean', {defaultValue: false}),
  40. isInstallable: DS.attr('boolean', {defaultValue: true}),
  41. isServiceWithWidgets: DS.attr('boolean', {defaultValue: false}),
  42. stack: DS.belongsTo('App.Stack'),
  43. serviceComponents: DS.hasMany('App.StackServiceComponent'),
  44. configs: DS.attr('array'),
  45. requiredServices: DS.attr('array', {defaultValue: []}),
  46. isDisabled: function () {
  47. return this.get('isInstalled') || (this.get('isMandatory') && !App.get('router.clusterInstallCompleted'));
  48. }.property('isMandatory', 'isInstalled', 'App.router.clusterInstallCompleted'),
  49. /**
  50. * @type {String[]}
  51. */
  52. configTypeList: function() {
  53. var configTypes = Object.keys(this.get('configTypes') || {});
  54. //Falcon has dependency on oozie-site but oozie-site advanced/custom section should not be shown on Falcon page
  55. if (this.get('serviceName') === 'FALCON') {
  56. configTypes = configTypes.without('oozie-site');
  57. }
  58. return configTypes;
  59. }.property('configTypes'),
  60. /**
  61. * contains array of serviceNames that have configs that
  62. * depends on configs from current service
  63. * @type {String[]}
  64. */
  65. dependentServiceNames: DS.attr('array', {defaultValue: []}),
  66. // Is the service a distributed filesystem
  67. isDFS: function () {
  68. return this.get('serviceType') === 'HCFS' || ['HDFS', 'GLUSTERFS'].contains(this.get('serviceName'));
  69. }.property('serviceName', 'serviceType'),
  70. // Primary DFS. used if there is more than one DFS in a stack.
  71. // Only one service in the stack should be tagged as primary DFS.
  72. isPrimaryDFS: Em.computed.equal('serviceName', 'HDFS'),
  73. configTypesRendered: function () {
  74. var configTypes = this.get('configTypes');
  75. var renderedConfigTypes = $.extend(true, {}, configTypes);
  76. if (this.get('serviceName') == 'FALCON') {
  77. delete renderedConfigTypes['oozie-site'];
  78. }
  79. return renderedConfigTypes
  80. }.property('serviceName', 'configTypes'),
  81. displayNameOnSelectServicePage: function () {
  82. var displayName = this.get('displayName');
  83. var services = this.get('coSelectedServices').slice();
  84. var serviceDisplayNames = services.map(function (item) {
  85. return App.format.role(item, true);
  86. }, this);
  87. if (!!serviceDisplayNames.length) {
  88. serviceDisplayNames.unshift(displayName);
  89. displayName = serviceDisplayNames.join(" + ");
  90. }
  91. return displayName;
  92. }.property('coSelectedServices', 'serviceName'),
  93. isHiddenOnSelectServicePage: function () {
  94. var hiddenServices = ['MAPREDUCE2'];
  95. return hiddenServices.contains(this.get('serviceName')) || !this.get('isInstallable') || this.get('doNotShowAndInstall');
  96. }.property('serviceName', 'isInstallable'),
  97. doNotShowAndInstall: function () {
  98. var skipServices = [];
  99. if(!App.supports.installGanglia) {
  100. skipServices.push('GANGLIA');
  101. }
  102. if(App.router.get('clusterInstallCompleted') != true){
  103. skipServices.push('RANGER', 'RANGER_KMS');
  104. }
  105. return skipServices.contains(this.get('serviceName'));
  106. }.property('serviceName'),
  107. // Is the service required for monitoring of other hadoop ecosystem services
  108. isMonitoringService: Em.computed.existsIn('serviceName', ['GANGLIA']),
  109. // Is the service required for reporting host metrics
  110. isHostMetricsService: Em.computed.existsIn('serviceName', ['GANGLIA', 'AMBARI_METRICS']),
  111. // Is the service required for reporting hadoop service metrics
  112. isServiceMetricsService: Em.computed.existsIn('serviceName', ['GANGLIA']),
  113. coSelectedServices: function () {
  114. var coSelectedServices = App.StackService.coSelected[this.get('serviceName')];
  115. if (!!coSelectedServices) {
  116. return coSelectedServices;
  117. } else {
  118. return [];
  119. }
  120. }.property('serviceName'),
  121. hasClient: Em.computed.someBy('serviceComponents', 'isClient', true),
  122. hasMaster: Em.computed.someBy('serviceComponents', 'isMaster', true),
  123. hasSlave: Em.computed.someBy('serviceComponents', 'isSlave', true),
  124. hasNonMastersWithCustomAssignment: function () {
  125. var serviceComponents = this.get('serviceComponents');
  126. return serviceComponents.rejectProperty('isMaster').rejectProperty('cardinality', 'ALL').length > 0;
  127. }.property('serviceName'),
  128. isClientOnlyService: Em.computed.everyBy('serviceComponents', 'isClient', true),
  129. isNoConfigTypes: function () {
  130. var configTypes = this.get('configTypes');
  131. return !(configTypes && !!Object.keys(configTypes).length);
  132. }.property('configTypes'),
  133. customReviewHandler: function () {
  134. return App.StackService.reviewPageHandlers[this.get('serviceName')];
  135. }.property('serviceName'),
  136. hasHeatmapSection: Em.computed.existsIn('serviceName', ['HDFS', 'YARN', 'HBASE']),
  137. /**
  138. * configCategories are fetched from App.StackService.configCategories.
  139. * Also configCategories that does not match any serviceComponent of a service and not included in the permissible default pattern are omitted
  140. */
  141. configCategories: function () {
  142. var configCategories = [];
  143. var configTypes = this.get('configTypes');
  144. var serviceComponents = this.get('serviceComponents');
  145. if (configTypes && Object.keys(configTypes).length) {
  146. var pattern = ["General", "CapacityScheduler", "FaultTolerance", "Isolation", "Performance", "HIVE_SERVER2", "KDC", "Kadmin","^Advanced", "Env$", "^Custom", "Falcon - Oozie integration", "FalconStartupSite", "FalconRuntimeSite", "MetricCollector", "Settings$", "AdvancedHawqCheck", "LogsearchAdminJson"];
  147. configCategories = App.StackService.configCategories.call(this).filter(function (_configCategory) {
  148. var serviceComponentName = _configCategory.get('name');
  149. var isServiceComponent = serviceComponents.someProperty('componentName', serviceComponentName);
  150. if (isServiceComponent) return isServiceComponent;
  151. var result = false;
  152. pattern.forEach(function (_pattern) {
  153. var regex = new RegExp(_pattern);
  154. if (regex.test(serviceComponentName)) result = true;
  155. });
  156. return result;
  157. });
  158. }
  159. return configCategories;
  160. }.property('serviceName', 'configTypes', 'serviceComponents')
  161. });
  162. App.StackService.FIXTURES = [];
  163. App.StackService.displayOrder = [
  164. 'HDFS',
  165. 'GLUSTERFS',
  166. 'YARN',
  167. 'MAPREDUCE2',
  168. 'TEZ',
  169. 'GANGLIA',
  170. 'HIVE',
  171. 'HAWQ',
  172. 'PXF',
  173. 'HBASE',
  174. 'PIG',
  175. 'SQOOP',
  176. 'OOZIE',
  177. 'ZOOKEEPER',
  178. 'FALCON',
  179. 'STORM',
  180. 'FLUME',
  181. 'ACCUMULO',
  182. 'AMBARI_INFRA',
  183. 'AMBARI_METRICS',
  184. 'ATLAS',
  185. 'KAFKA',
  186. 'KNOX',
  187. 'LOGSEARCH',
  188. 'RANGER',
  189. 'RANGER_KMS',
  190. 'SMARTSENSE',
  191. 'SPARK',
  192. 'SPARK2',
  193. 'ZEPPELIN'
  194. ];
  195. App.StackService.componentsOrderForService = {
  196. 'HAWQ': ['HAWQMASTER', 'HAWQSTANDBY']
  197. };
  198. //@TODO: Write unit test for no two keys in the object should have any intersecting elements in their values
  199. App.StackService.coSelected = {
  200. 'YARN': ['MAPREDUCE2']
  201. };
  202. App.StackService.reviewPageHandlers = {
  203. 'HIVE': {
  204. 'Database': 'loadHiveDbValue'
  205. },
  206. 'OOZIE': {
  207. 'Database': 'loadOozieDbValue'
  208. }
  209. };
  210. App.StackService.configCategories = function () {
  211. var serviceConfigCategories = [];
  212. switch (this.get('serviceName')) {
  213. case 'HDFS':
  214. serviceConfigCategories.pushObject(App.ServiceConfigCategory.create({ name: 'NAMENODE', displayName: 'NameNode', showHost: true}));
  215. if (!App.get('isHaEnabled')) {
  216. serviceConfigCategories.pushObject(App.ServiceConfigCategory.create({ name: 'SECONDARY_NAMENODE', displayName: 'Secondary NameNode', showHost: true}));
  217. }
  218. serviceConfigCategories.pushObjects([
  219. App.ServiceConfigCategory.create({ name: 'DATANODE', displayName: 'DataNode', showHost: true}),
  220. App.ServiceConfigCategory.create({ name: 'General', displayName: 'General'}),
  221. App.ServiceConfigCategory.create({ name: 'NFS_GATEWAY', displayName: 'NFS Gateway', showHost: true})
  222. ]);
  223. break;
  224. case 'GLUSTERFS':
  225. serviceConfigCategories.pushObjects([
  226. App.ServiceConfigCategory.create({ name: 'General', displayName: 'General'})
  227. ]);
  228. break;
  229. case 'YARN':
  230. serviceConfigCategories.pushObjects([
  231. App.ServiceConfigCategory.create({ name: 'RESOURCEMANAGER', displayName: 'Resource Manager', showHost: true}),
  232. App.ServiceConfigCategory.create({ name: 'NODEMANAGER', displayName: 'Node Manager', showHost: true}),
  233. App.ServiceConfigCategory.create({ name: 'APP_TIMELINE_SERVER', displayName: 'Application Timeline Server', showHost: true}),
  234. App.ServiceConfigCategory.create({ name: 'General', displayName: 'General'}),
  235. App.ServiceConfigCategory.create({ name: 'FaultTolerance', displayName: 'Fault Tolerance'}),
  236. App.ServiceConfigCategory.create({ name: 'Isolation', displayName: 'Isolation'}),
  237. App.ServiceConfigCategory.create({ name: 'CapacityScheduler', displayName: 'Scheduler', siteFileName: 'capacity-scheduler.xml'})
  238. ]);
  239. break;
  240. case 'MAPREDUCE2':
  241. serviceConfigCategories.pushObjects([
  242. App.ServiceConfigCategory.create({ name: 'HISTORYSERVER', displayName: 'History Server', showHost: true}),
  243. App.ServiceConfigCategory.create({ name: 'General', displayName: 'General'})
  244. ]);
  245. break;
  246. case 'HIVE':
  247. serviceConfigCategories.pushObjects([
  248. App.ServiceConfigCategory.create({ name: 'HIVE_METASTORE', displayName: 'Hive Metastore', showHost: true}),
  249. App.ServiceConfigCategory.create({ name: 'WEBHCAT_SERVER', displayName: 'WebHCat Server', showHost: true}),
  250. App.ServiceConfigCategory.create({ name: 'General', displayName: 'General'}),
  251. App.ServiceConfigCategory.create({ name: 'Performance', displayName: 'Performance'}),
  252. App.ServiceConfigCategory.create({ name: 'HIVE_SERVER2', displayName: 'Hive Server2'}),
  253. App.ServiceConfigCategory.create({ name: 'HIVE_CLIENT', displayName: 'Hive Client'})
  254. ]);
  255. break;
  256. case 'HBASE':
  257. serviceConfigCategories.pushObjects([
  258. App.ServiceConfigCategory.create({ name: 'HBASE_MASTER', displayName: 'HBase Master', showHost: true}),
  259. App.ServiceConfigCategory.create({ name: 'HBASE_REGIONSERVER', displayName: 'RegionServer', showHost: true}),
  260. App.ServiceConfigCategory.create({ name: 'General', displayName: 'General'})
  261. ]);
  262. break;
  263. case 'ZOOKEEPER':
  264. serviceConfigCategories.pushObjects([
  265. App.ServiceConfigCategory.create({ name: 'ZOOKEEPER_SERVER', displayName: 'ZooKeeper Server', showHost: true})
  266. ]);
  267. break;
  268. case 'OOZIE':
  269. serviceConfigCategories.pushObjects([
  270. App.ServiceConfigCategory.create({ name: 'OOZIE_SERVER', displayName: 'Oozie Server', showHost: true}),
  271. App.ServiceConfigCategory.create({ name: 'Falcon - Oozie integration', displayName: 'Falcon - Oozie integration'})
  272. ]);
  273. break;
  274. case 'FALCON':
  275. serviceConfigCategories.pushObjects([
  276. App.ServiceConfigCategory.create({ name: 'FALCON_SERVER', displayName: 'Falcon Server', showHost: true}),
  277. App.ServiceConfigCategory.create({ name: 'Falcon - Oozie integration', displayName: 'Falcon - Oozie integration'}),
  278. App.ServiceConfigCategory.create({ name: 'FalconStartupSite', displayName: 'Falcon startup.properties'}),
  279. App.ServiceConfigCategory.create({ name: 'FalconRuntimeSite', displayName: 'Falcon runtime.properties'}),
  280. App.ServiceConfigCategory.create({ name: 'General', displayName: 'General'})
  281. ]);
  282. break;
  283. case 'STORM':
  284. serviceConfigCategories.pushObjects([
  285. App.ServiceConfigCategory.create({ name: 'NIMBUS', displayName: 'Nimbus', showHost: true}),
  286. App.ServiceConfigCategory.create({ name: 'SUPERVISOR', displayName: 'Supervisor', showHost: true}),
  287. App.ServiceConfigCategory.create({ name: 'STORM_UI_SERVER', displayName: 'Storm UI Server', showHost: true}),
  288. App.ServiceConfigCategory.create({ name: 'STORM_REST_API', displayName: 'Storm REST API Server', showHost: true}),
  289. App.ServiceConfigCategory.create({ name: 'DRPC_SERVER', displayName: 'DRPC Server', showHost: true}),
  290. App.ServiceConfigCategory.create({ name: 'General', displayName: 'General'})
  291. ]);
  292. break;
  293. case 'TEZ':
  294. serviceConfigCategories.pushObjects([
  295. App.ServiceConfigCategory.create({ name: 'General', displayName: 'General'})
  296. ]);
  297. break;
  298. case 'FLUME':
  299. serviceConfigCategories.pushObjects([
  300. App.ServiceConfigCategory.create({ name: 'FLUME_HANDLER', displayName: 'flume.conf', siteFileName: 'flume-conf', canAddProperty: false})
  301. ]);
  302. break;
  303. case 'KNOX':
  304. serviceConfigCategories.pushObjects([
  305. App.ServiceConfigCategory.create({ name: 'KNOX_GATEWAY', displayName: 'Knox Gateway', showHost: true})
  306. ]);
  307. break;
  308. case 'KAFKA':
  309. serviceConfigCategories.pushObjects([
  310. App.ServiceConfigCategory.create({ name: 'KAFKA_BROKER', displayName: 'Kafka Broker', showHost: true})
  311. ]);
  312. break;
  313. case 'KERBEROS':
  314. serviceConfigCategories.pushObjects([
  315. App.ServiceConfigCategory.create({ name: 'KDC', displayName: 'KDC'}),
  316. App.ServiceConfigCategory.create({ name: 'Kadmin', displayName: 'Kadmin'}),
  317. App.ServiceConfigCategory.create({ name: 'General', displayName: 'General'})
  318. ]);
  319. break;
  320. case 'AMBARI_METRICS':
  321. serviceConfigCategories.pushObjects([
  322. App.ServiceConfigCategory.create({ name: 'General', displayName: 'General'}),
  323. App.ServiceConfigCategory.create({ name: 'MetricCollector', displayName: 'Metric Collector'})
  324. ]);
  325. break;
  326. case 'RANGER':
  327. serviceConfigCategories.pushObjects([
  328. App.ServiceConfigCategory.create({ name: 'RANGER_ADMIN', displayName: 'Admin Settings', showHost: true}),
  329. App.ServiceConfigCategory.create({ name: 'DBSettings', displayName: 'DB Settings'}),
  330. App.ServiceConfigCategory.create({ name: 'RangerSettings', displayName: 'Ranger Settings'}),
  331. App.ServiceConfigCategory.create({ name: 'UnixAuthenticationSettings', displayName: 'Unix Authentication Settings'}),
  332. App.ServiceConfigCategory.create({ name: 'ADSettings', displayName: 'AD Settings'}),
  333. App.ServiceConfigCategory.create({ name: 'LDAPSettings', displayName: 'LDAP Settings'}),
  334. App.ServiceConfigCategory.create({ name: 'KnoxSSOSettings', displayName: 'Knox SSO Settings'}),
  335. App.ServiceConfigCategory.create({ name: 'SolrKerberosSettings', displayName: 'Solr Kerberos Settings'})
  336. ]);
  337. break;
  338. case 'ACCUMULO':
  339. serviceConfigCategories.pushObjects([
  340. App.ServiceConfigCategory.create({ name: 'General', displayName: 'General'})
  341. ]);
  342. break;
  343. case 'PIG':
  344. break;
  345. case 'SQOOP':
  346. break;
  347. case 'HAWQ':
  348. serviceConfigCategories.pushObjects([
  349. App.ServiceConfigCategory.create({ name: 'General', displayName: 'General'}),
  350. App.ServiceConfigCategory.create({ name: 'AdvancedHawqCheck', displayName: 'Advanced HAWQ Check'})
  351. ]);
  352. break;
  353. case 'LOGSEARCH':
  354. serviceConfigCategories.pushObjects([
  355. App.ServiceConfigCategory.create({ name: 'LogsearchAdminJson', displayName: 'Advanced logsearch-admin-json'})
  356. ]);
  357. break;
  358. default:
  359. serviceConfigCategories.pushObjects([
  360. App.ServiceConfigCategory.create({ name: 'General', displayName: 'General'})
  361. ]);
  362. }
  363. serviceConfigCategories.pushObject(App.ServiceConfigCategory.create({ name: 'Advanced', displayName: 'Advanced'}));
  364. var configTypes = this.get('configTypeList');
  365. // Add Advanced section for every configType to all the services
  366. configTypes.forEach(function (type) {
  367. serviceConfigCategories.pushObject(App.ServiceConfigCategory.create({
  368. name: 'Advanced ' + type,
  369. displayName: Em.I18n.t('common.advanced') + " " + type,
  370. canAddProperty: false
  371. }));
  372. }, this);
  373. // Add custom section for every configType to all the services
  374. configTypes.forEach(function (type) {
  375. if (Em.getWithDefault(this.get('configTypes')[type] || {}, 'supports.adding_forbidden', 'true') === 'false') {
  376. serviceConfigCategories.pushObject(App.ServiceConfigCategory.create({
  377. name: 'Custom ' + type,
  378. displayName: Em.I18n.t('common.custom') + " " + type,
  379. siteFileName: type + '.xml',
  380. canAddProperty: true
  381. }));
  382. }
  383. }, this);
  384. return serviceConfigCategories;
  385. };