diff --git a/hadoop-mapreduce-project/CHANGES.txt b/hadoop-mapreduce-project/CHANGES.txt index 829ee744b52..97178e424b8 100644 --- a/hadoop-mapreduce-project/CHANGES.txt +++ b/hadoop-mapreduce-project/CHANGES.txt @@ -736,6 +736,9 @@ Release 0.23.1 - Unreleased MAPREDUCE-3794. Support mapred.Task.Counter and mapred.JobInProgress.Counter enums for compatibility (Tom White via mahadev) + MAPREDUCE-3697. Support binary compatibility for Counters after + MAPREDUCE-901. (mahadev via acmurthy) + Release 0.23.0 - 2011-11-01 INCOMPATIBLE CHANGES diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/Counters.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/Counters.java index b739402ffb6..a0454ef8cee 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/Counters.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/Counters.java @@ -21,8 +21,14 @@ import static org.apache.hadoop.mapreduce.util.CountersStrings.parseEscapedCompactString; import static org.apache.hadoop.mapreduce.util.CountersStrings.toEscapedCompactString; +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; import java.text.ParseException; +import java.util.Collection; +import java.util.Iterator; +import org.apache.commons.collections.IteratorUtils; import org.apache.commons.logging.Log; import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceStability; @@ -36,6 +42,9 @@ import org.apache.hadoop.mapreduce.counters.GenericCounter; import org.apache.hadoop.mapreduce.counters.Limits; import org.apache.hadoop.mapreduce.lib.input.FileInputFormatCounter; +import org.apache.hadoop.mapreduce.util.CountersStrings; + +import com.google.common.collect.Iterators; /** * A set of named counters. @@ -51,7 +60,9 @@ @InterfaceStability.Stable public class Counters extends AbstractCounters { - + + public static int MAX_COUNTER_LIMIT = Limits.COUNTERS_MAX; + public Counters() { super(groupFactory); } @@ -69,17 +80,82 @@ static Counters downgrade(org.apache.hadoop.mapreduce.Counters newCounters) { return new Counters(newCounters); } + public synchronized Group getGroup(String groupName) { + return super.getGroup(groupName); + } + + @SuppressWarnings("unchecked") + public synchronized Collection getGroupNames() { + return IteratorUtils.toList(super.getGroupNames().iterator()); + } + + public synchronized String makeCompactString() { + return CountersStrings.toEscapedCompactString(this); + } + /** * A counter record, comprising its name and value. */ - public interface Counter extends org.apache.hadoop.mapreduce.Counter { + public static class Counter implements org.apache.hadoop.mapreduce.Counter { + org.apache.hadoop.mapreduce.Counter realCounter; + + Counter(org.apache.hadoop.mapreduce.Counter counter) { + this.realCounter = counter; + } + + public Counter() { + this(new GenericCounter()); + } + + @SuppressWarnings("deprecation") + @Override + public void setDisplayName(String displayName) { + realCounter.setDisplayName(displayName); + } + + @Override + public String getName() { + return realCounter.getName(); + } + + @Override + public String getDisplayName() { + return realCounter.getDisplayName(); + } + + @Override + public long getValue() { + return realCounter.getValue(); + } + + @Override + public void setValue(long value) { + realCounter.setValue(value); + } + + @Override + public void increment(long incr) { + realCounter.increment(incr); + } + + @Override + public void write(DataOutput out) throws IOException { + realCounter.write(out); + } + + @Override + public void readFields(DataInput in) throws IOException { + realCounter.readFields(in); + } /** * Returns the compact stringified version of the counter in the format * [(actual-name)(display-name)(value)] * @return the stringified result */ - String makeEscapedCompactString(); + public String makeEscapedCompactString() { + return toEscapedCompactString(realCounter); + } /** * Checks for (content) equality of two (basic) counters @@ -88,39 +164,42 @@ public interface Counter extends org.apache.hadoop.mapreduce.Counter { * @deprecated */ @Deprecated - boolean contentEquals(Counter counter); + public boolean contentEquals(Counter counter) { + return realCounter.equals(counter.getUnderlyingCounter()); + } /** * @return the value of the counter */ - long getCounter(); - } - - static class OldCounterImpl extends GenericCounter implements Counter { - - OldCounterImpl() { - } - - OldCounterImpl(String name, String displayName, long value) { - super(name, displayName, value); - } - - @Override - public synchronized String makeEscapedCompactString() { - return toEscapedCompactString(this); - } - - @Override @Deprecated - public boolean contentEquals(Counter counter) { - return equals(counter); - } - - @Override public long getCounter() { - return getValue(); + return realCounter.getValue(); + } + + @Override + public org.apache.hadoop.mapreduce.Counter getUnderlyingCounter() { + return realCounter; + } + + @Override + public synchronized boolean equals(Object genericRight) { + if (genericRight instanceof Counter) { + synchronized (genericRight) { + Counter right = (Counter) genericRight; + return getName().equals(right.getName()) && + getDisplayName().equals(right.getDisplayName()) && + getValue() == right.getValue(); + } + } + return false; + } + + @Override + public int hashCode() { + return realCounter.hashCode(); } } + /** * Group of counters, comprising of counters from a particular * counter {@link Enum} class. @@ -128,21 +207,38 @@ public long getCounter() { *

Grouphandles localization of the class name and the * counter names.

*/ - public static interface Group extends CounterGroupBase { - + public static class Group implements CounterGroupBase { + private CounterGroupBase realGroup; + + Group(GenericGroup group) { + this.realGroup = group; + } + Group(FSGroupImpl group) { + this.realGroup = group; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + Group(FrameworkGroupImpl group) { + this.realGroup = group; + } + /** * @param counterName the name of the counter * @return the value of the specified counter, or 0 if the counter does * not exist. */ - long getCounter(String counterName); + public long getCounter(String counterName) { + return getCounterValue(realGroup, counterName); + } /** * @return the compact stringified version of the group in the format * {(actual-name)(display-name)(value)[][][]} where [] are compact strings * for the counters within. */ - String makeEscapedCompactString(); + public String makeEscapedCompactString() { + return toEscapedCompactString(realGroup); + } /** * Get the counter for the given id and create it if it doesn't exist. @@ -152,172 +248,184 @@ public static interface Group extends CounterGroupBase { * @deprecated use {@link #findCounter(String)} instead */ @Deprecated - Counter getCounter(int id, String name); + public Counter getCounter(int id, String name) { + return findCounter(name); + } /** * Get the counter for the given name and create it if it doesn't exist. * @param name the internal counter name * @return the counter */ - Counter getCounterForName(String name); + public Counter getCounterForName(String name) { + return findCounter(name); + } + + @Override + public void write(DataOutput out) throws IOException { + realGroup.write(out); + } + + @Override + public void readFields(DataInput in) throws IOException { + realGroup.readFields(in); + } + + @Override + public Iterator iterator() { + return realGroup.iterator(); + } + + @Override + public String getName() { + return realGroup.getName(); + } + + @Override + public String getDisplayName() { + return realGroup.getDisplayName(); + } + + @Override + public void setDisplayName(String displayName) { + realGroup.setDisplayName(displayName); + } + + @Override + public void addCounter(Counter counter) { + realGroup.addCounter(counter); + } + + @Override + public Counter addCounter(String name, String displayName, long value) { + return realGroup.addCounter(name, displayName, value); + } + + @Override + public Counter findCounter(String counterName, String displayName) { + return realGroup.findCounter(counterName, displayName); + } + + @Override + public Counter findCounter(String counterName, boolean create) { + return realGroup.findCounter(counterName, create); + } + + @Override + public Counter findCounter(String counterName) { + return realGroup.findCounter(counterName); + } + + @Override + public int size() { + return realGroup.size(); + } + + @Override + public void incrAllCounters(CounterGroupBase rightGroup) { + realGroup.incrAllCounters(rightGroup); + } + + @Override + public CounterGroupBase getUnderlyingGroup() { + return realGroup; + } + + @Override + public synchronized boolean equals(Object genericRight) { + if (genericRight instanceof CounterGroupBase) { + @SuppressWarnings("unchecked") + CounterGroupBase right = ((CounterGroupBase) + genericRight).getUnderlyingGroup(); + return Iterators.elementsEqual(iterator(), right.iterator()); + } + return false; + } + + @Override + public int hashCode() { + return realGroup.hashCode(); + } } // All the group impls need this for legacy group interface - static long getCounterValue(Group group, String counterName) { + static long getCounterValue(CounterGroupBase group, String counterName) { Counter counter = group.findCounter(counterName, false); if (counter != null) return counter.getValue(); return 0L; } // Mix the generic group implementation into the Group interface - private static class GenericGroup extends AbstractCounterGroup - implements Group { + private static class GenericGroup extends AbstractCounterGroup { GenericGroup(String name, String displayName, Limits limits) { super(name, displayName, limits); } - @Override - public long getCounter(String counterName) { - return getCounterValue(this, counterName); - } - - @Override - public String makeEscapedCompactString() { - return toEscapedCompactString(this); - } - - @Override - public Counter getCounter(int id, String name) { - return findCounter(name); - } - - @Override - public Counter getCounterForName(String name) { - return findCounter(name); - } - @Override protected Counter newCounter(String counterName, String displayName, long value) { - return new OldCounterImpl(counterName, displayName, value); + return new Counter(new GenericCounter(counterName, displayName, value)); } @Override protected Counter newCounter() { - return new OldCounterImpl(); + return new Counter(); + } + + @Override + public CounterGroupBase getUnderlyingGroup() { + return this; } } // Mix the framework group implementation into the Group interface private static class FrameworkGroupImpl> - extends FrameworkCounterGroup implements Group { - - // Mix the framework counter implmementation into the Counter interface - class FrameworkCounterImpl extends FrameworkCounter implements Counter { + extends FrameworkCounterGroup { + // Mix the framework counter implementation into the Counter interface + class FrameworkCounterImpl extends FrameworkCounter { FrameworkCounterImpl(T key) { super(key); } - @Override - public String makeEscapedCompactString() { - return toEscapedCompactString(this); - } - - @Override - public boolean contentEquals(Counter counter) { - return equals(counter); - } - - @Override - public long getCounter() { - return getValue(); - } } FrameworkGroupImpl(Class cls) { super(cls); } - @Override - public long getCounter(String counterName) { - return getCounterValue(this, counterName); - } - - @Override - public String makeEscapedCompactString() { - return toEscapedCompactString(this); - } - - @Override @Deprecated - public Counter getCounter(int id, String name) { - return findCounter(name); - } - - @Override - public Counter getCounterForName(String name) { - return findCounter(name); - } - @Override protected Counter newCounter(T key) { - return new FrameworkCounterImpl(key); + return new Counter(new FrameworkCounterImpl(key)); + } + + @Override + public CounterGroupBase getUnderlyingGroup() { + return this; } } // Mix the file system counter group implementation into the Group interface - private static class FSGroupImpl extends FileSystemCounterGroup - implements Group { + private static class FSGroupImpl extends FileSystemCounterGroup { - private class FSCounterImpl extends FSCounter implements Counter { + private class FSCounterImpl extends FSCounter { FSCounterImpl(String scheme, FileSystemCounter key) { super(scheme, key); } - @Override - public String makeEscapedCompactString() { - return toEscapedCompactString(this); - } - - @Override @Deprecated - public boolean contentEquals(Counter counter) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public long getCounter() { - return getValue(); - } - } @Override protected Counter newCounter(String scheme, FileSystemCounter key) { - return new FSCounterImpl(scheme, key); + return new Counter(new FSCounterImpl(scheme, key)); } @Override - public long getCounter(String counterName) { - return getCounterValue(this, counterName); + public CounterGroupBase getUnderlyingGroup() { + return this; } - - @Override - public String makeEscapedCompactString() { - return toEscapedCompactString(this); - } - - @Override @Deprecated - public Counter getCounter(int id, String name) { - return findCounter(name); - } - - @Override - public Counter getCounterForName(String name) { - return findCounter(name); - } - } public synchronized Counter findCounter(String group, String name) { @@ -342,7 +450,7 @@ static class GroupFactory extends CounterGroupFactory { FrameworkGroupFactory newFrameworkGroupFactory(final Class cls) { return new FrameworkGroupFactory() { @Override public Group newGroup(String name) { - return new FrameworkGroupImpl(cls); // impl in this package + return new Group(new FrameworkGroupImpl(cls)); // impl in this package } }; } @@ -350,12 +458,12 @@ FrameworkGroupFactory newFrameworkGroupFactory(final Class cls) { @Override protected Group newGenericGroup(String name, String displayName, Limits limits) { - return new GenericGroup(name, displayName, limits); + return new Group(new GenericGroup(name, displayName, limits)); } @Override protected Group newFileSystemGroup() { - return new FSGroupImpl(); + return new Group(new FSGroupImpl()); } } diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/Counter.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/Counter.java index b74bbf32325..651beaaf99f 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/Counter.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/Counter.java @@ -72,4 +72,10 @@ public interface Counter extends Writable { * @param incr the value to increase this counter by */ void increment(long incr); + + /** + * Return the underlying object if this is a facade. + * @return the undelying object. + */ + Counter getUnderlyingCounter(); } diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/Counters.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/Counters.java index 8f82523adf5..4422fad8b57 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/Counters.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/Counters.java @@ -52,6 +52,11 @@ private static class FrameworkGroupImpl> protected FrameworkCounter newCounter(T key) { return new FrameworkCounter(key); } + + @Override + public CounterGroupBase getUnderlyingGroup() { + return this; + } } // Mix generic group implementation into CounterGroup interface @@ -72,6 +77,11 @@ protected Counter newCounter(String name, String displayName, long value) { protected Counter newCounter() { return new GenericCounter(); } + + @Override + public CounterGroupBase getUnderlyingGroup() { + return this; + } } // Mix file system group implementation into the CounterGroup interface @@ -82,6 +92,11 @@ private static class FileSystemGroup extends FileSystemCounterGroup protected Counter newCounter(String scheme, FileSystemCounter key) { return new FSCounter(scheme, key); } + + @Override + public CounterGroupBase getUnderlyingGroup() { + return this; + } } /** diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/counters/AbstractCounters.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/counters/AbstractCounters.java index 0a6e3b75a51..7e15e6fcb51 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/counters/AbstractCounters.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/counters/AbstractCounters.java @@ -172,7 +172,8 @@ public synchronized C findCounter(Enum key) { @InterfaceAudience.Private public synchronized C findCounter(String scheme, FileSystemCounter key) { return ((FileSystemCounterGroup) getGroup( - FileSystemCounter.class.getName())).findCounter(scheme, key); + FileSystemCounter.class.getName()).getUnderlyingGroup()). + findCounter(scheme, key); } /** @@ -243,11 +244,11 @@ public synchronized void write(DataOutput out) throws IOException { WritableUtils.writeVInt(out, groupFactory.version()); WritableUtils.writeVInt(out, fgroups.size()); // framework groups first for (G group : fgroups.values()) { - if (group instanceof FrameworkCounterGroup) { + if (group.getUnderlyingGroup() instanceof FrameworkCounterGroup) { WritableUtils.writeVInt(out, GroupType.FRAMEWORK.ordinal()); WritableUtils.writeVInt(out, getFrameworkGroupId(group.getName())); group.write(out); - } else if (group instanceof FileSystemCounterGroup) { + } else if (group.getUnderlyingGroup() instanceof FileSystemCounterGroup) { WritableUtils.writeVInt(out, GroupType.FILESYSTEM.ordinal()); group.write(out); } diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/counters/CounterGroupBase.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/counters/CounterGroupBase.java index b8e746d0a0b..f6f19036006 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/counters/CounterGroupBase.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/counters/CounterGroupBase.java @@ -98,4 +98,10 @@ public interface CounterGroupBase * @param rightGroup the group to be added to this group */ void incrAllCounters(CounterGroupBase rightGroup); + + /** + * Exposes the underlying group type if a facade. + * @return the underlying object that this object is wrapping up. + */ + CounterGroupBase getUnderlyingGroup(); } diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/counters/FileSystemCounterGroup.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/counters/FileSystemCounterGroup.java index 7bc63a98831..91f5f499c3a 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/counters/FileSystemCounterGroup.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/counters/FileSystemCounterGroup.java @@ -110,6 +110,11 @@ public void write(DataOutput out) throws IOException { public void readFields(DataInput in) throws IOException { assert false : "shouldn't be called"; } + + @Override + public Counter getUnderlyingCounter() { + return this; + } } @Override @@ -231,10 +236,10 @@ public int size() { @Override @SuppressWarnings("unchecked") public void incrAllCounters(CounterGroupBase other) { - if (checkNotNull(other, "other group") + if (checkNotNull(other.getUnderlyingGroup(), "other group") instanceof FileSystemCounterGroup) { for (Counter counter : other) { - FSCounter c = (FSCounter) counter; + FSCounter c = (FSCounter) ((Counter)counter).getUnderlyingCounter(); findCounter(c.scheme, c.key) .increment(counter.getValue()); } } @@ -253,7 +258,7 @@ public void write(DataOutput out) throws IOException { for (Object counter : entry.getValue()) { if (counter == null) continue; @SuppressWarnings("unchecked") - FSCounter c = (FSCounter) counter; + FSCounter c = (FSCounter) ((Counter)counter).getUnderlyingCounter(); WritableUtils.writeVInt(out, c.key.ordinal()); // key WritableUtils.writeVLong(out, c.getValue()); // value } diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/counters/FrameworkCounterGroup.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/counters/FrameworkCounterGroup.java index f00982b1df7..5dcf31bc099 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/counters/FrameworkCounterGroup.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/counters/FrameworkCounterGroup.java @@ -18,21 +18,24 @@ package org.apache.hadoop.mapreduce.counters; +import static com.google.common.base.Preconditions.checkNotNull; + import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; import java.util.Arrays; import java.util.Iterator; -import static com.google.common.base.Preconditions.*; -import com.google.common.collect.AbstractIterator; -import com.google.common.collect.Iterators; - +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.io.WritableUtils; import org.apache.hadoop.mapreduce.Counter; import org.apache.hadoop.mapreduce.util.ResourceBundles; +import com.google.common.collect.AbstractIterator; +import com.google.common.collect.Iterators; + /** * An abstract class to provide common implementation for the framework * counter group in both mapred and mapreduce packages. @@ -43,7 +46,8 @@ @InterfaceAudience.Private public abstract class FrameworkCounterGroup, C extends Counter> implements CounterGroupBase { - + private static final Log LOG = LogFactory.getLog(FrameworkCounterGroup.class); + private final Class enumClass; // for Enum.valueOf private final Object[] counters; // local casts are OK and save a class ref private String displayName = null; @@ -95,6 +99,11 @@ public void write(DataOutput out) throws IOException { public void readFields(DataInput in) throws IOException { assert false : "shouldn't be called"; } + + @Override + public Counter getUnderlyingCounter() { + return this; + } } @SuppressWarnings("unchecked") diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/counters/GenericCounter.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/counters/GenericCounter.java index 716441795b0..635f3704eff 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/counters/GenericCounter.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/counters/GenericCounter.java @@ -25,6 +25,7 @@ import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.io.Text; import org.apache.hadoop.io.WritableUtils; +import org.apache.hadoop.mapreduce.Counter; /** * A generic counter implementation @@ -101,4 +102,9 @@ public synchronized void setValue(long value) { public synchronized void increment(long incr) { value += incr; } + + @Override + public Counter getUnderlyingCounter() { + return this; + } } diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapred/TestCounters.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapred/TestCounters.java index 9a93f6fa586..f494556bac3 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapred/TestCounters.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapred/TestCounters.java @@ -24,6 +24,8 @@ import java.util.Iterator; import java.util.Random; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.apache.hadoop.mapred.Counters.Counter; import org.apache.hadoop.mapred.Counters.Group; import org.apache.hadoop.mapreduce.FileSystemCounter; @@ -37,6 +39,7 @@ public class TestCounters { enum myCounters {TEST1, TEST2}; private static final long MAX_VALUE = 10; + private static final Log LOG = LogFactory.getLog(TestCounters.class); // Generates enum based counters private Counters getEnumCounters(Enum[] keys) { diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/TestJobCounters.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/TestJobCounters.java index 88b5fa295f5..d476ba98a4c 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/TestJobCounters.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/TestJobCounters.java @@ -18,6 +18,10 @@ package org.apache.hadoop.mapred; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import java.io.IOException; import java.util.ArrayList; import java.util.Formatter; @@ -25,11 +29,6 @@ import java.util.List; import java.util.StringTokenizer; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; - import org.apache.commons.lang.RandomStringUtils; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FSDataOutputStream; @@ -40,12 +39,14 @@ import org.apache.hadoop.io.Text; import org.apache.hadoop.io.Writable; import org.apache.hadoop.io.WritableComparable; -import org.apache.hadoop.mapreduce.Cluster; import org.apache.hadoop.mapreduce.Job; import org.apache.hadoop.mapreduce.TaskCounter; import org.apache.hadoop.mapreduce.TaskType; import org.apache.hadoop.mapreduce.lib.input.FileInputFormatCounter; import org.apache.hadoop.mapreduce.lib.output.FileOutputFormatCounter; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; /** * This is an wordcount application that tests the count of records