@InterfaceAudience.Private public class MetaTableLocator extends 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.Modifier and Type | Field and Description |
---|---|
private static org.apache.commons.logging.Log |
LOG |
private boolean |
stopped |
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.
|
List<ServerName> |
blockUntilAvailable(ZooKeeperWatcher zkw,
long timeout,
org.apache.hadoop.conf.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) |
private static org.apache.hadoop.hbase.protobuf.generated.AdminProtos.AdminService.BlockingInterface |
getCachedConnection(HConnection hConnection,
ServerName sn) |
private List<HRegionInfo> |
getListOfHRegionInfos(List<Pair<HRegionInfo,ServerName>> pairs) |
ServerName |
getMetaRegionLocation(ZooKeeperWatcher zkw)
Gets the meta region location, if available.
|
ServerName |
getMetaRegionLocation(ZooKeeperWatcher zkw,
int replicaId)
Gets the meta region location, if available.
|
List<HRegionInfo> |
getMetaRegions(ZooKeeperWatcher zkw) |
List<HRegionInfo> |
getMetaRegions(ZooKeeperWatcher zkw,
int replicaId) |
List<Pair<HRegionInfo,ServerName>> |
getMetaRegionsAndLocations(ZooKeeperWatcher zkw) |
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.
|
private org.apache.hadoop.hbase.protobuf.generated.AdminProtos.AdminService.BlockingInterface |
getMetaServerConnection(HConnection hConnection,
ZooKeeperWatcher zkw,
long timeout,
int replicaId)
Gets a connection to the server hosting meta, as reported by ZooKeeper,
waiting up to the specified timeout for availability.
|
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. |
private boolean |
verifyRegionLocation(Connection connection,
org.apache.hadoop.hbase.protobuf.generated.AdminProtos.AdminService.BlockingInterface hostingServer,
ServerName address,
byte[] regionName)
Verify we can connect to
hostingServer and that its carrying
regionName . |
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.
|
private static final org.apache.commons.logging.Log LOG
private volatile boolean stopped
public boolean isLocationAvailable(ZooKeeperWatcher zkw)
public List<Pair<HRegionInfo,ServerName>> getMetaRegionsAndLocations(ZooKeeperWatcher zkw)
zkw
- ZooKeeper watcher to be usedpublic List<Pair<HRegionInfo,ServerName>> getMetaRegionsAndLocations(ZooKeeperWatcher zkw, int replicaId)
zkw
- replicaId
- public List<HRegionInfo> getMetaRegions(ZooKeeperWatcher zkw)
zkw
- ZooKeeper watcher to be usedpublic List<HRegionInfo> getMetaRegions(ZooKeeperWatcher zkw, int replicaId)
zkw
- replicaId
- private List<HRegionInfo> getListOfHRegionInfos(List<Pair<HRegionInfo,ServerName>> pairs)
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 InterruptedException, NotAllMetaRegionsOnlineException
zkw
- timeout
- maximum time to wait, in millisServerName
, or null if none availableInterruptedException
- if interrupted while waitingNotAllMetaRegionsOnlineException
public ServerName waitMetaRegionLocation(ZooKeeperWatcher zkw, int replicaId, long timeout) throws InterruptedException, NotAllMetaRegionsOnlineException
zkw
- replicaId
- timeout
- maximum time to wait, in millisServerName
, or null if none availableInterruptedException
NotAllMetaRegionsOnlineException
public void waitMetaRegionLocation(ZooKeeperWatcher zkw) throws InterruptedException
hbase:meta
. Used during
cluster startup. Does not verify meta, just that something has been
set up in zk.InterruptedException
- if interrupted while waitingwaitMetaRegionLocation(org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher, long)
public boolean verifyMetaRegionLocation(HConnection hConnection, ZooKeeperWatcher zkw, long timeout) throws InterruptedException, 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.IOException
InterruptedException
public boolean verifyMetaRegionLocation(HConnection hConnection, ZooKeeperWatcher zkw, long timeout, int replicaId) throws InterruptedException, 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.InterruptedException
IOException
private boolean verifyRegionLocation(Connection connection, org.apache.hadoop.hbase.protobuf.generated.AdminProtos.AdminService.BlockingInterface hostingServer, ServerName address, byte[] regionName) throws IOException
hostingServer
and that its carrying
regionName
.hostingServer
- Interface to the server hosting regionName
address
- The servername that goes with the metaServer
Interface. Used logging.regionName
- The regionname we are interested in.IOException
private org.apache.hadoop.hbase.protobuf.generated.AdminProtos.AdminService.BlockingInterface getMetaServerConnection(HConnection hConnection, ZooKeeperWatcher zkw, long timeout, int replicaId) throws InterruptedException, NotAllMetaRegionsOnlineException, IOException
WARNING: Does not retry. Use an HTable
instead.
hConnection
- zkw
- timeout
- How long to wait on meta locationreplicaId
- InterruptedException
NotAllMetaRegionsOnlineException
- if timed out waitingIOException
private static org.apache.hadoop.hbase.protobuf.generated.AdminProtos.AdminService.BlockingInterface getCachedConnection(HConnection hConnection, ServerName sn) throws IOException
sn
- ServerName to get a connection against.sn
May have come from cache, may not be good, may have been setup by this
invocation, or may be null.IOException
public static void setMetaLocation(ZooKeeperWatcher zookeeper, ServerName serverName, RegionState.State state) throws org.apache.zookeeper.KeeperException
hbase:meta
in ZooKeeper to the
specified server address.zookeeper
- zookeeper referenceserverName
- The server hosting hbase:meta
state
- The region transition stateorg.apache.zookeeper.KeeperException
- unexpected zookeeper exceptionpublic static void setMetaLocation(ZooKeeperWatcher zookeeper, ServerName serverName, int replicaId, RegionState.State state) throws org.apache.zookeeper.KeeperException
hbase:meta
in ZooKeeper to the
specified server address.zookeeper
- serverName
- replicaId
- state
- org.apache.zookeeper.KeeperException
public static RegionState getMetaRegionState(ZooKeeperWatcher zkw) throws org.apache.zookeeper.KeeperException
org.apache.zookeeper.KeeperException
public static RegionState getMetaRegionState(ZooKeeperWatcher zkw, int replicaId) throws org.apache.zookeeper.KeeperException
zkw
- replicaId
- org.apache.zookeeper.KeeperException
public void deleteMetaLocation(ZooKeeperWatcher zookeeper) throws org.apache.zookeeper.KeeperException
hbase:meta
in ZooKeeper.zookeeper
- zookeeper referenceorg.apache.zookeeper.KeeperException
- unexpected zookeeper exceptionpublic void deleteMetaLocation(ZooKeeperWatcher zookeeper, int replicaId) throws org.apache.zookeeper.KeeperException
org.apache.zookeeper.KeeperException
public List<ServerName> blockUntilAvailable(ZooKeeperWatcher zkw, long timeout, org.apache.hadoop.conf.Configuration conf) throws InterruptedException
zkw
- timeout
- conf
- InterruptedException
public ServerName blockUntilAvailable(ZooKeeperWatcher zkw, long timeout) throws InterruptedException
zkw
- zookeeper connection to usetimeout
- maximum time to wait, in millisInterruptedException
public ServerName blockUntilAvailable(ZooKeeperWatcher zkw, int replicaId, long timeout) throws InterruptedException
zkw
- replicaId
- timeout
- InterruptedException
public void stop()
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.