stack_service.js 15 KB

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