[Jboss-cvs] JBossAS SVN: r55341 - in branches/JBoss_4_0_3_SP1_CP: cluster/src/main/org/jboss/invocation/pooled/server server/src/main/org/jboss/invocation/pooled/interfaces server/src/main/org/jboss/invocation/pooled/server testsuite/imports testsuite/src/main/org/jboss/test/testbeancluster/bean testsuite/src/main/org/jboss/test/testbeancluster/interfaces testsuite/src/main/org/jboss/test/testbeancluster/test testsuite/src/resources/testbeancluster tools/etc/buildmagic

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sat Aug 5 11:39:34 EDT 2006


Author: ryan.campbell at jboss.com
Date: 2006-08-05 11:39:32 -0400 (Sat, 05 Aug 2006)
New Revision: 55341

Added:
   branches/JBoss_4_0_3_SP1_CP/server/src/main/org/jboss/invocation/pooled/interfaces/PooledInvokerProxy2.java
   branches/JBoss_4_0_3_SP1_CP/testsuite/src/main/org/jboss/test/testbeancluster/test/PooledHAUnitTestCase.java
   branches/JBoss_4_0_3_SP1_CP/testsuite/src/resources/testbeancluster/pooledha-ejb-jar.xml
   branches/JBoss_4_0_3_SP1_CP/testsuite/src/resources/testbeancluster/pooledha-jboss.xml
Modified:
   branches/JBoss_4_0_3_SP1_CP/cluster/src/main/org/jboss/invocation/pooled/server/PooledInvokerHA.java
   branches/JBoss_4_0_3_SP1_CP/server/src/main/org/jboss/invocation/pooled/interfaces/PooledInvokerProxy.java
   branches/JBoss_4_0_3_SP1_CP/server/src/main/org/jboss/invocation/pooled/interfaces/ServerAddress.java
   branches/JBoss_4_0_3_SP1_CP/server/src/main/org/jboss/invocation/pooled/server/PooledInvoker.java
   branches/JBoss_4_0_3_SP1_CP/testsuite/imports/test-jars.xml
   branches/JBoss_4_0_3_SP1_CP/testsuite/src/main/org/jboss/test/testbeancluster/bean/StatefulSessionBean.java
   branches/JBoss_4_0_3_SP1_CP/testsuite/src/main/org/jboss/test/testbeancluster/interfaces/StatefulSession.java
   branches/JBoss_4_0_3_SP1_CP/tools/etc/buildmagic/buildmagic.ent
Log:
merged JBAS-3300

Modified: branches/JBoss_4_0_3_SP1_CP/cluster/src/main/org/jboss/invocation/pooled/server/PooledInvokerHA.java
===================================================================
--- branches/JBoss_4_0_3_SP1_CP/cluster/src/main/org/jboss/invocation/pooled/server/PooledInvokerHA.java	2006-08-05 15:17:44 UTC (rev 55340)
+++ branches/JBoss_4_0_3_SP1_CP/cluster/src/main/org/jboss/invocation/pooled/server/PooledInvokerHA.java	2006-08-05 15:39:32 UTC (rev 55341)
@@ -10,6 +10,7 @@
 
 import org.jboss.system.Registry;
 import java.rmi.MarshalledObject;
+import java.rmi.NoSuchObjectException;
 import javax.management.ObjectName;
 import org.jboss.invocation.Invocation;
 import org.jboss.invocation.MarshalledInvocation;
@@ -121,6 +122,11 @@
 
          // Extract the ObjectName, the rest is still marshalled
          ObjectName mbean = (ObjectName) Registry.lookup(invocation.getObjectName());
+         if( mbean == null )
+         {
+            throw new GenericClusteringException(GenericClusteringException.COMPLETED_NO, 
+               "target is not/no more registered on this node");            
+         }
          long clientViewId = ((Long)invocation.getValue("CLUSTER_VIEW_ID")).longValue();
 
          HATarget target = (HATarget)beanMap.get(invocation.getObjectName());

