HDFS-15907. Reduce Memory Overhead of AclFeature by avoiding AtomicInteger. Contributed by Stephen O'Donnell.
This commit is contained in:
parent
174f3a96b1
commit
569e407f64
|
@ -19,7 +19,6 @@
|
||||||
package org.apache.hadoop.hdfs.server.namenode;
|
package org.apache.hadoop.hdfs.server.namenode;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
|
|
||||||
import org.apache.hadoop.classification.InterfaceAudience;
|
import org.apache.hadoop.classification.InterfaceAudience;
|
||||||
import org.apache.hadoop.fs.permission.AclEntry;
|
import org.apache.hadoop.fs.permission.AclEntry;
|
||||||
|
@ -35,7 +34,7 @@ import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableList;
|
||||||
public class AclFeature implements INode.Feature, ReferenceCounter {
|
public class AclFeature implements INode.Feature, ReferenceCounter {
|
||||||
public static final ImmutableList<AclEntry> EMPTY_ENTRY_LIST =
|
public static final ImmutableList<AclEntry> EMPTY_ENTRY_LIST =
|
||||||
ImmutableList.of();
|
ImmutableList.of();
|
||||||
private AtomicInteger value = new AtomicInteger();
|
private int refCount = 0;
|
||||||
|
|
||||||
private final int [] entries;
|
private final int [] entries;
|
||||||
|
|
||||||
|
@ -84,17 +83,17 @@ public class AclFeature implements INode.Feature, ReferenceCounter {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRefCount() {
|
public synchronized int getRefCount() {
|
||||||
return value.get();
|
return refCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int incrementAndGetRefCount() {
|
public synchronized int incrementAndGetRefCount() {
|
||||||
return value.incrementAndGet();
|
return ++refCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int decrementAndGetRefCount() {
|
public synchronized int decrementAndGetRefCount() {
|
||||||
return value.updateAndGet(i -> i > 0 ? i - 1 : i);
|
return (refCount > 0) ? --refCount : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue