stack_service.js 17 KB

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