Modified: branches/JBoss_4_0_3_SP1_CP/server/src/main/org/jboss/invocation/pooled/interfaces/PooledInvokerProxy.java
===================================================================
--- branches/JBoss_4_0_3_SP1_CP/server/src/main/org/jboss/invocation/pooled/interfaces/PooledInvokerProxy.java	2006-08-05 15:17:44 UTC (rev 55340)
+++ branches/JBoss_4_0_3_SP1_CP/server/src/main/org/jboss/invocation/pooled/interfaces/PooledInvokerProxy.java	2006-08-05 15:39:32 UTC (rev 55341)
@@ -1,10 +1,24 @@
 /*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
 package org.jboss.invocation.pooled.interfaces;
 
 import java.io.IOException;
@@ -17,30 +31,41 @@
 import java.io.ObjectOutputStream;
 import java.io.EOFException;
 import java.io.OptionalDataException;
+import java.io.UnsupportedEncodingException;
+import java.io.InterruptedIOException;
 import java.net.Socket;
+import java.net.SocketException;
 import java.rmi.MarshalledObject;
 import java.rmi.NoSuchObjectException;
 import java.rmi.ServerException;
 import java.rmi.ConnectException;
-import java.util.HashMap;
 import java.util.Iterator;
+import java.util.Map;
+import java.util.List;
 import java.util.LinkedList;
 
 import javax.transaction.TransactionRolledbackException;
 import javax.transaction.SystemException;
+import javax.net.ssl.SSLSocket;
+import javax.net.ssl.HandshakeCompletedListener;
+import javax.net.ssl.HandshakeCompletedEvent;
+import javax.net.ssl.SSLException;
 
 import org.jboss.invocation.Invocation;
 import org.jboss.invocation.Invoker;
 import org.jboss.tm.TransactionPropagationContextFactory;
 import org.jboss.logging.Logger;
+import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
 
 
+
 /**
  * Client socket connections are pooled to avoid the overhead of
  * making a connection.  RMI seems to do a new connection with each
  * request.
  *
  * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @author Scott.Stark at jboss.org
  * @version $Revision$
  */
 public class PooledInvokerProxy
@@ -64,7 +89,7 @@
     * remote method invocations.
     */
    protected static TransactionPropagationContextFactory tpcFactory = null;
-   
+
    //  @todo: MOVE TO TRANSACTION
    // 
    // TPC factory
@@ -72,66 +97,228 @@
       tpcFactory = tpcf;
    }
 
-   // Performance measurements
+   // Simple performance measurements, not thread safe
    public static long getSocketTime = 0;
    public static long readTime = 0;
    public static long writeTime = 0;
    public static long serializeTime = 0;
    public static long deserializeTime = 0;
+   /** The number of times a connection has been obtained from a pool */
    public static long usedPooled = 0;
+   /** The number of connections in use */
+   private static int inUseCount = 0;
+   /** The number of socket connections made */
+   private static long socketConnectCount = 0;
+   /** The number of socket close calls made */
+   private static long socketCloseCount = 0;
 
-
    /**
     * Set number of retries in getSocket method
     */
    public static int MAX_RETRIES = 10;
 
+   /** A class wide pool Map<ServerAddres, LinkedList<ClientSocket>> */
+   protected static final Map connectionPools = new ConcurrentReaderHashMap();
 
-   protected static HashMap connectionPools = new HashMap();
-
    /**
     * connection information
     */
    protected ServerAddress address;
-   
+
    /**
     * Pool for this invoker.  This is shared between all
     * instances of proxies attached to a specific invoker
+    * This should not be serializable, but is for backward compatibility.
     */
    protected LinkedList pool = null;
    /** */
    protected int maxPoolSize;
-   /** The */
+   /** The number of times to retry after seeing a ConnectionException */
    protected int retryCount = 1;
    /** The logging trace flag */
    private transient boolean trace;
 
+   /**
+    * An encapsulation of a client connection
+    */
    protected static class ClientSocket
