hbase.js 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. App.MainDashboardServiceHbaseView = App.MainDashboardServiceView.extend({
  20. templateName: require('templates/main/dashboard/service/hbase'),
  21. serviceName: 'hbase',
  22. masterServerHeapSummary: function () {
  23. var heapUsed = this.get('service').get('heapMemoryUsed');
  24. var heapMax = this.get('service').get('heapMemoryMax');
  25. var percent = heapMax > 0 ? 100 * heapUsed / heapMax : 0;
  26. var heapString = heapUsed > 0 ? heapUsed.bytesToSize(1, "parseFloat") : 0;
  27. var heapMaxString = heapMax > 0 ? heapMax.bytesToSize(1, "parseFloat") : 0;
  28. return this.t('dashboard.services.hbase.masterServerHeap.summary').format(heapString, heapMaxString, percent.toFixed(1));
  29. }.property('service.heapMemoryUsed', 'service.heapMemoryMax'),
  30. version: function(){
  31. return this.formatUnavailable(this.get('service.version'));
  32. }.property('service.version'),
  33. summaryHeader: function () {
  34. var avgLoad = this.get('service.averageLoad');
  35. if (avgLoad == null) {
  36. avgLoad = this.t("services.service.summary.unknown");
  37. }
  38. return this.t("dashboard.services.hbase.summary").format(this.get('service.regionServers.length'), avgLoad);
  39. }.property('service.regionServers', 'service.averageLoad'),
  40. hbaseMasterWebUrl: function () {
  41. return "http://" + this.get('service').get('master').get('publicHostName') + ":60010";
  42. }.property('service.master'),
  43. averageLoad: function () {
  44. var avgLoad = this.get('service.averageLoad');
  45. if (avgLoad == null) {
  46. avgLoad = this.t('services.service.summary.notAvailable');
  47. }
  48. return this.t('dashboard.services.hbase.averageLoadPerServer').format(avgLoad);
  49. }.property("service.averageLoad"),
  50. masterStartedTime: function () {
  51. var uptime = this.get('service').get('masterStartTime');
  52. if (uptime && uptime > 0) {
  53. var diff = (new Date()).getTime() - uptime;
  54. if (diff < 0) {
  55. diff = 0;
  56. }
  57. var formatted = date.timingFormat(diff);
  58. return this.t('dashboard.services.uptime').format(formatted);
  59. }
  60. return this.t('services.service.summary.notRunning');
  61. }.property("service.masterStartTime"),
  62. masterActivatedTime: function () {
  63. var uptime = this.get('service').get('masterActiveTime');
  64. if (uptime && uptime > 0) {
  65. var diff = (new Date()).getTime() - uptime;
  66. if (diff < 0) {
  67. diff = 0;
  68. }
  69. var formatted = date.timingFormat(diff);
  70. return this.t('dashboard.services.uptime').format(formatted);
  71. }
  72. return this.t('services.service.summary.notRunning');
  73. }.property("service.masterActiveTime"),
  74. regionServerComponent: function () {
  75. return App.HostComponent.find().findProperty('componentName', 'HBASE_REGIONSERVER');
  76. }.property('components'),
  77. isCollapsed: false,
  78. toggleInfoView: function () {
  79. $('#hbase-info').toggle('blind', 200);
  80. this.set('isCollapsed', !this.isCollapsed);
  81. }
  82. });