stack_service_component.js 8.6 KB

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