component.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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.Component = DS.Model.extend({
  20. componentName: DS.attr('string'),
  21. displayName: function () {
  22. return App.format.role(this.get('componentName'));
  23. }.property('componentName'),
  24. service: DS.belongsTo('App.Service'),
  25. //service_id: DS.attr('string'),
  26. host: DS.belongsTo('App.Host'),
  27. //host_id: DS.attr('string'),
  28. workStatus: DS.attr('string'),
  29. isMaster: function () {
  30. switch (this.get('componentName')) {
  31. case 'NAMENODE':
  32. case 'SECONDARY_NAMENODE':
  33. case 'SNAMENODE':
  34. case 'JOBTRACKER':
  35. case 'ZOOKEEPER_SERVER':
  36. case 'HIVE_SERVER':
  37. case 'HIVE_METASTORE':
  38. case 'MYSQL_SERVER':
  39. case 'HBASE_MASTER':
  40. case 'NAGIOS_SERVER':
  41. case 'GANGLIA_SERVER':
  42. case 'OOZIE_SERVER':
  43. case 'WEBHCAT_SERVER':
  44. return true;
  45. default:
  46. return false;
  47. }
  48. return this.get('componentName');
  49. }.property('componentName'),
  50. isSlave: function(){
  51. switch (this.get('componentName')) {
  52. case 'DATANODE':
  53. case 'TASKTRACKER':
  54. case 'HBASE_REGIONSERVER':
  55. case 'GANGLIA_MONITOR':
  56. return true;
  57. default:
  58. return false;
  59. }
  60. return this.get('componentName');
  61. }.property('componentName')
  62. });
  63. App.Component.Status = {
  64. started: "STARTED",
  65. starting: "STARTING",
  66. stopped: "INSTALLED",
  67. stopping: "STOPPING",
  68. stop_failed: "STOP_FAILED",
  69. start_failed: "START_FAILED",
  70. install_failed: "INSTALL_FAILED",
  71. getKeyName:function(value){
  72. switch(value){
  73. case this.started:
  74. return 'started';
  75. case this.starting:
  76. return 'starting';
  77. case this.stopped:
  78. return 'installed';
  79. case this.stopping:
  80. return 'stopping';
  81. case this.stop_failed:
  82. return 'stop_failed';
  83. case this.start_failed:
  84. return 'start_failed';
  85. case this.install_failed:
  86. return 'install_failed';
  87. }
  88. return 'none';
  89. }
  90. }
  91. App.Component.FIXTURES = [];