stack_service.js 17 KB

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