MAPREDUCE-4138. Reduce memory usage of counters due to non-static nested classes.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1331023 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
cda16311a9
commit
1a118d6a32
|
@ -154,6 +154,9 @@ Release 2.0.0 - UNRELEASED
|
|||
MAPREDUCE-4093. Improve RM WebApp start up when proxy address is not set
|
||||
(Devaraj K vai bobby)
|
||||
|
||||
MAPREDUCE-4138. Reduce memory usage of counters due to non-static nested
|
||||
classes. (tomwhite)
|
||||
|
||||
OPTIMIZATIONS
|
||||
|
||||
BUG FIXES
|
||||
|
|
|
@ -387,21 +387,13 @@ public class Counters
|
|||
private static class FrameworkGroupImpl<T extends Enum<T>>
|
||||
extends FrameworkCounterGroup<T, Counter> {
|
||||
|
||||
// Mix the framework counter implementation into the Counter interface
|
||||
class FrameworkCounterImpl extends FrameworkCounter {
|
||||
FrameworkCounterImpl(T key) {
|
||||
super(key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
FrameworkGroupImpl(Class<T> cls) {
|
||||
super(cls);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Counter newCounter(T key) {
|
||||
return new Counter(new FrameworkCounterImpl(key));
|
||||
return new Counter(new FrameworkCounter<T>(key, getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -413,17 +405,9 @@ public class Counters
|
|||
// Mix the file system counter group implementation into the Group interface
|
||||
private static class FSGroupImpl extends FileSystemCounterGroup<Counter> {
|
||||
|
||||
private class FSCounterImpl extends FSCounter {
|
||||
|
||||
FSCounterImpl(String scheme, FileSystemCounter key) {
|
||||
super(scheme, key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Counter newCounter(String scheme, FileSystemCounter key) {
|
||||
return new Counter(new FSCounterImpl(scheme, key));
|
||||
return new Counter(new FSCounter(scheme, key));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -49,8 +49,8 @@ public class Counters extends AbstractCounters<Counter, CounterGroup> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected FrameworkCounter newCounter(T key) {
|
||||
return new FrameworkCounter(key);
|
||||
protected FrameworkCounter<T> newCounter(T key) {
|
||||
return new FrameworkCounter<T>(key, getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -61,7 +61,7 @@ public abstract class FileSystemCounterGroup<C extends Counter>
|
|||
private static final Joiner DISP_JOINER = Joiner.on(": ");
|
||||
|
||||
@InterfaceAudience.Private
|
||||
public class FSCounter extends AbstractCounter {
|
||||
public static class FSCounter extends AbstractCounter {
|
||||
final String scheme;
|
||||
final FileSystemCounter key;
|
||||
private long value;
|
||||
|
@ -139,8 +139,7 @@ public abstract class FileSystemCounterGroup<C extends Counter>
|
|||
@Override
|
||||
public void addCounter(C counter) {
|
||||
C ours;
|
||||
if (counter instanceof FileSystemCounterGroup<?>.FSCounter) {
|
||||
@SuppressWarnings("unchecked")
|
||||
if (counter instanceof FileSystemCounterGroup.FSCounter) {
|
||||
FSCounter c = (FSCounter) counter;
|
||||
ours = findCounter(c.scheme, c.key);
|
||||
}
|
||||
|
|
|
@ -57,12 +57,14 @@ public abstract class FrameworkCounterGroup<T extends Enum<T>,
|
|||
* Use old (which extends new) interface to make compatibility easier.
|
||||
*/
|
||||
@InterfaceAudience.Private
|
||||
public class FrameworkCounter extends AbstractCounter {
|
||||
public static class FrameworkCounter<T extends Enum<T>> extends AbstractCounter {
|
||||
final T key;
|
||||
final String groupName;
|
||||
private long value;
|
||||
|
||||
public FrameworkCounter(T ref) {
|
||||
public FrameworkCounter(T ref, String groupName) {
|
||||
key = ref;
|
||||
this.groupName = groupName;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -72,7 +74,7 @@ public abstract class FrameworkCounterGroup<T extends Enum<T>,
|
|||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return localizeCounterName(getName());
|
||||
return ResourceBundles.getCounterName(groupName, getName(), getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -131,10 +133,6 @@ public abstract class FrameworkCounterGroup<T extends Enum<T>,
|
|||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
private String localizeCounterName(String counterName) {
|
||||
return ResourceBundles.getCounterName(getName(), counterName, counterName);
|
||||
}
|
||||
|
||||
private T valueOf(String name) {
|
||||
return Enum.valueOf(enumClass, name);
|
||||
}
|
||||
|
@ -204,7 +202,7 @@ public abstract class FrameworkCounterGroup<T extends Enum<T>,
|
|||
if (checkNotNull(other, "other counter group")
|
||||
instanceof FrameworkCounterGroup<?, ?>) {
|
||||
for (Counter counter : other) {
|
||||
findCounter(((FrameworkCounter) counter).key)
|
||||
findCounter(((FrameworkCounter) counter).key.name())
|
||||
.increment(counter.getValue());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue