public class CatalogTracker extends Object
-ROOT-
and
.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 -ROOT-
. -ROOT-
is used to learn of
the location of .META.
If not available in -ROOT-
,
ZooKeeper is used to monitor for a new location of .META.
.
Call start()
to start up operation. Call stop()
} to
interrupt waits and close up shop.
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
HConnection |
getConnection() |
ServerName |
getMetaLocation() |
ServerName |
getMetaLocationOrReadLocationFromRoot()
Method used by master on startup trying to figure state of cluster.
|
ServerName |
getRootLocation()
Gets the current location for
-ROOT- or null if location is
not currently available. |
void |
resetMetaLocation()
Called when we figure current meta is off (called from zk callback).
|
void |
start()
Starts the catalog tracker.
|
void |
stop()
Stop working.
|
boolean |
verifyMetaRegionLocation(long timeout)
Verify
.META. is deployed and accessible. |
boolean |
verifyRootRegionLocation(long timeout)
Verify
-ROOT- is deployed and accessible. |
void |
waitForMeta()
Waits indefinitely for availability of
.META. . |
ServerName |
waitForMeta(long timeout)
Gets the current location for
.META. if available and waits
for up to the specified timeout if not immediately available. |
HRegionInterface |
waitForMetaServerConnection(long timeout)
Deprecated.
Does not retry; use an HTable instance instead.
|
void |
waitForRoot()
Waits indefinitely for availability of
-ROOT- . |
ServerName |
waitForRoot(long timeout)
Gets the current location for
-ROOT- if available and waits
for up to the specified timeout if not immediately available. |
HRegionInterface |
waitForRootServerConnection(long timeout)
Deprecated.
Use #getRootServerConnection(long)
|
public CatalogTracker(org.apache.hadoop.conf.Configuration conf) throws IOException
start()
post construction. Does
not timeout.conf
- the Configuration
from which a HConnection
will be
obtained; if problem, this connections
Abortable.abort(String, Throwable)
will be called.IOException
public CatalogTracker(ZooKeeperWatcher zk, org.apache.hadoop.conf.Configuration conf, Abortable abortable) throws IOException
start()
post construction.
Does not timeout.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.IOException
public void start() throws IOException, InterruptedException
IOException
InterruptedException
public void stop()
public ServerName getRootLocation() throws InterruptedException
-ROOT-
or null if location is
not currently available.ServerName
for server hosting -ROOT-
or null
if none availableInterruptedException
public ServerName getMetaLocation()
ServerName
for server hosting .META.
or null
if none availablepublic ServerName getMetaLocationOrReadLocationFromRoot() throws IOException
-ROOT-
and
return that.ServerName
for server hosting .META.
or if null,
we'll read the location that is up in -ROOT-
table (which
could be null or just plain stale).IOException
public void waitForRoot() throws InterruptedException
-ROOT-
. Used during
cluster startup.InterruptedException
- if interrupted while waitingpublic ServerName waitForRoot(long timeout) throws InterruptedException, NotAllMetaRegionsOnlineException
-ROOT-
if available and waits
for up to the specified timeout if not immediately available. Returns null
if the timeout elapses before root is available.timeout
- maximum time to wait for root availability, in millisecondsServerName
for server hosting -ROOT-
or null
if none availableInterruptedException
- if interrupted while waitingNotAllMetaRegionsOnlineException
- if root not available before
timeoutpublic HRegionInterface waitForRootServerConnection(long timeout) throws InterruptedException, NotAllMetaRegionsOnlineException, IOException
timeout
- How long to wait on root locationInterruptedException
NotAllMetaRegionsOnlineException
- if timed out waitingIOException
for additional information
public void waitForMeta() throws InterruptedException
.META.
. Used during
cluster startup. Does not verify meta, just that something has been
set up in zk.InterruptedException
- if interrupted while waitingwaitForMeta(long)
public ServerName waitForMeta(long timeout) throws InterruptedException, IOException, NotAllMetaRegionsOnlineException
.META.
if available and waits
for up to the specified timeout if not immediately available. Throws an
exception if timed out waiting. This method differs from waitForMeta()
in that it will go ahead and verify the location gotten from ZooKeeper and
-ROOT- region by trying to use returned connection.timeout
- maximum time to wait for meta availability, in millisecondsServerName
for server hosting .META.
or null
if none availableInterruptedException
- if interrupted while waitingIOException
- unexpected exception connecting to meta serverNotAllMetaRegionsOnlineException
- if meta not available before
timeoutpublic HRegionInterface waitForMetaServerConnection(long timeout) throws InterruptedException, NotAllMetaRegionsOnlineException, IOException
InterruptedException
NotAllMetaRegionsOnlineException
- if timed out waitingIOException
for additional information
public void resetMetaLocation()
public boolean verifyRootRegionLocation(long timeout) throws InterruptedException, IOException
-ROOT-
is deployed and accessible.timeout
- How long to wait on zk for root address (passed through to
the internal call to waitForRootServerConnection(long)
.-ROOT-
location is healthy.IOException
InterruptedException
public boolean verifyMetaRegionLocation(long timeout) throws InterruptedException, IOException
.META.
is deployed and accessible.timeout
- How long to wait on zk for .META.
address
(passed through to the internal call to waitForMetaServerConnection(long)
..META.
location is healthy.IOException
- Some unexpected IOE.InterruptedException
public HConnection getConnection()
Copyright © 2014 The Apache Software Foundation. All Rights Reserved.