stack_service_component.js 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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')
  88. || ((this.get('isNotAddableOnlyInInstall') || this.get('isSlave') || this.get('isClient'))
  89. && (!this.get('isHAComponentOnly') || (App.get('isHaEnabled') && this.get('componentName') == 'JOURNALNODE')));
  90. }.property('componentName'),
  91. /** @property {Boolean} isDeletable - component supports delete action **/
  92. isDeletable: function() {
  93. var ignored = [];
  94. return (this.get('isAddableToHost') && !ignored.contains(this.get('componentName'))) || (this.get('componentName') == 'MYSQL_SERVER');
  95. }.property('componentName'),
  96. /** @property {Boolean} isShownOnInstallerAssignMasterPage - component visible on "Assign Masters" step of Install Wizard **/
  97. // Note: Components that are not visible on Assign Master Page are not saved as part of host component recommendation/validation layout
  98. isShownOnInstallerAssignMasterPage: function() {
  99. var component = this.get('componentName');
  100. var mastersNotShown = ['MYSQL_SERVER', 'POSTGRESQL_SERVER', 'HIVE_SERVER_INTERACTIVE'];
  101. return this.get('isMaster') && !mastersNotShown.contains(component);
  102. }.property('isMaster','componentName'),
  103. /** @property {Boolean} isShownOnInstallerSlaveClientPage - component visible on "Assign Slaves and Clients" step of Install Wizard**/
  104. // Note: Components that are not visible on Assign Slaves and Clients Page are saved as part of host component recommendation/validation layout
  105. isShownOnInstallerSlaveClientPage: function() {
  106. var component = this.get('componentName');
  107. var slavesNotShown = ['JOURNALNODE','ZKFC','APP_TIMELINE_SERVER'];
  108. return this.get('isSlave') && !this.get('isRequiredOnAllHosts') && !slavesNotShown.contains(component);
  109. }.property('isSlave','componentName', 'isRequiredOnAllHosts'),
  110. /** @property {Boolean} isShownOnAddServiceAssignMasterPage - component visible on "Assign Masters" step of Add Service Wizard **/
  111. // Note: Components that are not visible on Assign Master Page are not saved as part of host component recommendation/validation layout
  112. isShownOnAddServiceAssignMasterPage: function() {
  113. var isVisible = this.get('isShownOnInstallerAssignMasterPage');
  114. if (App.get('isHaEnabled')) {
  115. isVisible = isVisible && this.get('componentName') !== 'SECONDARY_NAMENODE';
  116. }
  117. return isVisible;
  118. }.property('isShownOnInstallerAssignMasterPage','App.isHaEnabled'),
  119. /** @property {Boolean} isMasterWithMultipleInstances **/
  120. isMasterWithMultipleInstances: function() {
  121. // @todo: safe removing JOURNALNODE from masters list
  122. return (this.get('isMaster') && this.get('isMultipleAllowed')) || this.get('componentName') == 'JOURNALNODE';
  123. }.property('componentName'),
  124. /**
  125. * Master component list that could be assigned for more than 1 host.
  126. * Some components like NameNode and ResourceManager have range cardinality value, so they are excluded using isMasterAddableOnlyOnHA property
  127. *
  128. * @property {Boolean} isMasterAddableInstallerWizard
  129. **/
  130. isMasterAddableInstallerWizard: Em.computed.and('isMaster', 'isMultipleAllowed', '!isMasterAddableOnlyOnHA', '!isNotAddableOnlyInInstall'),
  131. /**
  132. * Master components with cardinality more than 1 (n+ or n-n) that could not be added in wizards
  133. * New instances of these components are added in appropriate HA wizards
  134. * @property {Boolean} isMasterAddableOnlyOnHA
  135. */
  136. isMasterAddableOnlyOnHA: Em.computed.existsIn('componentName', ['NAMENODE', 'RESOURCEMANAGER', 'RANGER_ADMIN']),
  137. /** @property {Boolean} isHAComponentOnly - Components that can be installed only if HA enabled **/
  138. isHAComponentOnly: Em.computed.existsIn('componentName', ['ZKFC','JOURNALNODE']),
  139. /** @property {Boolean} isRequiredOnAllHosts - Is It require to install the components on all hosts. used in step-6 wizard controller **/
  140. isRequiredOnAllHosts: Em.computed.equal('minToInstall', Infinity),
  141. /** @property {Number} defaultNoOfMasterHosts - default number of master hosts on Assign Master page: **/
  142. defaultNoOfMasterHosts: function() {
  143. if (this.get('isMasterAddableInstallerWizard')) {
  144. return this.get('componentName') == 'ZOOKEEPER_SERVER' ? 3 : this.get('minToInstall');
  145. }
  146. }.property('componentName'),
  147. /** @property {Boolean} coHostedComponents - components that are co-hosted with this component **/
  148. coHostedComponents: function() {
  149. var componentName = this.get('componentName');
  150. var key, coHostedComponents = [];
  151. for (key in App.StackServiceComponent.coHost) {
  152. if (App.StackServiceComponent.coHost[key] === componentName) {
  153. coHostedComponents.push(key)
  154. }
  155. }
  156. return coHostedComponents;
  157. }.property('componentName'),
  158. /** @property {Boolean} isOtherComponentCoHosted - Is any other component co-hosted with this component **/
  159. isOtherComponentCoHosted: Em.computed.bool('coHostedComponents.length'),
  160. /** @property {Boolean} isCoHostedComponent - Is this component co-hosted with other component **/
  161. isCoHostedComponent: function() {
  162. var componentName = this.get('componentName');
  163. return !!App.StackServiceComponent.coHost[componentName];
  164. }.property('componentName'),
  165. /** @property {Boolean} isNotAddableOnlyInInstall - is this component addable, except Install and Add Service Wizards **/
  166. isNotAddableOnlyInInstall: Em.computed.existsIn('componentName', ['HIVE_METASTORE', 'HIVE_SERVER', 'RANGER_KMS_SERVER', 'OOZIE_SERVER']),
  167. /** @property {Boolean} isNotAllowedOnSingleNodeCluster - is this component allowed on single node **/
  168. isNotAllowedOnSingleNodeCluster: Em.computed.existsIn('componentName', ['HAWQSTANDBY'])
  169. });
  170. App.StackServiceComponent.FIXTURES = [];
  171. App.StackServiceComponent.coHost = {
  172. 'WEBHCAT_SERVER': 'HIVE_SERVER'
  173. };