[jboss-cvs] JBossAS SVN: r103696 - in trunk: cluster/src/main/java/org/jboss/ha/framework/server/util and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Apr 8 08:47:08 EDT 2010


Author: vblagojevic at jboss.com
Date: 2010-04-08 08:47:08 -0400 (Thu, 08 Apr 2010)
New Revision: 103696

Added:
   trunk/cluster/src/main/java/org/jboss/ha/framework/server/AddressPort.java
   trunk/cluster/src/main/java/org/jboss/ha/framework/server/ClusterNodeFactory.java
   trunk/testsuite/src/main/org/jboss/test/cluster/testutil/TestClusterNodeFactory.java
Modified:
   trunk/cluster/src/main/java/org/jboss/ha/framework/server/ClusterNodeImpl.java
   trunk/cluster/src/main/java/org/jboss/ha/framework/server/ClusterPartition.java
   trunk/cluster/src/main/java/org/jboss/ha/framework/server/JChannelFactory.java
   trunk/cluster/src/main/java/org/jboss/ha/framework/server/RspFilterAdapter.java
   trunk/cluster/src/main/java/org/jboss/ha/framework/server/util/PingJndi.java
   trunk/cluster/src/main/java/org/jboss/ha/framework/server/util/TopologyMonitorService.java
   trunk/component-matrix/pom.xml
   trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/DRMTestCase.java
   trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/JChannelFactoryOverrideUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/JChannelFactoryUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/LookupSucceededFilterUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/PreferredMasterElectionPolicyUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/cluster/lock/ClusteredLockManagerTestBase.java
Log:
[JBAS-7251] - Upgrade JGroups to a 2.10 release
[JBAS-7253] - Don't assume Address object available from Channel is an IpAddress

Added: trunk/cluster/src/main/java/org/jboss/ha/framework/server/AddressPort.java
===================================================================
--- trunk/cluster/src/main/java/org/jboss/ha/framework/server/AddressPort.java	                        (rev 0)
+++ trunk/cluster/src/main/java/org/jboss/ha/framework/server/AddressPort.java	2010-04-08 12:47:08 UTC (rev 103696)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ha.framework.server;
+
+import java.io.Serializable;
+import java.net.InetAddress;
+
+public class AddressPort implements Serializable
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = -1878072081329209058L;
+
+   private InetAddress addr;
+
+   private Integer port;
+
+   public AddressPort(InetAddress addr, Integer port)
+   {
+      this.addr = addr;
+      this.port = port;
+   }
+
+   public Integer getPort()
+   {
+      return this.port;
+   }
+
+   public InetAddress getInetAddress()
+   {
+      return this.addr;
+   }
+
+   public String getHostAddress()
+   {
+      return this.addr.getHostAddress();
+   }
+
+   public String getHostName()
+   {
+      return this.addr.getHostName();
+   }
+
+   @Override
+   public String toString()
+   {
+      return "{host(" + this.addr + "), port(" + this.port + ")}";
+   }
+}
\ No newline at end of file

Added: trunk/cluster/src/main/java/org/jboss/ha/framework/server/ClusterNodeFactory.java
===================================================================
--- trunk/cluster/src/main/java/org/jboss/ha/framework/server/ClusterNodeFactory.java	                        (rev 0)
+++ trunk/cluster/src/main/java/org/jboss/ha/framework/server/ClusterNodeFactory.java	2010-04-08 12:47:08 UTC (rev 103696)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ha.framework.server;
+
+import org.jboss.ha.framework.interfaces.ClusterNode;
+import org.jgroups.Address;
+
+/**
+ * Factory for ClusterNode(s)
+ * 
+ * 
+ * @see ClusterNodeImpl
+ * 
+ * @author Vladimir Blagojevic
+ */
+public interface ClusterNodeFactory
+{
+
+   public ClusterNode getClusterNode(Address address);
+
+}

Modified: trunk/cluster/src/main/java/org/jboss/ha/framework/server/ClusterNodeImpl.java
===================================================================
--- trunk/cluster/src/main/java/org/jboss/ha/framework/server/ClusterNodeImpl.java	2010-04-08 12:31:09 UTC (rev 103695)
+++ trunk/cluster/src/main/java/org/jboss/ha/framework/server/ClusterNodeImpl.java	2010-04-08 12:47:08 UTC (rev 103696)
@@ -22,10 +22,8 @@
 package org.jboss.ha.framework.server;
 
 import java.net.InetAddress;
-import java.net.UnknownHostException;
-
 import org.jboss.ha.framework.interfaces.ClusterNode;
-import org.jgroups.stack.IpAddress;
+import org.jgroups.Address;
 
 /**
  * Replacement for a JG IpAddress that doesn't base its representation
@@ -37,6 +35,7 @@
  *
  * @author  <a href="mailto:sacha.labourey at jboss.org">Sacha Labourey</a>.
  * @author Brian Stansberry
+ * @author Vladimir Blagojevic
  * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
  * @version $Revision$
  */
