host_component.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. /**
  53. * A host-component is decommissioning when it is in HDFS service's list of
  54. * decomNodes.
  55. */
  56. isDecommissioning: function () {
  57. var decommissioning = false;
  58. var hostName = this.get('host.hostName');
  59. var componentName = this.get('componentName');
  60. if (componentName == 'DATANODE') {
  61. var hdfsSvc = App.router.get('mainServiceController.hdfsService');
  62. if (hdfsSvc) {
  63. var decomNodes = hdfsSvc.get('decommissionDataNodes');
  64. var decomNode = decomNodes != null ? decomNodes.findProperty("hostName", hostName) : null;
  65. decommissioning = decomNode != null;
  66. }
  67. }
  68. return decommissioning;
  69. }.property('componentName', 'host.hostName', 'App.router.mainServiceController.hdfsService.decommissionDataNodes.@each.hostName')
  70. })
  71. App.HostComponent.Status = {
  72. started: "STARTED",
  73. starting: "STARTING",
  74. stopped: "INSTALLED",
  75. stopping: "STOPPING",
  76. getKeyName:function(value){
  77. switch(value){
  78. case this.started:
  79. return 'started';
  80. case this.starting:
  81. return 'starting';
  82. case this.stopped:
  83. return 'installed';
  84. case this.stopping:
  85. return 'stopping';
  86. }
  87. return 'none';
  88. }
  89. }
  90. App.HostComponent.FIXTURES = [];