hdfs.js 8.7 KB

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