@@ -45,34 +44,35 @@
    implements ClusterNode
 {
    // Constants -----------------------------------------------------
-
+   
    /** The serialVersionUID */
-   private static final long serialVersionUID = 2713397663824031616L;
+   private static final long serialVersionUID = -1831036833785680731L;
    
    // Attributes ----------------------------------------------------
-   
+  
    protected final String id;
    protected String jgId = null;
-   protected final IpAddress originalJGAddress;
+   protected final Address originalJGAddress;
+   protected final AddressPort address;
 
    // Static --------------------------------------------------------
    
    // Constructors --------------------------------------------------
        
-   public ClusterNodeImpl(IpAddress jgAddress)
+   public ClusterNodeImpl(Address jgAddress, AddressPort a)
    {
-      if (jgAddress.getAdditionalData() == null)
+      this.address = a;
+      this.originalJGAddress = jgAddress;
+      if (a != null)
       {
-         this.id = jgAddress.getIpAddress().getHostAddress() + ":" + jgAddress.getPort();
+         this.id = a.getHostAddress() + ":" + a.getPort();
       }
       else
       {
-         this.id = new String(jgAddress.getAdditionalData());
+         this.id = jgAddress.toString();
       }
-
-      this.originalJGAddress = jgAddress;
    }
-
+  
    // Public --------------------------------------------------------
 
    public String getName()
@@ -90,17 +90,17 @@
       return jgId;
    }
 
-   public IpAddress getOriginalJGAddress()
+   public Address getOriginalJGAddress()
    {
       return this.originalJGAddress;
    }
    public InetAddress getIpAddress()
    {
-      return this.originalJGAddress.getIpAddress();
+      return this.address.getInetAddress();
    }
    public int getPort()
    {
-      return this.originalJGAddress.getPort();      
+      return this.address.getPort();      
    }
 
    // Comparable implementation ----------------------------------------------
@@ -154,7 +154,7 @@
    protected String createJGName()
    {
       StringBuffer sb = new StringBuffer();
-      java.net.InetAddress jgIPAddr = originalJGAddress.getIpAddress();
+      java.net.InetAddress jgIPAddr = address.getInetAddress();
       if (jgIPAddr == null)
          sb.append("<null>");
       else
@@ -164,7 +164,7 @@
          else
             sb.append(getShortName(getFastHostName(jgIPAddr)));
       }
-      sb.append(":" + originalJGAddress.getPort());
+      sb.append(":" + address.getPort());
       
       return sb.toString();
    }

Modified: trunk/cluster/src/main/java/org/jboss/ha/framework/server/ClusterPartition.java
===================================================================
--- trunk/cluster/src/main/java/org/jboss/ha/framework/server/ClusterPartition.java	2010-04-08 12:31:09 UTC (rev 103695)
+++ trunk/cluster/src/main/java/org/jboss/ha/framework/server/ClusterPartition.java	2010-04-08 12:47:08 UTC (rev 103696)
@@ -38,6 +38,7 @@
 import java.util.Set;
 import java.util.Vector;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.Executor;
 import java.util.concurrent.TimeUnit;
@@ -78,6 +79,7 @@
 import org.jgroups.Address;
 import org.jgroups.Channel;
 import org.jgroups.ChannelFactory;
+import org.jgroups.Event;
 import org.jgroups.ExtendedMembershipListener;
 import org.jgroups.ExtendedMessageListener;
 import org.jgroups.MembershipListener;
@@ -88,6 +90,7 @@
 import org.jgroups.View;
 import org.jgroups.blocks.GroupRequest;
 import org.jgroups.blocks.MethodCall;
+import org.jgroups.blocks.RequestOptions;
 import org.jgroups.blocks.RpcDispatcher;
 import org.jgroups.stack.IpAddress;
 import org.jgroups.util.Rsp;
@@ -102,6 +105,7 @@
  * @author <a href="mailto:bill at burkecentral.com">Bill Burke</a>.
  * @author Scott.Stark at jboss.org
  * @author brian.stansberry at jboss.com
+ * @author Vladimir Blagojevic
  * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
  * @version $Revision$
  */
@@ -111,7 +115,7 @@
                   isRuntime=true)
 public class ClusterPartition
    extends ServiceMBeanSupport
-   implements ExtendedMembershipListener, HAPartition,
+   implements ClusterNodeFactory, ExtendedMembershipListener, HAPartition,
               AsynchEventHandler.AsynchEventProcessor,
               ClusterPartitionMBean
 {
@@ -236,6 +240,7 @@
    private Address localJGAddress = null;
    /** me as a ClusterNode */
    private ClusterNode me = null;
+   private ConcurrentMap<Address, IpAddress> addressMap = new ConcurrentHashMap<Address, IpAddress>();
    /** The JGroups partition channel */
    private Channel channel;
    /** The cluster replicant manager */
@@ -331,10 +336,7 @@
          this.log.debug("Creating Channel for partition " + this.getPartitionName() +
                " using stack " + this.getChannelStackName());
    
-         this.channel = this.createChannel();
-         
-         this.channel.setOpt(Channel.AUTO_RECONNECT, Boolean.TRUE);
-         this.channel.setOpt(Channel.AUTO_GETSTATE, Boolean.TRUE);
+         this.channel = this.createChannel();               
       }
       
       this.log.info("Initializing partition " + this.getPartitionName());
@@ -387,10 +389,10 @@
          
          // get current JG group properties
          this.log.debug("get nodeName");
-         this.localJGAddress = this.channel.getLocalAddress();
-         this.me = new ClusterNodeImpl((IpAddress) this.localJGAddress);
+         this.localJGAddress = this.channel.getAddress();
+         this.me = getClusterNode(localJGAddress);         
 
-         this.verifyNodeIsUnique();
+		 this.verifyNodeIsUnique();
 
          this.fetchState();
          
