stack_service_component.js 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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. cardinality: DS.attr('string'),
  27. dependencies: DS.attr('array'),
  28. serviceName: DS.attr('string'),
  29. componentCategory: DS.attr('string'),
  30. isMaster: DS.attr('boolean'),
  31. isClient: DS.attr('boolean'),
  32. stackName: DS.attr('string'),
  33. stackVersion: DS.attr('string'),
  34. stackService: DS.belongsTo('App.StackService'),
  35. serviceComponentId: DS.attr('number', {defaultValue: 1}), // this is used on Assign Master page for multiple masters
  36. /**
  37. * Minimum required count for installation.
  38. *
  39. * @property {Number} minToInstall
  40. **/
  41. minToInstall: function() {
  42. return numberUtils.getCardinalityValue(this.get('cardinality'), false);
  43. }.property('cardinality'),
  44. /**
  45. * Maximum required count for installation.
  46. *
  47. * @property {Number} maxToInstall
  48. **/
  49. maxToInstall: function() {
  50. return numberUtils.getCardinalityValue(this.get('cardinality'), true);
  51. }.property('cardinality'),
  52. /** @property {String} displayName**/
  53. displayName: function() {
  54. if (App.format.role(this.get('componentName'))) {
  55. return App.format.role(this.get('componentName'));
  56. } else {
  57. return this.get('componentName');
  58. }
  59. }.property('componentName'),
  60. /** @property {Boolean} isRequired - component required to install **/
  61. isRequired: function() {
  62. return this.get('minToInstall') > 0;
  63. }.property('cardinality'),
  64. /** @property {Boolean} isMultipleAllowed - component can be assigned for more than one host **/
  65. isMultipleAllowed: function() {
  66. return this.get('maxToInstall') > 1;
  67. }.property('cardinality'),
  68. /** @property {Boolean} isSlave **/
  69. isSlave: function() {
  70. return this.get('componentCategory') === 'SLAVE';
  71. }.property('componentCategory'),
  72. /** @property {Boolean} isRestartable - component supports restart action **/
  73. isRestartable: function() {
  74. return !this.get('isClient');
  75. }.property('isClient'),
  76. /** @property {Boolean} isReassignable - component supports reassign action **/
  77. isReassignable: function() {
  78. return ['NAMENODE', 'SECONDARY_NAMENODE', 'JOBTRACKER', 'RESOURCEMANAGER'].contains(this.get('componentName'));
  79. }.property('componentName'),
  80. /** @property {Boolean} isRollinRestartAllowed - component supports rolling restart action **/
  81. isRollinRestartAllowed: function() {
  82. return this.get('isSlave') && !this.get('isMasterBehavior');
  83. }.property('componentName'),
  84. /** @property {Boolean} isDecommissionAllowed - component supports decommission action **/
  85. isDecommissionAllowed: function() {
  86. return ["DATANODE", "TASKTRACKER", "NODEMANAGER", "HBASE_REGIONSERVER"].contains(this.get('componentName'));
  87. }.property('componentName'),
  88. /** @property {Boolean} isRefreshConfigsAllowed - component supports refresh configs action **/
  89. isRefreshConfigsAllowed: function() {
  90. return ["FLUME_HANDLER"].contains(this.get('componentName'));
  91. }.property('componentName'),
  92. /** @property {Boolean} isAddableToHost - component can be added on host details page **/
  93. isAddableToHost: function() {
  94. return ((this.get('isMasterAddableInstallerWizard') || (this.get('isSlave') && this.get('maxToInstall') > 2) || this.get('isClient')) && !this.get('isHAComponentOnly'));
  95. }.property('componentName'),
  96. /** @property {Boolean} isDeletable - component supports delete action **/
  97. isDeletable: function() {
  98. var ignored = ['HBASE_MASTER'];
  99. return this.get('isAddableToHost') && !ignored.contains(this.get('componentName'));
  100. }.property('componentName'),
  101. /** @property {Boolean} isShownOnInstallerAssignMasterPage - component visible on "Assign Masters" step of Install Wizard **/
  102. isShownOnInstallerAssignMasterPage: function() {
  103. var component = this.get('componentName');
  104. var mastersNotShown = ['MYSQL_SERVER'];
  105. return ((this.get('isMaster') && !mastersNotShown.contains(component)) || component === 'APP_TIMELINE_SERVER');
  106. }.property('isMaster','componentName'),
  107. /** @property {Boolean} isShownOnInstallerSlaveClientPage - component visible on "Assign Slaves and Clients" step of Install Wizard**/
  108. isShownOnInstallerSlaveClientPage: function() {
  109. var component = this.get('componentName');
  110. var slavesNotShown = ['JOURNALNODE','ZKFC','APP_TIMELINE_SERVER','GANGLIA_MONITOR'];
  111. return this.get('isSlave') && !slavesNotShown.contains(component);
  112. }.property('isSlave','componentName'),
  113. /** @property {Boolean} isShownOnAddServiceAssignMasterPage - component visible on "Assign Masters" step of Add Service Wizard **/
  114. isShownOnAddServiceAssignMasterPage: function() {
  115. var isVisible = this.get('isShownOnInstallerAssignMasterPage');
  116. if (App.get('isHaEnabled')) {
  117. isVisible = isVisible && this.get('componentName') !== 'SECONDARY_NAMENODE';
  118. }
  119. return isVisible;
  120. }.property('isShownOnInstallerAssignMasterPage','App.isHaEnabled'),
  121. /** @property {Boolean} isMasterWithMultipleInstances **/
  122. isMasterWithMultipleInstances: function() {
  123. // @todo: safe removing JOURNALNODE from masters list
  124. return (this.get('isMaster') && this.get('isMultipleAllowed')) || this.get('componentName') == 'JOURNALNODE';
  125. }.property('componentName'),
  126. /**
  127. * Master component list that could be assigned for more than 1 host.
  128. * Some components like NameNode and ResourceManager have range cardinality value
  129. * like 1-2. We can assign only components with cardinality 1+/0+. Strict range value
  130. * show that this components will be assigned for 2 hosts only if HA mode activated.
  131. *
  132. * @property {Boolean} isMasterAddableInstallerWizard
  133. **/
  134. isMasterAddableInstallerWizard: function() {
  135. return this.get('isMaster') && this.get('isMultipleAllowed') && this.get('maxToInstall') > 2;
  136. }.property('componentName'),
  137. /** @property {Boolean} isMasterBehavior - Some non master components can be assigned as master **/
  138. isMasterBehavior: function() {
  139. var componentsName = ['APP_TIMELINE_SERVER'];
  140. return componentsName.contains(this.get('componentName'));
  141. }.property('componentName'),
  142. /** @property {Boolean} isClientBehavior - Some non client components can be assigned as clients.
  143. *
  144. * Used for ignoring such components as Ganglia Monitor on Installer "Review" step.
  145. **/
  146. isClientBehavior: function() {
  147. var componentName = ['GANGLIA_MONITOR'];
  148. return componentName.contains(this.get('componentName'));
  149. }.property('componentName'),
  150. /** @property {Boolean} isHAComponentOnly - Components that can be installed only if HA enabled **/
  151. isHAComponentOnly: function() {
  152. var HAComponentNames = ['ZKFC','JOURNALNODE'];
  153. return HAComponentNames.contains(this.get('componentName'));
  154. }.property('componentName'),
  155. /** @property {Boolean} isRequiredOnAllHosts - Is It require to install the components on all hosts. used in step-6 wizard controller **/
  156. isRequiredOnAllHosts: function() {
  157. return this.get('minToInstall') == Infinity;
  158. }.property('stackService','isSlave'),
  159. /** components that are not to be installed with ambari server **/
  160. isNotPreferableOnAmbariServerHost: function() {
  161. var service = ['STORM_UI_SERVER', 'DRPC_SERVER', 'STORM_REST_API', 'NIMBUS', 'GANGLIA_SERVER', 'NAGIOS_SERVER', 'HUE_SERVER'];
  162. return service.contains(this.get('componentName'));
  163. }.property('componentName'),
  164. /** @property {Number} defaultNoOfMasterHosts - default number of master hosts on Assign Master page: **/
  165. defaultNoOfMasterHosts: function() {
  166. if (this.get('isMasterAddableInstallerWizard')) {
  167. return this.get('componentName') == 'ZOOKEEPER_SERVER' ? 3 : this.get('minToInstall');
  168. }
  169. }.property('componentName'),
  170. /** @property {Boolean} coHostedComponents - components that are co-hosted with this component **/
  171. coHostedComponents: function() {
  172. var componentName = this.get('componentName');
  173. var key, coHostedComponents = [];
  174. for (key in App.StackServiceComponent.coHost) {
  175. if (App.StackServiceComponent.coHost[key] === componentName) {
  176. coHostedComponents.push(key)
  177. }
  178. }
  179. return coHostedComponents;
  180. }.property('componentName'),
  181. /** @property {Boolean} isOtherComponentCoHosted - Is any other component co-hosted with this component **/
  182. isOtherComponentCoHosted: function() {
  183. return !!this.get('coHostedComponents').length;
  184. }.property('coHostedComponents'),
  185. /** @property {Boolean} isCoHostedComponent - Is this component co-hosted with other component **/
  186. isCoHostedComponent: function() {
  187. var componentName = this.get('componentName');
  188. return !!App.StackServiceComponent.coHost[componentName];
  189. }.property('componentName')
  190. });
  191. App.StackServiceComponent.FIXTURES = [];
  192. App.StackServiceComponent.coHost = {
  193. 'HIVE_METASTORE': 'HIVE_SERVER',
  194. 'WEBHCAT_SERVER': 'HIVE_SERVER'
  195. };