host_component.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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. App.HostComponent = DS.Model.extend({
  20. workStatus: DS.attr('string'),
  21. componentName: DS.attr('string'),
  22. haStatus: DS.attr('string'),
  23. displayNameAdvanced: DS.attr('string'),
  24. staleConfigs: DS.attr('boolean'),
  25. host: DS.belongsTo('App.Host'),
  26. service: DS.belongsTo('App.Service'),
  27. isClient:function () {
  28. if(['PIG', 'SQOOP', 'HCAT', 'MAPREDUCE2_CLIENT'].contains(this.get('componentName'))){
  29. return true;
  30. }
  31. return Boolean(this.get('componentName').match(/_client/gi));
  32. }.property('componentName'),
  33. isRunning: function(){
  34. return (this.get('workStatus') == 'STARTED' || this.get('workStatus') == 'STARTING');
  35. }.property('workStatus'),
  36. displayName: function () {
  37. return App.format.role(this.get('componentName'));
  38. }.property('componentName'),
  39. isMaster: function () {
  40. switch (this.get('componentName')) {
  41. case 'NAMENODE':
  42. case 'SECONDARY_NAMENODE':
  43. case 'SNAMENODE':
  44. case 'JOURNALNODE':
  45. case 'JOBTRACKER':
  46. case 'ZOOKEEPER_SERVER':
  47. case 'HIVE_SERVER':
  48. case 'HIVE_METASTORE':
  49. case 'MYSQL_SERVER':
  50. case 'HBASE_MASTER':
  51. case 'NAGIOS_SERVER':
  52. case 'GANGLIA_SERVER':
  53. case 'OOZIE_SERVER':
  54. case 'WEBHCAT_SERVER':
  55. case 'HUE_SERVER':
  56. case 'HISTORYSERVER':
  57. case 'FLUME_SERVER':
  58. case 'RESOURCEMANAGER':
  59. return true;
  60. default:
  61. return false;
  62. }
  63. }.property('componentName'),
  64. isSlave: function(){
  65. switch (this.get('componentName')) {
  66. case 'DATANODE':
  67. case 'TASKTRACKER':
  68. case 'HBASE_REGIONSERVER':
  69. case 'GANGLIA_MONITOR':
  70. case 'NODEMANAGER':
  71. case 'ZKFC':
  72. return true;
  73. default:
  74. return false;
  75. }
  76. }.property('componentName'),
  77. /**
  78. * Only certain components can be deleted.
  79. * They include some from master components,
  80. * some from slave components, and rest from
  81. * client components.
  82. */
  83. isDeletable: function() {
  84. var canDelete = false;
  85. switch (this.get('componentName')) {
  86. case 'DATANODE':
  87. case 'TASKTRACKER':
  88. case 'ZOOKEEPER_SERVER':
  89. case 'HBASE_REGIONSERVER':
  90. case 'GANGLIA_MONITOR':
  91. case 'NODEMANAGER':
  92. canDelete = true;
  93. break;
  94. default:
  95. }
  96. if (!canDelete) {
  97. canDelete = this.get('isClient');
  98. }
  99. return canDelete;
  100. }.property('componentName', 'isClient'),
  101. /**
  102. * A host-component is decommissioning when it is in HDFS service's list of
  103. * decomNodes.
  104. */
  105. isDecommissioning: function () {
  106. var decommissioning = false;
  107. var hostName = this.get('host.hostName');
  108. var componentName = this.get('componentName');
  109. var hdfsSvc = App.HDFSService.find().objectAt(0);
  110. if (componentName === 'DATANODE' && hdfsSvc) {
  111. var decomNodes = hdfsSvc.get('decommissionDataNodes');
  112. var decomNode = decomNodes != null ? decomNodes.findProperty("hostName", hostName) : null;
  113. decommissioning = decomNode != null;
  114. }
  115. return decommissioning;
  116. }.property('componentName', 'host.hostName', 'App.router.clusterController.isLoaded', 'App.router.updateController.isUpdated'),
  117. /**
  118. * User friendly host component status
  119. */
  120. componentTextStatus: function () {
  121. return App.HostComponentStatus.getTextStatus(this.get("workStatus"));
  122. }.property('workStatus','isDecommissioning')
  123. });
  124. App.HostComponent.FIXTURES = [];
  125. App.HostComponentStatus = {
  126. started: "STARTED",
  127. starting: "STARTING",
  128. stopped: "INSTALLED",
  129. stopping: "STOPPING",
  130. install_failed: "INSTALL_FAILED",
  131. installing: "INSTALLING",
  132. upgrade_failed: "UPGRADE_FAILED",
  133. maintenance: "MAINTENANCE",
  134. unknown: "UNKNOWN",
  135. getKeyName:function(value){
  136. switch(value){
  137. case this.started:
  138. return 'started';
  139. case this.starting:
  140. return 'starting';
  141. case this.stopped:
  142. return 'installed';
  143. case this.stopping:
  144. return 'stopping';
  145. case this.install_failed:
  146. return 'install_failed';
  147. case this.installing:
  148. return 'installing';
  149. case this.upgrade_failed:
  150. return 'upgrade_failed';
  151. case this.maintenance:
  152. return 'maintenance';
  153. case this.unknown:
  154. return 'unknown';
  155. }
  156. return 'Unknown';
  157. },
  158. getTextStatus: function (value) {
  159. switch (value) {
  160. case this.installing:
  161. return 'Installing...';
  162. case this.install_failed:
  163. return 'Install Failed';
  164. case this.stopped:
  165. return 'Stopped';
  166. case this.started:
  167. return 'Started';
  168. case this.starting:
  169. return 'Starting...';
  170. case this.stopping:
  171. return 'Stopping...';
  172. case this.unknown:
  173. return 'Heartbeat lost...';
  174. case this.upgrade_failed:
  175. return 'Upgrade Failed';
  176. }
  177. return 'Unknown';
  178. }
  179. };