[jboss-remoting-commits] JBoss Remoting SVN: r4032 - remoting2/branches/2.x/src/main/org/jboss/remoting.
jboss-remoting-commits at lists.jboss.org
jboss-remoting-commits at lists.jboss.org
Mon Apr 21 22:02:23 EDT 2008
Author: ron.sigal at jboss.com
Date: 2008-04-21 22:02:23 -0400 (Mon, 21 Apr 2008)
New Revision: 4032
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/LeasePinger.java
Log:
JBREM-956: Added leasePingerTimeout configuration parameter.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/LeasePinger.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/LeasePinger.java 2008-04-22 01:03:22 UTC (rev 4031)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/LeasePinger.java 2008-04-22 02:02:23 UTC (rev 4032)
@@ -25,6 +25,7 @@
public static final long DEFAULT_LEASE_PERIOD = 5000;
public static final int DEFAULT_DISCONNECT_TIMEOUT = -1;
+ public static final String LEASE_PINGER_TIMEOUT = "leasePingerTimeout";
// Static ---------------------------------------------------------------------------------------
@@ -44,15 +45,48 @@
private long pingPeriod = -1;
private int disconnectTimeout = DEFAULT_DISCONNECT_TIMEOUT;
+ private int leasePingerTimeout = -1;
+
+ // The following variables exist for testing purposes.
+ private boolean pingInvoked;
+ private boolean pingSucceeded;
// Constructors ---------------------------------------------------------------------------------
public LeasePinger(ClientInvoker invoker, String invokerSessionID, long defaultLeasePeriod)
{
+ this(invoker, invokerSessionID, defaultLeasePeriod, null);
+ }
+
+ public LeasePinger(ClientInvoker invoker, String invokerSessionID, long defaultLeasePeriod, Map config)
+ {
this.invoker = invoker;
this.invokerSessionID = invokerSessionID;
this.pingPeriod = defaultLeasePeriod;
this.defaultPingPeriod = defaultLeasePeriod;
+
+ if (config != null)
+ {
+ Object o = config.get(LEASE_PINGER_TIMEOUT);
+ if (o != null)
+ {
+ if (o instanceof String)
+ {
+ try
+ {
+ leasePingerTimeout = Integer.valueOf((String) o).intValue();
+ }
+ catch (NumberFormatException e)
+ {
+ log.warn("leasePingerTimeout parameter must represent an int: " + o);
+ }
+ }
+ else
+ {
+ log.warn("leasePingerTimeout parameter must be a String representing an int");
+ }
+ }
+ }
}
// Public ---------------------------------------------------------------------------------------
@@ -277,15 +311,25 @@
Map requestClients = new ConcurrentHashMap();
requestClients.put(ClientHolder.CLIENT_HOLDER_KEY, clientsClone);
+ if (leasePingerTimeout >= 0)
+ {
+ requestClients.put(ServerInvoker.TIMEOUT, Integer.toString(leasePingerTimeout));
+ }
+
InvocationRequest ir =
new InvocationRequest(invokerSessionID, null, "$PING$", requestClients, null, null);
-
+
+ pingSucceeded = false;
+ pingInvoked = true;
invoker.invoke(ir);
+ pingSucceeded = true;
+ pingInvoked = false;
if(trace) { log.trace(this + " successfully pinged the server"); }
}
catch (Throwable t)
{
+ pingInvoked = false;
log.debug(this + " failed to ping to server", t);
}
}
More information about the jboss-remoting-commits
mailing list