protoRelations.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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.Service1 = DS.Model.extend({
  20. //primaryKey : 'serviceName',
  21. serviceName: DS.attr('string'),
  22. description: DS.attr('string'),
  23. components: DS.hasMany('App.Service1Component', { embedded: true }),
  24. displayName: function() {
  25. switch (this.get('serviceName').toLowerCase()) {
  26. case 'hdfs':
  27. return 'HDFS';
  28. case 'mapreduce':
  29. return 'MapReduce';
  30. case 'hbase':
  31. return 'HBase';
  32. case 'oozie':
  33. return 'Oozie';
  34. case 'hive':
  35. return 'Hive/HCatalog';
  36. case 'zookeeper':
  37. return 'ZooKeeper';
  38. case 'pig':
  39. return 'Pig';
  40. case 'sqoop':
  41. return 'Sqoop';
  42. case 'templeton':
  43. return 'Templeton';
  44. case 'ganglia':
  45. return 'Ganglia';
  46. case 'nagios':
  47. return 'Nagios';
  48. }
  49. return this.get('serviceName');
  50. }.property('serviceName')
  51. });
  52. App.Service1.Health = {
  53. live:"LIVE",
  54. dead:"DEAD",
  55. start:"STARTING",
  56. stop:"STOPPING"
  57. };
  58. App.Service1Component = DS.Model.extend({
  59. componentName: DS.attr('string'),
  60. hostComponents: DS.hasMany('App.HostComponent1'),
  61. service: DS.belongsTo('App.Service1'),
  62. state : DS.attr('string'),
  63. host_name : DS.attr('string'),
  64. displayName: function() {
  65. return App.format.role(this.get('componentName'));
  66. }.property('componentName'),
  67. isMaster: function() {
  68. switch (this.get('componentName')) {
  69. case 'NAMENODE':
  70. case 'SNAMENODE':
  71. case 'JOBTRACKER':
  72. case 'ZOOKEEPER_SERVER':
  73. case 'HIVE_SERVER':
  74. case 'HBASE_MASTER':
  75. case 'NAGIOS_SERVER':
  76. case 'GANGLIA_SERVER':
  77. case 'OOZIE_SERVER':
  78. case 'TEMPLETON_SERVER':
  79. return true;
  80. default:
  81. return false;
  82. }
  83. return this.get('componentName');
  84. }.property('componentName')
  85. });
  86. App.HostComponent1 = DS.Model.extend({
  87. primaryKey: 'hostComponentId',
  88. hostComponentId: DS.attr('string'), // component_name + host_name
  89. state: DS.attr('string'),
  90. host: DS.belongsTo('App.Host'),
  91. hostName: DS.attr('string')
  92. });
  93. // A hack to allow App.<model>.find() with the DS.FixtureAdapter
  94. App.Service1.FIXTURES = [];
  95. App.Service1Component.FIXTURES = [];
  96. App.HostComponent1.FIXTURES = [];