stack_service.js 15 KB

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