stack_service.js 13 KB

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