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:
parent
ea1268b468
commit
83802d7f17
|
@ -28,6 +28,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
|
@ -457,8 +458,7 @@ public class ZKUtil {
|
||||||
throws KeeperException {
|
throws KeeperException {
|
||||||
try {
|
try {
|
||||||
byte [] data = zkw.getZooKeeper().getData(znode, null, null);
|
byte [] data = zkw.getZooKeeper().getData(znode, null, null);
|
||||||
LOG.debug(zkw.prefix("Retrieved " + data.length +
|
logRetrievedMsg(zkw, znode, data, false);
|
||||||
" bytes of data from znode " + znode));
|
|
||||||
return data;
|
return data;
|
||||||
} catch (KeeperException.NoNodeException e) {
|
} catch (KeeperException.NoNodeException e) {
|
||||||
LOG.debug(zkw.prefix("Unable to get data of znode " + znode + " " +
|
LOG.debug(zkw.prefix("Unable to get data of znode " + znode + " " +
|
||||||
|
@ -490,8 +490,7 @@ public class ZKUtil {
|
||||||
throws KeeperException {
|
throws KeeperException {
|
||||||
try {
|
try {
|
||||||
byte [] data = zkw.getZooKeeper().getData(znode, zkw, null);
|
byte [] data = zkw.getZooKeeper().getData(znode, zkw, null);
|
||||||
LOG.debug(zkw.prefix("Retrieved " + data.length +
|
logRetrievedMsg(zkw, znode, data, true);
|
||||||
" bytes of data from znode " + znode + " and set a watcher"));
|
|
||||||
return data;
|
return data;
|
||||||
} catch (KeeperException.NoNodeException e) {
|
} catch (KeeperException.NoNodeException e) {
|
||||||
LOG.debug(zkw.prefix("Unable to get data of znode " + znode + " " +
|
LOG.debug(zkw.prefix("Unable to get data of znode " + znode + " " +
|
||||||
|
@ -528,8 +527,7 @@ public class ZKUtil {
|
||||||
throws KeeperException {
|
throws KeeperException {
|
||||||
try {
|
try {
|
||||||
byte [] data = zkw.getZooKeeper().getData(znode, zkw, stat);
|
byte [] data = zkw.getZooKeeper().getData(znode, zkw, stat);
|
||||||
LOG.debug(zkw.prefix("Retrieved " + data.length +
|
logRetrievedMsg(zkw, znode, data, false);
|
||||||
" bytes of data from znode " + znode));
|
|
||||||
return data;
|
return data;
|
||||||
} catch (KeeperException.NoNodeException e) {
|
} catch (KeeperException.NoNodeException e) {
|
||||||
LOG.debug(zkw.prefix("Unable to get data of znode " + znode + " " +
|
LOG.debug(zkw.prefix("Unable to get data of znode " + znode + " " +
|
||||||
|
@ -1007,4 +1005,13 @@ public class ZKUtil {
|
||||||
socket.close();
|
socket.close();
|
||||||
return res.toArray(new String[res.size()]);
|
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))));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,18 +137,17 @@ public abstract class ZooKeeperNodeTracker extends ZooKeeperListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void nodeCreated(String path) {
|
public synchronized void nodeCreated(String path) {
|
||||||
if(path.equals(node)) {
|
if (!path.equals(node)) return;
|
||||||
try {
|
try {
|
||||||
byte [] data = ZKUtil.getDataAndWatch(watcher, node);
|
byte [] data = ZKUtil.getDataAndWatch(watcher, node);
|
||||||
if(data != null) {
|
if (data != null) {
|
||||||
this.data = data;
|
this.data = data;
|
||||||
notifyAll();
|
notifyAll();
|
||||||
} else {
|
} else {
|
||||||
nodeDeleted(path);
|
nodeDeleted(path);
|
||||||
}
|
|
||||||
} catch(KeeperException e) {
|
|
||||||
abortable.abort("Unexpected exception handling nodeCreated event", e);
|
|
||||||
}
|
}
|
||||||
|
} catch(KeeperException e) {
|
||||||
|
abortable.abort("Unexpected exception handling nodeCreated event", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -137,12 +137,14 @@ public class TestZooKeeper {
|
||||||
HTableDescriptor desc = new HTableDescriptor(tableName);
|
HTableDescriptor desc = new HTableDescriptor(tableName);
|
||||||
HColumnDescriptor family = new HColumnDescriptor("fam");
|
HColumnDescriptor family = new HColumnDescriptor("fam");
|
||||||
desc.addFamily(family);
|
desc.addFamily(family);
|
||||||
|
LOG.info("Creating table " + tableName);
|
||||||
admin.createTable(desc);
|
admin.createTable(desc);
|
||||||
|
|
||||||
HTable table = new HTable(conf, tableName);
|
HTable table = new HTable(conf, tableName);
|
||||||
Put put = new Put(Bytes.toBytes("testrow"));
|
Put put = new Put(Bytes.toBytes("testrow"));
|
||||||
put.add(Bytes.toBytes("fam"),
|
put.add(Bytes.toBytes("fam"),
|
||||||
Bytes.toBytes("col"), Bytes.toBytes("testdata"));
|
Bytes.toBytes("col"), Bytes.toBytes("testdata"));
|
||||||
|
LOG.info("Putting table " + tableName);
|
||||||
table.put(put);
|
table.put(put);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue