stack_service_component.js 10 KB

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