@@ -530,6 +532,21 @@
 
       this.log.info("Partition " + this.getPartitionName() + " destroyed.");
    }
+   
+   public ClusterNode getClusterNode(Address a)
+   {
+      IpAddress result = addressMap.get(a);
+      if (result == null)
+      {
+         result = (IpAddress) channel.downcall(new Event(Event.GET_PHYSICAL_ADDRESS, a));
+         if (result == null)
+         {
+            throw new IllegalStateException("Address " + a + "not registered in transport layer");
+         }
+         addressMap.put(a, result);
+      }
+      return new ClusterNodeImpl(a, new AddressPort(result.getIpAddress(), result.getPort()));
+   }
 
    /**
     * Adds an alias to our controller context -- the concatenation of
@@ -839,7 +856,7 @@
 
          // Keep a list of other members only for "exclude-self" RPC calls
          this.jgotherMembers = cloneMembers(newView);
-         this.jgotherMembers.remove (this.channel.getLocalAddress());
+         this.jgotherMembers.remove (this.channel.getAddress());
          this.otherMembers = this.translateAddresses (this.jgotherMembers); // TRANSLATE!
          Vector<ClusterNode> translatedNewView = this.translateAddresses (cloneMembers(newView));
          this.logHistory ("New view: " + translatedNewView + " with viewId: " + this.currentViewId +
@@ -1078,7 +1095,8 @@
       boolean trace = this.log.isTraceEnabled();
 
       MethodCall m = new MethodCall(objName + "." + methodName, args, types);
-      RspFilterAdapter rspFilter = filter == null ? null : new RspFilterAdapter(filter);
+      RspFilterAdapter rspFilter = filter == null ? null : new RspFilterAdapter(filter,this);
+      RequestOptions ro = new RequestOptions( GroupRequest.GET_ALL, methodTimeout, false, rspFilter);
       
       if(this.channel.flushSupported())
       {
@@ -1091,7 +1109,7 @@
             this.log.trace("callMethodOnCluster(true), objName="+objName
                +", methodName="+methodName+", members="+this.jgotherMembers);
          }
-         rsp = this.dispatcher.callRemoteMethods(this.jgotherMembers, m, GroupRequest.GET_ALL, methodTimeout, false, false, rspFilter);
+         rsp = this.dispatcher.callRemoteMethods(this.jgotherMembers, m, ro);
       }
       else
       {
@@ -1100,7 +1118,8 @@
             this.log.trace("callMethodOnCluster(false), objName="+objName
                +", methodName="+methodName+", members="+this.members);
          }
-         rsp = this.dispatcher.callRemoteMethods(null, m, GroupRequest.GET_ALL, methodTimeout, false, false, rspFilter);
+         
+         rsp = this.dispatcher.callRemoteMethods(null, m, ro);
       }
 
       return this.processResponseList(rsp, trace);
@@ -1159,9 +1178,8 @@
           false == excludeSelf)
       {
          coordinatorOnly.addElement(this.jgmembers.elementAt(0));
-      }
-      
-      RspList rsp = this.dispatcher.callRemoteMethods(coordinatorOnly, m, GroupRequest.GET_ALL, methodTimeout);
+      }      
+      RspList rsp = this.dispatcher.callRemoteMethods(coordinatorOnly, m, new RequestOptions( GroupRequest.GET_ALL, methodTimeout));
 
       return this.processResponseList(rsp, trace);
    }
@@ -1196,7 +1214,7 @@
           this.log.trace("callMethodOnNode( objName="+serviceName
              +", methodName="+methodName);
        }
-       Object rc = this.dispatcher.callRemoteMethod(((ClusterNodeImpl)targetNode).getOriginalJGAddress(), m, GroupRequest.GET_FIRST, methodTimeout);
+       Object rc = this.dispatcher.callRemoteMethod(((ClusterNodeImpl)targetNode).getOriginalJGAddress(), m, new RequestOptions( GroupRequest.GET_FIRST, methodTimeout));
        if (rc != null)
        {
           Object item = rc;
@@ -1264,7 +1282,7 @@
           this.log.trace("callAsyncMethodOnNode( objName="+serviceName
              +", methodName="+methodName);
        }
-       this.dispatcher.callRemoteMethod(((ClusterNodeImpl)targetNode).getOriginalJGAddress(), m, GroupRequest.GET_NONE, methodTimeout);
+       this.dispatcher.callRemoteMethod(((ClusterNodeImpl)targetNode).getOriginalJGAddress(), m, new RequestOptions( GroupRequest.GET_NONE, methodTimeout));
    }
 
    private ArrayList<Object> processResponseList(RspList rsp, boolean trace)
@@ -1319,7 +1337,7 @@
       boolean trace = this.log.isTraceEnabled();
 
       MethodCall m = new MethodCall(objName + "." + methodName, args, types);
-
+      RequestOptions ro = new RequestOptions( GroupRequest.GET_NONE, this.getMethodCallTimeout());
       if(this.channel.flushSupported())
       {
      	 this.flushBlockGate.await(this.getStateTransferTimeout());
@@ -1331,7 +1349,7 @@
             this.log.trace("callAsynchMethodOnCluster(true), objName="+objName
                +", methodName="+methodName+", members="+this.jgotherMembers);
          }
-         this.dispatcher.callRemoteMethods(this.jgotherMembers, m, GroupRequest.GET_NONE, this.getMethodCallTimeout());
+         this.dispatcher.callRemoteMethods(this.jgotherMembers, m, ro);
       }
       else
       {
@@ -1340,7 +1358,7 @@
             this.log.trace("callAsynchMethodOnCluster(false), objName="+objName
                +", methodName="+methodName+", members="+this.members);
          }
-         this.dispatcher.callRemoteMethods(null, m, GroupRequest.GET_NONE, this.getMethodCallTimeout());
+         this.dispatcher.callRemoteMethods(null, m, ro);
       }
    }
    
@@ -1676,7 +1694,7 @@
       Vector<ClusterNode> result = new Vector<ClusterNode>(addresses.size());
       for (Address address: addresses)
       {
-         result.add(new ClusterNodeImpl((IpAddress) address));
+         result.add(getClusterNode(address));
       }
 
       return result;
@@ -2198,7 +2216,8 @@
       private RpcHandler(Channel channel, MessageListener l, MembershipListener l2, Object server_obj,
             boolean deadlock_detection)
       {
-         super(channel, l, l2, server_obj, deadlock_detection);
+         //deadlock detection has been deprecated since JGroups 2.10
+         super(channel, l, l2, server_obj);
       }
       
       /**

Modified: trunk/cluster/src/main/java/org/jboss/ha/framework/server/JChannelFactory.java
===================================================================
--- trunk/cluster/src/main/java/org/jboss/ha/framework/server/JChannelFactory.java	2010-04-08 12:31:09 UTC (rev 103695)
+++ trunk/cluster/src/main/java/org/jboss/ha/framework/server/JChannelFactory.java	2010-04-08 12:47:08 UTC (rev 103696)
@@ -68,7 +68,7 @@
 import org.jgroups.conf.ProtocolStackConfigurator;
 import org.jgroups.jmx.JmxConfigurator;
 import org.jgroups.protocols.TP;
-import org.jgroups.stack.IpAddress;
+import org.jgroups.Address;
 import org.jgroups.stack.Protocol;
 import org.jgroups.stack.ProtocolStack;
 import org.jgroups.util.DefaultThreadFactory;
@@ -1275,7 +1275,7 @@
    
    private void setChannelUniqueId(Channel channel)
    {
-      IpAddress address = (IpAddress) channel.getLocalAddress();
+      Address address = channel.getAddress();
       if (address == null)
       {
          // We push the independent name in the protocol stack before connecting to the cluster
@@ -1287,23 +1287,8 @@
          
          HashMap<String, byte[]> staticNodeName = new HashMap<String, byte[]>();
          staticNodeName.put("additional_data", this.nodeName.getBytes());
-         channel.down(new Event(Event.CONFIG, staticNodeName));
-         
-      }
-      else if (address.getAdditionalData() == null)
-      {
-         if (channel.isConnected())
-         {
-            throw new IllegalStateException("Underlying JChannel was " +
-                    "connected before additional_data was set");
-         }
-      }
-      else if (this.nodeName == null || "".equals(this.nodeName))
-      {         
-         this.nodeName = new String(address.getAdditionalData());
-         log.warn("Field nodeName was not set but mux channel already had " +
-                "additional data -- setting nodeName to " + nodeName);
-      }
+         channel.downcall(new Event(Event.CONFIG, staticNodeName));         
+      }    
    }
 
    private String generateUniqueNodeName ()
@@ -1590,7 +1575,8 @@
       {
          allNames = new ArrayList<ObjectName>();
          ObjectName channelName = new ObjectName(getDomain() + ":type=channel,cluster=" + channelId);
-         getServer().registerMBean(new org.jgroups.jmx.JChannel(ch), channelName);
+         JmxConfigurator conf = new JmxConfigurator();
+         getServer().registerMBean(conf.asDynamicMBean(ch), channelName);
          allNames.add(channelName);
          if (isExposeProtocols())
          {
@@ -1599,36 +1585,9 @@
             List<Protocol> protocols=stack.getProtocols();
             
             for(Protocol prot : protocols)
-            {
-                org.jgroups.jmx.Protocol p=null;
-                try {
-                   String prot_name = prot.getClass().getName();
-                   String clname = prot_name.replaceFirst("org.jgroups.", "org.jgroups.jmx.");
-                   Class<?> cl = Util.loadClass(clname, JmxConfigurator.class);
-                   if (cl != null)
-                   {
-                      p = (org.jgroups.jmx.Protocol) cl.newInstance();
-                   }
-                }
-                catch(ClassNotFoundException e) 
-                {
-                   // ignore;
-                }
-                catch(Throwable e) {
-                    log.error("failed creating a JMX wrapper instance for " + prot, e);
-                    p = null;
-                }
-                if(p == null)
-                {
-                   // Use default
-                   p = new org.jgroups.jmx.Protocol(prot);
-                }
-                else
-                {
-                   p.attachProtocol(prot);
-                }
+            {                                
                 ObjectName prot_name=new ObjectName(baseName + ",protocol=" + prot.getName());
-                server.registerMBean(p, prot_name);
+                server.registerMBean(conf.asDynamicMBean(prot), prot_name);
                 allNames.add(prot_name);
             }
          }

Modified: trunk/cluster/src/main/java/org/jboss/ha/framework/server/RspFilterAdapter.java
===================================================================
--- trunk/cluster/src/main/java/org/jboss/ha/framework/server/RspFilterAdapter.java	2010-04-08 12:31:09 UTC (rev 103695)
+++ trunk/cluster/src/main/java/org/jboss/ha/framework/server/RspFilterAdapter.java	2010-04-08 12:47:08 UTC (rev 103696)
@@ -24,7 +24,6 @@
 import org.jboss.ha.framework.interfaces.ResponseFilter;
 import org.jgroups.Address;
 import org.jgroups.blocks.RspFilter;
-import org.jgroups.stack.IpAddress;
 
 /**
  * JGroups RspFilter adapter class that delegates work to ResponseFilter, 
@@ -34,16 +33,19 @@
  */
 public class RspFilterAdapter implements RspFilter
 {
-   private ResponseFilter filter;
-   
-   public RspFilterAdapter(ResponseFilter filter)
+   private final ResponseFilter filter;
+
+   private final ClusterNodeFactory factory;
+
+   public RspFilterAdapter(ResponseFilter filter, ClusterNodeFactory factory)
    {
       this.filter = filter;
+      this.factory = factory;
    }
 
    public boolean isAcceptable(Object response, Address sender)
    {
-      return filter.isAcceptable(response, new ClusterNodeImpl((IpAddress)sender));
+      return filter.isAcceptable(response, factory.getClusterNode(sender));
    }
 
    public boolean needMoreResponses()

Modified: trunk/cluster/src/main/java/org/jboss/ha/framework/server/util/PingJndi.java
===================================================================
--- trunk/cluster/src/main/java/org/jboss/ha/framework/server/util/PingJndi.java	2010-04-08 12:31:09 UTC (rev 103695)
+++ trunk/cluster/src/main/java/org/jboss/ha/framework/server/util/PingJndi.java	2010-04-08 12:47:08 UTC (rev 103696)
@@ -28,7 +28,8 @@
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 
-import org.jboss.ha.framework.server.util.TopologyMonitorService.AddressPort;
+import org.jboss.ha.framework.server.AddressPort;
+import org.jboss.ha.framework.server.util.TopologyMonitorService;
 import org.jboss.logging.Logger;
 import org.jboss.system.ServiceMBeanSupport;
 

Modified: trunk/cluster/src/main/java/org/jboss/ha/framework/server/util/TopologyMonitorService.java
===================================================================
--- trunk/cluster/src/main/java/org/jboss/ha/framework/server/util/TopologyMonitorService.java	2010-04-08 12:31:09 UTC (rev 103695)
+++ trunk/cluster/src/main/java/org/jboss/ha/framework/server/util/TopologyMonitorService.java	2010-04-08 12:47:08 UTC (rev 103696)
@@ -33,6 +33,7 @@
 import org.jboss.bootstrap.spi.as.config.JBossASBasedConfigurationInitializer;
 import org.jboss.ha.framework.interfaces.HAPartition;
 import org.jboss.ha.framework.interfaces.HAPartition.AsynchHAMembershipListener;
+import org.jboss.ha.framework.server.AddressPort;
 import org.jboss.ha.framework.server.HAPartitionLocator;
 import org.jboss.logging.Logger;
 import org.jboss.system.ServiceMBeanSupport;
@@ -252,42 +253,4 @@
       }
       return info;
    }
