HBASE-16146 Remove thread local usage in Counter

This commit is contained in:
Gary Helmling 2016-09-21 17:43:41 -07:00
parent b47ded3b42
commit 4f29c23038
2 changed files with 1 additions and 21 deletions

View File

@ -108,25 +108,12 @@ public class Counter {
return h;
}
private static class IndexHolder {
int index = hash();
}
private final ThreadLocal<IndexHolder> indexHolderThreadLocal =
new ThreadLocal<IndexHolder>() {
@Override
protected IndexHolder initialValue() {
return new IndexHolder();
}
};
public void add(long delta) {
Container container = containerRef.get();
Cell[] cells = container.cells;
int mask = cells.length - 1;
IndexHolder indexHolder = indexHolderThreadLocal.get();
int baseIndex = indexHolder.index;
int baseIndex = hash();
if(cells[baseIndex & mask].add(delta)) {
return;
}
@ -139,8 +126,6 @@ public class Counter {
index++;
}
indexHolder.index = index;
if(index - baseIndex >= cells.length &&
cells.length < MAX_CELLS_LENGTH &&
container.demoted.compareAndSet(false, true)) {
@ -181,10 +166,6 @@ public class Counter {
return sum;
}
public void destroy() {
indexHolderThreadLocal.remove();
}
@Override
public String toString() {
Cell[] cells = containerRef.get().cells;

View File

@ -2011,7 +2011,6 @@ public class RpcServer implements RpcServerInterface, ConfigurationObserver {
LOG.trace(ignored);
}
}
rpcCount.destroy();
}
private UserGroupInformation createUser(ConnectionHeader head) {