app.js 8.4 KB

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