app.js 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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. }),
  30. isAdmin: false,
  31. /**
  32. * return url prefix with number value of version of HDP stack
  33. */
  34. stackVersionURL: function () {
  35. var stackVersion = this.get('currentStackVersion') || this.get('defaultStackVersion');
  36. if (stackVersion.indexOf('HDPLocal') !== -1) {
  37. return '/stacks/HDPLocal/versions/' + stackVersion.replace(/HDPLocal-/g, '');
  38. }
  39. return '/stacks/HDP/versions/' + stackVersion.replace(/HDP-/g, '');
  40. }.property('currentStackVersion'),
  41. /**
  42. * return url prefix with number value of version of HDP stack
  43. */
  44. stack2VersionURL: function () {
  45. var stackVersion = this.get('currentStackVersion') || this.get('defaultStackVersion');
  46. if (stackVersion.indexOf('HDPLocal') !== -1) {
  47. return '/stacks2/HDPLocal/versions/' + stackVersion.replace(/HDPLocal-/g, '');
  48. }
  49. return '/stacks2/HDP/versions/' + stackVersion.replace(/HDP-/g, '');
  50. }.property('currentStackVersion'),
  51. falconServerURL: function () {
  52. var falconService = this.Service.find().findProperty('serviceName', 'FALCON');
  53. if (falconService) {
  54. return falconService.get('hostComponents').findProperty('componentName', 'FALCON_SERVER').get('host.hostName');
  55. }
  56. return '';
  57. }.property().volatile(),
  58. clusterName: null,
  59. clockDistance: null, // server clock - client clock
  60. currentStackVersion: '',
  61. currentStackVersionNumber: function () {
  62. return this.get('currentStackVersion').replace(/HDP(Local)?-/, '');
  63. }.property('currentStackVersion'),
  64. isHadoop2Stack: function () {
  65. return (stringUtils.compareVersions(this.get('currentStackVersionNumber'), "2.0") === 1 ||
  66. stringUtils.compareVersions(this.get('currentStackVersionNumber'), "2.0") === 0)
  67. }.property('currentStackVersionNumber'),
  68. isHadoop21Stack: function () {
  69. return (stringUtils.compareVersions(this.get('currentStackVersionNumber'), "2.1") === 1 ||
  70. stringUtils.compareVersions(this.get('currentStackVersionNumber'), "2.1") === 0)
  71. }.property('currentStackVersionNumber'),
  72. /**
  73. * If High Availability is enabled
  74. * Based on <code>clusterStatus.isInstalled</code>, stack version, <code>SNameNode</code> availability
  75. *
  76. * @type {bool}
  77. */
  78. isHaEnabled: function () {
  79. if (!this.get('isHadoop2Stack')) return false;
  80. return !this.HostComponent.find().someProperty('componentName', 'SECONDARY_NAMENODE');
  81. }.property('router.clusterController.isLoaded', 'isHadoop2Stack'),
  82. /**
  83. * Object with utility functions for list of service names with similar behavior
  84. */
  85. services: Em.Object.create({
  86. all: function () {
  87. return App.StackService.find().mapProperty('serviceName');
  88. }.property('App.router.clusterController.isLoaded'),
  89. clientOnly: function () {
  90. return App.StackService.find().filterProperty('isClientOnlyService').mapProperty('serviceName');
  91. }.property('App.router.clusterController.isLoaded'),
  92. hasClient: function () {
  93. return App.StackService.find().filterProperty('hasClient').mapProperty('serviceName');
  94. }.property('App.router.clusterController.isLoaded'),
  95. hasMaster: function () {
  96. return App.StackService.find().filterProperty('hasMaster').mapProperty('serviceName');
  97. }.property('App.router.clusterController.isLoaded'),
  98. hasSlave: function () {
  99. return App.StackService.find().filterProperty('hasSlave').mapProperty('serviceName');
  100. }.property('App.router.clusterController.isLoaded'),
  101. noConfigTypes: function () {
  102. return App.StackService.find().filterProperty('isNoConfigTypes').mapProperty('serviceName');
  103. }.property('App.router.clusterController.isLoaded'),
  104. monitoring: function () {
  105. return App.StackService.find().filterProperty('isMonitoringService').mapProperty('serviceName');
  106. }.property('App.router.clusterController.isLoaded')
  107. }),
  108. /**
  109. * List of components with allowed action for them
  110. * @type {Em.Object}
  111. */
  112. components: Em.Object.create({
  113. allComponents: function () {
  114. return App.StackServiceComponent.find().mapProperty('componentName')
  115. }.property('App.router.clusterController.isLoaded'),
  116. reassignable: function () {
  117. return App.StackServiceComponent.find().filterProperty('isReassignable', true).mapProperty('componentName')
  118. }.property('App.router.clusterController.isLoaded'),
  119. restartable: function () {
  120. return App.StackServiceComponent.find().filterProperty('isRestartable', true).mapProperty('componentName')
  121. }.property('App.router.clusterController.isLoaded'),
  122. deletable: function () {
  123. return App.StackServiceComponent.find().filterProperty('isDeletable', true).mapProperty('componentName')
  124. }.property('App.router.clusterController.isLoaded'),
  125. rollinRestartAllowed: function () {
  126. return App.StackServiceComponent.find().filterProperty('isRollinRestartAllowed', true).mapProperty('componentName')
  127. }.property('App.router.clusterController.isLoaded'),
  128. decommissionAllowed: function () {
  129. return App.StackServiceComponent.find().filterProperty('isDecommissionAllowed', true).mapProperty('componentName')
  130. }.property('App.router.clusterController.isLoaded'),
  131. refreshConfigsAllowed: function () {
  132. return App.StackServiceComponent.find().filterProperty('isRefreshConfigsAllowed', true).mapProperty('componentName')
  133. }.property('App.router.clusterController.isLoaded'),
  134. addableToHost: function () {
  135. return App.StackServiceComponent.find().filterProperty('isAddableToHost', true).mapProperty('componentName')
  136. }.property('App.router.clusterController.isLoaded'),
  137. addableMasterInstallerWizard: function () {
  138. return App.StackServiceComponent.find().filterProperty('isMasterAddableInstallerWizard', true).mapProperty('componentName')
  139. }.property('App.router.clusterController.isLoaded'),
  140. addableMasterHaWizard: function () {
  141. return App.StackServiceComponent.find().filterProperty('isMasterWithMultipleInstancesHaWizard', true).mapProperty('componentName')
  142. }.property('App.router.clusterController.isLoaded'),
  143. slaves: function () {
  144. return App.StackServiceComponent.find().filterProperty('isMaster', false).filterProperty('isClient', false).mapProperty('componentName')
  145. }.property('App.router.clusterController.isLoaded'),
  146. masters: function () {
  147. return App.StackServiceComponent.find().filterProperty('isMaster', true).mapProperty('componentName')
  148. }.property('App.router.clusterController.isLoaded'),
  149. clients: function () {
  150. return App.StackServiceComponent.find().filterProperty('isClient', true).mapProperty('componentName')
  151. }.property('App.router.clusterController.isLoaded')
  152. })
  153. });