hbase.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with this
  4. * work for additional information regarding copyright ownership. The ASF
  5. * licenses this file to you under the Apache License, Version 2.0 (the
  6. * "License"); you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  13. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  14. * License for the specific language governing permissions and limitations under
  15. * the License.
  16. */
  17. var App = require('app');
  18. var date = require('utils/date');
  19. var numberUtils = require('utils/number_utils');
  20. App.MainDashboardServiceHbaseView = App.MainDashboardServiceView.extend({
  21. templateName: require('templates/main/dashboard/service/hbase'),
  22. serviceName: 'hbase',
  23. /**
  24. * All master components
  25. */
  26. masters: function () {
  27. return this.get('service.hostComponents').filterProperty('isMaster', true);
  28. }.property('service.hostComponents.@each'),
  29. /**
  30. * Passive master components
  31. */
  32. passiveMasters: function () {
  33. if(App.supports.multipleHBaseMasters){
  34. return this.get('masters').filterProperty('haStatus', 'passive');
  35. }
  36. return [];
  37. }.property('masters'),
  38. liveRegionServers: function () {
  39. return App.HostComponent.find().filterProperty('componentName', 'HBASE_REGIONSERVER').filterProperty("workStatus","STARTED");
  40. }.property('service.hostComponents.@each'),
  41. regionServesText: function () {
  42. if (this.get('service.regionServers.length') == 0) {
  43. return '';
  44. } else if (this.get('service.regionServers.length') > 1) {
  45. return Em.I18n.t('services.service.summary.viewHosts');
  46. } else {
  47. return Em.I18n.t('services.service.summary.viewHost');
  48. }
  49. }.property("service"),
  50. regionServersLiveTextView: App.ComponentLiveTextView.extend({
  51. liveComponents: function() {
  52. return App.HostComponent.find().filterProperty('componentName', 'HBASE_REGIONSERVER').filterProperty("workStatus","STARTED").get('length');
  53. }.property("service.hostComponents.@each"),
  54. totalComponents: function() {
  55. return this.get("service.regionServers.length");
  56. }.property("service.regionServers.length")
  57. }),
  58. /**
  59. * Formatted output for passive master components
  60. */
  61. passiveMasterOutput: function () {
  62. return Em.I18n.t('service.hbase.passiveMasters').format(this.get('passiveMasters').length);
  63. }.property('passiveMasters'),
  64. /**
  65. * One(!) active master component
  66. */
  67. activeMaster: function () {
  68. if(App.supports.multipleHBaseMasters){
  69. return this.get('masters').findProperty('haStatus', 'active');
  70. } else {
  71. return this.get('masters')[0];
  72. }
  73. }.property('masters'),
  74. activeMasterTitle: function(){
  75. if(App.supports.multipleHBaseMasters){
  76. return this.t('service.hbase.activeMaster');
  77. } else {
  78. return this.get('activeMaster.host.publicHostName');
  79. }
  80. }.property('activeMaster'),
  81. masterServerHeapSummary: function () {
  82. var heapUsed = this.get('service').get('heapMemoryUsed');
  83. var heapMax = this.get('service').get('heapMemoryMax');
  84. var percent = heapMax > 0 ? 100 * heapUsed / heapMax : 0;
  85. var heapString = numberUtils.bytesToSize(heapUsed, 1, "parseFloat");
  86. var heapMaxString = numberUtils.bytesToSize(heapMax, 1, "parseFloat");
  87. return this.t('dashboard.services.hbase.masterServerHeap.summary').format(heapString, heapMaxString, percent.toFixed(1));
  88. }.property('service.heapMemoryUsed', 'service.heapMemoryMax'),
  89. summaryHeader: function () {
  90. var avgLoad = this.get('service.averageLoad');
  91. if (isNaN(avgLoad)) {
  92. avgLoad = this.t("services.service.summary.unknown");
  93. }
  94. return this.t("dashboard.services.hbase.summary").format(this.get('service.regionServers.length'), avgLoad);
  95. }.property('service.regionServers', 'service.averageLoad'),
  96. hbaseMasterWebUrl: function () {
  97. if (this.get('activeMaster.host') && this.get('activeMaster.host').get('publicHostName')) {
  98. return "http://" + (App.singleNodeInstall ? App.singleNodeAlias : this.get('activeMaster.host').get('publicHostName')) + ":60010";
  99. }
  100. }.property('activeMaster'),
  101. averageLoad: function () {
  102. var avgLoad = this.get('service.averageLoad');
  103. if (isNaN(avgLoad)) {
  104. avgLoad = this.t('services.service.summary.notAvailable');
  105. }
  106. return this.t('dashboard.services.hbase.averageLoadPerServer').format(avgLoad);
  107. }.property("service.averageLoad"),
  108. masterStartedTime: function () {
  109. var uptime = this.get('service').get('masterStartTime');
  110. if (uptime && uptime > 0) {
  111. var diff = (new Date()).getTime() - uptime;
  112. if (diff < 0) {
  113. diff = 0;
  114. }
  115. var formatted = date.timingFormat(diff);
  116. return this.t('dashboard.services.uptime').format(formatted);
  117. }
  118. return this.t('services.service.summary.notRunning');
  119. }.property("service.masterStartTime"),
  120. masterActivatedTime: function () {
  121. var uptime = this.get('service').get('masterActiveTime');
  122. if (uptime && uptime > 0) {
  123. var diff = (new Date()).getTime() - uptime;
  124. if (diff < 0) {
  125. diff = 0;
  126. }
  127. var formatted = date.timingFormat(diff);
  128. return this.t('dashboard.services.uptime').format(formatted);
  129. }
  130. return this.t('services.service.summary.notRunning');
  131. }.property("service.masterActiveTime"),
  132. regionServerComponent: function () {
  133. return App.HostComponent.find().findProperty('componentName', 'HBASE_REGIONSERVER');
  134. }.property()
  135. });