+      implements HandshakeCompletedListener
    {
       public ObjectOutputStream out;
       public ObjectInputStream in;
       public Socket socket;
       public int timeout;
+      public String sessionID;
+      private boolean handshakeComplete = false;
+      private boolean trace;
+
       public ClientSocket(Socket socket, int timeout) throws Exception
       {
          this.socket = socket;
+         trace = log.isTraceEnabled();
+         boolean needHandshake = false;
+
+         if( socket instanceof SSLSocket )
+         {
+            SSLSocket ssl = (SSLSocket) socket;
+            ssl.addHandshakeCompletedListener(this);
+            if( trace )
+               log.trace("Starting SSL handshake");
+            needHandshake = true;
+            handshakeComplete = false;
+            ssl.startHandshake();
+         }
          socket.setSoTimeout(timeout);
          this.timeout = timeout;
          out = new OptimizedObjectOutputStream(new BufferedOutputStream(socket.getOutputStream()));
          out.flush();
          in = new OptimizedObjectInputStream(new BufferedInputStream(socket.getInputStream()));
+         if( needHandshake )
+         {
+            // Loop waiting for the handshake to complete
+            socket.setSoTimeout(1000);
+            for(int n = 0; handshakeComplete == false && n < 60; n ++)
+            {
+               try
+               {
+                  int b = in.read();
+               }
+               catch(SSLException e)
+               {
+                  if( trace )
+                     log.trace("Error while waiting for handshake to complete", e);
+                  throw e;
+               }
+               catch(IOException e)
+               {
+                  if( trace )
+                     log.trace("Handshaked read()", e);
+               }
+            }
+            if( handshakeComplete == false )
+               throw new SSLException("Handshaked failed to complete in 60 seconds");
+            // Restore the original timeout
+            socket.setSoTimeout(timeout);
+         }
+
       }
 
+      public void handshakeCompleted(HandshakeCompletedEvent event)
+      {
+         handshakeComplete = true;
+         byte[] id = event.getSession().getId();
+         try
+         {
+            sessionID = new String(id, "UTF-8");
+         }
+         catch (UnsupportedEncodingException e)
+         {
+            log.warn("Failed to create session id using UTF-8, using default", e);
+            sessionID = new String(id);
+         }
+         if( trace )
+         {
+            log.trace("handshakeCompleted, event="+event+", sessionID="+sessionID);
+         }
+      }
+
+      public String toString()
+      {
+         StringBuffer tmp = new StringBuffer("ClientSocket@");
+         tmp.append(System.identityHashCode(this));
+         tmp.append('[');
+         tmp.append("socket=");
+         tmp.append(socket.toString());
+         tmp.append(']');
+         return tmp.toString();
+      }
+
+      /**
+       * @todo should this be handled with weak references as this should
+       * work better with gc
+       */
       protected void finalize()
       {
          if (socket != null)
          {
-            try { socket.close(); } catch (Exception ignored) {}
+            if( trace )
+               log.trace("Closing socket in finalize: "+socket);
+            try
+            {
+               socketCloseCount --;
+               socket.close();
+            }
+            catch (Exception ignored) {}
+            finally
+            {
+               socket = null;
+            }
          }
       }
    }
 
    /**
+    * Clear all class level stats
+    */
+   public static void clearStats()
+   {
+      getSocketTime = 0;
+      readTime = 0;
+      writeTime = 0;
+      serializeTime = 0;
+      deserializeTime = 0;
+      usedPooled = 0;      
+   }
+
+   /**
+    * @return the active number of client connections
+    */
+   public static long getInUseCount()
+   {
+      return inUseCount;
+   }
+
+   /**
+    * @return the number of times a connection was returned from a pool
+    */
+   public static long getUsedPooled()
+   {
+      return usedPooled;
+   }
+   public static long getSocketConnectCount()
+   {
+      return socketConnectCount;
+   }
+   public static long getSocketCloseCount()
+   {
+      return socketCloseCount;
+   }
+
+   /**
+    * @return the total number of pooled connections across all ServerAddresses
+    */
+   public static int getTotalPoolCount()
+   {
+      int count = 0;
+      Iterator iter = connectionPools.values().iterator();
+      while( iter.hasNext() )
+      {
+         List pool = (List) iter.next();
+         if( pool != null )
+            count += pool.size();
+      }
+      return count;
+   }
+
+   /**
+    * @return the proxy local pool count
+    */
+   public long getPoolCount()
+   {
+      return pool.size();
+   }
+
+   /**
     * Exposed for externalization.
     */
    public PooledInvokerProxy()
