host_component.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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 'JOBTRACKER':
  44. case 'ZOOKEEPER_SERVER':
  45. case 'HIVE_SERVER':
  46. case 'HIVE_METASTORE':
  47. case 'MYSQL_SERVER':
  48. case 'HBASE_MASTER':
  49. case 'NAGIOS_SERVER':
  50. case 'GANGLIA_SERVER':
  51. case 'OOZIE_SERVER':
  52. case 'WEBHCAT_SERVER':
  53. case 'HUE_SERVER':
  54. case 'HISTORYSERVER':
  55. case 'FLUME_SERVER':
  56. case 'RESOURCEMANAGER':
  57. return true;
  58. default:
  59. return false;
  60. }
  61. }.property('componentName'),
  62. isSlave: function(){
  63. switch (this.get('componentName')) {
  64. case 'DATANODE':
  65. case 'TASKTRACKER':
  66. case 'HBASE_REGIONSERVER':
  67. case 'GANGLIA_MONITOR':
  68. case 'NODEMANAGER':
  69. return true;
  70. default:
  71. return false;
  72. }
  73. }.property('componentName'),
  74. /**
  75. * A host-component is decommissioning when it is in HDFS service's list of
  76. * decomNodes.
  77. */
  78. isDecommissioning: function () {
  79. var decommissioning = false;
  80. var hostName = this.get('host.hostName');
  81. var componentName = this.get('componentName');
  82. var hdfsSvc = App.HDFSService.find().objectAt(0);
  83. if (componentName === 'DATANODE' && hdfsSvc) {
  84. var decomNodes = hdfsSvc.get('decommissionDataNodes');
  85. var decomNode = decomNodes != null ? decomNodes.findProperty("hostName", hostName) : null;
  86. decommissioning = decomNode != null;
  87. }
  88. return decommissioning;
  89. }.property('componentName', 'host.hostName', 'App.router.clusterController.isLoaded', 'App.router.updateController.isUpdated'),
  90. /**
  91. * User friendly host component status
  92. */
  93. componentTextStatus: function () {
  94. var value = this.get("workStatus");
  95. switch(value){
  96. case "INSTALLING":
  97. return 'Installing...';
  98. case "INSTALL_FAILED":
  99. return 'Install Failed';
  100. case "INSTALLED":
  101. return 'Stopped';
  102. case "STARTED":
  103. return 'Started';
  104. case "STARTING":
  105. return 'Starting...';
  106. case "STOPPING":
  107. return 'Stopping...';
  108. case "UNKNOWN":
  109. return 'Heartbeat lost...';
  110. case "UPGRADE_FAILED":
  111. return 'Upgrade Failed';
  112. }
  113. return 'Unknown';
  114. }.property('workStatus','isDecommissioning')
  115. });
  116. App.HostComponent.FIXTURES = [];
  117. App.HostComponentStatus = {
  118. started: "STARTED",
  119. starting: "STARTING",
  120. stopped: "INSTALLED",
  121. stopping: "STOPPING",
  122. install_failed: "INSTALL_FAILED",
  123. installing: "INSTALLING",
  124. upgrade_failed: "UPGRADE_FAILED",
  125. maintenance: "MAINTENANCE",
  126. unknown: "UNKNOWN",
  127. getKeyName:function(value){
  128. switch(value){
  129. case this.started:
  130. return 'started';
  131. case this.starting:
  132. return 'starting';
  133. case this.stopped:
  134. return 'installed';
  135. case this.stopping:
  136. return 'stopping';
  137. case this.install_failed:
  138. return 'install_failed';
  139. case this.installing:
  140. return 'installing';
  141. case this.upgrade_failed:
  142. return 'upgrade_failed';
  143. case this.maintenance:
  144. return 'maintenance';
  145. case this.unknown:
  146. return 'unknown';
  147. }
  148. return 'none';
  149. }
  150. };