protoRelations.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. switch (this.get('componentName')) {
  66. case 'NAMENODE':
  67. return 'NameNode';
  68. case 'SNAMENODE':
  69. return 'SNameNode';
  70. case 'DATANODE':
  71. return 'DataNode';
  72. case 'HDFS_CLIENT':
  73. return 'HDFS Client';
  74. case 'JOBTRACKER':
  75. return 'JobTracker';
  76. case 'TASKTRACKER':
  77. return 'TaskTracker';
  78. case 'MAPREDUCE_CLIENT':
  79. return 'MapReduce Client';
  80. case 'ZOOKEEPER_SERVER':
  81. return 'ZooKeeper Server';
  82. case 'ZOOKEEPER_CLIENT':
  83. return 'ZooKeeper Client';
  84. case 'HIVE_SERVER':
  85. return 'Hive Server';
  86. case 'HIVE_CLIENT':
  87. return 'Hive Client';
  88. case 'HIVE_MYSQL':
  89. return 'Hive MySQL';
  90. case 'HBASE_MASTER':
  91. return 'HBase Master';
  92. case 'HBASE_REGIONSERVER':
  93. return 'RegionServer';
  94. case 'HBASE_CLIENT':
  95. return 'HBase Client';
  96. case 'PIG_CLIENT':
  97. return 'Pig Client';
  98. case 'SQOOP_CLIENT':
  99. return 'Sqoop Client';
  100. case 'TEMPLETON_SERVER':
  101. return 'Templeton Server';
  102. case 'TEMPLETON_CLIENT':
  103. return 'Templeton Client';
  104. case 'OOZIE_SERVER':
  105. return 'Oozie Server';
  106. case 'OOZIE_CLIENT':
  107. return 'Oozie Client';
  108. case 'NAGIOS_SERVER':
  109. return 'Nagios Server';
  110. case 'GANGLIA_SERVER':
  111. return 'Ganglia Collector';
  112. case 'GANGLIA_MONITOR':
  113. return 'Ganglia Monitor';
  114. }
  115. return this.get('componentName');
  116. }.property('componentName'),
  117. isMaster: function() {
  118. switch (this.get('componentName')) {
  119. case 'NAMENODE':
  120. case 'SNAMENODE':
  121. case 'JOBTRACKER':
  122. case 'ZOOKEEPER_SERVER':
  123. case 'HIVE_SERVER':
  124. case 'HBASE_MASTER':
  125. case 'NAGIOS_SERVER':
  126. case 'GANGLIA_SERVER':
  127. case 'OOZIE_SERVER':
  128. case 'TEMPLETON_SERVER':
  129. return true;
  130. default:
  131. return false;
  132. }
  133. return this.get('componentName');
  134. }.property('componentName')
  135. });
  136. App.HostComponent1 = DS.Model.extend({
  137. primaryKey: 'hostComponentId',
  138. hostComponentId: DS.attr('string'), // component_name + host_name
  139. state: DS.attr('string'),
  140. host: DS.belongsTo('App.Host'),
  141. hostName: DS.attr('string')
  142. });
  143. // A hack to allow App.<model>.find() with the DS.FixtureAdapter
  144. App.Service1.FIXTURES = [];
  145. App.Service1Component.FIXTURES = [];
  146. App.HostComponent1.FIXTURES = [];