[jboss-cvs] JBossAS SVN: r75730 - trunk/cluster/src/main/org/jboss/ha/framework/server.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sat Jul 12 11:49:57 EDT 2008


Author: galder.zamarreno at jboss.com
Date: 2008-07-12 11:49:57 -0400 (Sat, 12 Jul 2008)
New Revision: 75730

Added:
   trunk/cluster/src/main/org/jboss/ha/framework/server/RspFilterAdapter.java
Modified:
   trunk/cluster/src/main/org/jboss/ha/framework/server/ClusterNodeImpl.java
   trunk/cluster/src/main/org/jboss/ha/framework/server/ClusterPartition.java
Log:
[JBAS-5647] Sync RPC with response filter implementation plus optimisation of ClusterNodeImpl creation.

Modified: trunk/cluster/src/main/org/jboss/ha/framework/server/ClusterNodeImpl.java
===================================================================
--- trunk/cluster/src/main/org/jboss/ha/framework/server/ClusterNodeImpl.java	2008-07-12 08:47:14 UTC (rev 75729)
+++ trunk/cluster/src/main/org/jboss/ha/framework/server/ClusterNodeImpl.java	2008-07-12 15:49:57 UTC (rev 75730)
@@ -37,6 +37,7 @@
  *
  * @author  <a href="mailto:sacha.labourey at jboss.org">Sacha Labourey</a>.
  * @author Brian Stansberry
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
  * @version $Revision: 58561 $
  */
 
@@ -50,9 +51,9 @@
    
    // Attributes ----------------------------------------------------
    
-   protected String id = null;
+   protected final String id;
    protected String jgId = null;
-   protected IpAddress originalJGAddress = null;
+   protected final IpAddress originalJGAddress;
 
    // Static --------------------------------------------------------
    
@@ -70,19 +71,6 @@
       }
 
       this.originalJGAddress = jgAddress;
-      StringBuffer sb = new StringBuffer();
-      java.net.InetAddress jgIPAddr = jgAddress.getIpAddress();
-      if (jgIPAddr == null)
-         sb.append("<null>");
-      else
-      {
-         if (jgIPAddr.isMulticastAddress())
-            sb.append(jgIPAddr.getHostAddress());
-         else
-            sb.append(getShortName(getFastHostName(jgIPAddr)));
-      }
-      sb.append(":" + jgAddress.getPort());
-      this.jgId = sb.toString();
    }
 
    // Public --------------------------------------------------------
@@ -94,7 +82,12 @@
 
    public String getJGName()
    {
-      return this.jgId;
+      if (jgId == null)
+      {
+         jgId = createJGName(); 
+      }
+      
+      return jgId;
    }
 
    public IpAddress getOriginalJGAddress()
@@ -157,6 +150,24 @@
       else
          return hostname;
    }
+   
+   protected String createJGName()
+   {
+      StringBuffer sb = new StringBuffer();
+      java.net.InetAddress jgIPAddr = originalJGAddress.getIpAddress();
+      if (jgIPAddr == null)
+         sb.append("<null>");
+      else
+      {
+         if (jgIPAddr.isMulticastAddress())
+            sb.append(jgIPAddr.getHostAddress());
+         else
+            sb.append(getShortName(getFastHostName(jgIPAddr)));
+      }
+      sb.append(":" + originalJGAddress.getPort());
+      
+      return sb.toString();
+   }
 
    // Private -------------------------------------------------------
    

Modified: trunk/cluster/src/main/org/jboss/ha/framework/server/ClusterPartition.java
===================================================================
--- trunk/cluster/src/main/org/jboss/ha/framework/server/ClusterPartition.java	2008-07-12 08:47:14 UTC (rev 75729)
+++ trunk/cluster/src/main/org/jboss/ha/framework/server/ClusterPartition.java	2008-07-12 15:49:57 UTC (rev 75730)
@@ -51,6 +51,7 @@
 import org.jboss.ha.framework.interfaces.DistributedReplicantManager;
 import org.jboss.ha.framework.interfaces.DistributedState;
 import org.jboss.ha.framework.interfaces.HAPartition;