-
-   public static class AddressPort
-   {
-      private InetAddress addr;
-      private Integer port;
-
-      AddressPort(InetAddress addr, Integer port)
-      {
-         this.addr = addr;
-         this.port = port;
-      }
-
-      public Integer getPort()
-      {
-         return this.port;
-      }
-
-      public InetAddress getInetAddress()
-      {
-         return this.addr;
-      }
-
-      public String getHostAddress()
-      {
-         return this.addr.getHostAddress();
-      }
-
-      public String getHostName()
-      {
-         return this.addr.getHostName();
-      }
-
-      @Override
-      public String toString()
-      {
-         return "{host(" + this.addr + "), port(" + this.port + ")}";
-      }
-   }
 }

Modified: trunk/component-matrix/pom.xml
===================================================================
--- trunk/component-matrix/pom.xml	2010-04-08 12:31:09 UTC (rev 103695)
+++ trunk/component-matrix/pom.xml	2010-04-08 12:47:08 UTC (rev 103696)
@@ -74,7 +74,7 @@
     <version.jboss.osgi.xml.binding>2.0.2.Beta4.SP1</version.jboss.osgi.xml.binding>
     <version.ops4j.pax.web>0.7.2</version.ops4j.pax.web>
     <version.jboss.web>3.0.0-beta-4</version.jboss.web>
