hdfs.js 8.6 KB

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