hdfs.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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.MainDashboardServiceHdfsView = App.MainDashboardServiceView.extend({
  20. templateName: require('templates/main/dashboard/service/hdfs'),
  21. serviceName: 'HDFS',
  22. Chart: App.ChartPieView.extend({
  23. service: null,
  24. data: function () {
  25. var total = this.get('service.capacityTotal') + 0;
  26. var remaining = (this.get('service.capacityRemaining') + 0);
  27. var used = total - remaining;
  28. return [ used, remaining ];
  29. }.property('service.capacityUsed', 'service.capacityTotal')
  30. }),
  31. version: function(){
  32. return this.formatUnavailable(this.get('service.version'));
  33. }.property('service.version'),
  34. dfsTotalBlocks: function(){
  35. return this.formatUnavailable(this.get('service.dfsTotalBlocks'));
  36. }.property('service.dfsTotalBlocks'),
  37. dfsTotalFiles: function(){
  38. return this.formatUnavailable(this.get('service.dfsTotalFiles'));
  39. }.property('service.dfsTotalFiles'),
  40. dfsCorruptBlocks: function(){
  41. return this.formatUnavailable(this.get('service.dfsCorruptBlocks'));
  42. }.property('service.dfsCorruptBlocks'),
  43. dfsMissingBlocks: function(){
  44. return this.formatUnavailable(this.get('service.dfsMissingBlocks'));
  45. }.property('service.dfsMissingBlocks'),
  46. dfsUnderReplicatedBlocks: function(){
  47. return this.formatUnavailable(this.get('service.dfsUnderReplicatedBlocks'));
  48. }.property('service.dfsUnderReplicatedBlocks'),
  49. nodeUptime: function () {
  50. var uptime = this.get('service').get('nameNodeStartTime');
  51. if (uptime && uptime > 0){
  52. var diff = (new Date()).getTime() - uptime;
  53. if (diff < 0) {
  54. diff = 0;
  55. }
  56. var formatted = date.timingFormat(diff);
  57. return this.t('dashboard.services.uptime').format(formatted);
  58. }
  59. return this.t('services.service.summary.notRunning');
  60. }.property("service.nameNodeStartTime"),
  61. nodeWebUrl: function () {
  62. return "http://" + this.get('service').get('nameNode').get('publicHostName') + ":50070";
  63. }.property('service.nameNode'),
  64. nodeHeap: function () {
  65. var memUsed = this.get('service').get('jvmMemoryHeapUsed') * 1000000;
  66. var memCommitted = this.get('service').get('jvmMemoryHeapCommitted') * 1000000;
  67. var percent = memCommitted > 0 ? ((100 * memUsed) / memCommitted) : 0;
  68. return this.t('dashboard.services.hdfs.nodes.heapUsed').format(memUsed.bytesToSize(1, 'parseFloat'), memCommitted.bytesToSize(1, 'parseFloat'), percent.toFixed(1));
  69. }.property('service.jvmMemoryHeapUsed', 'service.jvmMemoryHeapCommitted'),
  70. summaryHeader: function () {
  71. var text = this.t("dashboard.services.hdfs.summary");
  72. var svc = this.get('service');
  73. var liveCount = svc.get('liveDataNodes').get('length');
  74. var totalCount = svc.get('dataNodes').get('length');
  75. var total = this.get('service.capacityTotal') + 0;
  76. var remaining = this.get('service.capacityRemaining') + 0;
  77. var used = total - remaining;
  78. var percent = total > 0 ? ((used * 100) / total).toFixed(1) : 0;
  79. if (percent == "NaN" || percent < 0) {
  80. percent = "n/a ";
  81. }
  82. return text.format(liveCount, totalCount, percent);
  83. }.property('service.liveDataNodes', 'service.dataNodes', 'service.capacityUsed', 'service.capacityTotal'),
  84. capacity: function () {
  85. var text = this.t("dashboard.services.hdfs.capacityUsed");
  86. var total = this.get('service.capacityTotal') + 0;
  87. var remaining = this.get('service.capacityRemaining') + 0;
  88. var used = total - remaining;
  89. var percent = total > 0 ? ((used * 100) / total).toFixed(1) : 0;
  90. if (percent == "NaN" || percent < 0) {
  91. percent = "n/a ";
  92. }
  93. if (used < 0) {
  94. used = 0;
  95. }
  96. if (total < 0) {
  97. total = 0;
  98. }
  99. return text.format(used.bytesToSize(1, 'parseFloat'), total.bytesToSize(1, 'parseFloat'), percent);
  100. }.property('service.capacityUsed', 'service.capacityTotal'),
  101. dataNodeComponent: function () {
  102. return App.HostComponent.find().findProperty('componentName', 'DATANODE');
  103. }.property('+'),
  104. isSafeMode: function () {
  105. var safeMode = this.get('service.safeModeStatus');
  106. return safeMode != null && safeMode.length > 0;
  107. }.property('service.safeModeStatus')
  108. });