host_component.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 'HBASE_MASTER':
  42. case 'NAGIOS_SERVER':
  43. case 'GANGLIA_SERVER':
  44. case 'OOZIE_SERVER':
  45. case 'TEMPLETON_SERVER':
  46. return true;
  47. default:
  48. return false;
  49. }
  50. return this.get('componentName');
  51. }.property('componentName'),
  52. isSlave: function(){
  53. switch (this.get('componentName')) {
  54. case 'DATANODE':
  55. case 'TASKTRACKER':
  56. case 'HBASE_REGIONSERVER':
  57. case 'GANGLIA_MONITOR':
  58. return true;
  59. default:
  60. return false;
  61. }
  62. return this.get('componentName');
  63. }.property('componentName'),
  64. /**
  65. * A host-component is decommissioning when it is in HDFS service's list of
  66. * decomNodes.
  67. */
  68. isDecommissioning: function () {
  69. var decommissioning = false;
  70. var hostName = this.get('host.hostName');
  71. var componentName = this.get('componentName');
  72. if (componentName == 'DATANODE') {
  73. var hdfsSvc = App.router.get('mainServiceController.hdfsService');
  74. if (hdfsSvc) {
  75. var decomNodes = hdfsSvc.get('decommissionDataNodes');
  76. var decomNode = decomNodes != null ? decomNodes.findProperty("hostName", hostName) : null;
  77. decommissioning = decomNode != null;
  78. }
  79. }
  80. return decommissioning;
  81. }.property('componentName', 'host.hostName', 'App.router.mainServiceController.hdfsService.decommissionDataNodes.@each.hostName')
  82. })
  83. App.HostComponent.Status = {
  84. started: "STARTED",
  85. starting: "STARTING",
  86. stopped: "INSTALLED",
  87. stopping: "STOPPING",
  88. getKeyName:function(value){
  89. switch(value){
  90. case this.started:
  91. return 'started';
  92. case this.starting:
  93. return 'starting';
  94. case this.stopped:
  95. return 'installed';
  96. case this.stopping:
  97. return 'stopping';
  98. }
  99. return 'none';
  100. }
  101. }
  102. App.HostComponent.FIXTURES = [];