service.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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.Service = DS.Model.extend({
  20. serviceName: DS.attr('string'),
  21. serviceAudit: DS.hasMany('App.ServiceAudit'),
  22. workStatus: DS.attr('string'),
  23. alerts: DS.hasMany('App.Alert'),
  24. quickLinks: DS.hasMany('App.QuickLinks'),
  25. components: DS.hasMany('App.Component'),
  26. hostComponents: DS.hasMany('App.HostComponent'),
  27. isRunning: function () {
  28. return (this.get('healthStatus') == 'green' || this.get('healthStatus') == 'green-blinking');
  29. }.property('healthStatus'),
  30. healthStatus: function () {
  31. var components = this.get('components').filterProperty('isMaster', true);
  32. if (components.everyProperty('workStatus', App.Component.Status.started)) {
  33. return 'green';
  34. } else if (components.someProperty('workStatus', App.Component.Status.starting)) {
  35. return 'green-blinking';
  36. } else if (components.someProperty('workStatus', App.Component.Status.stopped)) {
  37. return 'red';
  38. } else {
  39. return 'red-blinking';
  40. }
  41. }.property('components.@each.workStatus'),
  42. isStopped: function () {
  43. var components = this.get('components');
  44. return components.everyProperty('workStatus', App.Component.Status.stopped);
  45. }.property('components.@each.workStatus'),
  46. isStarted: function () {
  47. var components = this.get('components').filterProperty('isMaster', true);
  48. return components.everyProperty('workStatus', App.Component.Status.started);
  49. }.property('components.@each.workStatus'),
  50. isMaintained: function(){
  51. var maintainedServices = [
  52. "HDFS",
  53. "MAPREDUCE",
  54. "HBASE",
  55. "OOZIE",
  56. "HIVE",
  57. "ZOOKEEPER",
  58. "PIG",
  59. "SQOOP"
  60. ];
  61. for(var i in maintainedServices){
  62. if(this.get('serviceName') == maintainedServices[i]) return true;
  63. }
  64. }.property('serviceName'),
  65. isConfigurable:function(){
  66. var configurableServices = [
  67. "HDFS",
  68. "MAPREDUCE",
  69. "HBASE",
  70. "OOZIE",
  71. "HIVE",
  72. "ZOOKEEPER",
  73. "PIG",
  74. "SQOOP",
  75. "NAGIOS"
  76. ];
  77. for(var i in configurableServices){
  78. if(this.get('serviceName') == configurableServices[i]) return true;
  79. }
  80. }.property('serviceName'),
  81. displayName: function () {
  82. switch (this.get('serviceName').toLowerCase()) {
  83. case 'hdfs':
  84. return 'HDFS';
  85. case 'mapreduce':
  86. return 'MapReduce';
  87. case 'hbase':
  88. return 'HBase';
  89. case 'oozie':
  90. return 'Oozie';
  91. case 'hive':
  92. return 'Hive/HCatalog';
  93. case 'zookeeper':
  94. return 'ZooKeeper';
  95. case 'pig':
  96. return 'Pig';
  97. case 'sqoop':
  98. return 'Sqoop';
  99. case 'templeton':
  100. return 'Templeton';
  101. case 'ganglia':
  102. return 'Ganglia';
  103. case 'nagios':
  104. return 'Nagios';
  105. }
  106. return this.get('serviceName');
  107. }.property('serviceName')
  108. });
  109. App.Service.Health = {
  110. live: "LIVE",
  111. dead: "DEAD",
  112. starting: "STARTING",
  113. stopping: "STOPPING",
  114. getKeyName: function (value) {
  115. switch (value) {
  116. case this.live:
  117. return 'live';
  118. case this.dead:
  119. return 'dead';
  120. case this.starting:
  121. return 'starting';
  122. case this.stopping:
  123. return 'stopping';
  124. }
  125. return 'none';
  126. }
  127. };
  128. App.Service.FIXTURES = [];