hdfs.js 9.2 KB

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