You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@river.apache.org by pe...@apache.org on 2011/06/13 07:23:03 UTC
svn commit: r1135026 - in /river/jtsk/trunk/src:
com/sun/jini/jeri/internal/mux/Mux.java
net/jini/jeri/connection/ConnectionManager.java
Author: peter_firmstone
Date: Mon Jun 13 05:23:02 2011
New Revision: 1135026
URL: http://svn.apache.org/viewvc?rev=1135026&view=rev
Log:
River-397 Christopher Dolan's patch and test case. I ran the test case first and confirmed the failure, it was supplied as a testng, I converted it to junit for now, until we convert all tests to testng.
Modified:
river/jtsk/trunk/src/com/sun/jini/jeri/internal/mux/Mux.java
river/jtsk/trunk/src/net/jini/jeri/connection/ConnectionManager.java
Modified: river/jtsk/trunk/src/com/sun/jini/jeri/internal/mux/Mux.java
URL: http://svn.apache.org/viewvc/river/jtsk/trunk/src/com/sun/jini/jeri/internal/mux/Mux.java?rev=1135026&r1=1135025&r2=1135026&view=diff
==============================================================================
--- river/jtsk/trunk/src/com/sun/jini/jeri/internal/mux/Mux.java (original)
+++ river/jtsk/trunk/src/com/sun/jini/jeri/internal/mux/Mux.java Mon Jun 13 05:23:02 2011
@@ -137,6 +137,7 @@ abstract class Mux {
final Map sessions = new HashMap(5);
private int expectedPingCookie = -1;
+ private long startTimeout = 15000; // milliseconds
/**
* Constructs a new Mux instance for a connection accessible through
@@ -177,6 +178,24 @@ abstract class Mux {
}
/**
+ * Time in milliseconds for client-side connections to wait for the server
+ * to acknowledge an opening handshake. The default value is 15000
+ * milliseconds (15 seconds).
+ *
+ * <p>
+ * This method is not thread-safe. It is expected to be called immediately
+ * after a constructor.
+ *
+ * @param timeout
+ * positive value in milliseconds
+ */
+ public void setStartTimeout(long timeout) {
+ if (timeout <= 0)
+ throw new IllegalArgumentException("start timeout must be a positive number of milliseconds");
+ this.startTimeout = timeout;
+ }
+
+ /**
* Starts I/O processing.
*
* This method should be invoked only after this instance has
@@ -201,12 +220,19 @@ abstract class Mux {
if (role == CLIENT) {
asyncSendClientConnectionHeader();
synchronized (muxLock) {
+ long now = System.currentTimeMillis();
+ long endTime = now + this.startTimeout;
while (!muxDown && !clientConnectionReady) {
- try {
- muxLock.wait(); // REMIND: timeout?
- } catch (InterruptedException e) {
- setDown("interrupt waiting for connection header", e);
- }
+ if (now >= endTime) {
+ setDown("timeout waiting for server to respond to handshake", null);
+ } else {
+ try {
+ muxLock.wait(endTime - now);
+ now = System.currentTimeMillis();
+ } catch (InterruptedException e) {
+ setDown("interrupt waiting for connection header", e);
+ }
+ }
}
if (muxDown) {
IOException ioe = new IOException(muxDownMessage);
Modified: river/jtsk/trunk/src/net/jini/jeri/connection/ConnectionManager.java
URL: http://svn.apache.org/viewvc/river/jtsk/trunk/src/net/jini/jeri/connection/ConnectionManager.java?rev=1135026&r1=1135025&r2=1135026&view=diff
==============================================================================
--- river/jtsk/trunk/src/net/jini/jeri/connection/ConnectionManager.java (original)
+++ river/jtsk/trunk/src/net/jini/jeri/connection/ConnectionManager.java Mon Jun 13 05:23:02 2011
@@ -106,6 +106,10 @@ import net.jini.jeri.OutboundRequestIter
* milliseconds to leave idle client-side connections around before
* closing them. The default value is 15000 milliseconds (15 seconds).
*
+ * <li><code>com.sun.jini.jeri.handshakeTimeout</code> - Time in
+ * milliseconds for client-side connections to wait for the server to
+ * acknowledge an opening handshake. The default value is 15000 milliseconds (15 seconds).
+ *
* </ul>
**/
public final class ConnectionManager {
@@ -113,10 +117,17 @@ public final class ConnectionManager {
* How long to leave idle muxes around before closing them.
*/
private static final long TIMEOUT =
- ((Long) AccessController.doPrivileged(new GetLongAction(
+ ( (Long) AccessController.doPrivileged(new GetLongAction(
"com.sun.jini.jeri.connectionTimeout",
15000))).longValue();
/**
+ * How long to wait for a server to respond to an initial client message.
+ */
+ private static final long HANDSHAKE_TIMEOUT =
+ ((Long) AccessController.doPrivileged(new GetLongAction(
+ "com.sun.jini.jeri.handshakeTimeout",
+ 15000))).longValue();
+ /**
* ConnectionManager logger.
*/
private static final Logger logger =
@@ -278,6 +289,7 @@ public final class ConnectionManager {
try {
mux = (c.getChannel() == null) ?
new OutboundMux(c) : new OutboundMux(c, true);
+ mux.setStartTimeout(HANDSHAKE_TIMEOUT);
} finally {
if (mux == null) {
try {