stack_service.js 17 KB

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