stack_service_component.js 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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: function() {
  56. return this.get('minToInstall') > 0;
  57. }.property('cardinality'),
  58. /** @property {Boolean} isMultipleAllowed - component can be assigned for more than one host **/
  59. isMultipleAllowed: function() {
  60. return this.get('maxToInstall') > 1;
  61. }.property('cardinality'),
  62. /** @property {Boolean} isSlave **/
  63. isSlave: function() {
  64. return this.get('componentCategory') === 'SLAVE';
  65. }.property('componentCategory'),
  66. /** @property {Boolean} isRestartable - component supports restart action **/
  67. isRestartable: function() {
  68. return !this.get('isClient');
  69. }.property('isClient'),
  70. /** @property {Boolean} isReassignable - component supports reassign action **/
  71. isReassignable: function() {
  72. return ['NAMENODE', 'SECONDARY_NAMENODE', 'JOBTRACKER', 'RESOURCEMANAGER', 'APP_TIMELINE_SERVER', 'OOZIE_SERVER', 'WEBHCAT_SERVER', 'HIVE_SERVER', 'HIVE_METASTORE', 'MYSQL_SERVER'].contains(this.get('componentName'));
  73. }.property('componentName'),
  74. /** @property {Boolean} isRollinRestartAllowed - component supports rolling restart action **/
  75. isRollinRestartAllowed: function() {
  76. return this.get('isSlave');
  77. }.property('componentName'),
  78. /** @property {Boolean} isDecommissionAllowed - component supports decommission action **/
  79. isDecommissionAllowed: function() {
  80. return ["DATANODE", "TASKTRACKER", "NODEMANAGER", "HBASE_REGIONSERVER"].contains(this.get('componentName'));
  81. }.property('componentName'),
  82. /** @property {Boolean} isRefreshConfigsAllowed - component supports refresh configs action **/
  83. isRefreshConfigsAllowed: function() {
  84. return ["FLUME_HANDLER"].contains(this.get('componentName'));
  85. }.property('componentName'),
  86. /** @property {Boolean} isAddableToHost - component can be added on host details page **/
  87. isAddableToHost: function() {
  88. return ((this.get('isMasterAddableInstallerWizard') || (this.get('isSlave') && this.get('maxToInstall') > 2) || this.get('isClient')) && !this.get('isHAComponentOnly'));
  89. }.property('componentName'),
  90. /** @property {Boolean} isDeletable - component supports delete action **/
  91. isDeletable: function() {
  92. var ignored = ['HBASE_MASTER'];
  93. return this.get('isAddableToHost') && !ignored.contains(this.get('componentName'));
  94. }.property('componentName'),
  95. /** @property {Boolean} isShownOnInstallerAssignMasterPage - component visible on "Assign Masters" step of Install Wizard **/
  96. isShownOnInstallerAssignMasterPage: function() {
  97. var component = this.get('componentName');
  98. var mastersNotShown = ['MYSQL_SERVER', 'POSTGRESQL_SERVER'];
  99. return this.get('isMaster') && !mastersNotShown.contains(component);
  100. }.property('isMaster','componentName'),
  101. /** @property {Boolean} isShownOnInstallerSlaveClientPage - component visible on "Assign Slaves and Clients" step of Install Wizard**/
  102. isShownOnInstallerSlaveClientPage: function() {
  103. var component = this.get('componentName');
  104. var slavesNotShown = ['JOURNALNODE','ZKFC','APP_TIMELINE_SERVER'];
  105. return this.get('isSlave') && !this.get('isRequiredOnAllHosts') && !slavesNotShown.contains(component);
  106. }.property('isSlave','componentName', 'isRequiredOnAllHosts'),
  107. /** @property {Boolean} isShownOnAddServiceAssignMasterPage - component visible on "Assign Masters" step of Add Service Wizard **/
  108. isShownOnAddServiceAssignMasterPage: function() {
  109. var isVisible = this.get('isShownOnInstallerAssignMasterPage');
  110. if (App.get('isHaEnabled')) {
  111. isVisible = isVisible && this.get('componentName') !== 'SECONDARY_NAMENODE';
  112. }
  113. return isVisible;
  114. }.property('isShownOnInstallerAssignMasterPage','App.isHaEnabled'),
  115. /** @property {Boolean} isMasterWithMultipleInstances **/
  116. isMasterWithMultipleInstances: function() {
  117. // @todo: safe removing JOURNALNODE from masters list
  118. return (this.get('isMaster') && this.get('isMultipleAllowed')) || this.get('componentName') == 'JOURNALNODE';
  119. }.property('componentName'),
  120. /**
  121. * Master component list that could be assigned for more than 1 host.
  122. * Some components like NameNode and ResourceManager have range cardinality value
  123. * like 1-2. We can assign only components with cardinality 1+/0+. Strict range value
  124. * show that this components will be assigned for 2 hosts only if HA mode activated.
  125. *
  126. * @property {Boolean} isMasterAddableInstallerWizard
  127. **/
  128. isMasterAddableInstallerWizard: function() {
  129. return this.get('isMaster') && this.get('isMultipleAllowed') && this.get('maxToInstall') > 2;
  130. }.property('componentName'),
  131. /** @property {Boolean} isHAComponentOnly - Components that can be installed only if HA enabled **/
  132. isHAComponentOnly: function() {
  133. var HAComponentNames = ['ZKFC','JOURNALNODE'];
  134. return HAComponentNames.contains(this.get('componentName'));
  135. }.property('componentName'),
  136. /** @property {Boolean} isRequiredOnAllHosts - Is It require to install the components on all hosts. used in step-6 wizard controller **/
  137. isRequiredOnAllHosts: function() {
  138. return this.get('minToInstall') == Infinity;
  139. }.property('stackService','isSlave'),
  140. /** @property {Number} defaultNoOfMasterHosts - default number of master hosts on Assign Master page: **/
  141. defaultNoOfMasterHosts: function() {
  142. if (this.get('isMasterAddableInstallerWizard')) {
  143. return this.get('componentName') == 'ZOOKEEPER_SERVER' ? 3 : this.get('minToInstall');
  144. }
  145. }.property('componentName'),
  146. /** @property {Boolean} coHostedComponents - components that are co-hosted with this component **/
  147. coHostedComponents: function() {
  148. var componentName = this.get('componentName');
  149. var key, coHostedComponents = [];
  150. for (key in App.StackServiceComponent.coHost) {
  151. if (App.StackServiceComponent.coHost[key] === componentName) {
  152. coHostedComponents.push(key)
  153. }
  154. }
  155. return coHostedComponents;
  156. }.property('componentName'),
  157. /** @property {Boolean} isOtherComponentCoHosted - Is any other component co-hosted with this component **/
  158. isOtherComponentCoHosted: function() {
  159. return !!this.get('coHostedComponents').length;
  160. }.property('coHostedComponents'),
  161. /** @property {Boolean} isCoHostedComponent - Is this component co-hosted with other component **/
  162. isCoHostedComponent: function() {
  163. var componentName = this.get('componentName');
  164. return !!App.StackServiceComponent.coHost[componentName];
  165. }.property('componentName')
  166. });
  167. App.StackServiceComponent.FIXTURES = [];
  168. App.StackServiceComponent.coHost = {
  169. 'WEBHCAT_SERVER': 'HIVE_SERVER'
  170. };