Author: ron.sigal(a)jboss.com
Date: 2009-05-01 00:51:34 -0400 (Fri, 01 May 2009)
New Revision: 5113
Modified:
remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/Lease.java
remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/LeasePinger.java
remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/MicroRemoteClientInvoker.java
Log:
Added timestamp to Lease pings.
Modified: remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/Lease.java
===================================================================
---
remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/Lease.java 2009-05-01
04:50:39 UTC (rev 5112)
+++
remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/Lease.java 2009-05-01
04:51:34 UTC (rev 5113)
@@ -54,6 +54,7 @@
private boolean stopped;
private boolean leaseUpdated = false;
+ private long lastUpdate;
private static final Logger log = Logger.getLogger(Lease.class);
private static final boolean isTraceEnabled = log.isTraceEnabled();
@@ -69,6 +70,9 @@
{
this.requestPayload = (Map)requestPayload.get(ClientHolder.CLIENT_HOLDER_KEY);
this.leasePingerId = (String) requestPayload.get(LeasePinger.LEASE_PINGER_ID);
+ this.lastUpdate = Long.valueOf((String)
requestPayload.get("time")).longValue();
+ log.debug(this + " initialized with lastUpdate: " + lastUpdate);
+ log.debug(this + " initialized with requestPayload: " +
this.requestPayload);
}
log.debug("leasePingerId: " + leasePingerId);
this.leaseWindow = leasePeriod * 2;
@@ -90,29 +94,54 @@
{
if(requestMap != null)
{
- synchronized (lock)
+ log.debug(this + " requestMap: " + requestMap);
+ long time = 0;
+ try
{
- this.requestPayload = (Map)requestMap.get(ClientHolder.CLIENT_HOLDER_KEY);
+ String timeString = (String) requestMap.get("time");
+ log.debug(this + " timeString: " + timeString);
+ time = Long.valueOf(timeString).longValue();
+ log.debug(this + " time: " + time);
+ }
+ catch(NullPointerException e)
+ {
+ log.error("time?", e);
+ throw e;
+ }
+ log.debug(this + " last update: " + lastUpdate + ", this update:
" + time);
+ if (time > lastUpdate)
+ {
+ synchronized (lock)
+ {
+ this.requestPayload =
(Map)requestMap.get(ClientHolder.CLIENT_HOLDER_KEY);
- log.debug(this + " updating: new Client list:");
- Collection clientHoldersCol = requestPayload.values();
- Iterator itr = clientHoldersCol.iterator();
- while (itr.hasNext())
- {
- Object val = itr.next();
- if (val != null && val instanceof ClientHolder)
+ log.debug(this + " updating: new Client list:");
+ Collection clientHoldersCol = requestPayload.values();
+ Iterator itr = clientHoldersCol.iterator();
+ while (itr.hasNext())
{
- ClientHolder clientHolder = (ClientHolder) val;
- log.debug(this + " " + clientHolder.getSessionId());
+ Object val = itr.next();
+ if (val != null && val instanceof ClientHolder)
+ {
+ ClientHolder clientHolder = (ClientHolder) val;
+ log.debug(this + " " + clientHolder.getSessionId());
+ }
}
+
+ lastUpdate = time;
+ updateLease(leasePeriod);
}
}
+ else
+ {
+ log.debug(this + " updating lease but not client list");
+ leaseUpdated = true;
+ }
}
else
{
log.debug(this + " requestPayload == null");
}
- updateLease(leasePeriod);
}
public void updateLease(long leasePeriod)
Modified:
remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/LeasePinger.java
===================================================================
---
remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/LeasePinger.java 2009-05-01
04:50:39 UTC (rev 5112)
+++
remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/LeasePinger.java 2009-05-01
04:51:34 UTC (rev 5113)
@@ -314,6 +314,7 @@
Map requestClients = new ConcurrentHashMap();
requestClients.put(ClientHolder.CLIENT_HOLDER_KEY, clientsClone);
requestClients.put(LeasePinger.LEASE_PINGER_ID, leasePingerId);
+ requestClients.put("time",
Long.toString(System.currentTimeMillis()));
InvocationRequest ir = new InvocationRequest(invokerSessionID, null,
"$PING$", requestClients, null, null);
invoker.invoke(ir);
Modified:
remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/MicroRemoteClientInvoker.java
===================================================================
---
remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/MicroRemoteClientInvoker.java 2009-05-01
04:50:39 UTC (rev 5112)
+++
remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/MicroRemoteClientInvoker.java 2009-05-01
04:51:34 UTC (rev 5113)
@@ -423,6 +423,7 @@
String leasePingerId = new GUID().toString();
Map requestMap = new HashMap();
requestMap.put(LeasePinger.LEASE_PINGER_ID, leasePingerId);
+ requestMap.put("time", Long.toString(System.currentTimeMillis()));
log.info(this + " initiating lease for leasePingerId " +
leasePingerId);
InvocationRequest ir = new InvocationRequest(invokerSessionID, null,
"$PING$", requestMap, new HashMap(), null);
Show replies by date