@@ -140,7 +327,6 @@
       trace = log.isTraceEnabled();
    }
 
-   
    /**
     * Create a new Proxy.
     *
@@ -173,17 +359,24 @@
             int size = thepool.size();
             for (int i = 0; i < size; i++)
             {
-               ClientSocket socket = (ClientSocket)thepool.removeFirst();
+               ClientSocket cs = null;
                try
                {
+                  ClientSocket socket = (ClientSocket)thepool.removeFirst();
+                  cs = socket;
                   if( trace )
-                     log.trace("Closing, ClientSocket: "+socket.socket);
+                     log.trace("Closing, ClientSocket: "+socket);
+                  socketCloseCount --;
                   socket.socket.close();
-                  socket.socket = null;
                }
                catch (Exception ignored)
                {
                }
+               finally
+               {
+                  if( cs != null )
+                     cs.socket = null;
+               }
             }
          }
       }
@@ -224,8 +417,8 @@
    protected ClientSocket getConnection() throws Exception
    {
       Socket socket = null;
+      ClientSocket cs = null;
 
-
       //
       // Need to retry a few times
       // on socket connection because, at least on Windoze,
@@ -240,82 +433,150 @@
       // 
       for (int i = 0; i < retryCount; i++)
       {
-         synchronized(pool)
+         ClientSocket pooled = getPooledConnection();
+         if (pooled != null)
          {
-            if (pool.size() > 0)
-            {
-               ClientSocket pooled = getPooledConnection();
-               if (pooled != null)
-               {
-                  usedPooled++;
-                  return pooled;
-               }
-            }
+            usedPooled++;
+            inUseCount ++;
+            return pooled;
          }
-         
+
          try
          {
             if( trace)
-               log.trace("Connecting to addr: "+address.address+", port: "+address.port);
+            {
+               log.trace("Connecting to addr: "+address.address
+                  +", port: "+address.port
+                  +",clientSocketFactory: "+address.clientSocketFactory
+                  +",enableTcpNoDelay: "+address.enableTcpNoDelay
+                  +",timeout: "+address.timeout);
+            }
             if( address.clientSocketFactory != null )
                socket = address.clientSocketFactory.createSocket(address.address, address.port);
             else
                socket = new Socket(address.address, address.port);
+            socketConnectCount ++;
             if( trace )
-               log.trace("Connected: "+socket);
+               log.trace("Connected, socket="+socket);
+
+            socket.setTcpNoDelay(address.enableTcpNoDelay);
+            cs = new ClientSocket(socket, address.timeout);
+            inUseCount ++;
+            if( trace )
+            {
+               log.trace("New ClientSocket: "+cs
+                  +", usedPooled="+ usedPooled
+                  +", inUseCount="+ inUseCount
+                  +", socketConnectCount="+ socketConnectCount
+                  +", socketCloseCount="+ socketCloseCount
+               );
+            }
             break;
          }
-         catch (ConnectException ex)
+         catch (Exception ex)
          {
-            if( trace )
-               log.trace("Connect failed", ex);
-            if (i + 1 < retryCount)
+            if( ex instanceof InterruptedIOException || ex instanceof SocketException )
             {
-               Thread.sleep(1);
-               continue;
+               if( trace )
+                  log.trace("Connect failed", ex);
+               if (i + 1 < retryCount)
+               {
+                  Thread.sleep(1);
+                  continue;
+               }
             }
             throw ex;
          }
       }
-      socket.setTcpNoDelay(address.enableTcpNoDelay);
-      return new ClientSocket(socket, address.timeout); 
+      // Should not happen
+      if( cs == null )
+         throw new ConnectException("Failed to obtain a socket, tries="+retryCount);
+      return cs;
    }
- 
-   protected ClientSocket getPooledConnection()
+
+   protected synchronized ClientSocket getPooledConnection()
    {
       ClientSocket socket = null;
       while (pool.size() > 0)
       {
-         socket = (ClientSocket)pool.removeFirst();
          try
          {
+            synchronized( pool )
+            {
+               socket = (ClientSocket)pool.removeFirst();
+            }
             // Test to see if socket is alive by send ACK message
+            if( trace )
+               log.trace("Checking pooled socket: "+socket+", address: "+socket.socket.getLocalSocketAddress());
             final byte ACK = 1;
             socket.out.writeByte(ACK);
             socket.out.flush();
             socket.in.readByte();
+            if( trace )
+            {
+               log.trace("Using pooled ClientSocket: "+socket
+                  +", usedPooled="+ usedPooled
+                  +", inUseCount="+ inUseCount
+                  +", socketConnectCount="+ socketConnectCount
+                  +", socketCloseCount="+ socketCloseCount
+               );
+            }
             return socket;
          }
          catch (Exception ex)
          {
+            if( trace )
+               log.trace("Failed to validate pooled socket: "+socket, ex);
             try
             {
-               socket.socket.close();
+               if( socket != null )
+               {
+                  socketCloseCount --;
+                  socket.socket.close();
+               }
             }
-            catch (Exception ignored) {}
+            catch (Exception ignored)
+            {
+            }
+            finally
+            {
+               if( socket != null )
+                  socket.socket = null;
+            }
          }
       }
       return null;
    }
 
    /**
+    * Return a socket to the pool
+    * @param socket
+    * @return true if socket was added to the pool, false if the pool
+    *    was full
+    */
+   protected synchronized boolean returnConnection(ClientSocket socket)
+   {
+      boolean pooled = false;
+      synchronized( pool )
+      {
+         if (pool.size() < maxPoolSize)
+         {
+            pool.add(socket);
+            inUseCount --;
+            pooled = true;
+         }
+      }
+      return pooled;
+   }
+
+   /**
     * The name of of the server.
     */
    public String getServerHostName() throws Exception
    {
       return address.address;
    }
