@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.slf4j.Logger | LOG | 
| private boolean | stopped | 
| Constructor and Description | 
|---|
| MetaTableLocator() | 
| Modifier and Type | Method and Description | 
|---|---|
| ServerName | blockUntilAvailable(ZKWatcher zkw,
                   int replicaId,
                   long timeout)Wait until the meta region is available and is not in transition. | 
| ServerName | blockUntilAvailable(ZKWatcher zkw,
                   long timeout)Wait until the meta region is available and is not in transition. | 
| List<ServerName> | blockUntilAvailable(ZKWatcher zkw,
                   long timeout,
                   org.apache.hadoop.conf.Configuration conf)Wait until the primary meta region is available. | 
| void | deleteMetaLocation(ZKWatcher zookeeper)Deletes the location of  hbase:metain ZooKeeper. | 
| void | deleteMetaLocation(ZKWatcher zookeeper,
                  int replicaId) | 
| private static org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.AdminService.BlockingInterface | getCachedConnection(ClusterConnection connection,
                   ServerName sn) | 
| private List<RegionInfo> | getListOfRegionInfos(List<Pair<RegionInfo,ServerName>> pairs) | 
| ServerName | getMetaRegionLocation(ZKWatcher zkw)Gets the meta region location, if available. | 
| ServerName | getMetaRegionLocation(ZKWatcher zkw,
                     int replicaId)Gets the meta region location, if available. | 
| List<RegionInfo> | getMetaRegions(ZKWatcher zkw)Gets the meta regions for the given path with the default replica ID. | 
| List<RegionInfo> | getMetaRegions(ZKWatcher zkw,
              int replicaId)Gets the meta regions for the given path and replica ID. | 
| List<Pair<RegionInfo,ServerName>> | getMetaRegionsAndLocations(ZKWatcher zkw) | 
| List<Pair<RegionInfo,ServerName>> | getMetaRegionsAndLocations(ZKWatcher zkw,
                          int replicaId)Gets the meta regions and their locations for the given path and replica ID. | 
| static RegionState | getMetaRegionState(ZKWatcher zkw)Load the meta region state from the meta server ZNode. | 
| static RegionState | getMetaRegionState(ZKWatcher zkw,
                  int replicaId)Load the meta region state from the meta server ZNode. | 
