stack_service.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  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. 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(App.ServiceModelMixin, {
  38. comments: DS.attr('string'),
  39. configTypes: DS.attr('object'),
  40. serviceVersion: DS.attr('string'),
  41. stackName: DS.attr('string'),
  42. stackVersion: DS.attr('string'),
  43. isSelected: DS.attr('boolean', {defaultValue: true}),
  44. isInstalled: DS.attr('boolean', {defaultValue: false}),
  45. serviceComponents: DS.hasMany('App.StackServiceComponent'),
  46. configs: DS.attr('array'),
  47. // Is the service a distributed filesystem
  48. isDFS: function () {
  49. var dfsServices = ['HDFS', 'GLUSTERFS'];
  50. return dfsServices.contains(this.get('serviceName'));
  51. }.property('serviceName'),
  52. // Primary DFS. used if there is more than one DFS in a stack.
  53. // Only one service in the stack should be tagged as primary DFS.
  54. isPrimaryDFS: function () {
  55. return this.get('serviceName') === 'HDFS';
  56. }.property('serviceName'),
  57. configTypesRendered: function () {
  58. var configTypes = this.get('configTypes');
  59. if (this.get('serviceName') == 'HDFS') return configTypes;
  60. else {
  61. var renderedConfigTypes = $.extend(true,{}, configTypes);
  62. delete renderedConfigTypes['core-site'];
  63. return renderedConfigTypes
  64. }
  65. }.property('serviceName','configTypes'),
  66. displayNameOnSelectServicePage: function () {
  67. var displayName = this.get('displayName');
  68. var services = this.get('coSelectedServices').slice();
  69. var serviceDisplayNames = services.map(function (item) {
  70. return App.format.role(item);
  71. }, this);
  72. if (!!serviceDisplayNames.length) {
  73. serviceDisplayNames.unshift(displayName);
  74. displayName = serviceDisplayNames.join(" + ");
  75. }
  76. return displayName;
  77. }.property('coSelectedServices', 'serviceName'),
  78. isHiddenOnSelectServicePage: function () {
  79. var hiddenServices = ['MAPREDUCE2', 'HCATALOG', 'WEBHCAT'];
  80. return hiddenServices.contains(this.get('serviceName'));
  81. }.property('serviceName'),
  82. dependentServices: function () {
  83. var serviceName = this.get('serviceName');
  84. var dependentServices = [];
  85. if (App.get('isHadoop2Stack')) {
  86. dependentServices = App.StackService.dependency['HDP-2'][serviceName];
  87. } else {
  88. dependentServices = App.StackService.dependency['HDP-1'][serviceName];
  89. }
  90. return dependentServices;
  91. }.property('serviceName'),
  92. /**
  93. * other services on which the service is dependent
  94. */
  95. serviceDependency: function () {
  96. var serviceName = this.get('serviceName');
  97. var serviceDependencyMap, key, serviceDependencies = [];
  98. if (App.get('isHadoop2Stack')) {
  99. serviceDependencyMap = App.StackService.dependency['HDP-2'];
  100. } else {
  101. serviceDependencyMap = App.StackService.dependency['HDP-1'];
  102. }
  103. for (key in serviceDependencyMap) {
  104. if (serviceDependencyMap[key].contains(serviceName)) serviceDependencies.pushObject(key);
  105. }
  106. return serviceDependencies;
  107. }.property('serviceName'),
  108. // Is the service required for monitoring of other hadoop ecosystem services
  109. isMonitoringService: function () {
  110. var services = ['NAGIOS', 'GANGLIA'];
  111. return services.contains(this.get('serviceName'));
  112. }.property('serviceName'),
  113. coSelectedServices: function () {
  114. var coSelectedServices = App.StackService.coSelected[this.get('serviceName')];
  115. if (!!coSelectedServices) {
  116. return coSelectedServices;
  117. } else {
  118. return [];
  119. }
  120. }.property('serviceName'),
  121. hasClient: function () {
  122. var serviceComponents = this.get('serviceComponents');
  123. return serviceComponents.someProperty('isClient');
  124. }.property('serviceName'),
  125. hasMaster: function () {
  126. var serviceComponents = this.get('serviceComponents');
  127. return serviceComponents.someProperty('isMaster');
  128. }.property('serviceName'),
  129. hasSlave: function () {
  130. var serviceComponents = this.get('serviceComponents');
  131. return serviceComponents.someProperty('isSlave');
  132. }.property('serviceName'),
  133. isClientOnlyService: function () {
  134. var serviceComponents = this.get('serviceComponents');
  135. return serviceComponents.everyProperty('isClient');
  136. }.property('serviceName'),
  137. isNoConfigTypes: function () {
  138. var configTypes = this.get('configTypes');
  139. return !(configTypes && !!Object.keys(configTypes).length);
  140. }.property('configTypes'),
  141. customReviewHandler: function () {
  142. return App.StackService.reviewPageHandlers[this.get('serviceName')];
  143. }.property('serviceName'),
  144. defaultsProviders: function () {
  145. var defaultConfigsHandler = App.StackService.defaultConfigsHandler[this.get('serviceName')];
  146. return defaultConfigsHandler && defaultConfigsHandler.defaultsProviders;
  147. }.property('serviceName'),
  148. configsValidator: function () {
  149. var defaultConfigsHandler = App.StackService.defaultConfigsHandler[this.get('serviceName')];
  150. return defaultConfigsHandler && defaultConfigsHandler.configsValidator;
  151. }.property('serviceName'),
  152. /**
  153. * configCategories are fetched from App.StackService.configCategories.
  154. * Also configCategories that does not match any serviceComponent of a service and not included in the permissible default pattern are omitted
  155. */
  156. configCategories: function () {
  157. var configCategories = [];
  158. var serviceName = this.get('serviceName');
  159. var configTypes = this.get('configTypes');
  160. var serviceComponents = this.get('serviceComponents');
  161. if (configTypes && Object.keys(configTypes).length) {
  162. var pattern = ["General", "CapacityScheduler", "^Advanced", "^Custom", "Falcon - Oozie integration", "FalconStartupSite", "FalconRuntimeSite"];
  163. configCategories = App.StackService.configCategories(serviceName).filter(function (_configCategory) {
  164. var serviceComponentName = _configCategory.get('name');
  165. var isServiceComponent = serviceComponents.someProperty('componentName', serviceComponentName);
  166. if (isServiceComponent) return isServiceComponent;
  167. var result = false;
  168. pattern.forEach(function (_pattern) {
  169. var regex = new RegExp(_pattern);
  170. if (regex.test(serviceComponentName)) result = true;
  171. });
  172. return result;
  173. });
  174. }
  175. return configCategories;
  176. }.property('serviceName', 'configTypes', 'serviceComponents'),
  177. serviceConfigs: function () {
  178. var configCategories = [];
  179. var serviceName = this.get('serviceName');
  180. var serviceComponents = this.get('serviceComponents');
  181. configCategories = App.StackService.configCategories(serviceName).filter(function (_configCategory) {
  182. var serviceComponentName = _configCategory.get('name');
  183. return serviceComponents.someProperty('componentName', serviceComponentName);
  184. });
  185. return configCategories;
  186. }.observes('serviceName', 'serviceComponents')
  187. });
  188. App.StackService.FIXTURES = [];
  189. App.StackService.displayOrder = [
  190. 'HDFS',
  191. 'MAPREDUCE',
  192. 'MAPREDUCE2',
  193. 'YARN',
  194. 'TEZ',
  195. 'NAGIOS',
  196. 'GANGLIA',
  197. 'HIVE',
  198. 'HCATALOG',
  199. 'WEBHCAT',
  200. 'HBASE',
  201. 'PIG',
  202. 'SQOOP',
  203. 'OOZIE',
  204. 'ZOOKEEPER',
  205. 'HUE',
  206. 'FALCON',
  207. 'STORM',
  208. 'FLUME'
  209. ];
  210. App.StackService.dependency = {
  211. 'HDP-1': {
  212. 'MAPREDUCE': ['PIG', 'OOZIE', 'HIVE'],
  213. 'ZOOKEEPER': ['HBASE', 'HIVE', 'WEBHCAT']
  214. },
  215. 'HDP-2': {
  216. 'YARN': ['PIG', 'OOZIE', 'HIVE', 'TEZ'],
  217. 'TEZ': ['YARN'],
  218. 'OOZIE': ['FALCON'],
  219. 'ZOOKEEPER': ['HDFS', 'HBASE', 'HIVE', 'WEBHCAT', 'STORM']
  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. App.StackService.defaultConfigsHandler = {
  239. YARN: {defaultsProviders: [App.YARNDefaultsProvider.create()], configsValidator: App.YARNConfigsValidator},
  240. MAPREDUCE2: {defaultsProviders: [App.YARNDefaultsProvider.create()], configsValidator: App.MapReduce2ConfigsValidator},
  241. HIVE: {defaultsProviders: [App.HiveDefaultsProvider.create()], configsValidator: App.HiveConfigsValidator},
  242. STORM: {defaultsProviders: [App.STORMDefaultsProvider.create()], configsValidator: App.STORMConfigsValidator},
  243. TEZ: {defaultsProviders: [App.TezDefaultsProvider.create()], configsValidator: App.TezConfigsValidator}
  244. };
  245. App.StackService.configCategories = function (serviceName) {
  246. switch (serviceName) {
  247. case 'HDFS':
  248. return [
  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. App.ServiceConfigCategory.create({ name: 'Advanced', displayName: 'Advanced'}),
  254. App.ServiceConfigCategory.create({ name: 'AdvancedCoreSite', displayName: 'Custom core-site.xml', siteFileName: 'core-site.xml', canAddProperty: true}),
  255. App.ServiceConfigCategory.create({ name: 'AdvancedHDFSSite', displayName: 'Custom hdfs-site.xml', siteFileName: 'hdfs-site.xml', canAddProperty: true}),
  256. App.ServiceConfigCategory.create({ name: 'AdvancedHDFSLog4j', displayName: 'Custom log4j.properties', siteFileName: 'hdfs-log4j.xml', canAddProperty: false})
  257. ];
  258. case 'GLUSTERFS':
  259. return [
  260. App.ServiceConfigCategory.create({ name: 'General', displayName: 'General'}),
  261. App.ServiceConfigCategory.create({ name: 'AdvancedGlusterFSSite', displayName : 'Custom core-site.xml', siteFileName: 'core-site.xml', canAddProperty: true})
  262. ];
  263. case 'MAPREDUCE':
  264. return [
  265. App.ServiceConfigCategory.create({ name: 'HISTORYSERVER', displayName: 'History Server'}),
  266. App.ServiceConfigCategory.create({ name: 'JOBTRACKER', displayName: 'JobTracker'}),
  267. App.ServiceConfigCategory.create({ name: 'TASKTRACKER', displayName: 'TaskTracker'}),
  268. App.ServiceConfigCategory.create({ name: 'General', displayName: 'General'}),
  269. App.ServiceConfigCategory.create({ name: 'Advanced', displayName: 'Advanced'}),
  270. App.ServiceConfigCategory.create({ name: 'AdvancedMapredSite', displayName: 'Custom mapred-site.xml', siteFileName: 'mapred-site.xml', canAddProperty: true}),
  271. App.ServiceConfigCategory.create({ name: 'AdvancedMapredLog4j', displayName: 'Custom log4j.properties', siteFileName: 'mapreduce-log4j.xml', canAddProperty: false})
  272. ];
  273. case 'YARN':
  274. return [
  275. App.ServiceConfigCategory.create({ name: 'RESOURCEMANAGER', displayName: 'Resource Manager'}),
  276. App.ServiceConfigCategory.create({ name: 'NODEMANAGER', displayName: 'Node Manager'}),
  277. App.ServiceConfigCategory.create({ name: 'APP_TIMELINE_SERVER', displayName: 'Application Timeline Server'}),
  278. App.ServiceConfigCategory.create({ name: 'General', displayName: 'General'}),
  279. App.ServiceConfigCategory.create({ name: 'CapacityScheduler', displayName: 'Scheduler', isCapacityScheduler: true, isCustomView: true, siteFileName: 'capacity-scheduler.xml', siteFileNames: ['capacity-scheduler.xml', 'mapred-queue-acls.xml'], canAddProperty: App.supports.capacitySchedulerUi}),
  280. App.ServiceConfigCategory.create({ name: 'Advanced', displayName: 'Advanced'}),
  281. App.ServiceConfigCategory.create({ name: 'AdvancedYARNSite', displayName: 'Custom yarn-site.xml', siteFileName: 'yarn-site.xml', canAddProperty: true}),
  282. App.ServiceConfigCategory.create({ name: 'AdvancedYARNLog4j', displayName: 'Custom log4j.properties', siteFileName: 'yarn-log4j.xml', canAddProperty: false})
  283. ];
  284. case 'MAPREDUCE2':
  285. return [
  286. App.ServiceConfigCategory.create({ name: 'HISTORYSERVER', displayName: 'History Server'}),
  287. App.ServiceConfigCategory.create({ name: 'General', displayName: 'General'}),
  288. App.ServiceConfigCategory.create({ name: 'Advanced', displayName: 'Advanced'}),
  289. App.ServiceConfigCategory.create({ name: 'AdvancedMapredSite', displayName: 'Custom mapred-site.xml', siteFileName: 'mapred-site.xml', canAddProperty: true}),
  290. App.ServiceConfigCategory.create({ name: 'AdvancedMapredLog4j', displayName: 'Custom log4j.properties', siteFileName: 'mapreduce2-log4j.xml', canAddProperty: false})
  291. ];
  292. case 'HIVE':
  293. return [
  294. App.ServiceConfigCategory.create({ name: 'HIVE_METASTORE', displayName: 'Hive Metastore'}),
  295. App.ServiceConfigCategory.create({ name: 'Advanced', displayName: 'Advanced'}),
  296. App.ServiceConfigCategory.create({ name: 'AdvancedHiveSite', displayName: 'Custom hive-site.xml', siteFileName: 'hive-site.xml', canAddProperty: true}),
  297. App.ServiceConfigCategory.create({ name: 'AdvancedHiveLog4j', displayName: 'Custom log4j.properties', siteFileName: 'hive-log4j.xml', canAddProperty: false}),
  298. App.ServiceConfigCategory.create({ name: 'AdvancedHiveExecLog4j', displayName: 'Custom hive-exec-log4j', siteFileName: 'hive-exec-log4j.xml', canAddProperty: false})
  299. ];
  300. case 'WEBHCAT':
  301. return [
  302. App.ServiceConfigCategory.create({ name: 'WEBHCAT_SERVER', displayName: 'WebHCat Server'}),
  303. App.ServiceConfigCategory.create({ name: 'Advanced', displayName: 'Advanced'}),
  304. App.ServiceConfigCategory.create({ name: 'AdvancedWebHCatSite', displayName: 'Custom webhcat-site.xml', siteFileName: 'webhcat-site.xml', canAddProperty: true})
  305. ];
  306. case 'HBASE':
  307. return [
  308. App.ServiceConfigCategory.create({ name: 'HBASE_MASTER', displayName: 'HBase Master'}),
  309. App.ServiceConfigCategory.create({ name: 'HBASE_REGIONSERVER', displayName: 'RegionServer'}),
  310. App.ServiceConfigCategory.create({ name: 'General', displayName: 'General'}),
  311. App.ServiceConfigCategory.create({ name: 'Advanced', displayName: 'Advanced'}),
  312. App.ServiceConfigCategory.create({ name: 'AdvancedHbaseSite', displayName: 'Custom hbase-site.xml', siteFileName: 'hbase-site.xml', canAddProperty: true}),
  313. App.ServiceConfigCategory.create({ name: 'AdvancedHbaseLog4j', displayName: 'Custom log4j.properties', siteFileName: 'hbase-log4j.xml', canAddProperty: false})
  314. ];
  315. case 'ZOOKEEPER':
  316. return [
  317. App.ServiceConfigCategory.create({ name: 'ZOOKEEPER_SERVER', displayName: 'ZooKeeper Server'}),
  318. App.ServiceConfigCategory.create({ name: 'Advanced', displayName: 'Advanced'}),
  319. App.ServiceConfigCategory.create({ name: 'AdvancedZooLog4j', displayName: 'Custom log4j.properties', siteFileName: 'zookeeper-log4j.xml', canAddProperty: false}),
  320. App.ServiceConfigCategory.create({ name: 'AdvancedZooCfg', displayName: 'Custom zoo.cfg', siteFileName: 'zoo.cfg', canAddProperty: true})
  321. ];
  322. case 'OOZIE':
  323. return [
  324. App.ServiceConfigCategory.create({ name: 'OOZIE_SERVER', displayName: 'Oozie Server'}),
  325. App.ServiceConfigCategory.create({ name: 'Advanced', displayName: 'Advanced'}),
  326. App.ServiceConfigCategory.create({ name: 'AdvancedOozieSite', displayName: 'Custom oozie-site.xml', siteFileName: 'oozie-site.xml', canAddProperty: true}),
  327. App.ServiceConfigCategory.create({ name: 'AdvancedOozieLog4j', displayName: 'Custom log4j.properties', siteFileName: 'oozie-log4j.xml', canAddProperty: false})
  328. ];
  329. case 'PIG':
  330. return [
  331. App.ServiceConfigCategory.create({ name: 'Advanced', displayName: 'Custom pig.properties', siteFileName: 'pig-properties.xml', canAddProperty: false}),
  332. App.ServiceConfigCategory.create({ name: 'AdvancedPigLog4j', displayName: 'Custom log4j.properties', siteFileName: 'pig-log4j.xml', canAddProperty: false})
  333. ];
  334. case 'FALCON':
  335. return [
  336. App.ServiceConfigCategory.create({ name: 'FALCON_SERVER', displayName: 'Falcon Server'}),
  337. App.ServiceConfigCategory.create({ name: 'Falcon - Oozie integration', displayName: 'Falcon - Oozie integration'}),
  338. App.ServiceConfigCategory.create({ name: 'FalconStartupSite', displayName: 'Falcon startup.properties'}),
  339. App.ServiceConfigCategory.create({ name: 'FalconRuntimeSite', displayName: 'Falcon runtime.properties'}),
  340. App.ServiceConfigCategory.create({ name: 'Advanced', displayName: 'Advanced'}),
  341. App.ServiceConfigCategory.create({ name: 'AdvancedFalconStartupSite', displayName: 'Custom startup.properties', siteFileName: 'falcon-startup.properties.xml', canAddProperty: true}),
  342. App.ServiceConfigCategory.create({ name: 'AdvancedFalconRuntimeSite', displayName: 'Custom runtime.properties', siteFileName: 'falcon-runtime.properties.xml', canAddProperty: true})
  343. ];
  344. case 'STORM':
  345. return [
  346. App.ServiceConfigCategory.create({ name: 'NIMBUS', displayName: 'Nimbus'}),
  347. App.ServiceConfigCategory.create({ name: 'SUPERVISOR', displayName: 'Supervisor'}),
  348. App.ServiceConfigCategory.create({ name: 'STORM_UI_SERVER', displayName: 'Storm UI Server'}),
  349. App.ServiceConfigCategory.create({ name: 'STORM_REST_API', displayName: 'Storm REST API Server'}),
  350. App.ServiceConfigCategory.create({ name: 'DRPC_SERVER', displayName: 'DRPC Server'}),
  351. App.ServiceConfigCategory.create({ name: 'General', displayName: 'General'}),
  352. App.ServiceConfigCategory.create({ name: 'Advanced', displayName: 'Advanced'}),
  353. App.ServiceConfigCategory.create({ name: 'AdvancedStormSite', displayName: 'Custom storm.yaml', siteFileName: 'storm-site.xml', canAddProperty: true})
  354. ];
  355. case 'TEZ':
  356. return [
  357. App.ServiceConfigCategory.create({ name: 'General', displayName: 'General'}),
  358. App.ServiceConfigCategory.create({ name: 'Advanced', displayName: 'Advanced'}),
  359. App.ServiceConfigCategory.create({ name: 'AdvancedTezSite', displayName: 'Custom tez-site.xml', siteFileName: 'tez-site.xml', canAddProperty: true})
  360. ];
  361. case 'FLUME':
  362. return [
  363. App.ServiceConfigCategory.create({ name: 'FLUME_HANDLER', displayName: 'flume.conf', siteFileName: 'flume-conf', canAddProperty: false})
  364. ];
  365. case 'HCATALOG':
  366. return [];
  367. default:
  368. return [
  369. App.ServiceConfigCategory.create({ name: 'General', displayName: 'General', canAddProperty: false}),
  370. App.ServiceConfigCategory.create({ name: 'Advanced', displayName: 'Advanced', canAddProperty: false})
  371. ];
  372. }
  373. };