[jboss-cvs] JBossRemoting/src/main/org/jboss/remoting ...

Tom Elrod tom.elrod at jboss.com
Tue Dec 12 00:16:50 EST 2006


  User: telrod  
  Date: 06/12/12 00:16:50

  Modified:    src/main/org/jboss/remoting  LeasePinger.java
  Log:
  JBREM-649 - fixed thread sync issue for lease pinging
  
  Revision  Changes    Path
  1.9       +12 -9     JBossRemoting/src/main/org/jboss/remoting/LeasePinger.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: LeasePinger.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossRemoting/src/main/org/jboss/remoting/LeasePinger.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -b -r1.8 -r1.9
  --- LeasePinger.java	21 Sep 2006 15:59:04 -0000	1.8
  +++ LeasePinger.java	12 Dec 2006 05:16:50 -0000	1.9
  @@ -1,5 +1,6 @@
   package org.jboss.remoting;
   
  +import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap;
   import org.jboss.logging.Logger;
   import org.jboss.remoting.transport.ClientInvoker;
   import org.jboss.remoting.util.TimerUtil;
  @@ -21,7 +22,7 @@
      private long pingPeriod = -1;
      private long defaultPingPeriod = -1;
      private String invokerSessionId = null;
  -   private Map clients = new HashMap();
  +   private Map clients = new ConcurrentHashMap();
      private TimerTask timerTask = null;
   
      private static final Logger log = Logger.getLogger(LeasePinger.class);
  @@ -35,7 +36,7 @@
         this.invokerSessionId = invokerSessionId;
      }
   
  -   public void startPing()
  +   public synchronized void startPing()
      {
         if(isTraceEnabled)
         {
  @@ -45,7 +46,7 @@
         TimerUtil.schedule(timerTask, pingPeriod);
      }
   
  -   public void stopPing()
  +   public synchronized void stopPing()
      {
         if(isTraceEnabled)
         {
  @@ -69,7 +70,7 @@
         }
      }
   
  -   protected void sendClientPing()
  +   protected synchronized void sendClientPing()
      {
         if (client != null)
         {
  @@ -92,9 +93,11 @@
                            "Currently managing lease for following clients:\n" + clientSessionIds);
               } // end trace
   
  -            Map clientsClone = new HashMap();
  -            clientsClone.put(ClientHolder.CLIENT_HOLDER_KEY, clients);
  -            client.invoke(new InvocationRequest(invokerSessionId, null, "$PING$", clientsClone, null, null));
  +            Map clientsClone = new ConcurrentHashMap();
  +            clientsClone.putAll(clients);
  +            Map requestClients = new ConcurrentHashMap();
  +            requestClients.put(ClientHolder.CLIENT_HOLDER_KEY, clientsClone);
  +            client.invoke(new InvocationRequest(invokerSessionId, null, "$PING$", requestClients, null, null));
            }
            catch (Throwable throwable)
            {
  @@ -103,7 +106,7 @@
         }
      }
   
  -   public void addClient(String sessionId, Map configuration, long leasePeriod)
  +   public synchronized void addClient(String sessionId, Map configuration, long leasePeriod)
      {
         if (leasePeriod <= 0)
         {
  @@ -134,7 +137,7 @@
         }
      }
   
  -   public boolean removeClient(String sessionId)
  +   public synchronized boolean removeClient(String sessionId)
      {
         boolean isLastClientLease = false;
   
  
  
  



More information about the jboss-cvs-commits mailing list