-   
+
    /**
     * ???
     *
@@ -340,21 +601,31 @@
    public Object invoke(Invocation invocation)
       throws Exception
    {
+      boolean trace = log.isTraceEnabled();
       // We are going to go through a Remote invocation, switch to a Marshalled Invocation
       PooledMarshalledInvocation mi = new PooledMarshalledInvocation(invocation);
-         
+
       // Set the transaction propagation context
       //  @todo: MOVE TO TRANSACTION
       mi.setTransactionPropagationContext(getTransactionPropagationContext());
 
-
       Object response = null;
       long start = System.currentTimeMillis();
       ClientSocket socket = getConnection();
       long end = System.currentTimeMillis() - start;
       getSocketTime += end;
+      // Add the socket session if it exists
+      if( socket.sessionID != null )
+      {
+         mi.setValue("SESSION_ID", socket.sessionID);
+         if( trace )
+            log.trace("Added SESSION_ID to invocation");
+      }
+
       try
       {
+         if( trace )
+            log.trace("Sending invocation to: "+mi.getObjectName());
          socket.out.writeObject(mi);
          socket.out.reset();
          socket.out.writeObject(Boolean.TRUE); // for stupid ObjectInputStream reset
@@ -373,38 +644,43 @@
       }
       catch (Exception ex)
       {
+         if( trace )
+            log.trace("Failure during invoke", ex);
          try
          {
+            socketCloseCount --;
             socket.socket.close();
          }
          catch (Exception ignored) {}
-         //System.out.println("got read exception, exiting");
-         throw new ConnectException("Failed to communicate", ex);
+         finally
+         {
+            socket.socket = null;
+         }
+         throw new java.rmi.ConnectException("Failure during invoke", ex);
       }
-      
-      //System.out.println("put back in pool");
+
       // Put socket back in pool for reuse
-      synchronized (pool)
+      if( returnConnection(socket) == false )
       {
-         if (pool.size() < maxPoolSize)
+         // Failed, close the socket
+         if( trace )
+            log.trace("Closing unpooled socket: "+socket);
+         try
          {
-            pool.add(socket);
+            socketCloseCount --;
+            socket.socket.close();
          }
-         else
+         catch (Exception ignored) {}
+         finally
          {
-            try
-            {
-               socket.socket.close();
-            }
-            catch (Exception ignored) {}
+            socket.socket = null;
          }
       }
-      
+
       // Return response
-      //System.out.println("return response");
 
       try
-      { 
+      {
          if (response instanceof Exception)
          {
             throw ((Exception)response);
@@ -413,7 +689,7 @@
          {
             return ((MarshalledObject)response).get();
          }
-         return response; 
+         return response;
       }
       catch (ServerException ex)
       {
@@ -430,7 +706,7 @@
             throw (TransactionRolledbackException) ex.detail;
          }
          throw ex;
-      }  
+      }
    }
 
    /**
@@ -441,7 +717,7 @@
     * @serialData retryCount int
     * @param out
     * @throws IOException
-    */ 
+    */
    public void writeExternal(final ObjectOutput out)
       throws IOException
    {
@@ -452,7 +728,7 @@
       out.writeInt(WIRE_VERSION);
       out.writeInt(retryCount);
    }
