host_component.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. host: DS.belongsTo('App.Host'),
  23. service: DS.belongsTo('App.Service'),
  24. isClient:function () {
  25. return Boolean(this.get('componentName').match(/_client/gi));
  26. }.property('componentName'),
  27. isRunning: function(){
  28. return (this.get('workStatus') == 'STARTED' || this.get('workStatus') == 'STARTING');
  29. }.property('workStatus'),
  30. displayName: function () {
  31. return App.format.role(this.get('componentName'));
  32. }.property('componentName'),
  33. isMaster: function () {
  34. switch (this.get('componentName')) {
  35. case 'NAMENODE':
  36. case 'SECONDARY_NAMENODE':
  37. case 'SNAMENODE':
  38. case 'JOBTRACKER':
  39. case 'ZOOKEEPER_SERVER':
  40. case 'HIVE_SERVER':
  41. case 'HIVE_METASTORE':
  42. case 'MYSQL_SERVER':
  43. case 'HBASE_MASTER':
  44. case 'NAGIOS_SERVER':
  45. case 'GANGLIA_SERVER':
  46. case 'OOZIE_SERVER':
  47. case 'WEBHCAT_SERVER':
  48. return true;
  49. default:
  50. return false;
  51. }
  52. return this.get('componentName');
  53. }.property('componentName'),
  54. isSlave: function(){
  55. switch (this.get('componentName')) {
  56. case 'DATANODE':
  57. case 'TASKTRACKER':
  58. case 'HBASE_REGIONSERVER':
  59. case 'GANGLIA_MONITOR':
  60. return true;
  61. default:
  62. return false;
  63. }
  64. return this.get('componentName');
  65. }.property('componentName'),
  66. /**
  67. * A host-component is decommissioning when it is in HDFS service's list of
  68. * decomNodes.
  69. */
  70. isDecommissioning: function () {
  71. var decommissioning = false;
  72. var hostName = this.get('host.hostName');
  73. var componentName = this.get('componentName');
  74. if (componentName == 'DATANODE') {
  75. var hdfsSvc = App.router.get('mainServiceController.hdfsService');
  76. if (hdfsSvc) {
  77. var decomNodes = hdfsSvc.get('decommissionDataNodes');
  78. var decomNode = decomNodes != null ? decomNodes.findProperty("hostName", hostName) : null;
  79. decommissioning = decomNode != null;
  80. }
  81. }
  82. return decommissioning;
  83. }.property('componentName', 'host.hostName', 'App.router.mainServiceController.hdfsService.decommissionDataNodes.@each.hostName')
  84. });
  85. App.HostComponent.FIXTURES = [];
  86. App.HostComponentStatus = {
  87. started: "STARTED",
  88. starting: "STARTING",
  89. stopped: "INSTALLED",
  90. stopping: "STOPPING",
  91. stop_failed: "STOP_FAILED",
  92. start_failed: "START_FAILED",
  93. install_failed: "INSTALL_FAILED",
  94. getKeyName:function(value){
  95. switch(value){
  96. case this.started:
  97. return 'started';
  98. case this.starting:
  99. return 'starting';
  100. case this.stopped:
  101. return 'installed';
  102. case this.stopping:
  103. return 'stopping';
  104. case this.stop_failed:
  105. return 'stop_failed';
  106. case this.start_failed:
  107. return 'start_failed';
  108. case this.install_failed:
  109. return 'install_failed';
  110. }
  111. return 'none';
  112. }
  113. }