stack_service.js 17 KB

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