- 
+
    public void readExternal(final ObjectInput in)
       throws IOException, ClassNotFoundException
    {

Copied: branches/JBoss_4_0_3_SP1_CP/server/src/main/org/jboss/invocation/pooled/interfaces/PooledInvokerProxy2.java (from rev 55340, branches/JBoss_4_0_3_JBAS-3300/server/src/main/org/jboss/invocation/pooled/interfaces/PooledInvokerProxy2.java)

Modified: branches/JBoss_4_0_3_SP1_CP/server/src/main/org/jboss/invocation/pooled/interfaces/ServerAddress.java
===================================================================
--- branches/JBoss_4_0_3_SP1_CP/server/src/main/org/jboss/invocation/pooled/interfaces/ServerAddress.java	2006-08-05 15:17:44 UTC (rev 55340)
+++ branches/JBoss_4_0_3_SP1_CP/server/src/main/org/jboss/invocation/pooled/interfaces/ServerAddress.java	2006-08-05 15:39:32 UTC (rev 55341)
@@ -1,12 +1,28 @@
 /*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
 package org.jboss.invocation.pooled.interfaces;
 
 import java.io.Serializable;
+import java.io.IOException;
 import javax.net.SocketFactory;
 
 /**
@@ -75,6 +91,8 @@
       this.port = port;
       this.enableTcpNoDelay = enableTcpNoDelay;
       this.hashCode = address.hashCode() + port;
+      if( enableTcpNoDelay )
+         this.hashCode ++;
       this.timeout = timeout;
       this.clientSocketFactory = clientSocketFactory;
    }
@@ -88,15 +106,14 @@
    {
       try
       {
+         // Compare this to obj
          ServerAddress o = (ServerAddress) obj;
-         if (o.hashCode != hashCode)
+         if (port != o.port)
             return false;
-         if (port != port)
+         if (address.equals(o.address) == false)
             return false;
-         if (!o.address.equals(address))
+         if (enableTcpNoDelay != o.enableTcpNoDelay)
             return false;
-         if (o.enableTcpNoDelay != enableTcpNoDelay)
-            return false;
          return true;
       }
       catch (Throwable e)
@@ -110,4 +127,20 @@
       return hashCode;
    }
 
+   /**
+    * Create the transient hashCode 
+    * @param in
+    * @throws IOException
+    * @throws ClassNotFoundException
+    */
+   private void readObject(java.io.ObjectInputStream in)
+     throws IOException, ClassNotFoundException
+   {
+      // Trigger default serialization
+      in.defaultReadObject();
+      // Build the hashCode
+      this.hashCode = address.hashCode() + port;
+      if( enableTcpNoDelay )
+         this.hashCode ++;
+   }
 }