-    <version.jgroups>2.6.13.GA</version.jgroups>
+    <version.jgroups>2.10.0.Alpha3</version.jgroups>
     <version.jsr181.api>1.0-MR1</version.jsr181.api>
     <version.junit>3.8.2</version.junit>
     <version.ops4j.pax.web>0.7.2</version.ops4j.pax.web>

Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/DRMTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/DRMTestCase.java	2010-04-08 12:31:09 UTC (rev 103695)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/DRMTestCase.java	2010-04-08 12:47:08 UTC (rev 103696)
@@ -38,7 +38,6 @@
 import org.jboss.ha.framework.interfaces.ClusterNode;
 import org.jboss.ha.framework.interfaces.DistributedReplicantManager;
 import org.jboss.ha.framework.interfaces.DistributedReplicantManager.ReplicantListener;
-import org.jboss.ha.framework.server.ClusterNodeImpl;
 import org.jboss.ha.framework.server.ClusterPartition;
 import org.jboss.ha.framework.server.DistributedReplicantManagerImpl;
 import org.jboss.ha.framework.server.DistributedStateImpl;
@@ -46,6 +45,8 @@
 import org.jboss.ha.framework.server.JChannelFactory;
 import org.jboss.logging.Logger;
 import org.jboss.test.JBossClusteredTestCase;
