[jboss-remoting-commits] JBoss Remoting SVN: r5126 - remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting.

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Mon May 4 21:46:25 EDT 2009


Author: ron.sigal at jboss.com
Date: 2009-05-04 21:46:25 -0400 (Mon, 04 May 2009)
New Revision: 5126

Modified:
   remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/ConnectionValidator.java
Log:
JBREM-1112 (and others to be named): Doesn't need to call notifyListeners() if stopLeaseOnFailure is true.

Modified: remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/ConnectionValidator.java
===================================================================
--- remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/ConnectionValidator.java	2009-05-05 01:42:48 UTC (rev 5125)
+++ remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/ConnectionValidator.java	2009-05-05 01:46:25 UTC (rev 5126)
@@ -468,6 +468,44 @@
 
    // Package protected ----------------------------------------------------------------------------
 
+   void notifyListeners(Throwable thr)
+   {
+      final Throwable t = thr;
+      synchronized (lock)
+      {
+         if (stopped)
+         {
+            return;
+         }
+         stopped = true;
+         log.debug(this + " is stopped.  No more listeners will be accepted.");
+         
+         Iterator itr = listeners.keySet().iterator();
+         while (itr.hasNext())
+         {
+            final ConnectionListener listener = (ConnectionListener) itr.next();
+            Set clients = (Set) listeners.get(listener);
+            Iterator itr2 = clients.iterator();
+            while (itr2.hasNext())
+            {
+               final Client client  = (Client) itr2.next();
+               new Thread()
+               {
+                  public void run()
+                  {
+                     log.debug(ConnectionValidator.this + " calling " + listener + ".handleConnectionException() for " + client);
+                     listener.handleConnectionException(t, client);
+                  }
+               }.start();
+            }
+         }
+         
+         listeners.clear();
+      }
+      
+      stop();
+   }
+   
    // Protected ------------------------------------------------------------------------------------
 
    // Private --------------------------------------------------------------------------------------
@@ -626,7 +664,7 @@
 
       try
       {
-      TimerUtil.schedule(this, pingPeriod);
+          TimerUtil.schedule(this, pingPeriod);
       }
       catch (Exception e)
       {
@@ -727,43 +765,43 @@
       return result;
    }
 
-   private void notifyListeners(Throwable thr)
-   {
-      final Throwable t = thr;
-      synchronized (lock)
-      {
-         if (stopped)
-         {
-            return;
-         }
-         stopped = true;
-         log.debug(this + " is stopped.  No more listeners will be accepted.");
-         
-         Iterator itr = listeners.keySet().iterator();
-         while (itr.hasNext())
-         {
-            final ConnectionListener listener = (ConnectionListener) itr.next();
-            Set clients = (Set) listeners.get(listener);
-            Iterator itr2 = clients.iterator();
-            while (itr2.hasNext())
-            {
-               final Client client  = (Client) itr2.next();
-               new Thread()
-               {
-                  public void run()
-                  {
-                     log.debug(ConnectionValidator.this + " calling " + listener + ".handleConnectionException() for " + client);
-                     listener.handleConnectionException(t, client);
-                  }
-               }.start();
-            }
-         }
-         
-         listeners.clear();
-      }
-      
-      stop();
-   }
+//   void notifyListeners(Throwable thr)
+//   {
+//      final Throwable t = thr;
+//      synchronized (lock)
+//      {
+//         if (stopped)
+//         {
+//            return;
+//         }
+//         stopped = true;
+//         log.debug(this + " is stopped.  No more listeners will be accepted.");
+//         
+//         Iterator itr = listeners.keySet().iterator();
+//         while (itr.hasNext())
+//         {
+//            final ConnectionListener listener = (ConnectionListener) itr.next();
+//            Set clients = (Set) listeners.get(listener);
+//            Iterator itr2 = clients.iterator();
+//            while (itr2.hasNext())
+//            {
+//               final Client client  = (Client) itr2.next();
+//               new Thread()
+//               {
+//                  public void run()
+//                  {
+//                     log.debug(ConnectionValidator.this + " calling " + listener + ".handleConnectionException() for " + client);
+//                     listener.handleConnectionException(t, client);
+//                  }
+//               }.start();
+//            }
+//         }
+//         
+//         listeners.clear();
+//      }
+//      
+//      stop();
+//   }
 
    // Inner classes --------------------------------------------------------------------------------
 
@@ -808,23 +846,31 @@
 //               
 //               if (invoker != null)
 //               {
-               if (leasePinger == null)
+//               if (leasePinger == null)
+//               {
+//                  leasePinger = sharedInvoker.getLeasePinger();
+//               }
+               if (leasePinger != null)
                {
-                  leasePinger = sharedInvoker.getLeasePinger();
+                  log.debug(ConnectionValidator.this + " shutting down lease pinger: " + leasePinger);
+                  int disconnectTimeout = (failureDisconnectTimeout == -1) ? client.getDisconnectTimeout() : failureDisconnectTimeout;
+                  // MicroRemoteClientInvoker.terminateLease() will call LeasePinger.stopPing(), which will call
+                  // Client.disconnectAndNotify() for all Clients with registered ConnectionListeners, and
+                  // Client.disconnectAndNotify() will call ConnectionValidator.notifyListeners().
+                  sharedInvoker.terminateLease(null, disconnectTimeout, leasePinger);
                }
-               log.debug(ConnectionValidator.this + " shutting down lease pinger: " + leasePinger);
-                  int disconnectTimeout = (failureDisconnectTimeout == -1) ? client.getDisconnectTimeout() : failureDisconnectTimeout;
-                  sharedInvoker.terminateLease(null, disconnectTimeout);
-//               }
-//               else
-//               {
+               else
+               {
 //                  log.debug(ConnectionValidator.this + " unable to shut down lease pinger: " + leasePinger + ". Client must have shut down");
-//               }
+                  log.debug(ConnectionValidator.this + " unable to shut down null lease pinger. Client must have shut down");
+               }
                
                cancel();
             }
-            
-            notifyListeners(new Exception("Could not connect to server!"));
+            else
+            {
+                notifyListeners(new Exception("Could not connect to server!"));
+            }
          }
       }
    }




More information about the jboss-remoting-commits mailing list