Author: ron.sigal(a)jboss.com
Date: 2009-04-03 01:40:18 -0400 (Fri, 03 Apr 2009)
New Revision: 4912
Modified:
remoting2/branches/2.2/src/main/org/jboss/remoting/ConnectionValidator.java
Log:
JBREM-1112: Introduced failureDisconnectTimeout variable.
Modified: remoting2/branches/2.2/src/main/org/jboss/remoting/ConnectionValidator.java
===================================================================
--- remoting2/branches/2.2/src/main/org/jboss/remoting/ConnectionValidator.java 2009-04-03
05:36:05 UTC (rev 4911)
+++ remoting2/branches/2.2/src/main/org/jboss/remoting/ConnectionValidator.java 2009-04-03
05:40:18 UTC (rev 4912)
@@ -72,12 +72,18 @@
* of active lease on server side. Default value is "true".
*/
public static final String TIE_TO_LEASE = "tieToLease";
+
/**
* Key to determine whether to stop ConnectionValidator when PING fails.
* Default value is "true".
*/
public static final String STOP_LEASE_ON_FAILURE = "stopLeaseOnFailure";
+ /**
+ * Key to determine value of disconnectTimeout upon connection failure.
+ */
+ public static final String FAILURE_DISCONNECT_TIMEOUT =
"failureDisconnectTimeout";
+
// Static
---------------------------------------------------------------------------------------
private static boolean trace = log.isTraceEnabled();
@@ -237,6 +243,7 @@
private boolean tieToLease = true;
private boolean stopLeaseOnFailure = true;
private int pingTimeout;
+ private int failureDisconnectTimeout = -1;
private boolean isValid;
private Timer timer;
@@ -409,7 +416,7 @@
public String toString()
{
- return "ConnectionValidator[" + clientInvoker + ", pingPeriod="
+ pingPeriod + " ms]";
+ return "ConnectionValidator[" +
Integer.toHexString(System.identityHashCode(this)) + ":" + clientInvoker +
", pingPeriod=" + pingPeriod + " ms]";
}
// Package protected
----------------------------------------------------------------------------
@@ -577,6 +584,28 @@
" to a boolean: must be a String");
}
}
+
+ o = config.get(FAILURE_DISCONNECT_TIMEOUT);
+ if (o != null)
+ {
+ if (o instanceof String)
+ {
+ try
+ {
+ failureDisconnectTimeout = Integer.valueOf(((String) o)).intValue();
+ }
+ catch (Exception e)
+ {
+ log.warn(this + " could not convert " +
FAILURE_DISCONNECT_TIMEOUT + " value" +
+ " to an int: " + o);
+ }
+ }
+ else
+ {
+ log.warn(this + " could not convert " +
FAILURE_DISCONNECT_TIMEOUT + " value" +
+ " to an int: must be a String");
+ }
+ }
}
}
@@ -717,6 +746,7 @@
{
public void run()
{
+ log.debug(this + " calling " + listener +
".handleConnectionException()");
listener.handleConnectionException(t, client);
}
}.start();
@@ -758,7 +788,7 @@
if (!isValid)
{
- log.debug(ConnectionValidator.this + "'s connections is
invalid");
+ log.debug(ConnectionValidator.this + "'s connection is
invalid");
notifyListeners(new Exception("Could not connect to server!"));
@@ -769,7 +799,8 @@
if (invoker != null)
{
- invoker.terminateLease(null, client.getDisconnectTimeout());
+ int disconnectTimeout = (failureDisconnectTimeout == -1) ?
client.getDisconnectTimeout() : failureDisconnectTimeout;
+ invoker.terminateLease(null, disconnectTimeout);
log.debug(ConnectionValidator.this + " shut down lease
pinger");
}
else
Show replies by date