+import org.jboss.ha.framework.server.ClusterNodeFactory;
+import org.jboss.test.cluster.testutil.TestClusterNodeFactory;
 import org.jboss.test.cluster.hapartition.drm.MockHAPartition;
 import org.jgroups.stack.GossipRouter;
 import org.jgroups.stack.IpAddress;
@@ -62,7 +63,7 @@
 public class DRMTestCase extends JBossClusteredTestCase
 {  
    private static final String SERVICEA = "serviceA";
-   private static final String SERVICEB = "serviceB";
+   private static final String SERVICEB = "serviceB"; 
    
    /**
     * Thread that will first register a DRM ReplicantLister that synchronizes
@@ -476,6 +477,7 @@
 
    private static Object lock = new Object();
    private static int LOOP_COUNT = 30;
+   private final ClusterNodeFactory factory = new TestClusterNodeFactory();
    
    public static Test suite() throws Exception
    {
@@ -736,7 +738,7 @@
       MBeanServer mbeanServer = 
          MBeanServerFactory.createMBeanServer("mockPartition");
       try {
-         ClusterNode localAddress = new ClusterNodeImpl(new IpAddress("127.0.0.1", 12345));
+         ClusterNode localAddress = factory.getClusterNode(new IpAddress("127.0.0.1", 12345));
          MockHAPartition partition = new MockHAPartition(localAddress);
       
          DistributedReplicantManagerImpl drm = new DistributedReplicantManagerImpl(partition);
@@ -747,7 +749,7 @@
          
          Vector<ClusterNode> remoteAddresses = new Vector<ClusterNode>();
          for (int i = 1; i < 5; i++)
-            remoteAddresses.add(new ClusterNodeImpl(new IpAddress("127.0.0.1", 12340 + i)));
+            remoteAddresses.add(factory.getClusterNode(new IpAddress("127.0.0.1", 12340 + i)));
          
          Vector<ClusterNode> allNodes = new Vector<ClusterNode>(remoteAddresses);
          allNodes.add(localAddress);
@@ -840,7 +842,7 @@
       MBeanServer mbeanServer = 
          MBeanServerFactory.createMBeanServer("mockPartition");
       try {
-         ClusterNode localAddress = new ClusterNodeImpl(new IpAddress("127.0.0.1", 12345));
+         ClusterNode localAddress = factory.getClusterNode(new IpAddress("127.0.0.1", 12345));
          MockHAPartition partition = new MockHAPartition(localAddress);
       
          DistributedReplicantManagerImpl drm = new DistributedReplicantManagerImpl(partition);
@@ -851,7 +853,7 @@
          
          Vector<ClusterNode> remoteAddresses = new Vector<ClusterNode>();
          for (int i = 1; i < 5; i++)
-            remoteAddresses.add(new ClusterNodeImpl(new IpAddress("127.0.0.1", 12340 + i)));
+            remoteAddresses.add(factory.getClusterNode(new IpAddress("127.0.0.1", 12340 + i)));
          
          Vector<ClusterNode> allNodes = new Vector<ClusterNode>(remoteAddresses);
          allNodes.add(localAddress);
@@ -958,7 +960,8 @@
       MBeanServer mbeanServer = 
          MBeanServerFactory.createMBeanServer("mockPartition");
       try {
-         ClusterNode localAddress = new ClusterNodeImpl(new IpAddress("127.0.0.1", 12345));
+    	  
+         ClusterNode localAddress = factory.getClusterNode(new IpAddress("127.0.0.1", 12345));
          MockHAPartition partition = new MockHAPartition(localAddress);
       
          DistributedReplicantManagerImpl drm = new DistributedReplicantManagerImpl(partition);
@@ -968,7 +971,7 @@
          // Create a fake view for the MockHAPartition
          
          Vector<ClusterNode> remoteAddresses = new Vector<ClusterNode>();
-         ClusterNode remote = new ClusterNodeImpl(new IpAddress("127.0.0.1", 12341));
+         ClusterNode remote = factory.getClusterNode(new IpAddress("127.0.0.1", 12341));
          remoteAddresses.add(remote);
          
          Vector<ClusterNode> allNodes = new Vector<ClusterNode>(remoteAddresses);
@@ -1140,7 +1143,7 @@
          Vector<ClusterNode> allNodes = new Vector<ClusterNode>();
          for (int i = 0; i < nodes.length; i++)
          {
-            nodes[i] = new ClusterNodeImpl(new IpAddress("127.0.0.1", 12340 + i));
+            nodes[i] = factory.getClusterNode(new IpAddress("127.0.0.1", 12340 + i));
             allNodes.add(nodes[i]);
             names[i] = nodes[i].getName();
             replicants[i] = new Integer(i);
@@ -1217,7 +1220,7 @@
          Vector<ClusterNode> allNodes = new Vector<ClusterNode>();
          for (int i = 0; i < nodes.length; i++)
          {
-            nodes[i] = new ClusterNodeImpl(new IpAddress("127.0.0.1", 12340 + i));
+            nodes[i] = factory.getClusterNode(new IpAddress("127.0.0.1", 12340 + i));
             allNodes.add(nodes[i]);
 //            names[i] = nodes[i].getName();
             replicants[i] = new Integer(i);

Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/JChannelFactoryOverrideUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/JChannelFactoryOverrideUnitTestCase.java	2010-04-08 12:31:09 UTC (rev 103695)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/JChannelFactoryOverrideUnitTestCase.java	2010-04-08 12:47:08 UTC (rev 103696)
@@ -36,6 +36,7 @@
 import org.jboss.logging.Logger;
 import org.jgroups.Channel;
 import org.jgroups.JChannel;
+import org.jgroups.protocols.TP;
 import org.jgroups.conf.ProtocolData;
 import org.jgroups.conf.ProtocolParameter;
 
@@ -215,9 +216,11 @@
       
       // Validate that the overrides actuall affect created channels
       channel1 = factory.createChannel("unshared1");
-      assertEquals("50000", ((JChannel) channel1).getProtocolStack().findProtocol("UDP").getProperties().get("max_bundle_size"));
-      channel2 = factory.createChannel("added");   
-      assertEquals("64000", ((JChannel) channel2).getProtocolStack().findProtocol("UDP").getProperties().get("max_bundle_size"));
+      TP transport = (TP)((JChannel) channel1).getProtocolStack().findProtocol("UDP");      
+      assertEquals(50000, transport.getMaxBundleSize());
+      channel2 = factory.createChannel("added");  
+      transport = (TP)((JChannel) channel2).getProtocolStack().findProtocol("UDP");
+      assertEquals(64000,transport.getMaxBundleSize());
       try
       {
          factory.createChannel("shared2");

Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/JChannelFactoryUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/JChannelFactoryUnitTestCase.java	2010-04-08 12:31:09 UTC (rev 103695)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/JChannelFactoryUnitTestCase.java	2010-04-08 12:47:08 UTC (rev 103696)
@@ -188,14 +188,17 @@
       channel1.connect("test");
       TP tp1 = getTP((JChannel) channel1);
       
-      assertEquals(3000, tp1.getIncomingKeepAliveTime());
+      /*
+       * Access to these properties is deprecated. 
+       * 
+       * assertEquals(3000, tp1.getIncomingKeepAliveTime());
       assertEquals(22, tp1.getIncomingMaxPoolSize());
       assertEquals(2, tp1.getIncomingMinPoolSize());
       assertEquals(750, tp1.getIncomingMaxQueueSize());
       assertEquals(4000, tp1.getOOBKeepAliveTime());
       assertEquals(12, tp1.getOOBMaxPoolSize());
       assertEquals(3, tp1.getOOBMinPoolSize());
-      assertEquals(75, tp1.getOOBMaxQueueSize());
+      assertEquals(75, tp1.getOOBMaxQueueSize());*/
       
       Executor exec = tp1.getDefaultThreadPool();
       assertNotNull(exec);
@@ -276,33 +279,6 @@
       assertFalse(udpName2 + " unregistered", mbeanServer.isRegistered(udpName2));
    }
    
