stack_service.js 14 KB

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