stack_service.js 15 KB

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