You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zookeeper.apache.org by br...@apache.org on 2009/12/11 21:24:24 UTC
svn commit: r889797 - in /hadoop/zookeeper/trunk: CHANGES.txt
src/java/main/org/apache/zookeeper/KeeperException.java
src/java/main/org/apache/zookeeper/server/PrepRequestProcessor.java
src/java/main/org/apache/zookeeper/server/Request.java
Author: breed
Date: Fri Dec 11 20:24:23 2009
New Revision: 889797
URL: http://svn.apache.org/viewvc?rev=889797&view=rev
Log:
ZOOKEEPER-588. remove unnecessary/annoying log of tostring error in Request.toString()
Modified:
hadoop/zookeeper/trunk/CHANGES.txt
hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/KeeperException.java
hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/PrepRequestProcessor.java
hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/Request.java
Modified: hadoop/zookeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/CHANGES.txt?rev=889797&r1=889796&r2=889797&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/CHANGES.txt (original)
+++ hadoop/zookeeper/trunk/CHANGES.txt Fri Dec 11 20:24:23 2009
@@ -155,6 +155,10 @@
ZOOKEEPER-611. hudson build failure (take 2) (mahadev)
+ ZOOKEEPER-615. wrong javadoc for create with a sequence flag (mahadev via breed)
+
+ ZOOKEEPER-588. remove unnecessary/annoying log of tostring error in Request.toString() (phunt via breed)
+
IMPROVEMENTS:
ZOOKEEPER-473. cleanup junit tests to eliminate false positives due to
"socket reuse" and failure to close client (phunt via mahadev)
@@ -178,8 +182,6 @@
ZOOKEEPER-425. Add OSGi metadata to zookeeper.jar (david bosschaert via breed)
- ZOOKEEPER-615. wrong javadoc for create with a sequence flag (mahadev via breed)
-
NEW FEATURES:
ZOOKEEPER-539. generate eclipse project via ant target. (phunt via mahadev)
Modified: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/KeeperException.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/KeeperException.java?rev=889797&r1=889796&r2=889797&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/KeeperException.java (original)
+++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/KeeperException.java Fri Dec 11 20:24:23 2009
@@ -484,6 +484,9 @@
public BadArgumentsException() {
super(Code.BADARGUMENTS);
}
+ public BadArgumentsException(String path) {
+ super(Code.BADARGUMENTS, path);
+ }
}
/**
@@ -493,6 +496,9 @@
public BadVersionException() {
super(Code.BADVERSION);
}
+ public BadVersionException(String path) {
+ super(Code.BADVERSION, path);
+ }
}
/**
@@ -520,6 +526,9 @@
public InvalidACLException() {
super(Code.INVALIDACL);
}
+ public InvalidACLException(String path) {
+ super(Code.INVALIDACL, path);
+ }
}
/**
@@ -556,6 +565,9 @@
public NoChildrenForEphemeralsException() {
super(Code.NOCHILDRENFOREPHEMERALS);
}
+ public NoChildrenForEphemeralsException(String path) {
+ super(Code.NOCHILDRENFOREPHEMERALS, path);
+ }
}
/**
@@ -565,6 +577,9 @@
public NodeExistsException() {
super(Code.NODEEXISTS);
}
+ public NodeExistsException(String path) {
+ super(Code.NODEEXISTS, path);
+ }
}
/**
@@ -574,6 +589,9 @@
public NoNodeException() {
super(Code.NONODE);
}
+ public NoNodeException(String path) {
+ super(Code.NONODE, path);
+ }
}
/**
@@ -583,6 +601,9 @@
public NotEmptyException() {
super(Code.NOTEMPTY);
}
+ public NotEmptyException(String path) {
+ super(Code.NOTEMPTY, path);
+ }
}
/**
Modified: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/PrepRequestProcessor.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/PrepRequestProcessor.java?rev=889797&r1=889796&r2=889797&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/PrepRequestProcessor.java (original)
+++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/PrepRequestProcessor.java Fri Dec 11 20:24:23 2009
@@ -147,7 +147,7 @@
}
}
if (lastChange == null || lastChange.stat == null) {
- throw new KeeperException.NoNodeException();
+ throw new KeeperException.NoNodeException(path);
}
return lastChange;
}
@@ -218,10 +218,10 @@
if (lastSlash == -1 || path.indexOf('\0') != -1 || failCreate) {
LOG.info("Invalid path " + path + " with session " +
Long.toHexString(request.sessionId));
- throw new KeeperException.BadArgumentsException();
+ throw new KeeperException.BadArgumentsException(path);
}
if (!fixupACL(request.authInfo, createRequest.getAcl())) {
- throw new KeeperException.InvalidACLException();
+ throw new KeeperException.InvalidACLException(path);
}
String parentPath = path.substring(0, lastSlash);
ChangeRecord parentRecord = getRecordForPath(parentPath);
@@ -239,18 +239,18 @@
} catch(IllegalArgumentException ie) {
LOG.info("Invalid path " + path + " with session " +
Long.toHexString(request.sessionId));
- throw new KeeperException.BadArgumentsException();
+ throw new KeeperException.BadArgumentsException(path);
}
try {
if (getRecordForPath(path) != null) {
- throw new KeeperException.NodeExistsException();
+ throw new KeeperException.NodeExistsException(path);
}
} catch (KeeperException.NoNodeException e) {
// ignore this one
}
boolean ephemeralParent = parentRecord.stat.getEphemeralOwner() != 0;
if (ephemeralParent) {
- throw new KeeperException.NoChildrenForEphemeralsException();
+ throw new KeeperException.NoChildrenForEphemeralsException(path);
}
txn = new CreateTxn(path, createRequest.getData(),
createRequest.getAcl(),
@@ -279,7 +279,7 @@
lastSlash = path.lastIndexOf('/');
if (lastSlash == -1 || path.indexOf('\0') != -1
|| zks.dataTree.isSpecialPath(path)) {
- throw new KeeperException.BadArgumentsException();
+ throw new KeeperException.BadArgumentsException(path);
}
parentPath = path.substring(0, lastSlash);
parentRecord = getRecordForPath(parentPath);
@@ -288,10 +288,10 @@
request.authInfo);
int version = deleteRequest.getVersion();
if (version != -1 && nodeRecord.stat.getVersion() != version) {
- throw new KeeperException.BadVersionException();
+ throw new KeeperException.BadVersionException(path);
}
if (nodeRecord.childCount > 0) {
- throw new KeeperException.NotEmptyException();
+ throw new KeeperException.NotEmptyException(path);
}
txn = new DeleteTxn(path);
parentRecord = parentRecord.duplicate(txnHeader.getZxid());
@@ -316,7 +316,7 @@
version = setDataRequest.getVersion();
int currentVersion = nodeRecord.stat.getVersion();
if (version != -1 && version != currentVersion) {
- throw new KeeperException.BadVersionException();
+ throw new KeeperException.BadVersionException(path);
}
version = currentVersion + 1;
txn = new SetDataTxn(path, setDataRequest.getData(), version);
@@ -331,17 +331,17 @@
SetACLRequest setAclRequest = new SetACLRequest();
ZooKeeperServer.byteBuffer2Record(request.request,
setAclRequest);
+ path = setAclRequest.getPath();
if (!fixupACL(request.authInfo, setAclRequest.getAcl())) {
- throw new KeeperException.InvalidACLException();
+ throw new KeeperException.InvalidACLException(path);
}
- path = setAclRequest.getPath();
nodeRecord = getRecordForPath(path);
checkACL(zks, nodeRecord.acl, ZooDefs.Perms.ADMIN,
request.authInfo);
version = setAclRequest.getVersion();
currentVersion = nodeRecord.stat.getAversion();
if (version != -1 && version != currentVersion) {
- throw new KeeperException.BadVersionException();
+ throw new KeeperException.BadVersionException(path);
}
version = currentVersion + 1;
txn = new SetACLTxn(path, setAclRequest.getAcl(), version);
@@ -393,7 +393,8 @@
case OpCode.getChildren2:
case OpCode.ping:
case OpCode.setWatches:
- zks.sessionTracker.checkSession(request.sessionId, request.getOwner());
+ zks.sessionTracker.checkSession(request.sessionId,
+ request.getOwner());
break;
}
} catch (KeeperException e) {
@@ -402,7 +403,9 @@
txn = new ErrorTxn(e.code().intValue());
}
LOG.info("Got user-level KeeperException when processing "
- + request.toString() + " Error:" + e.getMessage());
+ + request.toString()
+ + " Error Path:" + e.getPath()
+ + " Error:" + e.getMessage());
request.setException(e);
} catch (Exception e) {
// log at error level as we are returning a marshalling
Modified: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/Request.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/Request.java?rev=889797&r1=889796&r2=889797&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/Request.java (original)
+++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/Request.java Fri Dec 11 20:24:23 2009
@@ -56,15 +56,15 @@
this.authInfo = authInfo;
}
- public long sessionId;
+ public final long sessionId;
- public int cxid;
+ public final int cxid;
- public int type;
+ public final int type;
- public ByteBuffer request;
+ public final ByteBuffer request;
- public ServerCnxn cnxn;
+ public final ServerCnxn cnxn;
public TxnHeader hdr;
@@ -72,14 +72,14 @@
public long zxid = -1;
- public List<Id> authInfo;
+ public final List<Id> authInfo;
- public long createTime = System.currentTimeMillis();
+ public final long createTime = System.currentTimeMillis();
private Object owner;
private KeeperException e;
-
+
public Object getOwner() {
return owner;
}
@@ -183,31 +183,41 @@
@Override
public String toString() {
StringBuffer sb = new StringBuffer();
- sb.append("sessionid:0x").append(Long.toHexString(sessionId));
- sb.append(" type:").append(op2String(type));
- sb.append(" cxid:0x").append(Long.toHexString(cxid));
- sb.append(" zxid:0x").append(Long.toHexString((hdr == null ?
- -2 : hdr.getZxid())));
- sb.append(" txntype:" + (hdr == null ?
- "unknown" : "" + hdr.getType()));
- sb.append(" ");
+ sb.append("sessionid:0x").append(Long.toHexString(sessionId))
+ .append(" type:").append(op2String(type))
+ .append(" cxid:0x").append(Long.toHexString(cxid))
+ .append(" zxid:0x").append(Long.toHexString(hdr == null ?
+ -2 : hdr.getZxid()))
+ .append(" txntype:").append(hdr == null ?
+ "unknown" : "" + hdr.getType());
+ // best effort to print the path assoc with this request
String path = "n/a";
- if (type != OpCode.createSession && request != null
+ if (type != OpCode.createSession
+ && type != OpCode.setWatches
+ && type != OpCode.closeSession
+ && request != null
&& request.remaining() >= 4)
{
try {
- request.clear();
- int pathLen = request.getInt();
- byte b[] = new byte[pathLen];
- request.get(b);
- path = new String(b);
- request.clear();
+ // make sure we don't mess with request itself
+ ByteBuffer rbuf = request.asReadOnlyBuffer();
+ rbuf.clear();
+ int pathLen = rbuf.getInt();
+ // sanity check
+ if (pathLen >= 0
+ && pathLen < 4096
+ && rbuf.remaining() >= pathLen)
+ {
+ byte b[] = new byte[pathLen];
+ rbuf.get(b);
+ path = new String(b);
+ }
} catch (Exception e) {
- LOG.warn("Ignoring exception during toString", e);
+ // ignore - can't find the path, will output "n/a" instead
}
}
- sb.append(path).append(" ");
+ sb.append(" reqpath:").append(path);
return sb.toString();
}