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