host_component.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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. host: DS.belongsTo('App.Host'),
  24. service: DS.belongsTo('App.Service'),
  25. actualConfigs: null,
  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. * A host-component is decommissioning when it is in HDFS service's list of
  78. * decomNodes.
  79. */
  80. isDecommissioning: function () {
  81. var decommissioning = false;
  82. var hostName = this.get('host.hostName');
  83. var componentName = this.get('componentName');
  84. var hdfsSvc = App.HDFSService.find().objectAt(0);
  85. if (componentName === 'DATANODE' && hdfsSvc) {
  86. var decomNodes = hdfsSvc.get('decommissionDataNodes');
  87. var decomNode = decomNodes != null ? decomNodes.findProperty("hostName", hostName) : null;
  88. decommissioning = decomNode != null;
  89. }
  90. return decommissioning;
  91. }.property('componentName', 'host.hostName', 'App.router.clusterController.isLoaded', 'App.router.updateController.isUpdated'),
  92. /**
  93. * User friendly host component status
  94. */
  95. componentTextStatus: function () {
  96. var value = this.get("workStatus");
  97. switch(value){
  98. case "INSTALLING":
  99. return 'Installing...';
  100. case "INSTALL_FAILED":
  101. return 'Install Failed';
  102. case "INSTALLED":
  103. return 'Stopped';
  104. case "STARTED":
  105. return 'Started';
  106. case "STARTING":
  107. return 'Starting...';
  108. case "STOPPING":
  109. return 'Stopping...';
  110. case "UNKNOWN":
  111. return 'Heartbeat lost...';
  112. case "UPGRADE_FAILED":
  113. return 'Upgrade Failed';
  114. }
  115. return 'Unknown';
  116. }.property('workStatus','isDecommissioning')
  117. });
  118. App.HostComponent.FIXTURES = [];
  119. App.HostComponentStatus = {
  120. started: "STARTED",
  121. starting: "STARTING",
  122. stopped: "INSTALLED",
  123. stopping: "STOPPING",
  124. install_failed: "INSTALL_FAILED",
  125. installing: "INSTALLING",
  126. upgrade_failed: "UPGRADE_FAILED",
  127. maintenance: "MAINTENANCE",
  128. unknown: "UNKNOWN",
  129. getKeyName:function(value){
  130. switch(value){
  131. case this.started:
  132. return 'started';
  133. case this.starting:
  134. return 'starting';
  135. case this.stopped:
  136. return 'installed';
  137. case this.stopping:
  138. return 'stopping';
  139. case this.install_failed:
  140. return 'install_failed';
  141. case this.installing:
  142. return 'installing';
  143. case this.upgrade_failed:
  144. return 'upgrade_failed';
  145. case this.maintenance:
  146. return 'maintenance';
  147. case this.unknown:
  148. return 'unknown';
  149. }
  150. return 'none';
  151. }
  152. };