Modified: branches/JBoss_4_0_3_SP1_CP/server/src/main/org/jboss/invocation/pooled/server/PooledInvoker.java
===================================================================
--- branches/JBoss_4_0_3_SP1_CP/server/src/main/org/jboss/invocation/pooled/server/PooledInvoker.java	2006-08-05 15:17:44 UTC (rev 55340)
+++ branches/JBoss_4_0_3_SP1_CP/server/src/main/org/jboss/invocation/pooled/server/PooledInvoker.java	2006-08-05 15:39:32 UTC (rev 55341)
@@ -16,6 +16,7 @@
 import java.security.AccessController;
 import java.security.PrivilegedActionException;
 import java.lang.reflect.Method;
+import java.rmi.NoSuchObjectException;
 import javax.management.ObjectName;
 import javax.naming.InitialContext;
 import javax.transaction.Transaction;
@@ -351,6 +352,11 @@
          PooledMarshalledInvocation mi = (PooledMarshalledInvocation) invocation;
          invocation.setTransaction(importTPC(mi.getTransactionPropagationContext()));
          ObjectName mbean = (ObjectName) Registry.lookup(invocation.getObjectName());
+         if( mbean == null )
+         {
+            System.err.println("NoSuchObjectException: "+invocation.getObjectName());
+            throw new NoSuchObjectException("Failed to find target for objectName: "+invocation.getObjectName());
+         }
 
          // The cl on the thread should be set in another interceptor
          Object obj = serverAction.invoke(mbean, "invoke",

Modified: branches/JBoss_4_0_3_SP1_CP/testsuite/imports/test-jars.xml
===================================================================
--- branches/JBoss_4_0_3_SP1_CP/testsuite/imports/test-jars.xml	2006-08-05 15:17:44 UTC (rev 55340)
+++ branches/JBoss_4_0_3_SP1_CP/testsuite/imports/test-jars.xml	2006-08-05 15:39:32 UTC (rev 55341)
@@ -4545,6 +4545,20 @@
         <include name="cif-ds.xml"/>
       </fileset>
     </ear>
+
+    <jar destfile="${build.lib}/pooledha.jar">
+       <fileset dir="${build.classes}">
+          <include name="org/jboss/test/testbean/interfaces/**"/>
+          <include name="org/jboss/test/testbean/bean/**"/>
+          <include name="org/jboss/test/testbeancluster/interfaces/**"/>
+          <include name="org/jboss/test/testbeancluster/bean/**"/>
+       </fileset>
+       <zipfileset dir="${build.resources}/testbeancluster"
+          fullpath="META-INF/ejb-jar.xml" includes="pooledha-ejb-jar.xml"/>
+       <zipfileset dir="${build.resources}/testbeancluster"
+          fullpath="META-INF/jboss.xml" includes="pooledha-jboss.xml"/>
+    </jar>
+
   </target>
 
   <!-- threading test -->

Modified: branches/JBoss_4_0_3_SP1_CP/testsuite/src/main/org/jboss/test/testbeancluster/bean/StatefulSessionBean.java
===================================================================
--- branches/JBoss_4_0_3_SP1_CP/testsuite/src/main/org/jboss/test/testbeancluster/bean/StatefulSessionBean.java	2006-08-05 15:17:44 UTC (rev 55340)
+++ branches/JBoss_4_0_3_SP1_CP/testsuite/src/main/org/jboss/test/testbeancluster/bean/StatefulSessionBean.java	2006-08-05 15:39:32 UTC (rev 55341)
@@ -26,7 +26,8 @@
    // Attributes ----------------------------------------------------
    
    public transient VMID myId = null; 
-   
+   private long callCount;
+
    // Static --------------------------------------------------------
    
    // Constructors --------------------------------------------------
@@ -36,7 +37,7 @@
       super.ejbCreate(name);
 
       this.myId = new VMID();
-      log.debug("My ID: " + this.myId);
+      log.info("My ID: " + this.myId);
    }
 
    public void ejbActivate() throws RemoteException
