org.apache.hadoop.hbase.catalog
Class CatalogTracker

java.lang.Object
  extended by org.apache.hadoop.hbase.catalog.CatalogTracker

@InterfaceAudience.Private
public class CatalogTracker
extends Object

Tracks the availability of the catalog tables hbase:meta. This class is "read-only" in that the locations of the catalog tables cannot be explicitly set. Instead, ZooKeeper is used to learn of the availability and location of hbase:meta.

Call start() to start up operation. Call stop()} to interrupt waits and close up shop.


Constructor Summary
CatalogTracker(org.apache.hadoop.conf.Configuration conf)
          Constructs a catalog tracker.
CatalogTracker(ZooKeeperWatcher zk, org.apache.hadoop.conf.Configuration conf, Abortable abortable)
          Constructs the catalog tracker.
CatalogTracker(ZooKeeperWatcher zk, org.apache.hadoop.conf.Configuration conf, HConnection connection, Abortable abortable)
           
 
Method Summary
 HConnection getConnection()
           
 ServerName getMetaLocation()
          Gets the current location for hbase:meta or null if location is not currently available.
 RegionState getMetaRegionState()
          Get meta region state
 boolean isMetaLocationAvailable()
          Checks whether meta regionserver znode has some non null data.
 boolean isStopped()
           
 void start()
          Starts the catalog tracker.
 void stop()
          Stop working.
 boolean verifyMetaRegionLocation(long timeout)
          Verify hbase:meta is deployed and accessible.
 void waitForMeta()
          Waits indefinitely for availability of hbase:meta.
 ServerName waitForMeta(long timeout)
          Gets the current location for hbase:meta if available and waits for up to the specified timeout if not immediately available.
 AdminProtos.AdminService.BlockingInterface waitForMetaServerConnection(long timeout)
          Deprecated. Use #getMetaServerConnection(long)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CatalogTracker

public CatalogTracker(org.apache.hadoop.conf.Configuration conf)
               throws IOException
Constructs a catalog tracker. Find current state of catalog tables. Begin active tracking by executing start() post construction. Does not timeout.

Parameters:
conf - the Configuration from which a HConnection will be obtained; if problem, this connections Abortable.abort(String, Throwable) will be called.
Throws:
IOException

CatalogTracker

public CatalogTracker(ZooKeeperWatcher zk,
                      org.apache.hadoop.conf.Configuration conf,
                      Abortable abortable)
               throws IOException
Constructs the catalog tracker. Find current state of catalog tables. Begin active tracking by executing start() post construction. Does not timeout.

Parameters:
zk - If zk is null, we'll create an instance (and shut it down when stop() is called) else we'll use what is passed.
conf -
abortable - If fatal exception we'll call abort on this. May be null. If it is we'll use the Connection associated with the passed Configuration as our Abortable.
Throws:
IOException

CatalogTracker

public CatalogTracker(ZooKeeperWatcher zk,
                      org.apache.hadoop.conf.Configuration conf,
                      HConnection connection,
                      Abortable abortable)
               throws IOException
Throws:
IOException
Method Detail

start

public void start()
           throws IOException,
                  InterruptedException
Starts the catalog tracker. Determines current availability of catalog tables and ensures all further transitions of either region are tracked.

Throws:
IOException
InterruptedException

isStopped

public boolean isStopped()
Returns:
True if we are stopped. Call only after start else indeterminate answer.

stop

public void stop()
Stop working. Interrupts any ongoing waits.


getMetaLocation

public ServerName getMetaLocation()
                           throws InterruptedException
Gets the current location for hbase:meta or null if location is not currently available.

Returns:
ServerName for server hosting hbase:meta or null if none available
Throws:
InterruptedException

isMetaLocationAvailable

public boolean isMetaLocationAvailable()
Checks whether meta regionserver znode has some non null data.

Returns:
true if data is not null, false otherwise.

waitForMeta

public ServerName waitForMeta(long timeout)
                       throws InterruptedException,
                              NotAllMetaRegionsOnlineException
Gets the current location for hbase:meta if available and waits for up to the specified timeout if not immediately available. Returns null if the timeout elapses before root is available.

Parameters:
timeout - maximum time to wait for root availability, in milliseconds
Returns:
ServerName for server hosting hbase:meta or null if none available
Throws:
InterruptedException - if interrupted while waiting
NotAllMetaRegionsOnlineException - if meta not available before timeout

getMetaRegionState

public RegionState getMetaRegionState()
Get meta region state

Returns:
RegionState

waitForMetaServerConnection

public AdminProtos.AdminService.BlockingInterface waitForMetaServerConnection(long timeout)
                                                                       throws InterruptedException,
                                                                              NotAllMetaRegionsOnlineException,
                                                                              IOException
Deprecated. Use #getMetaServerConnection(long)

Gets a connection to the server hosting meta, as reported by ZooKeeper, waiting up to the specified timeout for availability.

Parameters:
timeout - How long to wait on meta location
Returns:
connection to server hosting meta
Throws:
InterruptedException
NotAllMetaRegionsOnlineException - if timed out waiting
IOException
See Also:
for additional information

waitForMeta

public void waitForMeta()
                 throws InterruptedException
Waits indefinitely for availability of hbase:meta. Used during cluster startup. Does not verify meta, just that something has been set up in zk.

Throws:
InterruptedException - if interrupted while waiting
See Also:
waitForMeta(long)

verifyMetaRegionLocation

public boolean verifyMetaRegionLocation(long timeout)
                                 throws InterruptedException,
                                        IOException
Verify hbase:meta is deployed and accessible.

Parameters:
timeout - How long to wait on zk for meta address (passed through to the internal call to waitForMetaServerConnection(long).
Returns:
True if the hbase:meta location is healthy.
Throws:
IOException
InterruptedException

getConnection

public HConnection getConnection()


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