001/** 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.apache.hadoop.fs; 019 020import org.apache.hadoop.classification.InterfaceAudience; 021 022import java.util.Iterator; 023 024/** 025 * StorageStatistics contains statistics data for a FileSystem or FileContext 026 * instance. 027 */ 028@InterfaceAudience.Public 029public abstract class StorageStatistics { 030 /** 031 * A 64-bit storage statistic. 032 */ 033 public static class LongStatistic { 034 private final String name; 035 private final long value; 036 037 public LongStatistic(String name, long value) { 038 this.name = name; 039 this.value = value; 040 } 041 042 /** 043 * @return The name of this statistic. 044 */ 045 public String getName() { 046 return name; 047 } 048 049 /** 050 * @return The value of this statistic. 051 */ 052 public long getValue() { 053 return value; 054 } 055 } 056 057 private final String name; 058 059 public StorageStatistics(String name) { 060 this.name = name; 061 } 062 063 /** 064 * Get the name of this StorageStatistics object. 065 */ 066 public String getName() { 067 return name; 068 } 069 070 /** 071 * Get an iterator over all the currently tracked long statistics. 072 * 073 * The values returned will depend on the type of FileSystem or FileContext 074 * object. The values do not necessarily reflect a snapshot in time. 075 */ 076 public abstract Iterator<LongStatistic> getLongStatistics(); 077 078 /** 079 * Get the value of a statistic. 080 * 081 * @return null if the statistic is not being tracked or is not a 082 * long statistic. 083 * The value of the statistic, otherwise. 084 */ 085 public abstract Long getLong(String key); 086 087 /** 088 * Return true if a statistic is being tracked. 089 * 090 * @return True only if the statistic is being tracked. 091 */ 092 public abstract boolean isTracked(String key); 093}