stack_service_component.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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. /**
  20. * This model loads all serviceComponents supported by the stack
  21. * @type {*}
  22. */
  23. App.StackServiceComponent = DS.Model.extend({
  24. componentName: DS.attr('string'),
  25. dependencies: DS.attr('array'),
  26. serviceName: DS.attr('string'),
  27. componentCategory: DS.attr('string'),
  28. isMaster: DS.attr('boolean'),
  29. isClient: DS.attr('boolean'),
  30. stackName: DS.attr('string'),
  31. stackVersion: DS.attr('string'),
  32. stackService: DS.belongsTo('App.StackService'),
  33. serviceComponentId: DS.attr('number', {defaultValue: 1}), // this is used on Assign Master page for multiple masters
  34. displayName: function() {
  35. if (App.format.role(this.get('componentName'))) {
  36. return App.format.role(this.get('componentName'));
  37. } else {
  38. return this.get('componentName');
  39. }
  40. }.property('componentName'),
  41. isSlave: function() {
  42. return this.get('componentCategory') === 'SLAVE';
  43. }.property('componentCategory'),
  44. isRestartable: function() {
  45. return !this.get('isClient');
  46. }.property('isClient'),
  47. isReassignable: function() {
  48. return ['NAMENODE', 'SECONDARY_NAMENODE', 'JOBTRACKER', 'RESOURCEMANAGER'].contains(this.get('componentName'));
  49. }.property('componentName'),
  50. isDeletable: function() {
  51. return ['SUPERVISOR', 'HBASE_MASTER', 'DATANODE', 'TASKTRACKER', 'NODEMANAGER', 'HBASE_REGIONSERVER', 'GANGLIA_MONITOR', 'ZOOKEEPER_SERVER'].contains(this.get('componentName'));
  52. }.property('componentName'),
  53. isRollinRestartAllowed: function() {
  54. return ["DATANODE", "TASKTRACKER", "NODEMANAGER", "HBASE_REGIONSERVER", "SUPERVISOR"].contains(this.get('componentName'));
  55. }.property('componentName'),
  56. isDecommissionAllowed: function() {
  57. return ["DATANODE", "TASKTRACKER", "NODEMANAGER", "HBASE_REGIONSERVER"].contains(this.get('componentName'));
  58. }.property('componentName'),
  59. isRefreshConfigsAllowed: function() {
  60. return ["FLUME_HANDLER"].contains(this.get('componentName'));
  61. }.property('componentName'),
  62. isAddableToHost: function() {
  63. return ["DATANODE", "TASKTRACKER", "NODEMANAGER", "HBASE_REGIONSERVER", "HBASE_MASTER", "ZOOKEEPER_SERVER", "SUPERVISOR", "GANGLIA_MONITOR"].contains(this.get('componentName'));
  64. }.property('componentName'),
  65. isShownOnInstallerAssignMasterPage: function() {
  66. var component = this.get('componentName');
  67. var mastersNotShown = ['MYSQL_SERVER'];
  68. return ((this.get('isMaster') && !mastersNotShown.contains(component)) || component === 'APP_TIMELINE_SERVER');
  69. }.property('isMaster','componentName'),
  70. isShownOnInstallerSlaveClientPage: function() {
  71. var component = this.get('componentName');
  72. var slavesNotShown = ['JOURNALNODE','ZKFC','APP_TIMELINE_SERVER','GANGLIA_MONITOR'];
  73. return this.get('isSlave') && !slavesNotShown.contains(component);
  74. }.property('isSlave','componentName'),
  75. isShownOnAddServiceAssignMasterPage: function() {
  76. var isVisible = this.get('isShownOnInstallerAssignMasterPage');
  77. if (App.get('isHaEnabled')) {
  78. isVisible = isVisible && this.get('componentName') !== 'SECONDARY_NAMENODE';
  79. }
  80. return isVisible;
  81. }.property('isShownOnInstallerAssignMasterPage','App.isHaEnabled'),
  82. isMasterWithMultipleInstances: function() {
  83. var masters = ['ZOOKEEPER_SERVER', 'HBASE_MASTER', 'NAMENODE', 'JOURNALNODE', 'RESOURCEMANAGER'];
  84. return masters.contains(this.get('componentName'));
  85. }.property('componentName'),
  86. isMasterAddableInstallerWizard: function() {
  87. var masters = ['ZOOKEEPER_SERVER', 'HBASE_MASTER'];
  88. return masters.contains(this.get('componentName'));
  89. }.property('componentName'),
  90. /** Some non master components can be assigned as master **/
  91. isMasterBehavior: function() {
  92. var componentsName = ['APP_TIMELINE_SERVER'];
  93. return componentsName.contains(this.get('componentName'));
  94. }.property('componentName'),
  95. /** Some non client components can be assigned as clients **/
  96. isClientBehavior: function() {
  97. var componentName = ['GANGLIA_MONITOR'];
  98. return componentName.contains(this.get('componentName'));
  99. }.property('componentName'),
  100. /** Components that can be installed only if HA enabled **/
  101. isHAComponentOnly: function() {
  102. var HAComponentNames = ['ZKFC','JOURNALNODE'];
  103. return HAComponentNames.contains(this.get('componentName'));
  104. }.property('componentName'),
  105. // Is It require to install the components on all hosts. used in step-6 wizard controller
  106. isRequiredOnAllHosts: function() {
  107. var service = this.get('stackService');
  108. return service.get('isMonitoringService') && this.get('isSlave') ;
  109. }.property('stackService','isSlave'),
  110. // components that are not to be installed with ambari server
  111. isNotPreferableOnAmbariServerHost: function() {
  112. var service = ['STORM_UI_SERVER', 'DRPC_SERVER', 'STORM_REST_API', 'NIMBUS', 'GANGLIA_SERVER', 'NAGIOS_SERVER', 'HUE_SERVER'];
  113. return service.contains(this.get('componentName'));
  114. }.property('componentName'),
  115. // default number of master hosts on Assign Master page:
  116. defaultNoOfMasterHosts: function() {
  117. var componentName = this.get('componentName');
  118. if (this.get('isMasterAddableInstallerWizard')) {
  119. return App.StackServiceComponent.cardinality(componentName).min;
  120. }
  121. }.property('componentName'),
  122. selectionSchemeForMasterComponent: function() {
  123. return App.StackServiceComponent.selectionScheme(this.get('componentName'));
  124. }.property('componentName'),
  125. // components that are co-hosted with this component
  126. coHostedComponents: function() {
  127. var componentName = this.get('componentName');
  128. var key, coHostedComponents = [];
  129. for (key in App.StackServiceComponent.coHost) {
  130. if (App.StackServiceComponent.coHost[key] === componentName) {
  131. coHostedComponents.push(key)
  132. }
  133. }
  134. return coHostedComponents;
  135. }.property('componentName'),
  136. // Is any other component co-hosted with this component
  137. isOtherComponentCoHosted: function() {
  138. return !!this.get('coHostedComponents').length;
  139. }.property('coHostedComponents'),
  140. // Is this component co-hosted with other component
  141. isCoHostedComponent: function() {
  142. var componentName = this.get('componentName');
  143. return !!App.StackServiceComponent.coHost[componentName];
  144. }.property('componentName')
  145. });
  146. App.StackServiceComponent.FIXTURES = [];
  147. App.StackServiceComponent.selectionScheme = function (componentName){
  148. switch (componentName) {
  149. case 'NAMENODE' :
  150. return {"else": 0};
  151. case 'SECONDARY_NAMENODE' :
  152. return {"else": 1};
  153. case 'HBASE_MASTER':
  154. return {"6": 0, "31": 2, "else": 3};
  155. case 'JOBTRACKER':
  156. case 'HISTORYSERVER':
  157. case 'RESOURCEMANAGER':
  158. case 'APP_TIMELINE_SERVER':
  159. return {"31": 1, "else": 2};
  160. case 'OOZIE_SERVER':
  161. case 'FALCON_SERVER' :
  162. return {"6": 1, "31": 2, "else": 3};
  163. case 'HIVE_SERVER' :
  164. case 'HIVE_METASTORE' :
  165. case 'WEBHCAT_SERVER' :
  166. return {"6": 1, "31": 2, "else": 4};
  167. default:
  168. return {"else": 0};
  169. }
  170. };
  171. App.StackServiceComponent.cardinality = function (componentName) {
  172. switch (componentName) {
  173. case 'ZOOKEEPER_SERVER':
  174. return {min: 3};
  175. case 'HBASE_MASTER':
  176. return {min: 1};
  177. default:
  178. return {min:1, max:1};
  179. }
  180. };
  181. App.StackServiceComponent.coHost = {
  182. 'HIVE_METASTORE': 'HIVE_SERVER',
  183. 'WEBHCAT_SERVER': 'HIVE_SERVER'
  184. };