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