@InterfaceAudience.Private public class MetaTableLocator extends java.lang.Object
RegionServerServices.
This class doesn't use ZK watchers, rather accesses ZK directly.
This class it stateless. The only reason it's not made a non-instantiable util class
with a collection of static methods is that it'd be rather hard to mock properly in tests.
TODO: rewrite using RPC calls to master to find out about hbase:meta.| Constructor and Description |
|---|
MetaTableLocator() |
| Modifier and Type | Method and Description |
|---|---|
ServerName |
blockUntilAvailable(ZooKeeperWatcher zkw,
int replicaId,
long timeout)
Wait until the meta region is available and is not in transition.
|
ServerName |
blockUntilAvailable(ZooKeeperWatcher zkw,
long timeout)
Wait until the meta region is available and is not in transition.
|
java.util.List<ServerName> |
blockUntilAvailable(ZooKeeperWatcher zkw,
long timeout,
Configuration conf)
Wait until the primary meta region is available.
|
void |
deleteMetaLocation(ZooKeeperWatcher zookeeper)
Deletes the location of
hbase:meta in ZooKeeper. |
void |
deleteMetaLocation(ZooKeeperWatcher zookeeper,
int replicaId) |
ServerName |
getMetaRegionLocation(ZooKeeperWatcher zkw)
Gets the meta region location, if available.
|
ServerName |
getMetaRegionLocation(ZooKeeperWatcher zkw,
int replicaId)
Gets the meta region location, if available.
|
java.util.List<HRegionInfo> |
getMetaRegions(ZooKeeperWatcher zkw) |
java.util.List<HRegionInfo> |
getMetaRegions(ZooKeeperWatcher zkw,
int replicaId) |
java.util.List<Pair<HRegionInfo,ServerName>> |
getMetaRegionsAndLocations(ZooKeeperWatcher zkw) |
java.util.List<Pair<HRegionInfo,ServerName>> |
getMetaRegionsAndLocations(ZooKeeperWatcher zkw,
int replicaId) |
static RegionState |
getMetaRegionState(ZooKeeperWatcher zkw)
Load the meta region state from the meta server ZNode.
|
static RegionState |
getMetaRegionState(ZooKeeperWatcher zkw,
int replicaId)
Load the meta region state from the meta server ZNode.
|
boolean |
isLocationAvailable(ZooKeeperWatcher zkw)
Checks if the meta region location is available.
|
static void |
setMetaLocation(ZooKeeperWatcher zookeeper,
ServerName serverName,
int replicaId,
RegionState.State state)
Sets the location of
hbase:meta in ZooKeeper to the
specified server address. |
static void |
setMetaLocation(ZooKeeperWatcher zookeeper,
ServerName serverName,
RegionState.State state)
Sets the location of
hbase:meta in ZooKeeper to the
specified server address. |
void |
stop()
Stop working.
|
boolean |
verifyMetaRegionLocation(HConnection hConnection,
ZooKeeperWatcher zkw,
long timeout)
Verify
hbase:meta is deployed and accessible. |
boolean |
verifyMetaRegionLocation(HConnection hConnection,
ZooKeeperWatcher zkw,
long timeout,
int replicaId)
Verify
hbase:meta is deployed and accessible. |
void |
waitMetaRegionLocation(ZooKeeperWatcher zkw)
Waits indefinitely for availability of
hbase:meta. |
ServerName |
waitMetaRegionLocation(ZooKeeperWatcher zkw,
int replicaId,
long timeout)
Gets the meta region location, if available, and waits for up to the
specified timeout if not immediately available.
|
ServerName |
waitMetaRegionLocation(ZooKeeperWatcher zkw,
long timeout)
Gets the meta region location, if available, and waits for up to the
specified timeout if not immediately available.
|
public boolean isLocationAvailable(ZooKeeperWatcher zkw)
public java.util.List<Pair<HRegionInfo,ServerName>> getMetaRegionsAndLocations(ZooKeeperWatcher zkw)
zkw - ZooKeeper watcher to be usedpublic java.util.List<Pair<HRegionInfo,ServerName>> getMetaRegionsAndLocations(ZooKeeperWatcher zkw, int replicaId)
zkw - replicaId - public java.util.List<HRegionInfo> getMetaRegions(ZooKeeperWatcher zkw)
zkw - ZooKeeper watcher to be usedpublic java.util.List<HRegionInfo> getMetaRegions(ZooKeeperWatcher zkw, int replicaId)
zkw - replicaId - public ServerName getMetaRegionLocation(ZooKeeperWatcher zkw)
zkw - zookeeper connection to usepublic ServerName getMetaRegionLocation(ZooKeeperWatcher zkw, int replicaId)
zkw - replicaId - public ServerName waitMetaRegionLocation(ZooKeeperWatcher zkw, long timeout) throws java.lang.InterruptedException, NotAllMetaRegionsOnlineException
zkw - timeout - maximum time to wait, in millisServerName, or null if none availablejava.lang.InterruptedException - if interrupted while waitingNotAllMetaRegionsOnlineExceptionpublic ServerName waitMetaRegionLocation(ZooKeeperWatcher zkw, int replicaId, long timeout) throws java.lang.InterruptedException, NotAllMetaRegionsOnlineException
zkw - replicaId - timeout - maximum time to wait, in millisServerName, or null if none availablejava.lang.InterruptedExceptionNotAllMetaRegionsOnlineExceptionpublic void waitMetaRegionLocation(ZooKeeperWatcher zkw) throws java.lang.InterruptedException
hbase:meta. Used during
cluster startup. Does not verify meta, just that something has been
set up in zk.java.lang.InterruptedException - if interrupted while waitingwaitMetaRegionLocation(org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher, long)public boolean verifyMetaRegionLocation(HConnection hConnection, ZooKeeperWatcher zkw, long timeout) throws java.lang.InterruptedException, java.io.IOException
hbase:meta is deployed and accessible.hConnection - zkw - timeout - How long to wait on zk for meta address (passed through to
the internal call to getMetaServerConnection(org.apache.hadoop.hbase.client.HConnection, org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher, long, int).hbase:meta location is healthy.java.io.IOExceptionjava.lang.InterruptedExceptionpublic boolean verifyMetaRegionLocation(HConnection hConnection, ZooKeeperWatcher zkw, long timeout, int replicaId) throws java.lang.InterruptedException, java.io.IOException
hbase:meta is deployed and accessible.hConnection - zkw - timeout - How long to wait on zk for meta address (passed through toreplicaId - hbase:meta location is healthy.java.lang.InterruptedExceptionjava.io.IOExceptionpublic static void setMetaLocation(ZooKeeperWatcher zookeeper, ServerName serverName, RegionState.State state) throws KeeperException
hbase:meta in ZooKeeper to the
specified server address.zookeeper - zookeeper referenceserverName - The server hosting hbase:metastate - The region transition stateKeeperException - unexpected zookeeper exceptionpublic static void setMetaLocation(ZooKeeperWatcher zookeeper, ServerName serverName, int replicaId, RegionState.State state) throws KeeperException
hbase:meta in ZooKeeper to the
specified server address.zookeeper - serverName - replicaId - state - KeeperExceptionpublic static RegionState getMetaRegionState(ZooKeeperWatcher zkw) throws KeeperException
KeeperExceptionpublic static RegionState getMetaRegionState(ZooKeeperWatcher zkw, int replicaId) throws KeeperException
zkw - replicaId - KeeperExceptionpublic void deleteMetaLocation(ZooKeeperWatcher zookeeper) throws KeeperException
hbase:meta in ZooKeeper.zookeeper - zookeeper referenceKeeperException - unexpected zookeeper exceptionpublic void deleteMetaLocation(ZooKeeperWatcher zookeeper, int replicaId) throws KeeperException
KeeperExceptionpublic java.util.List<ServerName> blockUntilAvailable(ZooKeeperWatcher zkw, long timeout, Configuration conf) throws java.lang.InterruptedException
zkw - timeout - conf - java.lang.InterruptedExceptionpublic ServerName blockUntilAvailable(ZooKeeperWatcher zkw, long timeout) throws java.lang.InterruptedException
zkw - zookeeper connection to usetimeout - maximum time to wait, in millisjava.lang.InterruptedExceptionpublic ServerName blockUntilAvailable(ZooKeeperWatcher zkw, int replicaId, long timeout) throws java.lang.InterruptedException
zkw - replicaId - timeout - java.lang.InterruptedExceptionpublic void stop()