stack_service_component.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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('isHAComponentOnly'));
  95. }.property('componentName'),
  96. /** @property {Boolean} isDeletable - component supports delete action **/
  97. isDeletable: function() {
  98. return this.get('isAddableToHost');
  99. }.property('componentName'),
  100. /** @property {Boolean} isShownOnInstallerAssignMasterPage - component visible on "Assign Masters" step of Install Wizard **/
  101. isShownOnInstallerAssignMasterPage: function() {
  102. var component = this.get('componentName');
  103. var mastersNotShown = ['MYSQL_SERVER'];
  104. return ((this.get('isMaster') && !mastersNotShown.contains(component)) || component === 'APP_TIMELINE_SERVER');
  105. }.property('isMaster','componentName'),
  106. /** @property {Boolean} isShownOnInstallerSlaveClientPage - component visible on "Assign Slaves and Clients" step of Install Wizard**/
  107. isShownOnInstallerSlaveClientPage: function() {
  108. var component = this.get('componentName');
  109. var slavesNotShown = ['JOURNALNODE','ZKFC','APP_TIMELINE_SERVER','GANGLIA_MONITOR'];
  110. return this.get('isSlave') && !slavesNotShown.contains(component);
  111. }.property('isSlave','componentName'),
  112. /** @property {Boolean} isShownOnAddServiceAssignMasterPage - component visible on "Assign Masters" step of Add Service Wizard **/
  113. isShownOnAddServiceAssignMasterPage: function() {
  114. var isVisible = this.get('isShownOnInstallerAssignMasterPage');
  115. if (App.get('isHaEnabled')) {
  116. isVisible = isVisible && this.get('componentName') !== 'SECONDARY_NAMENODE';
  117. }
  118. return isVisible;
  119. }.property('isShownOnInstallerAssignMasterPage','App.isHaEnabled'),
  120. /** @property {Boolean} isMasterWithMultipleInstances **/
  121. isMasterWithMultipleInstances: function() {
  122. // @todo: safe removing JOURNALNODE from masters list
  123. return (this.get('isMaster') && this.get('isMultipleAllowed')) || this.get('componentName') == 'JOURNALNODE';
  124. }.property('componentName'),
  125. /**
  126. * Master component list that could be assigned for more than 1 host.
  127. * Some components like NameNode and ResourceManager have range cardinality value
  128. * like 1-2. We can assign only components with cardinality 1+/0+. Strict range value
  129. * show that this components will be assigned for 2 hosts only if HA mode activated.
  130. *
  131. * @property {Boolean} isMasterAddableInstallerWizard
  132. **/
  133. isMasterAddableInstallerWizard: function() {
  134. return this.get('isMaster') && this.get('isMultipleAllowed') && this.get('maxToInstall') > 2;
  135. }.property('componentName'),
  136. /** @property {Boolean} isMasterBehavior - Some non master components can be assigned as master **/
  137. isMasterBehavior: function() {
  138. var componentsName = ['APP_TIMELINE_SERVER'];
  139. return componentsName.contains(this.get('componentName'));
  140. }.property('componentName'),
  141. /** @property {Boolean} isClientBehavior - Some non client components can be assigned as clients.
  142. *
  143. * Used for ignoring such components as Ganglia Monitor on Installer "Review" step.
  144. **/
  145. isClientBehavior: function() {
  146. var componentName = ['GANGLIA_MONITOR'];
  147. return componentName.contains(this.get('componentName'));
  148. }.property('componentName'),
  149. /** @property {Boolean} isHAComponentOnly - Components that can be installed only if HA enabled **/
  150. isHAComponentOnly: function() {
  151. var HAComponentNames = ['ZKFC','JOURNALNODE'];
  152. return HAComponentNames.contains(this.get('componentName'));
  153. }.property('componentName'),
  154. /** @property {Boolean} isRequiredOnAllHosts - Is It require to install the components on all hosts. used in step-6 wizard controller **/
  155. isRequiredOnAllHosts: function() {
  156. return this.get('minToInstall') == Infinity;
  157. }.property('stackService','isSlave'),
  158. /** components that are not to be installed with ambari server **/
  159. isNotPreferableOnAmbariServerHost: function() {
  160. var service = ['STORM_UI_SERVER', 'DRPC_SERVER', 'STORM_REST_API', 'NIMBUS', 'GANGLIA_SERVER', 'NAGIOS_SERVER', 'HUE_SERVER'];
  161. return service.contains(this.get('componentName'));
  162. }.property('componentName'),
  163. /** @property {Number} defaultNoOfMasterHosts - default number of master hosts on Assign Master page: **/
  164. defaultNoOfMasterHosts: function() {
  165. if (this.get('isMasterAddableInstallerWizard')) {
  166. return this.get('componentName') == 'ZOOKEEPER_SERVER' ? 3 : this.get('minToInstall');
  167. }
  168. }.property('componentName'),
  169. selectionSchemeForMasterComponent: function() {
  170. return App.StackServiceComponent.selectionScheme(this.get('componentName'));
  171. }.property('componentName'),
  172. /** @property {Boolean} coHostedComponents - components that are co-hosted with this component **/
  173. coHostedComponents: function() {
  174. var componentName = this.get('componentName');
  175. var key, coHostedComponents = [];
  176. for (key in App.StackServiceComponent.coHost) {
  177. if (App.StackServiceComponent.coHost[key] === componentName) {
  178. coHostedComponents.push(key)
  179. }
  180. }
  181. return coHostedComponents;
  182. }.property('componentName'),
  183. /** @property {Boolean} isOtherComponentCoHosted - Is any other component co-hosted with this component **/
  184. isOtherComponentCoHosted: function() {
  185. return !!this.get('coHostedComponents').length;
  186. }.property('coHostedComponents'),
  187. /** @property {Boolean} isCoHostedComponent - Is this component co-hosted with other component **/
  188. isCoHostedComponent: function() {
  189. var componentName = this.get('componentName');
  190. return !!App.StackServiceComponent.coHost[componentName];
  191. }.property('componentName')
  192. });
  193. App.StackServiceComponent.FIXTURES = [];
  194. App.StackServiceComponent.selectionScheme = function (componentName){
  195. switch (componentName) {
  196. case 'NAMENODE' :
  197. return {"else": 0};
  198. case 'SECONDARY_NAMENODE' :
  199. return {"else": 1};
  200. case 'HBASE_MASTER':
  201. return {"6": 0, "31": 2, "else": 3};
  202. case 'JOBTRACKER':
  203. case 'HISTORYSERVER':
  204. case 'RESOURCEMANAGER':
  205. case 'APP_TIMELINE_SERVER':
  206. return {"31": 1, "else": 2};
  207. case 'OOZIE_SERVER':
  208. case 'FALCON_SERVER' :
  209. return {"6": 1, "31": 2, "else": 3};
  210. case 'HIVE_SERVER' :
  211. case 'HIVE_METASTORE' :
  212. case 'WEBHCAT_SERVER' :
  213. return {"6": 1, "31": 2, "else": 4};
  214. default:
  215. return {"else": 0};
  216. }
  217. };
  218. App.StackServiceComponent.coHost = {
  219. 'HIVE_METASTORE': 'HIVE_SERVER',
  220. 'WEBHCAT_SERVER': 'HIVE_SERVER'
  221. };