@@ -61,10 +62,17 @@
    
    public NodeAnswer getNodeState() throws RemoteException
    {
+      callCount ++;
       NodeAnswer state = new NodeAnswer(this.myId, this.name);
       log.debug("getNodeState, " + state);
+      if( callCount % 100 == 0 )
+         System.out.println("CallCount: "+callCount);
       return state;
    }
+   public long getCallCount()
+   {
+      return callCount;
+   }
 
    public void setName(String name) throws RemoteException
    {
@@ -80,14 +88,4 @@
          throw new EJBException("Trying to assign value on node " + this.myId + " but this node expected: " + node);
    }
 
-   // Y overrides ---------------------------------------------------
-   
-   // Package protected ---------------------------------------------
-   
-   // Protected -----------------------------------------------------
-   
-   // Private -------------------------------------------------------
-   
-   // Inner classes -------------------------------------------------
-
 }

Modified: branches/JBoss_4_0_3_SP1_CP/testsuite/src/main/org/jboss/test/testbeancluster/interfaces/StatefulSession.java
===================================================================
--- branches/JBoss_4_0_3_SP1_CP/testsuite/src/main/org/jboss/test/testbeancluster/interfaces/StatefulSession.java	2006-08-05 15:17:44 UTC (rev 55340)
+++ branches/JBoss_4_0_3_SP1_CP/testsuite/src/main/org/jboss/test/testbeancluster/interfaces/StatefulSession.java	2006-08-05 15:39:32 UTC (rev 55341)
@@ -31,4 +31,6 @@
    public NodeAnswer getNodeState () throws RemoteException;
    public void setName (String name) throws RemoteException;
    public void setNameOnlyOnNode (String name, VMID node) throws RemoteException;
+   public long getCallCount()
+      throws RemoteException;
 }

Copied: branches/JBoss_4_0_3_SP1_CP/testsuite/src/main/org/jboss/test/testbeancluster/test/PooledHAUnitTestCase.java (from rev 55340, branches/JBoss_4_0_3_JBAS-3300/testsuite/src/main/org/jboss/test/testbeancluster/test/PooledHAUnitTestCase.java)

Copied: branches/JBoss_4_0_3_SP1_CP/testsuite/src/resources/testbeancluster/pooledha-ejb-jar.xml (from rev 55340, branches/JBoss_4_0_3_JBAS-3300/testsuite/src/resources/testbeancluster/pooledha-ejb-jar.xml)

Copied: branches/JBoss_4_0_3_SP1_CP/testsuite/src/resources/testbeancluster/pooledha-jboss.xml (from rev 55340, branches/JBoss_4_0_3_JBAS-3300/testsuite/src/resources/testbeancluster/pooledha-jboss.xml)

Modified: branches/JBoss_4_0_3_SP1_CP/tools/etc/buildmagic/buildmagic.ent
===================================================================
--- branches/JBoss_4_0_3_SP1_CP/tools/etc/buildmagic/buildmagic.ent	2006-08-05 15:17:44 UTC (rev 55340)
+++ branches/JBoss_4_0_3_SP1_CP/tools/etc/buildmagic/buildmagic.ent	2006-08-05 15:39:32 UTC (rev 55341)
@@ -102,7 +102,7 @@
   <property name="version.tag" value="SP1"/>
   <property name="version.name" value="Zion"/>
   <!-- This must be set to the CVS tag for any release -->
-  <property name="version.cvstag" value="JBoss_4_0_3_SP1"/>
+  <property name="version.cvstag" value="JBoss_4_0_3_JBAS-3300"/>
 
   <!-- Manifest version info -->
   <property name="specification.title" value="JBoss"/>




More information about the jboss-cvs-commits mailing list