hdfs.js 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. App.MainDashboardServiceHdfsView = App.MainDashboardServiceView.extend({
  20. templateName: require('templates/main/dashboard/service/hdfs'),
  21. serviceName: 'HDFS',
  22. Chart: App.ChartPieView.extend({
  23. service: null,
  24. data: function () {
  25. var total = this.get('service.capacityTotal') + 0;
  26. var remaining = (this.get('service.capacityRemaining') + 0);
  27. var used = total - remaining;
  28. return [ used, remaining ];
  29. }.property('service.capacityUsed', 'service.capacityTotal')
  30. }),
  31. nodeUptime: function () {
  32. var uptime = this.get('service').get('nameNodeStartTime');
  33. var formatted = date.timingFormat((new Date().getTime() - uptime));
  34. return this.t('dashboard.services.uptime').format(formatted);
  35. }.property("service.nameNodeStartTime"),
  36. nodeWebUrl: function () {
  37. return "http://" + this.get('service').get('nameNode').get('publicHostName') + ":50070";
  38. }.property('service.nameNode'),
  39. nodeHeap: function () {
  40. var memUsed = this.get('service').get('jvmMemoryHeapUsed') * 1000000;
  41. var memCommitted = this.get('service').get('jvmMemoryHeapCommitted') * 1000000;
  42. var percent = memCommitted > 0 ? ((100 * memUsed) / memCommitted) : 0;
  43. return this.t('dashboard.services.hdfs.nodes.heapUsed').format(memUsed.bytesToSize(1, 'parseFloat'), memCommitted.bytesToSize(1, 'parseFloat'), percent.toFixed(1));
  44. }.property('service.jvmMemoryHeapUsed', 'service.jvmMemoryHeapCommitted'),
  45. summaryHeader: function () {
  46. var text = this.t("dashboard.services.hdfs.summary");
  47. var svc = this.get('service');
  48. var liveCount = svc.get('liveDataNodes').get('length');
  49. var totalCount = svc.get('dataNodes').get('length');
  50. var total = svc.get('capacityTotal') + 0;
  51. var used = svc.get('capacityUsed') + 0;
  52. var percentRemaining = (100 - Math.round((used * 100) / total)).toFixed(1);
  53. if (percentRemaining == "NaN") {
  54. percentRemaining = "n/a ";
  55. }
  56. return text.format(liveCount, totalCount, percentRemaining);
  57. }.property('service.liveDataNodes', 'service.dataNodes', 'service.capacityUsed', 'service.capacityTotal'),
  58. capacity: function () {
  59. var text = this.t("dashboard.services.hdfs.capacityUsed");
  60. var total = this.get('service.capacityTotal') + 0;
  61. var used = total - (this.get('service.capacityRemaining') + 0);
  62. var percent = total > 0 ? ((used * 100) / total).toFixed(1) : 0;
  63. if (percent == "NaN") {
  64. percent = "n/a ";
  65. }
  66. return text.format(used.bytesToSize(1, 'parseFloat'), total.bytesToSize(1, 'parseFloat'), percent);
  67. }.property('service.capacityUsed', 'service.capacityTotal'),
  68. dataNodeComponent: function () {
  69. return App.Component.find().findProperty('componentName', 'DATANODE');
  70. }.property('+'),
  71. isCollapsed: false,
  72. toggleInfoView: function () {
  73. $('#hdfs-info').toggle('blind', 200);
  74. this.set('isCollapsed', !this.isCollapsed);
  75. },
  76. isSafeMode: function () {
  77. var safeMode = this.get('service.safeModeStatus');
  78. return safeMode != null && safeMode.length > 0;
  79. }.property('service.safeModeStatus')
  80. });