Author: ron.sigal(a)jboss.com
Date: 2009-04-03 02:44:46 -0400 (Fri, 03 Apr 2009)
New Revision: 4917
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/ConnectionValidator.java
Log:
JBREM-1112: Introduced failureDisconnectTimeout variable.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/ConnectionValidator.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/ConnectionValidator.java 2009-04-03
06:43:56 UTC (rev 4916)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/ConnectionValidator.java 2009-04-03
06:44:46 UTC (rev 4917)
@@ -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();
@@ -236,6 +242,7 @@
private boolean tieToLease = true;
private boolean stopLeaseOnFailure = true;
private int pingTimeout;
+ private int failureDisconnectTimeout = -1;
private boolean isValid;
private Timer timer;
@@ -408,7 +415,7 @@
public String toString()
{
- return "ConnectionValidator[" + clientInvoker + ", pingPeriod="
+ pingPeriod + " ms]";
+ return "ConnectionValidator[" +
Integer.toHexString(System.identityHashCode(this)) + ":" + clientInvoker +
", pingPeriod=" + pingPeriod + " ms]";
}
// Package protected
----------------------------------------------------------------------------
@@ -576,6 +583,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");
+ }
+ }
}
}
@@ -716,6 +745,7 @@
{
public void run()
{
+ log.debug(this + " calling " + listener +
".handleConnectionException()");
listener.handleConnectionException(t, client);
}
}.start();
@@ -757,7 +787,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!"));
@@ -768,7 +798,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