component.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 'SNAMENODE':
  33. case 'JOBTRACKER':
  34. case 'ZOOKEEPER_SERVER':
  35. case 'HIVE_SERVER':
  36. case 'HBASE_MASTER':
  37. case 'NAGIOS_SERVER':
  38. case 'GANGLIA_SERVER':
  39. case 'OOZIE_SERVER':
  40. case 'TEMPLETON_SERVER':
  41. return true;
  42. default:
  43. return false;
  44. }
  45. return this.get('componentName');
  46. }.property('componentName'),
  47. decommissioned: DS.attr('boolean')
  48. });
  49. App.Component.Status = {
  50. started: "STARTED",
  51. starting: "STARTING",
  52. stopped: "INSTALLED",
  53. stopping: "STOPPING",
  54. getKeyName:function(value){
  55. switch(value){
  56. case this.started:
  57. return 'started';
  58. case this.starting:
  59. return 'starting';
  60. case this.stopped:
  61. return 'installed';
  62. case this.stopping:
  63. return 'stopping';
  64. }
  65. return 'none';
  66. }
  67. }
  68. App.Component.FIXTURES = [];