All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.hadoop.mapreduce.Counters Maven / Gradle / Ivy

/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.hadoop.mapreduce;

import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.mapreduce.counters.Limits;
import org.apache.hadoop.mapreduce.counters.GenericCounter;
import org.apache.hadoop.mapreduce.counters.AbstractCounterGroup;
import org.apache.hadoop.mapreduce.counters.CounterGroupBase;
import org.apache.hadoop.mapreduce.counters.FileSystemCounterGroup;
import org.apache.hadoop.mapreduce.counters.AbstractCounters;
import org.apache.hadoop.mapreduce.counters.CounterGroupFactory;
import org.apache.hadoop.mapreduce.counters.FrameworkCounterGroup;

/**
 * 

Counters holds per job/task counters, defined either by the * Map-Reduce framework or applications. Each Counter can be of * any {@link Enum} type.

* *

Counters are bunched into {@link CounterGroup}s, each * comprising of counters from a particular Enum class. */ @InterfaceAudience.Public @InterfaceStability.Stable public class Counters extends AbstractCounters { // Mix framework group implementation into CounterGroup interface private static class FrameworkGroupImpl> extends FrameworkCounterGroup implements CounterGroup { FrameworkGroupImpl(Class cls) { super(cls); } @Override protected FrameworkCounter newCounter(T key) { return new FrameworkCounter(key, getName()); } @Override public CounterGroupBase getUnderlyingGroup() { return this; } } // Mix generic group implementation into CounterGroup interface // and provide some mandatory group factory methods. private static class GenericGroup extends AbstractCounterGroup implements CounterGroup { GenericGroup(String name, String displayName, Limits limits) { super(name, displayName, limits); } @Override protected Counter newCounter(String name, String displayName, long value) { return new GenericCounter(name, displayName, value); } @Override protected Counter newCounter() { return new GenericCounter(); } @Override public CounterGroupBase getUnderlyingGroup() { return this; } } // Mix file system group implementation into the CounterGroup interface private static class FileSystemGroup extends FileSystemCounterGroup implements CounterGroup { @Override protected Counter newCounter(String scheme, FileSystemCounter key) { return new FSCounter(scheme, key); } @Override public CounterGroupBase getUnderlyingGroup() { return this; } } /** * Provide factory methods for counter group factory implementation. * See also the GroupFactory in * {@link org.apache.hadoop.mapred.Counters mapred.Counters} */ private static class GroupFactory extends CounterGroupFactory { @Override protected > FrameworkGroupFactory newFrameworkGroupFactory(final Class cls) { return new FrameworkGroupFactory() { @Override public CounterGroup newGroup(String name) { return new FrameworkGroupImpl(cls); // impl in this package } }; } @Override protected CounterGroup newGenericGroup(String name, String displayName, Limits limits) { return new GenericGroup(name, displayName, limits); } @Override protected CounterGroup newFileSystemGroup() { return new FileSystemGroup(); } } private static final GroupFactory groupFactory = new GroupFactory(); /** * Default constructor */ public Counters() { super(groupFactory); } /** * Construct the Counters object from the another counters object * @param the type of counter * @param the type of counter group * @param counters the old counters object */ public > Counters(AbstractCounters counters) { super(counters, groupFactory); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy