stack_service.js 16 KB

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