hdfs.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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.data.dfs_used_bytes') + this.get('_parentView.data.nondfs_used_bytes'), this.get('_parentView.data.dfs_free_bytes') ];
  25. }.property('_parentView.data')
  26. }),
  27. nodeUptime:function () {
  28. var uptime = this.get('data.namenode_starttime');
  29. var formatted = uptime.toDaysHoursMinutes();
  30. return this.t('dashboard.services.uptime').format(formatted.d, formatted.h, formatted.m);
  31. }.property("data"),
  32. nodeHeap:function () {
  33. var percent = this.get('data.namenode_heap_total') > 0 ? 100 * this.get('data.namenode_heap_used') / this.get('data.namenode_heap_total') : 0;
  34. return this.t('dashboard.services.hdfs.nodes.heapUsed').format(
  35. this.get('data.namenode_heap_used').bytesToSize(1, 'parseFloat'),
  36. this.get('data.namenode_heap_total').bytesToSize(1, 'parseFloat')
  37. , percent.toFixed(1));
  38. }.property('data'),
  39. summaryHeader:function () {
  40. var text = this.t("dashboard.services.hdfs.summary");
  41. return text.format(this.get('data.live_nodes'), this.get('data.total_nodes'), this.get('data.dfs_percent_remaining'));
  42. }.property('data'),
  43. capacity:function () {
  44. var text = this.t("dashboard.services.hdfs.capacityUsed");
  45. var total = this.get('data.dfs_total_bytes') + 0;
  46. var used = this.get('data.dfs_used_bytes') + this.get('data.nondfs_used_bytes');
  47. return text.format(used.bytesToSize(1), total.bytesToSize(1), this.get('data.dfs_percent_used'));
  48. }.property('data')
  49. });