[jboss-remoting-commits] JBoss Remoting SVN: r3505 - remoting2/branches/2.2/src/main/org/jboss/remoting.

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Mon Feb 25 20:36:09 EST 2008


Author: ron.sigal at jboss.com
Date: 2008-02-25 20:36:09 -0500 (Mon, 25 Feb 2008)
New Revision: 3505

Modified:
   remoting2/branches/2.2/src/main/org/jboss/remoting/ServerInvoker.java
Log:
JBREM-892: Added facility for responding to ConnectionValidator based on status of Lease..

Modified: remoting2/branches/2.2/src/main/org/jboss/remoting/ServerInvoker.java
===================================================================
--- remoting2/branches/2.2/src/main/org/jboss/remoting/ServerInvoker.java	2008-02-26 00:50:56 UTC (rev 3504)
+++ remoting2/branches/2.2/src/main/org/jboss/remoting/ServerInvoker.java	2008-02-26 01:36:09 UTC (rev 3505)
@@ -211,6 +211,8 @@
     * registered as ConnectionListeners.
     */
    public static final String REGISTER_CALLBACK_LISTENER = "registerCallbackListener";
+   
+   public static final String INVOKER_SESSION_ID = "invokerSessionId";
 
 
    // Static ---------------------------------------------------------------------------------------
@@ -699,11 +701,23 @@
          // check to see if this is a is alive ping
          if ("$PING$".equals(param))
          {
-            // if checking lease, need to update lease flag
+            Map metadata = invocation.getRequestPayload();
+            if (metadata != null)
+            {
+               String invokerSessionId = (String) metadata.get(INVOKER_SESSION_ID);
+               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);
+                  return new Boolean(response);
+               }
+            }
+            
             if (leaseManagement)
             {
-               //NOTE we only update the lease when we receive a PING, not for
-               //all invocations
+               // Otherwise, it's a normal PING.  NOTE we only update the lease when we
+               // receive a PING, not for all invocations.
                updateClientLease(invocation);
             }
 
@@ -1754,6 +1768,28 @@
       }
    }
 
+   private boolean checkForClientLease(String invokerSessionId)
+   {
+      if(leaseManagement && invokerSessionId != null)
+      {
+         if(trace) { log.trace("Checking lease for client session id: " + invokerSessionId); }
+
+         Lease clientLease = (Lease)clientLeases.get(invokerSessionId);
+         if(clientLease == null)
+         {
+            if(trace) { log.trace("No lease established for invoker session id (" + invokerSessionId + ")"); }
+            return false;
+         }
+         else
+         {
+            if(trace) { log.trace("Found lease for invoker session id (" + invokerSessionId + ")"); }
+            return true;
+         }
+      }
+
+      return false;
+   }
+
    /**
     * Takes the real invocation from the client out of the OnewayInvocation and then executes the
     * invoke() with the real invocation on a seperate thread.




More information about the jboss-remoting-commits mailing list