| private org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.AdminService.BlockingInterface | getMetaServerConnection(ClusterConnection connection,
                       ZKWatcher 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(ZKWatcher zkw)Checks if the meta region location is available. | 
| static void | setMetaLocation(ZKWatcher zookeeper,
               ServerName serverName,
               int replicaId,
               RegionState.State state)Sets the location of  hbase:metain ZooKeeper to the specified server address. | 
| static void | setMetaLocation(ZKWatcher zookeeper,
               ServerName serverName,
               RegionState.State state)Sets the location of  hbase:metain ZooKeeper to the
 specified server address. | 
| void | stop()Stop working. | 
| boolean | verifyMetaRegionLocation(ClusterConnection hConnection,
                        ZKWatcher zkw,
                        long timeout)Verify  hbase:metais deployed and accessible. | 
| boolean | verifyMetaRegionLocation(ClusterConnection connection,
                        ZKWatcher zkw,
                        long timeout,
                        int replicaId)Verify  hbase:metais deployed and accessible. | 
| private boolean | verifyRegionLocation(ClusterConnection connection,
                    org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.AdminService.BlockingInterface hostingServer,
                    ServerName address,
                    byte[] regionName)Verify we can connect to  hostingServerand that its carryingregionName. | 
| void | waitMetaRegionLocation(ZKWatcher zkw)Waits indefinitely for availability of  hbase:meta. | 
| ServerName | waitMetaRegionLocation(ZKWatcher 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(ZKWatcher zkw,
                      long timeout)Gets the meta region location, if available, and waits for up to the
 specified timeout if not immediately available. | 
public MetaTableLocator()
public boolean isLocationAvailable(ZKWatcher zkw)
public List<Pair<RegionInfo,ServerName>> getMetaRegionsAndLocations(ZKWatcher zkw)
zkw - ZooKeeper watcher to be usedpublic List<Pair<RegionInfo,ServerName>> getMetaRegionsAndLocations(ZKWatcher zkw, int replicaId)
zkw - reference to the ZKWatcher which also contains configuration and operationreplicaId - the ID of the replicapublic List<RegionInfo> getMetaRegions(ZKWatcher zkw)
zkw - ZooKeeper watcher to be usedpublic List<RegionInfo> getMetaRegions(ZKWatcher zkw, int replicaId)
zkw - reference to the ZKWatcher which also contains configuration and operationreplicaId - the ID of the replicaprivate List<RegionInfo> getListOfRegionInfos(List<Pair<RegionInfo,ServerName>> pairs)
public ServerName getMetaRegionLocation(ZKWatcher zkw)
zkw - zookeeper connection to usepublic ServerName getMetaRegionLocation(ZKWatcher zkw, int replicaId)
zkw - reference to the ZKWatcher which also contains configuration and operationreplicaId - the ID of the replicapublic ServerName waitMetaRegionLocation(ZKWatcher zkw, long timeout) throws InterruptedException, NotAllMetaRegionsOnlineException
zkw - reference to the ZKWatcher which also contains configuration and operationtimeout - maximum time to wait, in millisServerName, or null if none availableInterruptedException - if interrupted while waitingNotAllMetaRegionsOnlineException - if a meta or root region is not onlinepublic ServerName waitMetaRegionLocation(ZKWatcher zkw, int replicaId, long timeout) throws InterruptedException, NotAllMetaRegionsOnlineException
zkw - reference to the ZKWatcher which also contains configuration and operationreplicaId - the ID of the replicatimeout - maximum time to wait, in millisServerName, or null if none availableInterruptedException - if waiting for the socket operation failsNotAllMetaRegionsOnlineException - if a meta or root region is not onlinepublic void waitMetaRegionLocation(ZKWatcher 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(ZKWatcher, long)public boolean verifyMetaRegionLocation(ClusterConnection hConnection, ZKWatcher zkw, long timeout) throws InterruptedException, IOException
hbase:meta is deployed and accessible.hConnection - the connection to usezkw - reference to the ZKWatcher which also contains configuration and operationtimeout - How long to wait on zk for meta address (passed through to
                the internal call to getMetaServerConnection(org.apache.hadoop.hbase.client.ClusterConnection, org.apache.hadoop.hbase.zookeeper.ZKWatcher, long, int).hbase:meta location is healthy.IOException - if the number of retries for getting the connection is exceededInterruptedException - if waiting for the socket operation failspublic boolean verifyMetaRegionLocation(ClusterConnection connection, ZKWatcher zkw, long timeout, int replicaId) throws InterruptedException, IOException
hbase:meta is deployed and accessible.connection - the connection to usezkw - reference to the ZKWatcher which also contains configuration and operationtimeout - How long to wait on zk for meta address (passed through toreplicaId - the ID of the replicahbase:meta location is healthy.InterruptedException - if waiting for the socket operation failsIOException - if the number of retries for getting the connection is exceededprivate boolean verifyRegionLocation(ClusterConnection connection, org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.AdminService.BlockingInterface hostingServer, ServerName address, byte[] regionName)
hostingServer and that its carrying
 regionName.hostingServer - Interface to the server hosting regionNameaddress - The servername that goes with the metaServer interface.
                Used logging.regionName - The regionname we are interested in.private org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.AdminService.BlockingInterface getMetaServerConnection(ClusterConnection connection, ZKWatcher zkw, long timeout, int replicaId) throws InterruptedException, IOException
WARNING: Does not retry.  Use an HTable instead.
connection - the connection to usezkw - reference to the ZKWatcher which also contains configuration and operationtimeout - How long to wait on meta locationreplicaId - the ID of the replicaInterruptedException - if waiting for the socket operation failsIOException - if the number of retries for getting the connection is exceededprivate static org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.AdminService.BlockingInterface getCachedConnection(ClusterConnection connection, 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 - if the number of retries for getting the connection is exceededpublic static void setMetaLocation(ZKWatcher 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:metastate - The region transition stateorg.apache.zookeeper.KeeperException - unexpected zookeeper exceptionpublic static void setMetaLocation(ZKWatcher zookeeper, ServerName serverName, int replicaId, RegionState.State state) throws org.apache.zookeeper.KeeperException
hbase:meta in ZooKeeper to the specified server address.zookeeper - reference to the ZKWatcher which also contains configuration and
                  operationserverName - the name of the serverreplicaId - the ID of the replicastate - the state of the regionorg.apache.zookeeper.KeeperException - if a ZooKeeper operation failspublic static RegionState getMetaRegionState(ZKWatcher zkw) throws org.apache.zookeeper.KeeperException
org.apache.zookeeper.KeeperExceptionpublic static RegionState getMetaRegionState(ZKWatcher zkw, int replicaId) throws org.apache.zookeeper.KeeperException
zkw - reference to the ZKWatcher which also contains configuration and operationreplicaId - the ID of the replicaorg.apache.zookeeper.KeeperException - if a ZooKeeper operation failspublic void deleteMetaLocation(ZKWatcher zookeeper) throws org.apache.zookeeper.KeeperException
hbase:meta in ZooKeeper.zookeeper - zookeeper referenceorg.apache.zookeeper.KeeperException - unexpected zookeeper exceptionpublic void deleteMetaLocation(ZKWatcher zookeeper, int replicaId) throws org.apache.zookeeper.KeeperException
org.apache.zookeeper.KeeperExceptionpublic List<ServerName> blockUntilAvailable(ZKWatcher zkw, long timeout, org.apache.hadoop.conf.Configuration conf) throws InterruptedException
zkw - reference to the ZKWatcher which also contains configuration and operationtimeout - maximum time to wait in millisconf - the Configuration to useInterruptedException - if waiting for the socket operation failspublic ServerName blockUntilAvailable(ZKWatcher zkw, long timeout) throws InterruptedException
zkw - zookeeper connection to usetimeout - maximum time to wait, in millisInterruptedException - if waiting for the socket operation failspublic ServerName blockUntilAvailable(ZKWatcher zkw, int replicaId, long timeout) throws InterruptedException
zkw - reference to the ZKWatcher which also contains configuration and constantsreplicaId - the ID of the replicatimeout - maximum time to wait in millisInterruptedException - if waiting for the socket operation failspublic void stop()
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.