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

Ron Sigal ron_sigal at yahoo.com
Wed Aug 29 02:07:27 EDT 2007


  User: rsigal  
  Date: 07/08/29 02:07:27

  Modified:    src/main/org/jboss/remoting  Tag: remoting_2_x
                        LeasePinger.java
  Log:
  JBREM-783: Synchronized with branch remoting_2_2_0_GA: reverted to version before JBREM-783 changes.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.8.2.15  +37 -85    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.2.14
  retrieving revision 1.8.2.15
  diff -u -b -r1.8.2.14 -r1.8.2.15
  --- LeasePinger.java	2 Aug 2007 06:36:12 -0000	1.8.2.14
  +++ LeasePinger.java	29 Aug 2007 06:07:27 -0000	1.8.2.15
  @@ -44,15 +44,9 @@
   
      private long pingPeriod = -1;
      private int disconnectTimeout = DEFAULT_DISCONNECT_TIMEOUT;
  -   private boolean started;
   
      // Constructors ---------------------------------------------------------------------------------
   
  -   public LeasePinger(ClientInvoker invoker, String invokerSessionID)
  -   {
  -      this(invoker, invokerSessionID, DEFAULT_LEASE_PERIOD);
  -   }
  -   
      public LeasePinger(ClientInvoker invoker, String invokerSessionID, long defaultLeasePeriod)
      {
         this.invoker = invoker;
  @@ -63,25 +57,12 @@
   
      // Public ---------------------------------------------------------------------------------------
   
  -   public void setDefaultLeasePeriod(long defaultLeasePeriod)
  -   {
  -      this.defaultPingPeriod = defaultLeasePeriod;
  -      if (defaultLeasePeriod < this.pingPeriod)
  -         this.pingPeriod = defaultLeasePeriod;
  -   }
  -   
      public void startPing()
      {
         if(trace) { log.trace(this + " starting lease timer with ping period of " + pingPeriod); }
   
         timerTask = new LeaseTimerTask(this);
         timer.schedule(timerTask, pingPeriod, pingPeriod);
  -      started = true;
  -   }
  -   
  -   public boolean isStarted()
  -   {
  -      return started;
      }
   
      public void stopPing()
  @@ -152,16 +133,45 @@
      
      public boolean removeClient(String sessionID)
      {
  -      // removeClient() has been reorganized to support more nimble use of
  -      // synchronization blocks - see JBREM-783.
  -      
  -      // In particular, the network i/o formerly found in removeClient() has been
  -      // moved to the new method disconnectClient().
  -      
         boolean isLastClientLease = false;
   
         if(trace) { log.trace(this + " removing client with session ID " + sessionID); }
         
  +      ClientHolder holder = (ClientHolder)clients.remove(sessionID);
  +      
  +      if (holder != null)
  +      {
  +         // send disconnect for this client
  +         try
  +         {
  +            Map clientMap = new HashMap();
  +            clientMap.put(ClientHolder.CLIENT_HOLDER_KEY, holder);
  +            
  +            // If disconnectTimeout == 0, skip network i/o.
  +            if (disconnectTimeout != 0)
  +            {
  +               if (disconnectTimeout > 0)
  +                  clientMap.put(ServerInvoker.TIMEOUT, Integer.toString(disconnectTimeout));
  +               
  +               InvocationRequest ir = new InvocationRequest(invokerSessionID, null, "$DISCONNECT$",
  +                     clientMap, null, null);
  +               invoker.invoke(ir);
  +               
  +               if(trace) { log.trace(this + " sent out disconnect message to server for lease tied to client with session ID " + sessionID); }
  +            }
  +         }
  +         catch (Throwable throwable)
  +         {
  +            log.warn(this + " failed sending disconnect for client lease for " +
  +                  "client with session ID " + sessionID);
  +         }
  +      }
  +      else
  +      {
  +         log.warn(this + " tried to remove lease for client with session ID " + sessionID +
  +         ", but no such lease was found");
  +      }
  +      
         if (clients.isEmpty())
         {
            isLastClientLease = true;
  @@ -202,52 +212,6 @@
         return isLastClientLease;
      }
      
  -   public void disconnectClient(String sessionID)
  -   {
  -      if(trace) { log.trace(this + " disconnection client with session ID " + sessionID); }
  -
  -      ClientHolder holder = (ClientHolder)clients.remove(sessionID);
  -      
  -      if (holder != null)
  -      {
  -         // send disconnect for this client
  -         Map clientMap = new HashMap();
  -         clientMap.put(ClientHolder.CLIENT_HOLDER_KEY, holder);
  -
  -         // If disconnectTimeout == 0, skip network i/o.
  -         if (disconnectTimeout != 0)
  -         {
  -            if (disconnectTimeout > 0)
  -               clientMap.put(ServerInvoker.TIMEOUT, Integer.toString(disconnectTimeout));
  -
  -            InvocationRequest ir = new InvocationRequest(invokerSessionID, null, "$DISCONNECT$",
  -                                                               clientMap, null, null);
  -            try
  -            {
  -               invoker.invoke(ir);
  -            }
  -            catch (Throwable throwable)
  -            {
  -               log.error(this + " failed sending disconnect for client lease for " +
  -                     "client with session ID " + sessionID, throwable);
  -               return;
  -            }
  -
  -            if(trace) { log.trace(this + " sent out disconnect message to server for lease tied to client with session ID " + sessionID); }
  -         }
  -      }
  -      else
  -      {
  -         log.warn(this + " tried to remove lease for client with session ID " + sessionID +
  -         ", but no such lease was found");
  -      }
  -   }
  -   
  -   public Map getClients()
  -   {
  -      return clients;
  -   }
  -
      public long getLeasePeriod(String sessionID)
      {
         if (timerTask == null)
  @@ -273,18 +237,6 @@
   
      // Package protected ----------------------------------------------------------------------------
      
  -   /**
  -    * Simply removes references to all clients.  Should only be called on a LeasePinger
  -    * which was never started.
  -    */
  -   protected void purgeClients()
  -   {
  -      if (!started)
  -      {
  -         clients.clear();
  -      }
  -   }
  -   
      // Protected ------------------------------------------------------------------------------------
   
      
  
  
  



More information about the jboss-cvs-commits mailing list