@InterfaceAudience.Private public class MetaRegionLocationCache extends ZKListener
Modifier and Type | Class and Description |
---|---|
private static class |
MetaRegionLocationCache.ZNodeOpType |
Modifier and Type | Field and Description |
---|---|
private CopyOnWriteArrayMap<Integer,HRegionLocation> |
cachedMetaLocations
Cached meta region locations indexed by replica ID.
|
private static org.slf4j.Logger |
LOG |
private static int |
MAX_ZK_META_FETCH_RETRIES
Maximum number of times we retry when ZK operation times out.
|
private RetryCounterFactory |
retryCounterFactory |
private static int |
SLEEP_INTERVAL_MS_BETWEEN_RETRIES
Sleep interval ms between ZK operation retries.
|
private static int |
SLEEP_INTERVAL_MS_MAX |
watcher
Constructor and Description |
---|
MetaRegionLocationCache(ZKWatcher zkWatcher) |
Modifier and Type | Method and Description |
---|---|
private HRegionLocation |
getMetaRegionLocation(int replicaId)
Gets the HRegionLocation for a given meta replica ID.
|
Optional<List<HRegionLocation>> |
getMetaRegionLocations()
Returns Optional list of HRegionLocations for meta replica(s), null if the cache is empty.
|
private boolean |
isValidMetaPath(String path)
Helper to check if the given 'path' corresponds to a meta znode.
|
private void |
loadMetaLocationsFromZk(RetryCounter retryCounter,
MetaRegionLocationCache.ZNodeOpType opType)
Populates the current snapshot of meta locations from ZK.
|
void |
nodeChildrenChanged(String path)
Called when an existing node has a child node added or removed.
|
void |
nodeCreated(String path)
Called when a new node has been created.
|
void |
nodeDataChanged(String path)
Called when an existing node has changed data.
|
void |
nodeDeleted(String path)
Called when a node has been deleted
|
private void |
updateMetaLocation(String path,
MetaRegionLocationCache.ZNodeOpType opType) |
getWatcher
private static final org.slf4j.Logger LOG
private static final int MAX_ZK_META_FETCH_RETRIES
private static final int SLEEP_INTERVAL_MS_BETWEEN_RETRIES
private static final int SLEEP_INTERVAL_MS_MAX
private final RetryCounterFactory retryCounterFactory
private final CopyOnWriteArrayMap<Integer,HRegionLocation> cachedMetaLocations
public MetaRegionLocationCache(ZKWatcher zkWatcher)
private void loadMetaLocationsFromZk(RetryCounter retryCounter, MetaRegionLocationCache.ZNodeOpType opType)
retryCounter
- controls the number of retries and sleep between retries.private HRegionLocation getMetaRegionLocation(int replicaId) throws org.apache.zookeeper.KeeperException
replicaId
- ReplicaID of the region.org.apache.zookeeper.KeeperException
- if there is any issue fetching/parsing the serialized data.private void updateMetaLocation(String path, MetaRegionLocationCache.ZNodeOpType opType)
public Optional<List<HRegionLocation>> getMetaRegionLocations()
private boolean isValidMetaPath(String path)
public void nodeCreated(String path)
ZKListener
nodeCreated
in class ZKListener
path
- full path of the new nodepublic void nodeDeleted(String path)
ZKListener
nodeDeleted
in class ZKListener
path
- full path of the deleted nodepublic void nodeDataChanged(String path)
ZKListener
nodeDataChanged
in class ZKListener
path
- full path of the updated nodepublic void nodeChildrenChanged(String path)
ZKListener
nodeChildrenChanged
in class ZKListener
path
- full path of the node whose children have changedCopyright © 2007–2020 The Apache Software Foundation. All rights reserved.