stack_service_component.js 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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. var numberUtils = require('utils/number_utils');
  20. /**
  21. * This model loads all serviceComponents supported by the stack
  22. * @type {*}
  23. */
  24. App.StackServiceComponent = DS.Model.extend({
  25. componentName: DS.attr('string'),
  26. displayName: DS.attr('string'),
  27. cardinality: DS.attr('string'),
  28. customCommands: DS.attr('array'),
  29. reassignAllowed: DS.attr('boolean'),
  30. decommissionAllowed: DS.attr('boolean'),
  31. hasBulkCommandsDefinition: DS.attr('boolean'),
  32. bulkCommandsDisplayName: DS.attr('string'),
  33. bulkCommandsMasterComponentName: DS.attr('string'),
  34. dependencies: DS.attr('array'),
  35. serviceName: DS.attr('string'),
  36. componentCategory: DS.attr('string'),
  37. isMaster: DS.attr('boolean'),
  38. isClient: DS.attr('boolean'),
  39. stackName: DS.attr('string'),
  40. stackVersion: DS.attr('string'),
  41. stackService: DS.belongsTo('App.StackService'),
  42. serviceComponentId: DS.attr('number', {defaultValue: 1}), // this is used on Assign Master page for multiple masters
  43. /**
  44. * Minimum required count for installation.
  45. *
  46. * @property {Number} minToInstall
  47. **/
  48. minToInstall: function() {
  49. return numberUtils.getCardinalityValue(this.get('cardinality'), false);
  50. }.property('cardinality'),
  51. /**
  52. * Maximum required count for installation.
  53. *
  54. * @property {Number} maxToInstall
  55. **/
  56. maxToInstall: function() {
  57. return numberUtils.getCardinalityValue(this.get('cardinality'), true);
  58. }.property('cardinality'),
  59. /** @property {Boolean} isRequired - component required to install **/
  60. isRequired: Em.computed.gt('minToInstall', 0),
  61. /** @property {Boolean} isMultipleAllowed - component can be assigned for more than one host **/
  62. isMultipleAllowed: Em.computed.gt('maxToInstall', 1),
  63. /** @property {Boolean} isSlave **/
  64. isSlave: Em.computed.equal('componentCategory', 'SLAVE'),
  65. /** @property {Boolean} isRestartable - component supports restart action **/
  66. isRestartable: Em.computed.not('isClient'),
  67. /** @property {Boolean} isReassignable - component supports reassign action **/
  68. isReassignable: function(){
  69. return this.get('reassignAllowed');
  70. }.property('reassignAllowed'),
  71. /** @property {Boolean} isNonHDPComponent - component not belongs to HDP services **/
  72. isNonHDPComponent: function() {
  73. return ['METRICS_COLLECTOR', 'METRICS_MONITOR'].contains(this.get('componentName'));
  74. }.property('componentName'),
  75. /** @property {Boolean} isRollinRestartAllowed - component supports rolling restart action **/
  76. isRollinRestartAllowed: function() {
  77. return this.get('isSlave') || this.get('componentName') === 'KAFKA_BROKER';
  78. }.property('componentName'),
  79. /** @property {Boolean} isDecommissionAllowed - component supports decommission action **/
  80. isDecommissionAllowed: function() {
  81. return this.get('decommissionAllowed');
  82. }.property('decommissionAllowed'),
  83. /** @property {Boolean} isRefreshConfigsAllowed - component supports refresh configs action **/
  84. isRefreshConfigsAllowed: Em.computed.existsIn('componentName', ['FLUME_HANDLER']),
  85. /** @property {Boolean} isAddableToHost - component can be added on host details page **/
  86. isAddableToHost: function() {
  87. return this.get('isMasterAddableInstallerWizard') || ((this.get('isNotAddableOnlyInInstall') || this.get('isSlave') || this.get('isClient')) && !this.get('isHAComponentOnly'));
  88. }.property('componentName'),
  89. /** @property {Boolean} isDeletable - component supports delete action **/
  90. isDeletable: function() {
  91. var ignored = [];
  92. return this.get('isAddableToHost') && !ignored.contains(this.get('componentName'));
  93. }.property('componentName'),
  94. /** @property {Boolean} isShownOnInstallerAssignMasterPage - component visible on "Assign Masters" step of Install Wizard **/
  95. isShownOnInstallerAssignMasterPage: function() {
  96. var component = this.get('componentName');
  97. var mastersNotShown = ['MYSQL_SERVER', 'POSTGRESQL_SERVER', 'HIVE_SERVER_INTERACTIVE'];
  98. return this.get('isMaster') && !mastersNotShown.contains(component);
  99. }.property('isMaster','componentName'),
  100. /** @property {Boolean} isShownOnInstallerSlaveClientPage - component visible on "Assign Slaves and Clients" step of Install Wizard**/
  101. isShownOnInstallerSlaveClientPage: function() {
  102. var component = this.get('componentName');
  103. var slavesNotShown = ['JOURNALNODE','ZKFC','APP_TIMELINE_SERVER'];
  104. return this.get('isSlave') && !this.get('isRequiredOnAllHosts') && !slavesNotShown.contains(component);
  105. }.property('isSlave','componentName', 'isRequiredOnAllHosts'),
  106. /** @property {Boolean} isShownOnAddServiceAssignMasterPage - component visible on "Assign Masters" step of Add Service Wizard **/
  107. isShownOnAddServiceAssignMasterPage: function() {
  108. var isVisible = this.get('isShownOnInstallerAssignMasterPage');
  109. if (App.get('isHaEnabled')) {
  110. isVisible = isVisible && this.get('componentName') !== 'SECONDARY_NAMENODE';
  111. }
  112. return isVisible;
  113. }.property('isShownOnInstallerAssignMasterPage','App.isHaEnabled'),
  114. /** @property {Boolean} isMasterWithMultipleInstances **/
  115. isMasterWithMultipleInstances: function() {
  116. // @todo: safe removing JOURNALNODE from masters list
  117. return (this.get('isMaster') && this.get('isMultipleAllowed')) || this.get('componentName') == 'JOURNALNODE';
  118. }.property('componentName'),
  119. /**
  120. * Master component list that could be assigned for more than 1 host.
  121. * Some components like NameNode and ResourceManager have range cardinality value, so they are excluded using isMasterAddableOnlyOnHA property
  122. *
  123. * @property {Boolean} isMasterAddableInstallerWizard
  124. **/
  125. isMasterAddableInstallerWizard: Em.computed.and('isMaster', 'isMultipleAllowed', '!isMasterAddableOnlyOnHA', '!isNotAddableOnlyInInstall'),
  126. /**
  127. * Master components with cardinality more than 1 (n+ or n-n) that could not be added in wizards
  128. * New instances of these components are added in appropriate HA wizards
  129. * @property {Boolean} isMasterAddableOnlyOnHA
  130. */
  131. isMasterAddableOnlyOnHA: Em.computed.existsIn('componentName', ['NAMENODE', 'RESOURCEMANAGER', 'RANGER_ADMIN']),
  132. /** @property {Boolean} isHAComponentOnly - Components that can be installed only if HA enabled **/
  133. isHAComponentOnly: Em.computed.existsIn('componentName', ['ZKFC','JOURNALNODE']),
  134. /** @property {Boolean} isRequiredOnAllHosts - Is It require to install the components on all hosts. used in step-6 wizard controller **/
  135. isRequiredOnAllHosts: Em.computed.equal('minToInstall', Infinity),
  136. /** @property {Number} defaultNoOfMasterHosts - default number of master hosts on Assign Master page: **/
  137. defaultNoOfMasterHosts: function() {
  138. if (this.get('isMasterAddableInstallerWizard')) {
  139. return this.get('componentName') == 'ZOOKEEPER_SERVER' ? 3 : this.get('minToInstall');
  140. }
  141. }.property('componentName'),
  142. /** @property {Boolean} coHostedComponents - components that are co-hosted with this component **/
  143. coHostedComponents: function() {
  144. var componentName = this.get('componentName');
  145. var key, coHostedComponents = [];
  146. for (key in App.StackServiceComponent.coHost) {
  147. if (App.StackServiceComponent.coHost[key] === componentName) {
  148. coHostedComponents.push(key)
  149. }
  150. }
  151. return coHostedComponents;
  152. }.property('componentName'),
  153. /** @property {Boolean} isOtherComponentCoHosted - Is any other component co-hosted with this component **/
  154. isOtherComponentCoHosted: Em.computed.bool('coHostedComponents.length'),
  155. /** @property {Boolean} isCoHostedComponent - Is this component co-hosted with other component **/
  156. isCoHostedComponent: function() {
  157. var componentName = this.get('componentName');
  158. return !!App.StackServiceComponent.coHost[componentName];
  159. }.property('componentName'),
  160. /** @property {Boolean} isNotAddableOnlyInInstall - is this component addable, except Install and Add Service Wizards **/
  161. isNotAddableOnlyInInstall: Em.computed.existsIn('componentName', ['HIVE_METASTORE', 'HIVE_SERVER', 'RANGER_KMS_SERVER', 'OOZIE_SERVER']),
  162. /** @property {Boolean} isNotAllowedOnSingleNodeCluster - is this component allowed on single node **/
  163. isNotAllowedOnSingleNodeCluster: Em.computed.existsIn('componentName', ['HAWQSTANDBY'])
  164. });
  165. App.StackServiceComponent.FIXTURES = [];
  166. App.StackServiceComponent.coHost = {
  167. 'WEBHCAT_SERVER': 'HIVE_SERVER'
  168. };