org.apache.hadoop.hbase.zookeeper
Class MetaRegionTracker

java.lang.Object
  extended by org.apache.hadoop.hbase.zookeeper.ZooKeeperListener
      extended by org.apache.hadoop.hbase.zookeeper.ZooKeeperNodeTracker
          extended by org.apache.hadoop.hbase.zookeeper.MetaRegionTracker

@InterfaceAudience.Private
public class MetaRegionTracker
extends ZooKeeperNodeTracker

Tracks the meta region server location node in zookeeper. Meta region location is set by RegionServerServices. This class has a watcher on the meta location and notices changes.


Field Summary
 
Fields inherited from class org.apache.hadoop.hbase.zookeeper.ZooKeeperNodeTracker
abortable, node
 
Fields inherited from class org.apache.hadoop.hbase.zookeeper.ZooKeeperListener
watcher
 
Constructor Summary
MetaRegionTracker(ZooKeeperWatcher watcher, Abortable abortable)
          Creates a meta region location tracker.
 
Method Summary
static ServerName blockUntilAvailable(ZooKeeperWatcher zkw, long timeout)
          Wait until the meta region is available.
static void deleteMetaLocation(ZooKeeperWatcher zookeeper)
          Deletes the location of hbase:meta in ZooKeeper.
 ServerName getMetaRegionLocation()
          Gets the meta region location, if available.
static ServerName getMetaRegionLocation(ZooKeeperWatcher zkw)
          Gets the meta region location, if available.
 RegionState getMetaRegionState()
          Get meta region state
 boolean isLocationAvailable()
          Checks if the meta region location is available.
static void setMetaLocation(ZooKeeperWatcher zookeeper, ServerName location, RegionState.State regionState)
          Sets the location of hbase:meta in ZooKeeper to the specified server address.
 ServerName waitMetaRegionLocation(long timeout)
          Gets the meta region location, if available, and waits for up to the specified timeout if not immediately available.
 
Methods inherited from class org.apache.hadoop.hbase.zookeeper.ZooKeeperNodeTracker
blockUntilAvailable, blockUntilAvailable, checkIfBaseNodeAvailable, getData, getNode, nodeCreated, nodeDataChanged, nodeDeleted, start, stop
 
Methods inherited from class org.apache.hadoop.hbase.zookeeper.ZooKeeperListener
getWatcher, nodeChildrenChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MetaRegionTracker

public MetaRegionTracker(ZooKeeperWatcher watcher,
                         Abortable abortable)
Creates a meta region location tracker.

After construction, use ZooKeeperNodeTracker.start() to kick off tracking.

Parameters:
watcher -
abortable -
Method Detail

isLocationAvailable

public boolean isLocationAvailable()
Checks if the meta region location is available.

Returns:
true if meta region location is available, false if not

getMetaRegionLocation

public ServerName getMetaRegionLocation()
Gets the meta region location, if available. Does not block. Sets a watcher.

Returns:
server name or null if we failed to get the data.
Throws:
InterruptedException

getMetaRegionLocation

public static ServerName getMetaRegionLocation(ZooKeeperWatcher zkw)
                                        throws org.apache.zookeeper.KeeperException
Gets the meta region location, if available. Does not block. Does not set a watcher (In this regard it differs from getMetaRegionLocation().

Parameters:
zkw -
Returns:
server name or null if we failed to get the data.
Throws:
org.apache.zookeeper.KeeperException

waitMetaRegionLocation

public ServerName waitMetaRegionLocation(long timeout)
                                  throws InterruptedException
Gets the meta region location, if available, and waits for up to the specified timeout if not immediately available. Given the zookeeper notification could be delayed, we will try to get the latest data.

Parameters:
timeout - maximum time to wait, in millis
Returns:
server name for server hosting meta region formatted as per ServerName, or null if none available
Throws:
InterruptedException - if interrupted while waiting

setMetaLocation

public static void setMetaLocation(ZooKeeperWatcher zookeeper,
                                   ServerName location,
                                   RegionState.State regionState)
                            throws org.apache.zookeeper.KeeperException
Sets the location of hbase:meta in ZooKeeper to the specified server address.

Parameters:
zookeeper - zookeeper reference
location - The server hosting hbase:meta
Throws:
org.apache.zookeeper.KeeperException - unexpected zookeeper exception

deleteMetaLocation

public static void deleteMetaLocation(ZooKeeperWatcher zookeeper)
                               throws org.apache.zookeeper.KeeperException
Deletes the location of hbase:meta in ZooKeeper.

Parameters:
zookeeper - zookeeper reference
Throws:
org.apache.zookeeper.KeeperException - unexpected zookeeper exception

blockUntilAvailable

public static ServerName blockUntilAvailable(ZooKeeperWatcher zkw,
                                             long timeout)
                                      throws InterruptedException
Wait until the meta region is available.

Parameters:
zkw -
timeout -
Returns:
ServerName or null if we timed out.
Throws:
InterruptedException

getMetaRegionState

public RegionState getMetaRegionState()
Get meta region state

Returns:
RegionState


Copyright © 2007-2015 The Apache Software Foundation. All Rights Reserved.