HBASE-5060 HBase client is blocked forever (Jinchao)

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1220863 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Zhihong Yu 2011-12-19 17:24:21 +00:00
parent a46959a370
commit 4e09ea6be8
2 changed files with 26 additions and 5 deletions

View File

@ -837,6 +837,7 @@ Release 0.90.6 - Unreleased
BUG FIXES
HBASE-4970 Add a parameter so that keepAliveTime of Htable thread pool can be changed (gaojinchao)
HBASE-5060 HBase client is blocked forever (Jinchao)
Release 0.90.5 - Unreleased

View File

@ -105,6 +105,7 @@ public class CatalogTracker {
private final MetaNodeTracker metaNodeTracker;
private final AtomicBoolean metaAvailable = new AtomicBoolean(false);
private boolean instantiatedzkw = false;
private Abortable abortable;
/*
* Do not clear this address once set. Its needed when we do
@ -184,8 +185,21 @@ public class CatalogTracker {
this.connection = connection;
if (abortable == null) {
// A connection is abortable.
abortable = this.connection;
this.abortable = this.connection;
}
Abortable throwableAborter = new Abortable() {
@Override
public void abort(String why, Throwable e) {
throw new RuntimeException(why, e);
}
@Override
public boolean isAborted() {
return true;
}
};
if (zk == null) {
// Create our own. Set flag so we tear it down on stop.
this.zookeeper =
@ -195,10 +209,10 @@ public class CatalogTracker {
} else {
this.zookeeper = zk;
}
this.rootRegionTracker = new RootRegionTracker(zookeeper, abortable);
this.rootRegionTracker = new RootRegionTracker(zookeeper, throwableAborter);
final CatalogTracker ct = this;
// Override nodeDeleted so we get notified when meta node deleted
this.metaNodeTracker = new MetaNodeTracker(zookeeper, abortable) {
this.metaNodeTracker = new MetaNodeTracker(zookeeper, throwableAborter) {
public void nodeDeleted(String path) {
if (!path.equals(node)) return;
ct.resetMetaLocation();
@ -216,8 +230,14 @@ public class CatalogTracker {
*/
public void start() throws IOException, InterruptedException {
LOG.debug("Starting catalog tracker " + this);
this.rootRegionTracker.start();
this.metaNodeTracker.start();
try {
this.rootRegionTracker.start();
this.metaNodeTracker.start();
} catch (RuntimeException e) {
Throwable t = e.getCause();
this.abortable.abort(e.getMessage(), t);
throw new IOException("Attempt to start root/meta tracker failed.", t);
}
}
/**