Adding even more logging to figure why we're reading old root region location though its been updated in zk -- for failing TestZooKeeper

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1004462 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2010-10-04 22:27:40 +00:00
parent ea1268b468
commit 83802d7f17
3 changed files with 25 additions and 17 deletions

View File

@ -28,6 +28,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
@ -457,8 +458,7 @@ public class ZKUtil {
throws KeeperException {
try {
byte [] data = zkw.getZooKeeper().getData(znode, null, null);
LOG.debug(zkw.prefix("Retrieved " + data.length +
" bytes of data from znode " + znode));
logRetrievedMsg(zkw, znode, data, false);
return data;
} catch (KeeperException.NoNodeException e) {
LOG.debug(zkw.prefix("Unable to get data of znode " + znode + " " +
@ -490,8 +490,7 @@ public class ZKUtil {
throws KeeperException {
try {
byte [] data = zkw.getZooKeeper().getData(znode, zkw, null);
LOG.debug(zkw.prefix("Retrieved " + data.length +
" bytes of data from znode " + znode + " and set a watcher"));
logRetrievedMsg(zkw, znode, data, true);
return data;
} catch (KeeperException.NoNodeException e) {
LOG.debug(zkw.prefix("Unable to get data of znode " + znode + " " +
@ -528,8 +527,7 @@ public class ZKUtil {
throws KeeperException {
try {
byte [] data = zkw.getZooKeeper().getData(znode, zkw, stat);
LOG.debug(zkw.prefix("Retrieved " + data.length +
" bytes of data from znode " + znode));
logRetrievedMsg(zkw, znode, data, false);
return data;
} catch (KeeperException.NoNodeException e) {
LOG.debug(zkw.prefix("Unable to get data of znode " + znode + " " +
@ -1007,4 +1005,13 @@ public class ZKUtil {
socket.close();
return res.toArray(new String[res.size()]);
}
private static void logRetrievedMsg(final ZooKeeperWatcher zkw,
final String znode, final byte [] data, final boolean watcherSet) {
if (!LOG.isDebugEnabled()) return;
LOG.debug(zkw.prefix("Retrieved " + ((data == null)? 0: data.length) +
" byte(s) of data from znode " + znode +
(watcherSet? " and set watcher; ": "; data=") +
(data == null? "null": StringUtils.abbreviate(Bytes.toString(data), 128))));
}
}

View File

@ -137,18 +137,17 @@ public abstract class ZooKeeperNodeTracker extends ZooKeeperListener {
@Override
public synchronized void nodeCreated(String path) {
if(path.equals(node)) {
try {
byte [] data = ZKUtil.getDataAndWatch(watcher, node);
if(data != null) {
this.data = data;
notifyAll();
} else {
nodeDeleted(path);
}
} catch(KeeperException e) {
abortable.abort("Unexpected exception handling nodeCreated event", e);
if (!path.equals(node)) return;
try {
byte [] data = ZKUtil.getDataAndWatch(watcher, node);
if (data != null) {
this.data = data;
notifyAll();
} else {
nodeDeleted(path);
}
} catch(KeeperException e) {
abortable.abort("Unexpected exception handling nodeCreated event", e);
}
}

View File

@ -137,12 +137,14 @@ public class TestZooKeeper {
HTableDescriptor desc = new HTableDescriptor(tableName);
HColumnDescriptor family = new HColumnDescriptor("fam");
desc.addFamily(family);
LOG.info("Creating table " + tableName);
admin.createTable(desc);
HTable table = new HTable(conf, tableName);
Put put = new Put(Bytes.toBytes("testrow"));
put.add(Bytes.toBytes("fam"),
Bytes.toBytes("col"), Bytes.toBytes("testdata"));
LOG.info("Putting table " + tableName);
table.put(put);
}