Author: mahadev
Date: Fri Dec 4 23:47:30 2009
New Revision: 887457
URL: http://svn.apache.org/viewvc?rev=887457&view=rev
Log:
ZOOKEEPER-597. ASyncHammerTest is failing intermittently on hudson trunk (take 5) (mahadev)
Modified:
hadoop/zookeeper/trunk/CHANGES.txt
hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/NIOServerCnxn.java
Modified: hadoop/zookeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/CHANGES.txt?rev=887457&r1=887456&r2=887457&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/CHANGES.txt (original)
+++ hadoop/zookeeper/trunk/CHANGES.txt Fri Dec 4 23:47:30 2009
@@ -148,6 +148,9 @@
ZOOKEEPER-597. ASyncHammerTest is failing intermittently on hudson trunk
(take 4) (breed via mahadev)
+ ZOOKEEPER-597. ASyncHammerTest is failing intermittently on hudson trunk
+ (take 5) (mahadev)
+
IMPROVEMENTS:
ZOOKEEPER-473. cleanup junit tests to eliminate false positives due to
"socket reuse" and failure to close client (phunt via mahadev)
Modified: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/NIOServerCnxn.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/NIOServerCnxn.java?rev=887457&r1=887456&r2=887457&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/NIOServerCnxn.java (original)
+++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/NIOServerCnxn.java Fri
Dec 4 23:47:30 2009
@@ -77,6 +77,17 @@
LOG.error("Thread " + t + " died", e);
}
});
+
+ /**
+ * this is to avoid the jvm bug:
+ * NullPointerException in Selector.open()
+ * http://bugs.sun.com/view_bug.do?bug_id=6427854
+ */
+ try {
+ Selector.open().close();
+ } catch(IOException ie) {
+ LOG.error("Exception while opening a selector", ie);
+ }
}
static public class Factory extends Thread {
@@ -350,36 +361,40 @@
}
void sendBuffer(ByteBuffer bb) {
- if (bb != closeConn) {
- // We check if write interest here because if it is NOT set,
- // nothing is queued, so we can try to send the buffer right
- // away without waking up the selector
- if ((sk.interestOps() & SelectionKey.OP_WRITE) == 0) {
- try {
- sock.write(bb);
- } catch (IOException e) {
- // we are just doing best effort right now
+ try {
+ if (bb != closeConn) {
+ // We check if write interest here because if it is NOT set,
+ // nothing is queued, so we can try to send the buffer right
+ // away without waking up the selector
+ if ((sk.interestOps() & SelectionKey.OP_WRITE) == 0) {
+ try {
+ sock.write(bb);
+ } catch (IOException e) {
+ // we are just doing best effort right now
+ }
+ }
+ // if there is nothing left to send, we are done
+ if (bb.remaining() == 0) {
+ packetSent();
+ return;
}
}
- // if there is nothing left to send, we are done
- if (bb.remaining() == 0) {
- packetSent();
- return;
- }
- }
- synchronized (factory) {
- sk.selector().wakeup();
- if (LOG.isTraceEnabled()) {
- LOG.trace("Add a buffer to outgoingBuffers, sk " + sk
- + " is valid: " + sk.isValid());
- }
- outgoingBuffers.add(bb);
- if (sk.isValid()) {
- sk.interestOps(sk.interestOps() | SelectionKey.OP_WRITE);
+ synchronized (factory) {
+ sk.selector().wakeup();
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Add a buffer to outgoingBuffers, sk " + sk
+ + " is valid: " + sk.isValid());
+ }
+ outgoingBuffers.add(bb);
+ if (sk.isValid()) {
+ sk.interestOps(sk.interestOps() | SelectionKey.OP_WRITE);
+ }
}
+ } catch(Exception e) {
+ LOG.error("Unexpected Exception: ", e);
}
}
-
+
private static class CloseRequestException extends IOException {
private static final long serialVersionUID = -7854505709816442681L;
|