Author: ron.sigal(a)jboss.com
Date: 2011-01-25 23:16:48 -0500 (Tue, 25 Jan 2011)
New Revision: 6220
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/Lease.java
remoting2/branches/2.x/src/main/org/jboss/remoting/ServerInvoker.java
Log:
JBREM-1144: Adding a unique id to Lease.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/Lease.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/Lease.java 2011-01-25 03:52:17 UTC
(rev 6219)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/Lease.java 2011-01-26 04:16:48 UTC
(rev 6220)
@@ -23,6 +23,7 @@
import org.jboss.logging.Logger;
import org.jboss.remoting.util.TimerUtil;
+import org.jboss.util.id.GUID;
import java.util.Collection;
import java.util.HashMap;
@@ -59,6 +60,9 @@
private static final Logger log = Logger.getLogger(Lease.class);
private static final boolean isTraceEnabled = log.isTraceEnabled();
+
+ /** Used by ConnectionValidator to detect a change of server. **/
+ protected String leaseId = new GUID().toString();
public Lease(String clientSessionId, long leasePeriod, String locatorurl, Map
requestPayload,
ConnectionNotifier notifier, Map clientLeases)
@@ -355,6 +359,11 @@
{
return leasePingerId;
}
+
+ protected String getLeaseId()
+ {
+ return leaseId;
+ }
private void stopLease()
{
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/ServerInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/ServerInvoker.java 2011-01-25
03:52:17 UTC (rev 6219)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/ServerInvoker.java 2011-01-26
04:16:48 UTC (rev 6220)
@@ -861,19 +861,20 @@
if (invokerSessionId != null)
{
// Comes from ConnectionValidator configured to tie validation with
lease.
- boolean response = checkForClientLease(invokerSessionId);
- if (trace) log.trace(this + " responding " + response +
" to $PING$ for invoker sessionId " + invokerSessionId);
+ String leaseId = checkForClientLease(invokerSessionId);
+ Boolean success = leaseId == null ? Boolean.FALSE : Boolean.TRUE;
+ if (trace) log.trace(this + " responding " + leaseId +
" to $PING$ for invoker sessionId " + invokerSessionId);
if (metadata.get(Remoting.USE_SERVER_CONNECTION_IDENTITY) != null)
{
Map responseMap = new HashMap();
responseMap.put(Remoting.SERVER_ID, serverId);
- if (trace) log.trace(this + " returning serverId: " +
serverId);
- return new InvocationResponse(invocation.getSessionId(), new
Boolean(response), false, responseMap);
+ if (trace) log.trace(this + " returning leaseId: " +
leaseId);
+ return new InvocationResponse(invocation.getSessionId(), success,
false, responseMap);
}
else
{
- if (trace) log.trace(this + " not returning serverId: "
+ serverId);
- return new Boolean(response);
+ if (trace) log.trace(this + " not returning leaseId: "
+ leaseId);
+ return success;
}
}
else
@@ -2123,7 +2124,7 @@
}
}
- private boolean checkForClientLease(String invokerSessionId)
+ private String checkForClientLease(String invokerSessionId)
{
if(leaseManagement && invokerSessionId != null)
{
@@ -2133,16 +2134,16 @@
if(clientLease == null)
{
if(trace) { log.trace("No lease established for invoker session id
(" + invokerSessionId + ")"); }
- return false;
+ return null;
}
else
{
if(trace) { log.trace("Found lease for invoker session id (" +
invokerSessionId + ")"); }
- return true;
+ return clientLease.getLeaseId();
}
}
- return false;
+ return null;
}
/**
Show replies by date