app.js 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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. // Application bootstrapper
  19. require('utils/ember_reopen');
  20. var stringUtils = require('utils/string_utils');
  21. module.exports = Em.Application.create({
  22. name: 'Ambari Web',
  23. rootElement: '#wrapper',
  24. store: DS.Store.create({
  25. revision: 4,
  26. adapter: DS.FixtureAdapter.create({
  27. simulateRemoteResponse: false
  28. }),
  29. typeMaps: {},
  30. recordCache: []
  31. }),
  32. isAdmin: false,
  33. isOperator: false,
  34. isManager: function() {
  35. return this.get('isAdmin') || this.get('isOperator');
  36. }.property('isAdmin','isOperator'),
  37. /**
  38. * return url prefix with number value of version of HDP stack
  39. */
  40. stackVersionURL: function () {
  41. return '/stacks/{0}/versions/{1}'.format(this.get('currentStackName') || 'HDP', this.get('currentStackVersionNumber'));
  42. }.property('currentStackName','currentStackVersionNumber'),
  43. falconServerURL: function () {
  44. var falconService = this.Service.find().findProperty('serviceName', 'FALCON');
  45. if (falconService) {
  46. return falconService.get('hostComponents').findProperty('componentName', 'FALCON_SERVER').get('hostName');
  47. }
  48. return '';
  49. }.property().volatile(),
  50. /* Determine if Application Timeline Service supports Kerberization.
  51. * Because this value is retrieved from the cardinality of the component, it is safe to keep in app.js
  52. * since its value will not change during the lifetime of the application.
  53. */
  54. doesATSSupportKerberos: function() {
  55. var YARNService = App.StackServiceComponent.find().filterProperty('serviceName', 'YARN');
  56. if (YARNService.length) {
  57. var ATS = App.StackServiceComponent.find().findProperty('componentName', 'APP_TIMELINE_SERVER');
  58. return (!!ATS && !!ATS.get('minToInstall'));
  59. }
  60. return false;
  61. }.property('App.router.clusterController.isLoaded'),
  62. clusterName: null,
  63. clockDistance: null, // server clock - client clock
  64. currentStackVersion: '',
  65. currentStackName: function() {
  66. return Em.get((this.get('currentStackVersion') || this.get('defaultStackVersion')).match(/(.+)-\d.+/), '1');
  67. }.property('currentStackVersion'),
  68. currentStackVersionNumber: function () {
  69. var regExp = new RegExp(this.get('currentStackName') + '-');
  70. return (this.get('currentStackVersion') || this.get('defaultStackVersion')).replace(regExp, '');
  71. }.property('currentStackVersion', 'currentStackName'),
  72. isHadoop2Stack: function () {
  73. return (stringUtils.compareVersions(this.get('currentStackVersionNumber'), "2.0") === 1 ||
  74. stringUtils.compareVersions(this.get('currentStackVersionNumber'), "2.0") === 0)
  75. }.property('currentStackVersionNumber'),
  76. /**
  77. * If NameNode High Availability is enabled
  78. * Based on <code>clusterStatus.isInstalled</code>, stack version, <code>SNameNode</code> availability
  79. *
  80. * @type {bool}
  81. */
  82. isHaEnabled: function () {
  83. if (!this.get('isHadoop2Stack')) return false;
  84. var isHDFSInstalled = App.Service.find().findProperty('serviceName','HDFS');
  85. return !!isHDFSInstalled && !this.HostComponent.find().someProperty('componentName', 'SECONDARY_NAMENODE');
  86. }.property('router.clusterController.isLoaded', 'isHadoop2Stack'),
  87. /**
  88. * If ResourceManager High Availability is enabled
  89. * Based on number of ResourceManager components host components installed
  90. *
  91. * @type {bool}
  92. */
  93. isRMHaEnabled: function () {
  94. var result = false;
  95. var rmStackComponent = App.StackServiceComponent.find().findProperty('componentName','RESOURCEMANAGER');
  96. if (rmStackComponent && rmStackComponent.get('isMultipleAllowed')) {
  97. result = this.HostComponent.find().filterProperty('componentName', 'RESOURCEMANAGER').length > 1;
  98. }
  99. return result;
  100. }.property('router.clusterController.isLoaded'),
  101. /**
  102. * Object with utility functions for list of service names with similar behavior
  103. */
  104. services: Em.Object.create({
  105. all: function () {
  106. return App.StackService.find().mapProperty('serviceName');
  107. }.property('App.router.clusterController.isLoaded'),
  108. clientOnly: function () {
  109. return App.StackService.find().filterProperty('isClientOnlyService').mapProperty('serviceName');
  110. }.property('App.router.clusterController.isLoaded'),
  111. hasClient: function () {
  112. return App.StackService.find().filterProperty('hasClient').mapProperty('serviceName');
  113. }.property('App.router.clusterController.isLoaded'),
  114. hasMaster: function () {
  115. return App.StackService.find().filterProperty('hasMaster').mapProperty('serviceName');
  116. }.property('App.router.clusterController.isLoaded'),
  117. hasSlave: function () {
  118. return App.StackService.find().filterProperty('hasSlave').mapProperty('serviceName');
  119. }.property('App.router.clusterController.isLoaded'),
  120. noConfigTypes: function () {
  121. return App.StackService.find().filterProperty('isNoConfigTypes').mapProperty('serviceName');
  122. }.property('App.router.clusterController.isLoaded'),
  123. monitoring: function () {
  124. return App.StackService.find().filterProperty('isMonitoringService').mapProperty('serviceName');
  125. }.property('App.router.clusterController.isLoaded'),
  126. supportsServiceCheck: function() {
  127. return App.StackService.find().filterProperty('serviceCheckSupported').mapProperty('serviceName');
  128. }.property('App.router.clusterController.isLoaded')
  129. }),
  130. /**
  131. * List of components with allowed action for them
  132. * @type {Em.Object}
  133. */
  134. components: Em.Object.create({
  135. allComponents: function () {
  136. return App.StackServiceComponent.find().mapProperty('componentName')
  137. }.property('App.router.clusterController.isLoaded'),
  138. reassignable: function () {
  139. return App.StackServiceComponent.find().filterProperty('isReassignable').mapProperty('componentName')
  140. }.property('App.router.clusterController.isLoaded'),
  141. restartable: function () {
  142. return App.StackServiceComponent.find().filterProperty('isRestartable').mapProperty('componentName')
  143. }.property('App.router.clusterController.isLoaded'),
  144. deletable: function () {
  145. return App.StackServiceComponent.find().filterProperty('isDeletable').mapProperty('componentName')
  146. }.property('App.router.clusterController.isLoaded'),
  147. rollinRestartAllowed: function () {
  148. return App.StackServiceComponent.find().filterProperty('isRollinRestartAllowed').mapProperty('componentName')
  149. }.property('App.router.clusterController.isLoaded'),
  150. decommissionAllowed: function () {
  151. return App.StackServiceComponent.find().filterProperty('isDecommissionAllowed').mapProperty('componentName')
  152. }.property('App.router.clusterController.isLoaded'),
  153. refreshConfigsAllowed: function () {
  154. return App.StackServiceComponent.find().filterProperty('isRefreshConfigsAllowed').mapProperty('componentName')
  155. }.property('App.router.clusterController.isLoaded'),
  156. addableToHost: function () {
  157. return App.StackServiceComponent.find().filterProperty('isAddableToHost').mapProperty('componentName')
  158. }.property('App.router.clusterController.isLoaded'),
  159. addableMasterInstallerWizard: function () {
  160. return App.StackServiceComponent.find().filterProperty('isMasterAddableInstallerWizard').mapProperty('componentName')
  161. }.property('App.router.clusterController.isLoaded'),
  162. multipleMasters: function () {
  163. return App.StackServiceComponent.find().filterProperty('isMasterWithMultipleInstances').mapProperty('componentName')
  164. }.property('App.router.clusterController.isLoaded'),
  165. slaves: function () {
  166. return App.StackServiceComponent.find().filterProperty('isSlave').mapProperty('componentName')
  167. }.property('App.router.clusterController.isLoaded'),
  168. masters: function () {
  169. return App.StackServiceComponent.find().filterProperty('isMaster').mapProperty('componentName')
  170. }.property('App.router.clusterController.isLoaded'),
  171. clients: function () {
  172. return App.StackServiceComponent.find().filterProperty('isClient').mapProperty('componentName')
  173. }.property('App.router.clusterController.isLoaded')
  174. })
  175. });