-   public void testLogicalAddressAssignment() throws Exception
-   {
-      log.info("+++ testLogicalAddressAssignment()");
-      
-      channel1 = factory1.createChannel("shared1");
-      channel1.connect("shared");
-      IpAddress addr = (IpAddress) channel1.getLocalAddress();
-      assertEquals(null, addr.getAdditionalData());
-
-      factory1.setAssignLogicalAddresses(true);
-      factory2.setAssignLogicalAddresses(true);
-      
-      channel2 = factory1.createChannel("shared2");
-      channel2.connect("shared");
-      addr = (IpAddress) channel2.getLocalAddress();
-      byte[] addlData = addr.getAdditionalData();
-      assertNotNull(addlData);
-      assertEquals("127.0.0.1:123", new String(addlData));
-
-      channel3 = factory2.createChannel("unshared1");
-      channel3.connect("unshared");
-      addr = (IpAddress) channel3.getLocalAddress();
-      addlData = addr.getAdditionalData();
-      assertNotNull(addlData);
-      assertEquals("node1",  new String(addlData));
-   }
-   
    private TP getTP(JChannel channel)
    {
       List<Protocol> protocols = channel.getProtocolStack().getProtocols();

Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/LookupSucceededFilterUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/LookupSucceededFilterUnitTestCase.java	2010-04-08 12:31:09 UTC (rev 103695)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/LookupSucceededFilterUnitTestCase.java	2010-04-08 12:47:08 UTC (rev 103696)
@@ -29,6 +29,8 @@
 import org.jboss.ha.framework.server.ClusterPartition;
 import org.jboss.ha.framework.server.RspFilterAdapter;
 import org.jboss.ha.jndi.LookupSucceededFilter;
+import org.jboss.ha.framework.server.ClusterNodeFactory;
+import org.jboss.test.cluster.testutil.TestClusterNodeFactory;
 import org.jgroups.Address;
 import org.jgroups.blocks.RspFilter;
 import org.jgroups.stack.IpAddress;
@@ -40,10 +42,11 @@
  */
 public class LookupSucceededFilterUnitTestCase extends TestCase
 {
+   private final ClusterNodeFactory factory = new TestClusterNodeFactory();
    public void testFilterLogic()
    {
       ResponseFilter filter = new LookupSucceededFilter();
-      ClusterNode sender = new ClusterNodeImpl(new IpAddress(12345));
+      ClusterNode sender = factory.getClusterNode(new IpAddress(12345));
       exerciseFilterLogic(filter, sender);
    }
 
@@ -51,7 +54,7 @@
    {
       ResponseFilter filter = new LookupSucceededFilter();
       Address sender = new IpAddress(12345);
-      RspFilterAdapter adapter = new RspFilterAdapter(filter);
+      RspFilterAdapter adapter = new RspFilterAdapter(filter,factory);
       exerciseFilterLogic(adapter, sender);
   }
    

Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/PreferredMasterElectionPolicyUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/PreferredMasterElectionPolicyUnitTestCase.java	2010-04-08 12:31:09 UTC (rev 103695)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/PreferredMasterElectionPolicyUnitTestCase.java	2010-04-08 12:47:08 UTC (rev 103696)
@@ -30,7 +30,8 @@
 import junit.framework.TestCase;
 
 import org.jboss.ha.framework.interfaces.ClusterNode;
-import org.jboss.ha.framework.server.ClusterNodeImpl;
+import org.jboss.ha.framework.server.ClusterNodeFactory;
+import org.jboss.test.cluster.testutil.TestClusterNodeFactory;
 import org.jboss.ha.singleton.PreferredMasterElectionPolicy;
 import org.jgroups.stack.IpAddress;
 
@@ -48,15 +49,16 @@
 {
    private PreferredMasterElectionPolicy policy;
    private List<ClusterNode> candidates = new ArrayList<ClusterNode>();
+   private final ClusterNodeFactory factory = new TestClusterNodeFactory();
    
    @Override
    protected void setUp() throws UnknownHostException
    {
       InetAddress localAddress = InetAddress.getByName("localhost");
       
-      this.candidates.add(new ClusterNodeImpl(new IpAddress(localAddress, 10000)));
-      this.candidates.add(new ClusterNodeImpl(new IpAddress(localAddress, 10001)));
-      this.candidates.add(new ClusterNodeImpl(new IpAddress(localAddress, 10002)));
+      this.candidates.add(factory.getClusterNode(new IpAddress(localAddress, 10000)));
+      this.candidates.add(factory.getClusterNode(new IpAddress(localAddress, 10001)));
+      this.candidates.add(factory.getClusterNode(new IpAddress(localAddress, 10002)));
       
       this.policy = new PreferredMasterElectionPolicy();
    }

Modified: trunk/testsuite/src/main/org/jboss/test/cluster/lock/ClusteredLockManagerTestBase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/lock/ClusteredLockManagerTestBase.java	2010-04-08 12:31:09 UTC (rev 103695)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/lock/ClusteredLockManagerTestBase.java	2010-04-08 12:47:08 UTC (rev 103696)
@@ -32,11 +32,12 @@
 import org.easymock.IArgumentMatcher;
 import org.jboss.ha.framework.interfaces.ClusterNode;
 import org.jboss.ha.framework.interfaces.HAPartition;
-import org.jboss.ha.framework.server.ClusterNodeImpl;
 import org.jboss.ha.framework.server.lock.AbstractClusterLockSupport;
 import org.jboss.ha.framework.server.lock.LocalLockHandler;
 import org.jboss.ha.framework.server.lock.RemoteLockResponse;
 import org.jboss.ha.framework.server.lock.AbstractClusterLockSupport.RpcTarget;
+import org.jboss.ha.framework.server.ClusterNodeFactory;
+import org.jboss.test.cluster.testutil.TestClusterNodeFactory;
 import org.jgroups.stack.IpAddress;
 
 public abstract class ClusteredLockManagerTestBase<T extends AbstractClusterLockSupport> extends TestCase
@@ -45,6 +46,7 @@
    protected ClusterNode node1;
    protected ClusterNode node2;
    protected ClusterNode node3;
+   protected final ClusterNodeFactory factory = new TestClusterNodeFactory();
 
    public static Object[] eqLockParams(ClusterNode node, long timeout)
    {
@@ -105,9 +107,9 @@
    protected void setUp() throws Exception
    {
       super.setUp();
-      node1 = new ClusterNodeImpl(new IpAddress("localhost", 1));
-      node2 = new ClusterNodeImpl(new IpAddress("localhost", 2));
-      node3 = new ClusterNodeImpl(new IpAddress("localhost", 3));
+      node1 = factory.getClusterNode(new IpAddress("localhost", 1));
+      node2 = factory.getClusterNode(new IpAddress("localhost", 2));
+      node3 = factory.getClusterNode(new IpAddress("localhost", 3));
    }
 
    protected void tearDown() throws Exception

Added: trunk/testsuite/src/main/org/jboss/test/cluster/testutil/TestClusterNodeFactory.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/testutil/TestClusterNodeFactory.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/testutil/TestClusterNodeFactory.java	2010-04-08 12:47:08 UTC (rev 103696)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.cluster.testutil;
+
+import org.jboss.ha.framework.interfaces.ClusterNode;
+import org.jboss.ha.framework.server.*;
+import org.jgroups.Address;
+import org.jgroups.stack.IpAddress;
+
+/**
+ * @author Vladimir Blagojevic
+ *
+ */
+public class TestClusterNodeFactory implements ClusterNodeFactory
+{
+	
+	public ClusterNode getClusterNode(Address address){
+		IpAddress ip = (IpAddress) address;
+		return new ClusterNodeImpl(address,new AddressPort(ip.getIpAddress(), ip.getPort()));
+	}   
+}




More information about the jboss-cvs-commits mailing list