hdfs.js 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var App = require('app');
  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. return [ this.get('service.capacityUsed'), this.get('service.capacityTotal') ];
  26. }.property('service')
  27. }),
  28. nodeUptime:function () {
  29. var uptime = this.get('service').get('nameNodeStartTime');
  30. var formatted = (new Date().getTime() - uptime).toDaysHoursMinutes();
  31. return this.t('dashboard.services.uptime').format(formatted.d, formatted.h, formatted.m);
  32. }.property("service.nameNodeStartTime"),
  33. nodeWebUrl: function(){
  34. return "http://"+this.get('service').get('nameNode').get('publicHostName')+":50070";
  35. }.property('service.nameNode'),
  36. nodeHeap:function () {
  37. var memUsed = this.get('service').get('jvmMemoryHeapUsed')*1000000;
  38. var memCommitted = this.get('service').get('jvmMemoryHeapCommitted')*1000000;
  39. var percent = memCommitted>0 ? ((100*memUsed)/memCommitted) : 0;
  40. return this.t('dashboard.services.hdfs.nodes.heapUsed').format(
  41. memUsed.bytesToSize(1, 'parseFloat'),
  42. memCommitted.bytesToSize(1, 'parseFloat'),
  43. percent.toFixed(1));
  44. }.property('service'),
  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. return text.format(liveCount, totalCount, percentRemaining);
  54. }.property('service'),
  55. capacity:function () {
  56. var text = this.t("dashboard.services.hdfs.capacityUsed");
  57. var total = this.get('service').get('capacityTotal') + 0;
  58. var used = this.get('service').get('capacityUsed') + 0;
  59. var percent = Math.round((used*100)/total).toFixed(1);
  60. return text.format(used.bytesToSize(1), total.bytesToSize(1), percent);
  61. }.property('service'),
  62. dataNodeComponent: function(){
  63. return App.Component.find().findProperty('componentName', 'DATANODE');
  64. }.property('+'),
  65. toggleInfoView: function() {
  66. $('#hdfs-info').toggle('blind', 200);
  67. }
  68. });