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     */
018    package org.apache.hadoop.hdfs.server.namenode;
019    
020    import org.apache.hadoop.hdfs.util.EnumCounters;
021    
022    /**
023     * The content types such as file, directory and symlink to be computed.
024     */
025    public enum Content {
026      /** The number of files. */
027      FILE,
028      /** The number of directories. */
029      DIRECTORY,
030      /** The number of symlinks. */
031      SYMLINK,
032    
033      /** The total of file length in bytes. */
034      LENGTH,
035      /** The total of disk space usage in bytes including replication. */
036      DISKSPACE,
037    
038      /** The number of snapshots. */
039      SNAPSHOT,
040      /** The number of snapshottable directories. */
041      SNAPSHOTTABLE_DIRECTORY;
042    
043      /** Content counts. */
044      public static class Counts extends EnumCounters<Content> {
045        public static Counts newInstance() {
046          return new Counts();
047        }
048    
049        private Counts() {
050          super(Content.class);
051        }
052      }
053    
054      private static final EnumCounters.Factory<Content, Counts> FACTORY
055          = new EnumCounters.Factory<Content, Counts>() {
056        @Override
057        public Counts newInstance() {
058          return Counts.newInstance();
059        }
060      };
061    
062      /** A map of counters for the current state and the snapshots. */
063      public static class CountsMap
064          extends EnumCounters.Map<CountsMap.Key, Content, Counts> {
065        /** The key type of the map. */
066        public static enum Key { CURRENT, SNAPSHOT }
067    
068        CountsMap() {
069          super(FACTORY);
070        }
071      }
072    }