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

Ovidiu Feodorov ovidiu.feodorov at jboss.com
Wed Jan 10 05:30:33 EST 2007


  User: ovidiu  
  Date: 07/01/10 05:30:33

  Modified:    src/main/org/jboss/remoting/transport/socket   Tag:
                        remoting_2_x MicroSocketClientInvoker.java
                        SocketClientInvoker.java
  Log:
  Proposed fix for http://jira.jboss.org/jira/browse/JBREM-662
  Even if functionality changes will be refactored, I would kindly request
  that the extra log statements to be left in place.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.16.2.3  +37 -11    JBossRemoting/src/main/org/jboss/remoting/transport/socket/MicroSocketClientInvoker.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: MicroSocketClientInvoker.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossRemoting/src/main/org/jboss/remoting/transport/socket/MicroSocketClientInvoker.java,v
  retrieving revision 1.16.2.2
  retrieving revision 1.16.2.3
  diff -u -b -r1.16.2.2 -r1.16.2.3
  --- MicroSocketClientInvoker.java	19 Dec 2006 06:01:42 -0000	1.16.2.2
  +++ MicroSocketClientInvoker.java	10 Jan 2007 10:30:33 -0000	1.16.2.3
  @@ -31,7 +31,7 @@
    *
    * @author <a href="mailto:jhaynie at vocalocity.net">Jeff Haynie</a>
    * @author <a href="mailto:telrod at e2technologies.net">Tom Elrod</a>
  - * @version $Revision: 1.16.2.2 $
  + * @version $Revision: 1.16.2.3 $
    */
   public class MicroSocketClientInvoker extends RemoteClientInvoker
   {
  @@ -133,6 +133,11 @@
   
      private boolean reuseAddress = true;
   
  +   // flag being set on true by a disconnect request. If trying to create a connection goes on in a
  +   // loop and a disconnect request arrives, this flag will be used to sent this information into
  +   // the connect loop
  +   private volatile boolean bailOut;
  +
      public MicroSocketClientInvoker(InvokerLocator locator)
            throws IOException
      {
  @@ -236,7 +241,6 @@
      /**
       * Indicates if will check socket connection when returning from
       * pool by sending byte to the server.  Default value will be false.
  -    * @return
       */
      public boolean checkingConnection()
      {
  @@ -246,7 +250,6 @@
      /**
       * Returns if newly created sockets will have SO_REUSEADDR enabled.
       * Default is for this to be true.
  -    * @return
       */
      public boolean getReuseAddress()
      {
  @@ -263,6 +266,14 @@
         reuseAddress = reuse;
      }
   
  +
  +   public synchronized void disconnect()
  +   {
  +      if (isTraceEnabled) { log.trace(this + " disconnecting ..."); }
  +      bailOut = true;
  +      super.disconnect();
  +   }
  +
      protected void finalize() throws Throwable
      {
         disconnect();
  @@ -284,8 +295,6 @@
       * Each implementation of the remote client invoker should have
       * a default data type that is uses in the case it is not specified
       * in the invoker locator uri.
  -    *
  -    * @return
       */
      protected String getDefaultDataType()
      {
  @@ -374,7 +383,8 @@
            }
            catch (SocketException sex)
            {
  -            log.debug(sex);
  +            log.debug(this + " got SocketException " + sex);
  +
               try
               {
                  socketWrapper.close();
  @@ -382,6 +392,7 @@
               }
               catch (Exception ex)
               {
  +               if (isTraceEnabled) { log.trace(this + " couldn't successfully close its socketWrapper", ex); }
               }
   
               /**
  @@ -399,6 +410,8 @@
            }
            catch (Exception ex)
            {
  +            log.debug(this + " got Exception " + ex);
  +
               try
               {
                  socketWrapper.close();
  @@ -479,7 +492,7 @@
      protected Object handleException(Exception ex, SocketWrapper socketWrapper)
            throws ClassNotFoundException, MarshalException
      {
  -      log.error("Got marshalling exception, exiting", ex);
  +      log.error(this + " got marshalling exception, exiting ...", ex);
         if (ex instanceof ClassNotFoundException)
         {
            //TODO: -TME Add better exception handling for class not found exception
  @@ -487,7 +500,7 @@
            throw (ClassNotFoundException) ex;
         }
   
  -      throw new MarshalException("Failed to communicate.  Problem during marshalling/unmarshalling", ex);
  +      throw new MarshalException("Failed to communicate. Problem during marshalling/unmarshalling.", ex);
      }
   
      private Object versionedRead(InputStream inputStream, UnMarshaller unmarshaller, int version) throws IOException, ClassNotFoundException
  @@ -584,6 +597,9 @@
            while (it.hasNext())
            {
               ServerAddress sa = (ServerAddress) it.next();
  +
  +            if (isTraceEnabled) { log.trace("clearing pool for " + sa); }
  +
               clearPool(sa);
            }
         }
  @@ -678,6 +694,7 @@
                  pooled = getPooledConnection();
               }
            }
  +
            synchronized(usedPoolLock)
            {
               if (pooled != null)
  @@ -691,18 +708,28 @@
                  // not in use, then need create a new connection which
                  // will be latered returned to the pool (thus filling out
                  // the pool, since starts out empty).
  +
  +               if (bailOut)
  +               {
  +                  log.debug(this + " has been concurrently disconnected, " +
  +                     "bailing out from trying to create a new connection");
  +                  break;
  +               }
  +
                  Socket socket = null;
  +               long timestamp = System.currentTimeMillis();
                  try
                  {
                     if (isTraceEnabled)
                     {
  -                     log.trace("Creating socket number " + (counter++));
  +                     log.trace(this + " creating socket number " + (counter++) + ", attempt number " + (i + 1));
                     }
                     socket = createSocket(address.address, address.port);
                  }
                  catch (Exception ex)
                  {
  -                  log.debug(ex);
  +                  log.debug(this + " got Exception " + ex + ", creation attempt took " + (System.currentTimeMillis() - timestamp) + " ms");
  +
                     if (i + 1 < numberOfRetries)
                     {
                        Thread.sleep(1);
  @@ -815,5 +842,4 @@
         return address.address;
      }
   
  -
   }
  
  
  
  1.38.2.1  +8 -3      JBossRemoting/src/main/org/jboss/remoting/transport/socket/SocketClientInvoker.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: SocketClientInvoker.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossRemoting/src/main/org/jboss/remoting/transport/socket/SocketClientInvoker.java,v
  retrieving revision 1.38
  retrieving revision 1.38.2.1
  diff -u -b -r1.38 -r1.38.2.1
  --- SocketClientInvoker.java	20 Sep 2006 04:22:24 -0000	1.38
  +++ SocketClientInvoker.java	10 Jan 2007 10:30:33 -0000	1.38.2.1
  @@ -39,7 +39,7 @@
    *
    * @author <a href="mailto:jhaynie at vocalocity.net">Jeff Haynie</a>
    * @author <a href="mailto:telrod at e2technologies.net">Tom Elrod</a>
  - * @version $Revision: 1.38 $
  + * @version $Revision: 1.38.2.1 $
    */
   public class SocketClientInvoker extends MicroSocketClientInvoker
   {
  @@ -91,8 +91,7 @@
            {
               try
               {
  -               int nVal = Integer.valueOf((String) val).intValue();
  -               timeout = nVal;
  +               timeout = Integer.valueOf((String) val).intValue();;
                  log.debug("Setting SocketClientInvoker::timeout to: " + timeout);
               }
               catch (Exception e)
  @@ -247,4 +246,10 @@
      {
         return timeout;
      }
  +
  +   public String toString()
  +   {
  +      return "SocketClientInvoker[" + Integer.toHexString(hashCode()) + ", " +
  +         locator.getProtocol() + "://" + locator.getHost() + ":" + locator.getPort() + "]";
  +   }
   }
  
  
  



More information about the jboss-cvs-commits mailing list