hdfs.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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.MainDashboardServiceHdfsView = App.MainDashboardServiceView.extend({
  21. templateName: require('templates/main/dashboard/service/hdfs'),
  22. serviceName: 'HDFS',
  23. Chart: App.ChartPieView.extend({
  24. service: null,
  25. color: '#0066B3',
  26. stroke: '#0066B3',
  27. palette: new Rickshaw.Color.Palette({
  28. scheme: [ 'rgba(0,102,179,0)', 'rgba(0,102,179,1)'].reverse()
  29. }),
  30. data: function () {
  31. var total = this.get('service.capacityTotal') + 0;
  32. var remaining = (this.get('service.capacityRemaining') + 0);
  33. var used = total - remaining;
  34. return [ used, remaining ];
  35. }.property('service.capacityUsed', 'service.capacityTotal')
  36. }),
  37. dataNodesLive: function(){
  38. return App.HostComponent.find().filterProperty('componentName', 'DATANODE').filterProperty("workStatus","STARTED");
  39. }.property('service.hostComponents.@each'),
  40. dataNodesDead: function(){
  41. return App.HostComponent.find().filterProperty('componentName', 'DATANODE').filterProperty("workStatus","INSTALLED");
  42. }.property('service.hostComponents.@each'),
  43. dataNodeHostText: function () {
  44. if(this.get("service.dataNodes") > 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. dataNodesLiveTextView: App.ComponentLiveTextView.extend({
  51. liveComponents: function() {
  52. return App.HostComponent.find().filterProperty('componentName', 'DATANODE').filterProperty("workStatus","STARTED").get("length");
  53. }.property("service.hostComponents.@each"),
  54. totalComponents: function() {
  55. return this.get("service.dataNodes.length");
  56. }.property("service.dataNodes.length")
  57. }),
  58. dfsTotalBlocks: function(){
  59. return this.formatUnavailable(this.get('service.dfsTotalBlocks'));
  60. }.property('service.dfsTotalBlocks'),
  61. dfsTotalFiles: function(){
  62. return this.formatUnavailable(this.get('service.dfsTotalFiles'));
  63. }.property('service.dfsTotalFiles'),
  64. dfsCorruptBlocks: function(){
  65. return this.formatUnavailable(this.get('service.dfsCorruptBlocks'));
  66. }.property('service.dfsCorruptBlocks'),
  67. dfsMissingBlocks: function(){
  68. return this.formatUnavailable(this.get('service.dfsMissingBlocks'));
  69. }.property('service.dfsMissingBlocks'),
  70. dfsUnderReplicatedBlocks: function(){
  71. return this.formatUnavailable(this.get('service.dfsUnderReplicatedBlocks'));
  72. }.property('service.dfsUnderReplicatedBlocks'),
  73. blockErrorsMessage: function() {
  74. return Em.I18n.t('dashboard.services.hdfs.blockErrors').format(this.get('dfsCorruptBlocks'), this.get('dfsMissingBlocks'), this.get('dfsUnderReplicatedBlocks'));
  75. }.property('dfsCorruptBlocks','dfsMissingBlocks','dfsUnderReplicatedBlocks'),
  76. nodeUptime: function () {
  77. var uptime = this.get('service').get('nameNodeStartTime');
  78. if (uptime && uptime > 0){
  79. var diff = (new Date()).getTime() - uptime;
  80. if (diff < 0) {
  81. diff = 0;
  82. }
  83. var formatted = date.timingFormat(diff);
  84. return this.t('dashboard.services.uptime').format(formatted);
  85. }
  86. return this.t('services.service.summary.notRunning');
  87. }.property("service.nameNodeStartTime"),
  88. nodeWebUrl: function () {
  89. return "http://" + (App.singleNodeInstall ? App.singleNodeAlias : this.get('service').get('nameNode').get('publicHostName')) + ":50070";
  90. }.property('service.nameNode'),
  91. nodeHeap: function () {
  92. var memUsed = this.get('service').get('jvmMemoryHeapUsed');
  93. var memCommitted = this.get('service').get('jvmMemoryHeapCommitted');
  94. var percent = memCommitted > 0 ? ((100 * memUsed) / memCommitted) : 0;
  95. return this.t('dashboard.services.hdfs.nodes.heapUsed').format(
  96. numberUtils.bytesToSize(memUsed, 1, 'parseFloat', 1024 * 1024),
  97. numberUtils.bytesToSize(memCommitted, 1, 'parseFloat', 1024 * 1024),
  98. percent.toFixed(1));
  99. }.property('service.jvmMemoryHeapUsed', 'service.jvmMemoryHeapCommitted'),
  100. summaryHeader: function () {
  101. var text = this.t("dashboard.services.hdfs.summary");
  102. var svc = this.get('service');
  103. var liveCount = svc.get('liveDataNodes').get('length');
  104. var totalCount = svc.get('dataNodes').get('length');
  105. var total = this.get('service.capacityTotal') + 0;
  106. var remaining = this.get('service.capacityRemaining') + 0;
  107. var used = total - remaining;
  108. var percent = total > 0 ? ((used * 100) / total).toFixed(1) : 0;
  109. if (percent == "NaN" || percent < 0) {
  110. percent = Em.I18n.t('services.service.summary.notAvailable') + " ";
  111. }
  112. return text.format(liveCount, totalCount, percent);
  113. }.property('service.liveDataNodes', 'service.dataNodes', 'service.capacityUsed', 'service.capacityTotal'),
  114. capacity: function () {
  115. var text = this.t("dashboard.services.hdfs.capacityUsed");
  116. var total = this.get('service.capacityTotal');
  117. var remaining = this.get('service.capacityRemaining');
  118. var used = total !== null && remaining !== null ? total - remaining : null;
  119. var percent = total > 0 ? ((used * 100) / total).toFixed(1) : 0;
  120. if (percent == "NaN" || percent < 0) {
  121. percent = Em.I18n.t('services.service.summary.notAvailable') + " ";
  122. }
  123. return text.format(numberUtils.bytesToSize(used, 1, 'parseFloat'), numberUtils.bytesToSize(total, 1, 'parseFloat'), percent);
  124. }.property('service.capacityUsed', 'service.capacityTotal'),
  125. dataNodeComponent: function () {
  126. return App.HostComponent.find().findProperty('componentName', 'DATANODE');
  127. }.property(),
  128. isSafeMode: function () {
  129. var safeMode = this.get('service.safeModeStatus');
  130. return safeMode != null && safeMode.length > 0;
  131. }.property('service.safeModeStatus')
  132. });