host_component.js 5.4 KB

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