stack_service.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  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. /**
  22. * This model loads all services supported by the stack
  23. * The model maps to the http://hostname:8080/api/v1/stacks/HDP/versions/${versionNumber}/services?fields=StackServices/*,serviceComponents/*
  24. * @type {*}
  25. */
  26. App.StackService = DS.Model.extend({
  27. serviceName: DS.attr('string'),
  28. displayName: DS.attr('string'),
  29. comments: DS.attr('string'),
  30. configTypes: DS.attr('object'),
  31. serviceVersion: DS.attr('string'),
  32. serviceCheckSupported: DS.attr('boolean'),
  33. stackName: DS.attr('string'),
  34. stackVersion: DS.attr('string'),
  35. isSelected: DS.attr('boolean', {defaultValue: true}),
  36. isInstalled: DS.attr('boolean', {defaultValue: false}),
  37. isInstallable: DS.attr('boolean', {defaultValue: true}),
  38. stack: DS.belongsTo('App.Stack'),
  39. serviceComponents: DS.hasMany('App.StackServiceComponent'),
  40. configs: DS.attr('array'),
  41. requiredServices: DS.attr('array'),
  42. // Is the service a distributed filesystem
  43. isDFS: function () {
  44. var dfsServices = ['HDFS', 'GLUSTERFS'];
  45. return dfsServices.contains(this.get('serviceName'));
  46. }.property('serviceName'),
  47. // Primary DFS. used if there is more than one DFS in a stack.
  48. // Only one service in the stack should be tagged as primary DFS.
  49. isPrimaryDFS: function () {
  50. return this.get('serviceName') === 'HDFS';
  51. }.property('serviceName'),
  52. configTypesRendered: function () {
  53. var configTypes = this.get('configTypes');
  54. var renderedConfigTypes = $.extend(true, {}, configTypes);
  55. if (this.get('serviceName') == 'FALCON') {
  56. delete renderedConfigTypes['oozie-site'];
  57. }
  58. return renderedConfigTypes
  59. }.property('serviceName', 'configTypes'),
  60. displayNameOnSelectServicePage: function () {
  61. var displayName = this.get('displayName');
  62. console.info("displayName = " + displayName);
  63. var services = this.get('coSelectedServices').slice();
  64. var serviceDisplayNames = services.map(function (item) {
  65. return App.format.role(item);
  66. }, this);
  67. if (!!serviceDisplayNames.length) {
  68. serviceDisplayNames.unshift(displayName);
  69. displayName = serviceDisplayNames.join(" + ");
  70. }
  71. return displayName;
  72. }.property('coSelectedServices', 'serviceName'),
  73. isHiddenOnSelectServicePage: function () {
  74. var hiddenServices = ['MAPREDUCE2'];
  75. return hiddenServices.contains(this.get('serviceName')) || !this.get('isInstallable') || this.get('doNotShowAndInstall');
  76. }.property('serviceName', 'isInstallable'),
  77. doNotShowAndInstall: function () {
  78. var skipServices = [];
  79. if(!App.supports.installGanglia) {
  80. skipServices.push('GANGLIA');
  81. }
  82. if(App.router.get('clusterInstallCompleted') != true){
  83. skipServices.push('RANGER');
  84. }
  85. return skipServices.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. // Is the service required for reporting host metrics
  93. isHostMetricsService: function () {
  94. var services = ['GANGLIA'];
  95. return services.contains(this.get('serviceName'));
  96. }.property('serviceName'),
  97. // Is the service required for reporting hadoop service metrics
  98. isServiceMetricsService: function () {
  99. var services = ['GANGLIA'];
  100. return services.contains(this.get('serviceName'));
  101. }.property('serviceName'),
  102. // Is the service required for reporting aleerts
  103. isAlertingService: function () {
  104. var services = ['NAGIOS'];
  105. return services.contains(this.get('serviceName'));
  106. }.property('serviceName'),
  107. coSelectedServices: function () {
  108. var coSelectedServices = App.StackService.coSelected[this.get('serviceName')];
  109. if (!!coSelectedServices) {
  110. return coSelectedServices;
  111. } else {
  112. return [];
  113. }
  114. }.property('serviceName'),
  115. hasClient: function () {
  116. var serviceComponents = this.get('serviceComponents');
  117. return serviceComponents.someProperty('isClient');
  118. }.property('serviceName'),
  119. hasMaster: function () {
  120. var serviceComponents = this.get('serviceComponents');
  121. return serviceComponents.someProperty('isMaster');
  122. }.property('serviceName'),
  123. hasSlave: function () {
  124. var serviceComponents = this.get('serviceComponents');
  125. return serviceComponents.someProperty('isSlave');
  126. }.property('serviceName'),
  127. hasNonMastersWithCustomAssignment: function () {
  128. var serviceComponents = this.get('serviceComponents');
  129. return serviceComponents.rejectProperty('isMaster').rejectProperty('cardinality', 'ALL').length > 0;
  130. }.property('serviceName'),
  131. isClientOnlyService: function () {
  132. var serviceComponents = this.get('serviceComponents');
  133. return serviceComponents.everyProperty('isClient');
  134. }.property('serviceName'),
  135. isNoConfigTypes: function () {
  136. var configTypes = this.get('configTypes');
  137. return !(configTypes && !!Object.keys(configTypes).length);
  138. }.property('configTypes'),
  139. customReviewHandler: function () {
  140. return App.StackService.reviewPageHandlers[this.get('serviceName')];
  141. }.property('serviceName'),
  142. /**
  143. * configCategories are fetched from App.StackService.configCategories.
  144. * Also configCategories that does not match any serviceComponent of a service and not included in the permissible default pattern are omitted
  145. */
  146. configCategories: function () {
  147. var configCategories = [];
  148. var configTypes = this.get('configTypes');
  149. var serviceComponents = this.get('serviceComponents');
  150. if (configTypes && Object.keys(configTypes).length) {
  151. var pattern = ["General", "CapacityScheduler", "FaultTolerance", "Isolation", "Performance", "KDC","^Advanced", "Env$", "^Custom", "Falcon - Oozie integration", "FalconStartupSite", "FalconRuntimeSite", "MetricCollector", "Settings$"];
  152. configCategories = App.StackService.configCategories.call(this).filter(function (_configCategory) {
  153. var serviceComponentName = _configCategory.get('name');
  154. var isServiceComponent = serviceComponents.someProperty('componentName', serviceComponentName);
  155. if (isServiceComponent) return isServiceComponent;
  156. var result = false;
  157. pattern.forEach(function (_pattern) {
  158. var regex = new RegExp(_pattern);
  159. if (regex.test(serviceComponentName)) result = true;
  160. });
  161. return result;
  162. });
  163. }
  164. return configCategories;
  165. }.property('serviceName', 'configTypes', 'serviceComponents')
  166. });
  167. App.StackService.FIXTURES = [];
  168. App.StackService.displayOrder = [
  169. 'HDFS',
  170. 'GLUSTERFS',
  171. 'MAPREDUCE2',
  172. 'YARN',
  173. 'TEZ',
  174. 'NAGIOS',
  175. 'GANGLIA',
  176. 'HIVE',
  177. 'HBASE',
  178. 'PIG',
  179. 'SQOOP',
  180. 'OOZIE',
  181. 'ZOOKEEPER',
  182. 'FALCON',
  183. 'STORM',
  184. 'FLUME'
  185. ];
  186. //@TODO: Write unit test for no two keys in the object should have any intersecting elements in their values
  187. App.StackService.coSelected = {
  188. 'YARN': ['MAPREDUCE2']
  189. };
  190. App.StackService.reviewPageHandlers = {
  191. 'HIVE': {
  192. 'Database': 'loadHiveDbValue'
  193. },
  194. 'NAGIOS': {
  195. 'Administrator': 'loadNagiosAdminValue'
  196. },
  197. 'OOZIE': {
  198. 'Database': 'loadOozieDbValue'
  199. }
  200. };
  201. App.StackService.configCategories = function () {
  202. var serviceConfigCategories = [];
  203. switch (this.get('serviceName')) {
  204. case 'HDFS':
  205. serviceConfigCategories.pushObjects([
  206. App.ServiceConfigCategory.create({ name: 'NAMENODE', displayName: 'NameNode'}),
  207. App.ServiceConfigCategory.create({ name: 'SECONDARY_NAMENODE', displayName: 'Secondary NameNode'}),
  208. App.ServiceConfigCategory.create({ name: 'DATANODE', displayName: 'DataNode'}),
  209. App.ServiceConfigCategory.create({ name: 'General', displayName: 'General'})
  210. ]);
  211. break;
  212. case 'GLUSTERFS':
  213. serviceConfigCategories.pushObjects([
  214. App.ServiceConfigCategory.create({ name: 'General', displayName: 'General'})
  215. ]);
  216. break;
  217. case 'YARN':
  218. serviceConfigCategories.pushObjects([
  219. App.ServiceConfigCategory.create({ name: 'RESOURCEMANAGER', displayName: 'Resource Manager'}),
  220. App.ServiceConfigCategory.create({ name: 'NODEMANAGER', displayName: 'Node Manager'}),
  221. App.ServiceConfigCategory.create({ name: 'APP_TIMELINE_SERVER', displayName: 'Application Timeline Server'}),
  222. App.ServiceConfigCategory.create({ name: 'General', displayName: 'General'}),
  223. App.ServiceConfigCategory.create({ name: 'FaultTolerance', displayName: 'Fault Tolerance'}),
  224. App.ServiceConfigCategory.create({ name: 'Isolation', displayName: 'Isolation'}),
  225. App.ServiceConfigCategory.create({ name: 'CapacityScheduler', displayName: 'Scheduler', siteFileName: 'capacity-scheduler.xml'})
  226. ]);
  227. break;
  228. case 'MAPREDUCE2':
  229. serviceConfigCategories.pushObjects([
  230. App.ServiceConfigCategory.create({ name: 'HISTORYSERVER', displayName: 'History Server'}),
  231. App.ServiceConfigCategory.create({ name: 'General', displayName: 'General'})
  232. ]);
  233. break;
  234. case 'HIVE':
  235. serviceConfigCategories.pushObjects([
  236. App.ServiceConfigCategory.create({ name: 'HIVE_METASTORE', displayName: 'Hive Metastore'}),
  237. App.ServiceConfigCategory.create({ name: 'WEBHCAT_SERVER', displayName: 'WebHCat Server'}),
  238. App.ServiceConfigCategory.create({ name: 'General', displayName: 'General'}),
  239. App.ServiceConfigCategory.create({ name: 'Performance', displayName: 'Performance'})
  240. ]);
  241. break;
  242. case 'HBASE':
  243. serviceConfigCategories.pushObjects([
  244. App.ServiceConfigCategory.create({ name: 'HBASE_MASTER', displayName: 'HBase Master'}),
  245. App.ServiceConfigCategory.create({ name: 'HBASE_REGIONSERVER', displayName: 'RegionServer'}),
  246. App.ServiceConfigCategory.create({ name: 'General', displayName: 'General'})
  247. ]);
  248. break;
  249. case 'ZOOKEEPER':
  250. serviceConfigCategories.pushObjects([
  251. App.ServiceConfigCategory.create({ name: 'ZOOKEEPER_SERVER', displayName: 'ZooKeeper Server'})
  252. ]);
  253. break;
  254. case 'OOZIE':
  255. serviceConfigCategories.pushObjects([
  256. App.ServiceConfigCategory.create({ name: 'OOZIE_SERVER', displayName: 'Oozie Server'})
  257. ]);
  258. break;
  259. case 'FALCON':
  260. serviceConfigCategories.pushObjects([
  261. App.ServiceConfigCategory.create({ name: 'FALCON_SERVER', displayName: 'Falcon Server'}),
  262. App.ServiceConfigCategory.create({ name: 'Falcon - Oozie integration', displayName: 'Falcon - Oozie integration'}),
  263. App.ServiceConfigCategory.create({ name: 'FalconStartupSite', displayName: 'Falcon startup.properties'}),
  264. App.ServiceConfigCategory.create({ name: 'FalconRuntimeSite', displayName: 'Falcon runtime.properties'}),
  265. App.ServiceConfigCategory.create({ name: 'General', displayName: 'General'})
  266. ]);
  267. break;
  268. case 'STORM':
  269. serviceConfigCategories.pushObjects([
  270. App.ServiceConfigCategory.create({ name: 'NIMBUS', displayName: 'Nimbus'}),
  271. App.ServiceConfigCategory.create({ name: 'SUPERVISOR', displayName: 'Supervisor'}),
  272. App.ServiceConfigCategory.create({ name: 'STORM_UI_SERVER', displayName: 'Storm UI Server'}),
  273. App.ServiceConfigCategory.create({ name: 'STORM_REST_API', displayName: 'Storm REST API Server'}),
  274. App.ServiceConfigCategory.create({ name: 'DRPC_SERVER', displayName: 'DRPC Server'}),
  275. App.ServiceConfigCategory.create({ name: 'General', displayName: 'General'})
  276. ]);
  277. break;
  278. case 'TEZ':
  279. serviceConfigCategories.pushObjects([
  280. App.ServiceConfigCategory.create({ name: 'General', displayName: 'General'})
  281. ]);
  282. break;
  283. case 'FLUME':
  284. serviceConfigCategories.pushObjects([
  285. App.ServiceConfigCategory.create({ name: 'FLUME_HANDLER', displayName: 'flume.conf', siteFileName: 'flume-conf', canAddProperty: false})
  286. ]);
  287. break;
  288. case 'KNOX':
  289. serviceConfigCategories.pushObjects([
  290. App.ServiceConfigCategory.create({ name: 'KNOX_GATEWAY', displayName: 'Knox Gateway'})
  291. ]);
  292. break;
  293. case 'KAFKA':
  294. serviceConfigCategories.pushObjects([
  295. App.ServiceConfigCategory.create({ name: 'KAFKA_BROKER', displayName: 'Kafka Broker'})
  296. ]);
  297. break;
  298. case 'KERBEROS':
  299. serviceConfigCategories.pushObjects([
  300. App.ServiceConfigCategory.create({ name: 'KDC', displayName: 'KDC and Kadmin'}),
  301. App.ServiceConfigCategory.create({ name: 'General', displayName: 'General'})
  302. ]);
  303. break;
  304. case 'AMS':
  305. serviceConfigCategories.pushObjects([
  306. App.ServiceConfigCategory.create({ name: 'General', displayName: 'General'}),
  307. App.ServiceConfigCategory.create({ name: 'MetricCollector', displayName: 'Metric Collector'})
  308. ]);
  309. break;
  310. case 'RANGER':
  311. serviceConfigCategories.pushObjects([
  312. App.ServiceConfigCategory.create({ name: 'AdminSettings', displayName: 'Admin Settings'}),
  313. App.ServiceConfigCategory.create({ name: 'DBSettings', displayName: 'DB Settings'})
  314. ]);
  315. break;
  316. case 'PIG':
  317. break;
  318. case 'SQOOP':
  319. break;
  320. default:
  321. serviceConfigCategories.pushObjects([
  322. App.ServiceConfigCategory.create({ name: 'General', displayName: 'General'})
  323. ]);
  324. }
  325. serviceConfigCategories.pushObject(App.ServiceConfigCategory.create({ name: 'Advanced', displayName: 'Advanced'}));
  326. var configTypes = Object.keys(this.get('configTypes'));
  327. //Falcon has dependency on oozie-site but oozie-site advanced/custom section should not be shown on Falcon page
  328. if (this.get('serviceName') !== 'OOZIE') {
  329. configTypes = configTypes.without('oozie-site');
  330. }
  331. // Add Advanced section for every configType to all the services
  332. configTypes.forEach(function (type) {
  333. serviceConfigCategories.pushObject(App.ServiceConfigCategory.create({
  334. name: 'Advanced ' + type,
  335. displayName: Em.I18n.t('common.advanced') + " " + type,
  336. canAddProperty: false
  337. }));
  338. }, this);
  339. // Add custom section for every configType to all the services
  340. configTypes.forEach(function (type) {
  341. var configTypesWithNoCustomSection = ['capacity-scheduler','mapred-queue-acls','flume-conf', 'pig-properties','topology','users-ldif'];
  342. if (type.endsWith('-env') || type.endsWith('-log4j') || configTypesWithNoCustomSection.contains(type)) {
  343. return;
  344. }
  345. serviceConfigCategories.pushObject(App.ServiceConfigCategory.create({
  346. name: 'Custom ' + type,
  347. displayName: Em.I18n.t('common.custom') + " " + type,
  348. siteFileName: type + '.xml',
  349. canAddProperty: true
  350. }));
  351. }, this);
  352. return serviceConfigCategories;
  353. };