host_component.js 4.5 KB

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