hbase.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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').get("length") > 1){
  43. return Em.I18n.t('services.service.summary.viewHosts');
  44. }else{
  45. return Em.I18n.t('services.service.summary.viewHost');
  46. }
  47. }.property("service"),
  48. regionServersLiveTextView: App.ComponentLiveTextView.extend({
  49. liveComponents: function() {
  50. return App.HostComponent.find().filterProperty('componentName', 'HBASE_REGIONSERVER').filterProperty("workStatus","STARTED").get('length');
  51. }.property("service.hostComponents.@each"),
  52. totalComponents: function() {
  53. return this.get("service.regionServers.length");
  54. }.property("service.regionServers.length")
  55. }),
  56. /**
  57. * Formatted output for passive master components
  58. */
  59. passiveMasterOutput: function () {
  60. return Em.I18n.t('service.hbase.passiveMasters').format(this.get('passiveMasters').length);
  61. }.property('passiveMasters'),
  62. /**
  63. * One(!) active master component
  64. */
  65. activeMaster: function () {
  66. if(App.supports.multipleHBaseMasters){
  67. return this.get('masters').findProperty('haStatus', 'active');
  68. } else {
  69. return this.get('masters')[0];
  70. }
  71. }.property('masters'),
  72. activeMasterTitle: function(){
  73. if(App.supports.multipleHBaseMasters){
  74. return this.t('service.hbase.activeMaster');
  75. } else {
  76. return this.get('activeMaster.host.publicHostName');
  77. }
  78. }.property('activeMaster'),
  79. masterServerHeapSummary: function () {
  80. var heapUsed = this.get('service').get('heapMemoryUsed');
  81. var heapMax = this.get('service').get('heapMemoryMax');
  82. var percent = heapMax > 0 ? 100 * heapUsed / heapMax : 0;
  83. var heapString = numberUtils.bytesToSize(heapUsed, 1, "parseFloat");
  84. var heapMaxString = numberUtils.bytesToSize(heapMax, 1, "parseFloat");
  85. return this.t('dashboard.services.hbase.masterServerHeap.summary').format(heapString, heapMaxString, percent.toFixed(1));
  86. }.property('service.heapMemoryUsed', 'service.heapMemoryMax'),
  87. summaryHeader: function () {
  88. var avgLoad = this.get('service.averageLoad');
  89. if (isNaN(avgLoad)) {
  90. avgLoad = this.t("services.service.summary.unknown");
  91. }
  92. return this.t("dashboard.services.hbase.summary").format(this.get('service.regionServers.length'), avgLoad);
  93. }.property('service.regionServers', 'service.averageLoad'),
  94. hbaseMasterWebUrl: function () {
  95. if (this.get('activeMaster.host') && this.get('activeMaster.host').get('publicHostName')) {
  96. return "http://" + (App.singleNodeInstall ? App.singleNodeAlias : this.get('activeMaster.host').get('publicHostName')) + ":60010";
  97. }
  98. }.property('activeMaster'),
  99. averageLoad: function () {
  100. var avgLoad = this.get('service.averageLoad');
  101. if (isNaN(avgLoad)) {
  102. avgLoad = this.t('services.service.summary.notAvailable');
  103. }
  104. return this.t('dashboard.services.hbase.averageLoadPerServer').format(avgLoad);
  105. }.property("service.averageLoad"),
  106. masterStartedTime: function () {
  107. var uptime = this.get('service').get('masterStartTime');
  108. if (uptime && uptime > 0) {
  109. var diff = (new Date()).getTime() - uptime;
  110. if (diff < 0) {
  111. diff = 0;
  112. }
  113. var formatted = date.timingFormat(diff);
  114. return this.t('dashboard.services.uptime').format(formatted);
  115. }
  116. return this.t('services.service.summary.notRunning');
  117. }.property("service.masterStartTime"),
  118. masterActivatedTime: function () {
  119. var uptime = this.get('service').get('masterActiveTime');
  120. if (uptime && uptime > 0) {
  121. var diff = (new Date()).getTime() - uptime;
  122. if (diff < 0) {
  123. diff = 0;
  124. }
  125. var formatted = date.timingFormat(diff);
  126. return this.t('dashboard.services.uptime').format(formatted);
  127. }
  128. return this.t('services.service.summary.notRunning');
  129. }.property("service.masterActiveTime"),
  130. regionServerComponent: function () {
  131. return App.HostComponent.find().findProperty('componentName', 'HBASE_REGIONSERVER');
  132. }.property()
  133. });