[jboss-remoting-commits] JBoss Remoting SVN: r5173 - remoting2/branches/2.2/src/main/org/jboss/remoting.
jboss-remoting-commits at lists.jboss.org
jboss-remoting-commits at lists.jboss.org
Sun May 10 01:52:57 EDT 2009
Author: ron.sigal at jboss.com
Date: 2009-05-10 01:52:57 -0400 (Sun, 10 May 2009)
New Revision: 5173
Modified:
remoting2/branches/2.2/src/main/org/jboss/remoting/ServerInvoker.java
Log:
JBREM-1128: Adopted use of leasePingerId.
Modified: remoting2/branches/2.2/src/main/org/jboss/remoting/ServerInvoker.java
===================================================================
--- remoting2/branches/2.2/src/main/org/jboss/remoting/ServerInvoker.java 2009-05-10 05:48:27 UTC (rev 5172)
+++ remoting2/branches/2.2/src/main/org/jboss/remoting/ServerInvoker.java 2009-05-10 05:52:57 UTC (rev 5173)
@@ -262,6 +262,8 @@
protected ServerSocketFactory serverSocketFactory = null;
protected boolean registerCallbackListeners = true;
+
+ protected boolean useClientConnectionIdentity;
// Constructors ---------------------------------------------------------------------------------
@@ -318,6 +320,11 @@
{
return timeout;
}
+
+ public ConnectionNotifier getConnectionNotifier()
+ {
+ return connectionNotifier;
+ }
public boolean isLeaseActivated()
{
@@ -702,6 +709,16 @@
return (ServerInvocationHandler) handlers.get(subsystem.toUpperCase());
}
+ protected boolean isUseClientConnectionIdentity()
+ {
+ return useClientConnectionIdentity;
+ }
+
+ protected void setUseClientConnectionIdentity(boolean useClientConnectionIdentity)
+ {
+ this.useClientConnectionIdentity = useClientConnectionIdentity;
+ }
+
public Object invoke(Object invoke) throws IOException
{
InvocationRequest request = null;
@@ -1156,6 +1173,13 @@
}
}
+ // config for useClientConnectionIdentity
+ String useClientConnectionIdentityString = (String)config.get(Remoting.USE_CLIENT_CONNECTION_IDENTITY);
+ if(useClientConnectionIdentityString != null)
+ {
+ useClientConnectionIdentity = Boolean.parseBoolean(useClientConnectionIdentityString);
+ }
+
// Inject ConnectionListener
String connectionListener = (String)config.get(CONNECTION_LISTENER);
if (connectionListener != null)
@@ -1477,6 +1501,10 @@
if (registerCallbackListeners)
{
connectionNotifier.addListenerFirst(callbackHandler);
+ if(leasePeriod > 0)
+ {
+ leaseManagement = true;
+ }
}
handler.addListener(callbackHandler);
}
@@ -1500,7 +1528,10 @@
"registered. Please add via xml configuration or via the Connector's " +
"addInvocationHandler() method.");
}
-
+ if (registerCallbackListeners)
+ {
+ connectionNotifier.removeListener(callbackHandler);
+ }
handler.removeListener(callbackHandler);
if(trace) { log.trace("ServerInvoker (" + this + ") removing server callback handler " + callbackHandler + "."); }
@@ -1703,6 +1734,7 @@
{
if (invocation != null)
{
+ // clientSessionId == MicroRemoteClientInvoker.invokerSessionID.
String clientSessionId = invocation.getSessionId();
Lease clientLease = (Lease)clientLeases.get(clientSessionId);
@@ -1738,7 +1770,7 @@
else
{
String type = "invoker";
- Map reqMap = invocation.getRequestPayload();
+ Map reqMap = invocation.getRequestPayload();
if (reqMap != null)
{
Object holderObj = reqMap.get(ClientHolder.CLIENT_HOLDER_KEY);
@@ -1747,8 +1779,9 @@
type = "client";
}
}
- log.warn("Asked to terminate " + type + " lease for client session id " + clientSessionId +
- ", but lease for this id could not be found." + ": " + clientLeases);
+ log.debug("Asked to terminate " + type + " lease for invoker session id "
+ + clientSessionId + ", but lease for this id could not be found." +"" +
+ "Probably has been removed due to connection failure.");
}
}
}
@@ -1760,7 +1793,7 @@
String clientSessionId = invocation.getSessionId();
if(clientSessionId != null)
{
- if(trace) { log.trace("Getting lease for client session id: " + clientSessionId); }
+ if(trace) { log.trace("Getting lease for invoker session id: " + clientSessionId); }
Lease clientLease = (Lease)clientLeases.get(clientSessionId);
if(clientLease == null)
@@ -1773,15 +1806,48 @@
clientLeases.put(clientSessionId, newClientLease);
newClientLease.startLease();
-
- if(trace) { log.trace("No lease established for client session id (" + clientSessionId + "), so starting a new one."); }
+
+ if(trace) { log.trace("No lease established for invoker session id (" + clientSessionId +
+ "), so starting a new one:" + newClientLease); }
}
else
{
- // including request payload from invocation as may contain updated list of clients.
- clientLease.updateLease(leasePeriod, invocation.getRequestPayload());
+ if (useClientConnectionIdentity)
+ {
+ String leasePingerId = (String) invocation.getRequestPayload().get(LeasePinger.LEASE_PINGER_ID);;
+ if (leasePingerId.equals(clientLease.getLeasePingerId()))
+ {
+ // including request payload from invocation as may contain updated list of clients.
+ if (trace) log.trace(clientLease + " matches: leasePingerId: " + leasePingerId);
+ clientLease.updateLease(leasePeriod, invocation.getRequestPayload());
+ if(trace) { log.trace("Updated lease for invoker session id (" + clientSessionId + ")"); }
+ }
+ else
+ {
+ if (trace) log.trace(clientLease + " does not match: leasePingerId: " + leasePingerId);
+ if (trace) log.trace("terminating invoker lease: " + clientLease);
+ clientLease.terminateLeaseUponFailure(clientSessionId);
+ clientLeases.remove(clientSessionId);
- if(trace) { log.trace("Updated lease for client session id (" + clientSessionId + ")"); }
+ Lease newClientLease = new Lease(clientSessionId, leasePeriod,
+ locator.getLocatorURI(),
+ invocation.getRequestPayload(),
+ connectionNotifier,
+ clientLeases);
+
+ clientLeases.put(clientSessionId, newClientLease);
+ newClientLease.startLease();
+
+ if(trace) { log.trace("starting a new lease:" + newClientLease); }
+ }
+ }
+ else
+ {
+ // including request payload from invocation as may contain updated list of clients.
+ clientLease.updateLease(leasePeriod, invocation.getRequestPayload());
+
+ if(trace) { log.trace("Updated lease for client session id (" + clientSessionId + ")"); }
+ }
}
}
}
@@ -1791,7 +1857,7 @@
{
if(leaseManagement && invokerSessionId != null)
{
- if(trace) { log.trace("Checking lease for client session id: " + invokerSessionId); }
+ if(trace) { log.trace("Checking lease for invoker session id: " + invokerSessionId); }
Lease clientLease = (Lease)clientLeases.get(invokerSessionId);
if(clientLease == null)
More information about the jboss-remoting-commits
mailing list