hdfs.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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/date');
  19. var numberUtils = require('utils/number_utils');
  20. function diskPart(i18nKey, totalKey, usedKey) {
  21. return Em.computed(totalKey, usedKey, function () {
  22. var text = Em.I18n.t(i18nKey);
  23. var total = this.get(totalKey);
  24. var used = this.get(usedKey);
  25. var percent = total > 0 ? ((used * 100) / total).toFixed(2) : 0;
  26. if (percent == "NaN" || percent < 0) {
  27. percent = Em.I18n.t('services.service.summary.notAvailable') + " ";
  28. }
  29. return text.format(numberUtils.bytesToSize(used, 1, 'parseFloat'), numberUtils.bytesToSize(total, 1, 'parseFloat'), percent);
  30. });
  31. }
  32. App.MainDashboardServiceHdfsView = App.MainDashboardServiceView.extend({
  33. templateName: require('templates/main/service/services/hdfs'),
  34. serviceName: 'HDFS',
  35. Chart: App.ChartPieView.extend({
  36. service: null,
  37. color: '#0066B3',
  38. stroke: '#0066B3',
  39. palette: new Rickshaw.Color.Palette({
  40. scheme: [ 'rgba(0,102,179,0)', 'rgba(0,102,179,1)'].reverse()
  41. }),
  42. data: function () {
  43. var total = this.get('service.capacityTotal') + 0;
  44. var remaining = (this.get('service.capacityRemaining') + 0);
  45. var used = total - remaining;
  46. return [ used, remaining ];
  47. }.property('service.capacityUsed', 'service.capacityTotal')
  48. }),
  49. dashboardMasterComponentView: Em.View.extend({
  50. didInsertElement: function() {
  51. App.tooltip($('[rel=healthTooltip]'));
  52. },
  53. templateName: require('templates/main/service/info/summary/master_components'),
  54. mastersComp: function() {
  55. var masterComponents = [];
  56. var zkfcs = this.get('parentView.service.hostComponents').filterProperty('componentName', 'ZKFC');
  57. this.get('parentView.service.hostComponents').forEach(function (comp) {
  58. if (comp.get('isMaster') && comp.get('componentName') !== 'JOURNALNODE') {
  59. masterComponents.push(comp);
  60. var zkfc = zkfcs.findProperty('hostName', comp.get('hostName'));
  61. if (zkfc) {
  62. zkfc.set('isSubComponent', true);
  63. masterComponents.push(zkfc);
  64. }
  65. }
  66. });
  67. return masterComponents;
  68. }.property('parentView.service.hostComponents.length'),
  69. willDestroyElement: function() {
  70. $('[rel=healthTooltip]').tooltip('destroy')
  71. }
  72. }),
  73. didInsertElement: function() {
  74. App.tooltip($("[rel='tooltip']"));
  75. },
  76. willDestroyElement: function() {
  77. $("[rel='tooltip']").tooltip('destroy');
  78. },
  79. dataNodesDead: Em.computed.alias('service.dataNodesInstalled'),
  80. showJournalNodes: Em.computed.gt('service.journalNodes.length', 0),
  81. journalNodesLive: function () {
  82. return this.get('service.journalNodes').filterProperty("workStatus", "STARTED").get("length");
  83. }.property("service.journalNodes.@each.workStatus"),
  84. journalNodesTotal: Em.computed.alias('service.journalNodes.length'),
  85. dfsTotalBlocks: Em.computed.formatUnavailable('service.dfsTotalBlocks'),
  86. dfsTotalFiles: Em.computed.formatUnavailable('service.dfsTotalFiles'),
  87. dfsCorruptBlocks: Em.computed.formatUnavailable('service.dfsCorruptBlocks'),
  88. dfsMissingBlocks: Em.computed.formatUnavailable('service.dfsMissingBlocks'),
  89. dfsUnderReplicatedBlocks: Em.computed.formatUnavailable('service.dfsUnderReplicatedBlocks'),
  90. blockErrorsMessage: Em.computed.i18nFormat('dashboard.services.hdfs.blockErrors', '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: App.MainDashboardServiceView.formattedHeap('dashboard.services.hdfs.nodes.heapUsed', 'service.jvmMemoryHeapUsed', 'service,jvmMemoryHeapMax'),
  107. dfsUsedDisk: diskPart('dashboard.services.hdfs.capacityUsed', 'service.capacityTotal', 'service.capacityUsed'),
  108. nonDfsUsed: function () {
  109. var total = this.get('service.capacityTotal');
  110. var remaining = this.get('service.capacityRemaining');
  111. var dfsUsed = this.get('service.capacityUsed');
  112. return total !== null && remaining !== null && dfsUsed !== null ? total - remaining - dfsUsed : null;
  113. }.property('service.capacityTotal', 'service.capacityRemaining', 'service.capacityUsed'),
  114. nonDfsUsedDisk: diskPart('dashboard.services.hdfs.capacityUsed', 'service.capacityTotal', 'nonDfsUsed'),
  115. remainingDisk: diskPart('dashboard.services.hdfs.capacityUsed', 'service.capacityTotal', 'service.capacityRemaining'),
  116. dataNodeComponent: Em.Object.create({
  117. componentName: 'DATANODE'
  118. }),
  119. nfsGatewayComponent: Em.Object.create({
  120. componentName: 'NFS_GATEWAY'
  121. }),
  122. /**
  123. * Define if NFS_GATEWAY is present in the installed stack
  124. * @type {Boolean}
  125. */
  126. isNfsInStack: function () {
  127. return App.StackServiceComponent.find().someProperty('componentName', 'NFS_GATEWAY');
  128. }.property(),
  129. journalNodeComponent: Em.computed.alias('service.journalNodes.firstObject'),
  130. safeModeStatus: function () {
  131. var safeMode = this.get('service.safeModeStatus');
  132. if (safeMode == null) {
  133. return Em.I18n.t("services.service.summary.notAvailable");
  134. } else if (safeMode.length == 0) {
  135. return Em.I18n.t("services.service.summary.safeModeStatus.notInSafeMode");
  136. } else {
  137. return Em.I18n.t("services.service.summary.safeModeStatus.inSafeMode");
  138. }
  139. }.property('service.safeModeStatus'),
  140. upgradeStatus: function () {
  141. var upgradeStatus = this.get('service.upgradeStatus');
  142. var healthStatus = this.get('service.healthStatus');
  143. if (upgradeStatus == 'true') {
  144. return Em.I18n.t('services.service.summary.pendingUpgradeStatus.notPending');
  145. } else if (upgradeStatus == 'false' && healthStatus == 'green') {
  146. return Em.I18n.t('services.service.summary.pendingUpgradeStatus.notFinalized');
  147. } else {
  148. // upgrade status == null
  149. return Em.I18n.t("services.service.summary.notAvailable");
  150. }
  151. }.property('service.upgradeStatus', 'service.healthStatus'),
  152. isUpgradeStatusWarning: function () {
  153. var upgradeStatus = this.get('service.upgradeStatus');
  154. var healthStatus = this.get('service.healthStatus');
  155. return upgradeStatus == 'false' && healthStatus == 'green';
  156. }.property('service.upgradeStatus', 'service.healthStatus')
  157. });