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

Ron Sigal ron_sigal at yahoo.com
Fri Jan 26 02:57:01 EST 2007


  User: rsigal  
  Date: 07/01/26 02:57:01

  Modified:    src/main/org/jboss/remoting/transport/socket  Tag:
                        remoting_2_x MicroSocketClientInvoker.java
  Log:
  JBREM-598:  transport() can use timeout value in metadata for a single invocation.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.16.2.13 +46 -13    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.12
  retrieving revision 1.16.2.13
  diff -u -b -r1.16.2.12 -r1.16.2.13
  --- MicroSocketClientInvoker.java	25 Jan 2007 01:07:10 -0000	1.16.2.12
  +++ MicroSocketClientInvoker.java	26 Jan 2007 07:57:01 -0000	1.16.2.13
  @@ -5,6 +5,7 @@
   import org.jboss.remoting.ConnectionFailedException;
   import org.jboss.remoting.InvokerLocator;
   import org.jboss.remoting.RemoteClientInvoker;
  +import org.jboss.remoting.ServerInvoker;
   import org.jboss.remoting.Version;
   import org.jboss.remoting.serialization.ClassLoaderUtility;
   import org.jboss.remoting.marshal.Marshaller;
  @@ -32,7 +33,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.12 $
  + * @version $Revision: 1.16.2.13 $
    */
   public class MicroSocketClientInvoker extends RemoteClientInvoker
   {
  @@ -306,8 +307,40 @@
         long start = System.currentTimeMillis();
         SocketWrapper socketWrapper = null;
   
  -      int retryCount = 0;
         boolean oneway = false;
  +      int tempTimeout = -1;
  +      int savedTimeout = -1;
  +      
  +      if(metadata != null)
  +      {
  +         // check to see if is one way invocation and return if is
  +         Object val = metadata.get(org.jboss.remoting.Client.ONEWAY_FLAG);
  +         if(val != null && val instanceof String && Boolean.valueOf((String)val).booleanValue())
  +         {
  +            if(trace) { log.trace(this + " sent oneway invocation, so not waiting for response, returning null"); }
  +            oneway = true;
  +         }
  +         
  +         // look for temporary timeout values
  +         String tempTimeoutString = (String) metadata.get(ServerInvoker.TIMEOUT);
  +         {
  +            if (tempTimeoutString != null)
  +            {
  +               try
  +               {
  +                  tempTimeout = Integer.valueOf(tempTimeoutString).intValue();
  +                  log.debug(this + " setting timeout to " + tempTimeout + " for this invocation");
  +               }
  +               catch (Exception e)
  +               {
  +                  log.warn("Could not convert " + ServerInvoker.TIMEOUT + " value of " + 
  +                            tempTimeoutString + " to an integer value.");
  +               }
  +            }
  +         }
  +      }
  +      
  +      int retryCount = 0;
         SocketException sockEx = null;
   
         for (; retryCount < numberOfCallRetries; retryCount++)
  @@ -323,6 +356,12 @@
                  "socket connection for " + locator, e);
            }
   
  +         if (tempTimeout >= 0)
  +         {
  +            savedTimeout = socketWrapper.getTimeout();
  +            socketWrapper.setTimeout(tempTimeout);
  +         }
  +         
            long end = System.currentTimeMillis() - start;
            getSocketTime += end;
   
  @@ -345,17 +384,6 @@
               writeTime += end;
               start = System.currentTimeMillis();
   
  -            // check to see if is one way invocation and return if is
  -            if(metadata != null)
  -            {
  -               Object val = metadata.get(org.jboss.remoting.Client.ONEWAY_FLAG);
  -               if(val != null && val instanceof String && Boolean.valueOf((String)val).booleanValue())
  -               {
  -                  if(trace) { log.trace(this + " sent oneway invocation, so not waiting for response, returning socket to the pool"); }
  -                  oneway = true;
  -               }
  -            }
  -            
               if (!oneway)
               {
                  InputStream inputStream = socketWrapper.getInputStream();
  @@ -373,6 +401,11 @@
   
               end = System.currentTimeMillis() - start;
               readTime += end;
  +            
  +            if (tempTimeout >= 0)
  +            {
  +               socketWrapper.setTimeout(savedTimeout);
  +            }
            }
            catch (SocketException sex)
            {
  
  
  



More information about the jboss-cvs-commits mailing list