@InterfaceAudience.Private public class RegionSizeStoreImpl extends Object implements RegionSizeStore
RegionSizeStore
implementation backed by a ConcurrentHashMap. We expected similar
amounts of reads and writes to the "store", so using a RWLock is not going to provide any
exceptional gains.Modifier and Type | Field and Description |
---|---|
private static org.slf4j.Logger |
LOG |
private static long |
sizeOfEntry |
private ConcurrentHashMap<RegionInfo,RegionSize> |
store |
Constructor and Description |
---|
RegionSizeStoreImpl() |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes all entries from the store.
|
RegionSize |
getRegionSize(RegionInfo regionInfo)
Returns the size for the give region if one exists.
|
long |
heapSize() |
void |
incrementRegionSize(RegionInfo regionInfo,
long delta)
Atomically alter the size of a region.
|
boolean |
isEmpty()
Returns if the store is empty.
|
Iterator<Map.Entry<RegionInfo,RegionSize>> |
iterator() |
void |
put(RegionInfo regionInfo,
long size)
Atomically sets the given
size for a region. |
RegionSize |
remove(RegionInfo regionInfo)
Removes the mapping for the given key, returning the value if one exists in the store.
|
int |
size()
Returns the number of entries in the store.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
private static final org.slf4j.Logger LOG
private static final long sizeOfEntry
private final ConcurrentHashMap<RegionInfo,RegionSize> store
public RegionSizeStoreImpl()
public Iterator<Map.Entry<RegionInfo,RegionSize>> iterator()
iterator
in interface Iterable<Map.Entry<RegionInfo,RegionSize>>
public RegionSize getRegionSize(RegionInfo regionInfo)
RegionSizeStore
null
is
returned.getRegionSize
in interface RegionSizeStore
regionInfo
- The region whose size is being fetched.public void put(RegionInfo regionInfo, long size)
RegionSizeStore
size
for a region.put
in interface RegionSizeStore
regionInfo
- An identifier for a region.size
- The size in bytes of the region.public void incrementRegionSize(RegionInfo regionInfo, long delta)
RegionSizeStore
incrementRegionSize
in interface RegionSizeStore
regionInfo
- The region to update.delta
- The change in size for the region, positive or negative.public RegionSize remove(RegionInfo regionInfo)
RegionSizeStore
remove
in interface RegionSizeStore
regionInfo
- The key to remove from the storepublic long heapSize()
public int size()
RegionSizeStore
size
in interface RegionSizeStore
public boolean isEmpty()
RegionSizeStore
isEmpty
in interface RegionSizeStore
public void clear()
RegionSizeStore
clear
in interface RegionSizeStore
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.