hdfs.js 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. dashboardMasterComponentView: Em.View.extend({
  38. templateName: require('templates/main/service/info/summary/master_components'),
  39. mastersComp : function() {
  40. var masters = this.get('parentView.service.hostComponents').filter(function(comp){
  41. return comp.get('isMaster') && comp.get('componentName') !== 'JOURNALNODE';
  42. });
  43. return masters;
  44. }.property('parentView.service.hostComponents')
  45. }),
  46. dataNodesLive: function () {
  47. return this.get('service.dataNodes').filterProperty("workStatus", "STARTED");
  48. }.property('service.dataNodes.@each.workStatus'),
  49. dataNodesDead: function () {
  50. return this.get('service.dataNodes').filterProperty("workStatus", "INSTALLED");
  51. }.property('service.dataNodes.@each.workStatus'),
  52. showJournalNodes: function () {
  53. return this.get('service.journalNodes.length') > 0;
  54. }.property('service.journalNodes.length'),
  55. dataNodesLiveTextView: App.ComponentLiveTextView.extend({
  56. liveComponents: function () {
  57. return this.get('service.dataNodes').filterProperty("workStatus", "STARTED").get("length");
  58. }.property("service.dataNodes.@each.workStatus"),
  59. totalComponents: function() {
  60. return this.get("service.dataNodes.length");
  61. }.property("service.dataNodes.length")
  62. }),
  63. journalNodesLiveTextView: App.ComponentLiveTextView.extend({
  64. liveComponents: function () {
  65. return this.get('service.journalNodes').filterProperty("workStatus", "STARTED").get("length");
  66. }.property("service.journalNodes.@each.workStatus"),
  67. totalComponents: function () {
  68. return this.get('service.journalNodes.length');
  69. }.property("service.journalNodes.length")
  70. }),
  71. dfsTotalBlocks: function(){
  72. return this.formatUnavailable(this.get('service.dfsTotalBlocks'));
  73. }.property('service.dfsTotalBlocks'),
  74. dfsTotalFiles: function(){
  75. return this.formatUnavailable(this.get('service.dfsTotalFiles'));
  76. }.property('service.dfsTotalFiles'),
  77. dfsCorruptBlocks: function(){
  78. return this.formatUnavailable(this.get('service.dfsCorruptBlocks'));
  79. }.property('service.dfsCorruptBlocks'),
  80. dfsMissingBlocks: function(){
  81. return this.formatUnavailable(this.get('service.dfsMissingBlocks'));
  82. }.property('service.dfsMissingBlocks'),
  83. dfsUnderReplicatedBlocks: function(){
  84. return this.formatUnavailable(this.get('service.dfsUnderReplicatedBlocks'));
  85. }.property('service.dfsUnderReplicatedBlocks'),
  86. blockErrorsMessage: function() {
  87. return Em.I18n.t('dashboard.services.hdfs.blockErrors').format(this.get('dfsCorruptBlocks'), this.get('dfsMissingBlocks'), this.get('dfsUnderReplicatedBlocks'));
  88. }.property('dfsCorruptBlocks','dfsMissingBlocks','dfsUnderReplicatedBlocks'),
  89. nodeUptime: function () {
  90. var uptime = this.get('service').get('nameNodeStartTime');
  91. if (uptime && uptime > 0){
  92. var diff = (new Date()).getTime() - uptime;
  93. if (diff < 0) {
  94. diff = 0;
  95. }
  96. var formatted = date.timingFormat(diff);
  97. return this.t('dashboard.services.uptime').format(formatted);
  98. }
  99. return this.t('services.service.summary.notRunning');
  100. }.property("service.nameNodeStartTime"),
  101. nodeWebUrl: function () {
  102. return "http://" + (App.singleNodeInstall ? App.singleNodeAlias : this.get('service').get('nameNode').get('publicHostName')) + ":50070";
  103. }.property('service.nameNode'),
  104. nodeHeap: function () {
  105. var memUsed = this.get('service').get('jvmMemoryHeapUsed');
  106. var memMax = this.get('service').get('jvmMemoryHeapMax');
  107. var percent = memMax > 0 ? ((100 * memUsed) / memMax) : 0;
  108. return this.t('dashboard.services.hdfs.nodes.heapUsed').format(
  109. numberUtils.bytesToSize(memUsed, 1, 'parseFloat'),
  110. numberUtils.bytesToSize(memMax, 1, 'parseFloat'),
  111. percent.toFixed(1));
  112. }.property('service.jvmMemoryHeapUsed', 'service.jvmMemoryHeapMax'),
  113. summaryHeader: function () {
  114. var text = this.t("dashboard.services.hdfs.summary");
  115. var svc = this.get('service');
  116. var liveCount = svc.get('liveDataNodes').get('length');
  117. var totalCount = svc.get('dataNodes').get('length');
  118. var total = this.get('service.capacityTotal') + 0;
  119. var remaining = this.get('service.capacityRemaining') + 0;
  120. var used = total - remaining;
  121. var percent = total > 0 ? ((used * 100) / total).toFixed(1) : 0;
  122. if (percent == "NaN" || percent < 0) {
  123. percent = Em.I18n.t('services.service.summary.notAvailable') + " ";
  124. }
  125. return text.format(liveCount, totalCount, percent);
  126. }.property('service.liveDataNodes', 'service.dataNodes', 'service.capacityUsed', 'service.capacityTotal'),
  127. capacity: function () {
  128. var text = this.t("dashboard.services.hdfs.capacityUsed");
  129. var total = this.get('service.capacityTotal');
  130. var remaining = this.get('service.capacityRemaining');
  131. var used = total !== null && remaining !== null ? total - remaining : null;
  132. var percent = total > 0 ? ((used * 100) / total).toFixed(1) : 0;
  133. if (percent == "NaN" || percent < 0) {
  134. percent = Em.I18n.t('services.service.summary.notAvailable') + " ";
  135. }
  136. return text.format(numberUtils.bytesToSize(used, 1, 'parseFloat'), numberUtils.bytesToSize(total, 1, 'parseFloat'), percent);
  137. }.property('service.capacityUsed', 'service.capacityTotal'),
  138. dataNodeComponent: function () {
  139. return this.get('service.dataNodes').objectAt(0);
  140. }.property(),
  141. journalNodeComponent: function () {
  142. return this.get('service.journalNodes').objectAt(0);
  143. }.property(),
  144. safeModeStatus: function () {
  145. var safeMode = this.get('service.safeModeStatus');
  146. if (safeMode == null) {
  147. return Em.I18n.t("services.service.summary.notAvailable");
  148. } else if (safeMode.length == 0) {
  149. return Em.I18n.t("services.service.summary.safeModeStatus.notInSafeMode");
  150. } else {
  151. return Em.I18n.t("services.service.summary.safeModeStatus.inSafeMode");
  152. }
  153. }.property('service.safeModeStatus'),
  154. upgradeStatus: function () {
  155. var upgradeStatus = this.get('service.upgradeStatus');
  156. var healthStatus = this.get('service.healthStatus');
  157. if (upgradeStatus) {
  158. return Em.I18n.t('services.service.summary.pendingUpgradeStatus.notPending');
  159. } else if (healthStatus == 'green') {
  160. return Em.I18n.t('services.service.summary.pendingUpgradeStatus.pending');
  161. } else {
  162. return Em.I18n.t("services.service.summary.notAvailable");
  163. }
  164. }.property('service.upgradeStatus', 'service.healthStatus')
  165. });