+import org.jboss.ha.framework.interfaces.ResponseFilter;
 import org.jboss.invocation.MarshalledValueInputStream;
 import org.jboss.invocation.MarshalledValueOutputStream;
 import org.jboss.logging.Logger;
@@ -85,6 +86,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 <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
  * @version $Revision$
  */
 public class ClusterPartition
@@ -970,17 +972,23 @@
    public ArrayList callMethodOnCluster(String objName, String methodName,
       Object[] args, Class[] types, boolean excludeSelf) throws Exception
    {
-      return this.callMethodOnCluster(objName, methodName, args, types, excludeSelf, this.getMethodCallTimeout());
+      return this.callMethodOnCluster(objName, methodName, args, types, excludeSelf, null);
    }
+   
+   public ArrayList callMethodOnCluster(String objName, String methodName, 
+      Object[] args, Class[] types, boolean excludeSelf, ResponseFilter filter) throws Exception
+   {
+      return this.callMethodOnCluster(objName, methodName, args, types, excludeSelf, this.getMethodCallTimeout(), filter);
+   }   
 
-
    public ArrayList callMethodOnCluster(String objName, String methodName,
-       Object[] args, Class[] types, boolean excludeSelf, long methodTimeout) throws Exception
+       Object[] args, Class[] types, boolean excludeSelf, long methodTimeout, ResponseFilter filter) throws Exception
    {
       RspList rsp = null;
       boolean trace = this.log.isTraceEnabled();
 
       MethodCall m = new MethodCall(objName + "." + methodName, args, types);
+      RspFilterAdapter rspFilter = filter == null ? null : new RspFilterAdapter(filter);
       
       if(this.channel.flushSupported())
       {
@@ -993,7 +1001,7 @@
             this.log.trace("callMethodOnCluster(true), objName="+objName
                +", methodName="+methodName+", members="+this.jgotherMembers);
          }
-         rsp = this.dispatcher.callRemoteMethods(this.jgotherMembers, m, GroupRequest.GET_ALL, methodTimeout);
+         rsp = this.dispatcher.callRemoteMethods(this.jgotherMembers, m, GroupRequest.GET_ALL, methodTimeout, false, false, rspFilter);
       }
       else
       {
@@ -1002,7 +1010,7 @@
             this.log.trace("callMethodOnCluster(false), objName="+objName
                +", methodName="+methodName+", members="+this.members);
          }
-         rsp = this.dispatcher.callRemoteMethods(null, m, GroupRequest.GET_ALL, methodTimeout);
+         rsp = this.dispatcher.callRemoteMethods(null, m, GroupRequest.GET_ALL, methodTimeout, false, false, rspFilter);
       }
 
       return this.processResponseList(rsp, trace);

Added: trunk/cluster/src/main/org/jboss/ha/framework/server/RspFilterAdapter.java
===================================================================
--- trunk/cluster/src/main/org/jboss/ha/framework/server/RspFilterAdapter.java	                        (rev 0)
+++ trunk/cluster/src/main/org/jboss/ha/framework/server/RspFilterAdapter.java	2008-07-12 15:49:57 UTC (rev 75730)
@@ -0,0 +1,53 @@
+/*
+ * 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 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, 
+ * Cluster abstraction of RspFilter.
+ * 
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
+ */
+public class RspFilterAdapter implements RspFilter
+{
+   private ResponseFilter filter;
+   
+   public RspFilterAdapter(ResponseFilter filter)
+   {
+      this.filter = filter;
+   }
+
+   public boolean isAcceptable(Object response, Address sender)
+   {
+      return filter.isAcceptable(response, new ClusterNodeImpl((IpAddress)sender));
+   }
+
+   public boolean needMoreResponses()
+   {
+      return filter.needMoreResponses();
+   }
+}




More information about the jboss-cvs-commits mailing list