hdfs.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. data:function () {
  24. return [ this.get('_parentView.service.capacityUsed'), this.get('_parentView.service.capacityTotal') ];
  25. }.property('_parentView.service')
  26. }),
  27. nodeUptime:function () {
  28. var uptime = this.get('service').get('nameNodeStartTime');
  29. var formatted = (new Date().getTime() - uptime).toDaysHoursMinutes();
  30. return this.t('dashboard.services.uptime').format(formatted.d, formatted.h, formatted.m);
  31. }.property("service.nameNodeStartTime"),
  32. service: function(){
  33. return App.HDFSService.find().objectAt(0);
  34. }.property('App.router.clusterController.dataLoadList.services'),
  35. nodeWebUrl: function(){
  36. return "http://"+this.get('service').get('nameNode').get('hostName')+":50070";
  37. }.property('service.nameNode'),
  38. nodeHeap:function () {
  39. var percent = this.get('data.namenode_heap_total') > 0 ? 100 * this.get('data.namenode_heap_used') / this.get('data.namenode_heap_total') : 0;
  40. return this.t('dashboard.services.hdfs.nodes.heapUsed').format(
  41. (this.get('service').get('jvmMemoryHeapUsed')*1000000).bytesToSize(1, 'parseFloat'),
  42. (this.get('service').get('jvmMemoryHeapCommitted')*1000000).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('components')
  65. });