app.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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. clusterName: null,
  48. clockDistance: null, // server clock - client clock
  49. currentStackVersion: '',
  50. currentStackName: function() {
  51. return Em.get((this.get('currentStackVersion') || this.get('defaultStackVersion')).match(/(.+)-\d.+/), '1');
  52. }.property('currentStackVersion'),
  53. currentStackVersionNumber: function () {
  54. var regExp = new RegExp(this.get('currentStackName') + '-');
  55. return (this.get('currentStackVersion') || this.get('defaultStackVersion')).replace(regExp, '');
  56. }.property('currentStackVersion', 'currentStackName'),
  57. isHadoop2Stack: function () {
  58. return (stringUtils.compareVersions(this.get('currentStackVersionNumber'), "2.0") === 1 ||
  59. stringUtils.compareVersions(this.get('currentStackVersionNumber'), "2.0") === 0)
  60. }.property('currentStackVersionNumber'),
  61. isHadoop21Stack: function () {
  62. return (stringUtils.compareVersions(this.get('currentStackVersionNumber'), "2.1") === 1 ||
  63. stringUtils.compareVersions(this.get('currentStackVersionNumber'), "2.1") === 0)
  64. }.property('currentStackVersionNumber'),
  65. /**
  66. * If NameNode High Availability is enabled
  67. * Based on <code>clusterStatus.isInstalled</code>, stack version, <code>SNameNode</code> availability
  68. *
  69. * @type {bool}
  70. */
  71. isHaEnabled: function () {
  72. if (!this.get('isHadoop2Stack')) return false;
  73. return !this.HostComponent.find().someProperty('componentName', 'SECONDARY_NAMENODE');
  74. }.property('router.clusterController.isLoaded', 'isHadoop2Stack'),
  75. /**
  76. * If ResourceManager High Availability is enabled
  77. * Based on number of ResourceManager components host components installed
  78. *
  79. * @type {bool}
  80. */
  81. isRMHaEnabled: function () {
  82. if (!this.get('isHadoop2Stack')) return false;
  83. return this.HostComponent.find().filterProperty('componentName', 'RESOURCEMANAGER').length > 1;
  84. }.property('router.clusterController.isLoaded', 'isHadoop2Stack'),
  85. /**
  86. * Object with utility functions for list of service names with similar behavior
  87. */
  88. services: Em.Object.create({
  89. all: function () {
  90. return App.StackService.find().mapProperty('serviceName');
  91. }.property('App.router.clusterController.isLoaded'),
  92. clientOnly: function () {
  93. return App.StackService.find().filterProperty('isClientOnlyService').mapProperty('serviceName');
  94. }.property('App.router.clusterController.isLoaded'),
  95. hasClient: function () {
  96. return App.StackService.find().filterProperty('hasClient').mapProperty('serviceName');
  97. }.property('App.router.clusterController.isLoaded'),
  98. hasMaster: function () {
  99. return App.StackService.find().filterProperty('hasMaster').mapProperty('serviceName');
  100. }.property('App.router.clusterController.isLoaded'),
  101. hasSlave: function () {
  102. return App.StackService.find().filterProperty('hasSlave').mapProperty('serviceName');
  103. }.property('App.router.clusterController.isLoaded'),
  104. noConfigTypes: function () {
  105. return App.StackService.find().filterProperty('isNoConfigTypes').mapProperty('serviceName');
  106. }.property('App.router.clusterController.isLoaded'),
  107. monitoring: function () {
  108. return App.StackService.find().filterProperty('isMonitoringService').mapProperty('serviceName');
  109. }.property('App.router.clusterController.isLoaded'),
  110. supportsServiceCheck: function() {
  111. return App.StackService.find().filterProperty('serviceCheckSupported').mapProperty('serviceName');
  112. }.property('App.router.clusterController.isLoaded')
  113. }),
  114. /**
  115. * List of components with allowed action for them
  116. * @type {Em.Object}
  117. */
  118. components: Em.Object.create({
  119. allComponents: function () {
  120. return App.StackServiceComponent.find().mapProperty('componentName')
  121. }.property('App.router.clusterController.isLoaded'),
  122. reassignable: function () {
  123. return App.StackServiceComponent.find().filterProperty('isReassignable').mapProperty('componentName')
  124. }.property('App.router.clusterController.isLoaded'),
  125. restartable: function () {
  126. return App.StackServiceComponent.find().filterProperty('isRestartable').mapProperty('componentName')
  127. }.property('App.router.clusterController.isLoaded'),
  128. deletable: function () {
  129. return App.StackServiceComponent.find().filterProperty('isDeletable').mapProperty('componentName')
  130. }.property('App.router.clusterController.isLoaded'),
  131. rollinRestartAllowed: function () {
  132. return App.StackServiceComponent.find().filterProperty('isRollinRestartAllowed').mapProperty('componentName')
  133. }.property('App.router.clusterController.isLoaded'),
  134. decommissionAllowed: function () {
  135. return App.StackServiceComponent.find().filterProperty('isDecommissionAllowed').mapProperty('componentName')
  136. }.property('App.router.clusterController.isLoaded'),
  137. refreshConfigsAllowed: function () {
  138. return App.StackServiceComponent.find().filterProperty('isRefreshConfigsAllowed').mapProperty('componentName')
  139. }.property('App.router.clusterController.isLoaded'),
  140. addableToHost: function () {
  141. return App.StackServiceComponent.find().filterProperty('isAddableToHost').mapProperty('componentName')
  142. }.property('App.router.clusterController.isLoaded'),
  143. addableMasterInstallerWizard: function () {
  144. return App.StackServiceComponent.find().filterProperty('isMasterAddableInstallerWizard').mapProperty('componentName')
  145. }.property('App.router.clusterController.isLoaded'),
  146. multipleMasters: function () {
  147. return App.StackServiceComponent.find().filterProperty('isMasterWithMultipleInstances').mapProperty('componentName')
  148. }.property('App.router.clusterController.isLoaded'),
  149. slaves: function () {
  150. return App.StackServiceComponent.find().filterProperty('isSlave').mapProperty('componentName')
  151. }.property('App.router.clusterController.isLoaded'),
  152. masters: function () {
  153. return App.StackServiceComponent.find().filterProperty('isMaster').mapProperty('componentName')
  154. }.property('App.router.clusterController.isLoaded'),
  155. clients: function () {
  156. return App.StackServiceComponent.find().filterProperty('isClient').mapProperty('componentName')
  157. }.property('App.router.clusterController.isLoaded')
  158. })
  159. });