HBASE-3074 Zookeeper test failing on hudson
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1005691 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8570a6af09
commit
c4d59d99dd
|
@ -515,7 +515,8 @@ public class HConnectionManager {
|
|||
|
||||
private HRegionLocation locateRegion(final byte [] tableName,
|
||||
final byte [] row, boolean useCache)
|
||||
throws IOException{
|
||||
throws IOException {
|
||||
if (this.closed) throw new IOException("closed");
|
||||
if (tableName == null || tableName.length == 0) {
|
||||
throw new IllegalArgumentException(
|
||||
"table name cannot be null or zero length");
|
||||
|
@ -525,7 +526,8 @@ public class HConnectionManager {
|
|||
try {
|
||||
HServerAddress hsa =
|
||||
this.rootRegionTracker.waitRootRegionLocation(this.rpcTimeout);
|
||||
LOG.debug("Lookedup root region location with hcm=" + this + "; " + hsa);
|
||||
LOG.debug("Lookedup root region location, connection=" + this +
|
||||
"; hsa=" + hsa);
|
||||
if (hsa == null) return null;
|
||||
return new HRegionLocation(HRegionInfo.ROOT_REGIONINFO, hsa);
|
||||
} catch (InterruptedException e) {
|
||||
|
@ -1030,6 +1032,7 @@ public class HConnectionManager {
|
|||
this.zooKeeper.close();
|
||||
this.zooKeeper = null;
|
||||
}
|
||||
this.closed = true;
|
||||
}
|
||||
|
||||
private Callable<MultiResponse> createCallable(
|
||||
|
@ -1289,6 +1292,7 @@ public class HConnectionManager {
|
|||
public void abort(final String msg, Throwable t) {
|
||||
if (t != null) LOG.fatal(msg, t);
|
||||
else LOG.fatal(msg);
|
||||
this.closed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -249,10 +249,13 @@ public class ZooKeeperWatcher implements Watcher {
|
|||
case Disconnected:
|
||||
LOG.info(prefix("Received Disconnected from ZooKeeper, ignoring"));
|
||||
break;
|
||||
|
||||
case Expired:
|
||||
String msg = prefix("Received Expired from ZooKeeper, aborting server");
|
||||
LOG.error(msg);
|
||||
if (abortable != null) abortable.abort(msg, null);
|
||||
String msg = prefix(this.identifier + " received expired from " +
|
||||
"ZooKeeper, aborting");
|
||||
// TODO: One thought is to add call to ZooKeeperListener so say,
|
||||
// ZooKeperNodeTracker can zero out its data values.
|
||||
if (this.abortable != null) this.abortable.abort(msg, null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,8 +40,12 @@ import org.apache.hadoop.hbase.zookeeper.ZKConfig;
|
|||
import org.apache.hadoop.hbase.zookeeper.ZKUtil;
|
||||
import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
|
||||
import org.apache.zookeeper.KeeperException;
|
||||
import org.apache.zookeeper.Watcher;
|
||||
import org.apache.zookeeper.ZooKeeper;
|
||||
import org.apache.zookeeper.ZooKeeper.States;
|
||||
import org.apache.zookeeper.proto.WatcherEvent;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
@ -90,11 +94,11 @@ public class TestZooKeeper {
|
|||
@Test
|
||||
public void testClientSessionExpired()
|
||||
throws IOException, InterruptedException {
|
||||
new HTable(conf, HConstants.META_TABLE_NAME);
|
||||
|
||||
String quorumServers = ZKConfig.getZKQuorumServersString(conf);
|
||||
Configuration c = new Configuration(this.conf);
|
||||
new HTable(c, HConstants.META_TABLE_NAME);
|
||||
String quorumServers = ZKConfig.getZKQuorumServersString(c);
|
||||
int sessionTimeout = 5 * 1000; // 5 seconds
|
||||
HConnection connection = HConnectionManager.getConnection(conf);
|
||||
HConnection connection = HConnectionManager.getConnection(c);
|
||||
ZooKeeperWatcher connectionZK = connection.getZooKeeperWatcher();
|
||||
long sessionID = connectionZK.getZooKeeper().getSessionId();
|
||||
byte[] password = connectionZK.getZooKeeper().getSessionPasswd();
|
||||
|
@ -106,7 +110,8 @@ public class TestZooKeeper {
|
|||
Thread.sleep(sessionTimeout * 3L);
|
||||
|
||||
System.err.println("ZooKeeper should have timed out");
|
||||
connection.relocateRegion(HConstants.ROOT_TABLE_NAME, HConstants.EMPTY_BYTE_ARRAY);
|
||||
Assert.assertTrue(connection.getZooKeeperWatcher().getZooKeeper().
|
||||
getState().equals(States.CLOSED));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue