host_component.js 3.7 KB

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