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    
019    package org.apache.hadoop.mapreduce;
020    
021    import org.apache.hadoop.classification.InterfaceAudience;
022    import org.apache.hadoop.classification.InterfaceStability;
023    import org.apache.hadoop.classification.InterfaceAudience.Private;
024    import org.apache.hadoop.io.Writable;
025    
026    /**
027     * A named counter that tracks the progress of a map/reduce job.
028     *
029     * <p><code>Counters</code> represent global counters, defined either by the
030     * Map-Reduce framework or applications. Each <code>Counter</code> is named by
031     * an {@link Enum} and has a long for the value.</p>
032     *
033     * <p><code>Counters</code> are bunched into Groups, each comprising of
034     * counters from a particular <code>Enum</code> class.
035     */
036    @InterfaceAudience.Public
037    @InterfaceStability.Stable
038    public interface Counter extends Writable {
039    
040      /**
041       * Set the display name of the counter
042       * @param displayName of the counter
043       * @deprecated (and no-op by default)
044       */
045      @Deprecated
046      void setDisplayName(String displayName);
047    
048      /**
049       * @return the name of the counter
050       */
051      String getName();
052    
053      /**
054       * Get the display name of the counter.
055       * @return the user facing name of the counter
056       */
057      String getDisplayName();
058    
059      /**
060       * What is the current value of this counter?
061       * @return the current value
062       */
063      long getValue();
064    
065      /**
066       * Set this counter by the given value
067       * @param value the value to set
068       */
069      void setValue(long value);
070    
071      /**
072       * Increment this counter by the given value
073       * @param incr the value to increase this counter by
074       */
075      void increment(long incr);
076     
077      @Private
078      /**
079       * Return the underlying object if this is a facade.
080       * @return the undelying object.
081       */
082      Counter getUnderlyingCounter();
083    }