[jboss-cvs] JBossAS SVN: r87434 - in branches/Branch_5_x/cluster/src/main/org/jboss/ha: jmx and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Apr 16 11:10:52 EDT 2009
Author: galder.zamarreno at jboss.com
Date: 2009-04-16 11:10:52 -0400 (Thu, 16 Apr 2009)
New Revision: 87434
Added:
branches/Branch_5_x/cluster/src/main/org/jboss/ha/jndi/LookupSucceededFilter.java
Modified:
branches/Branch_5_x/cluster/src/main/org/jboss/ha/framework/server/ClusterPartition.java
branches/Branch_5_x/cluster/src/main/org/jboss/ha/jmx/AbstractHAServiceMBeanSupport.java
branches/Branch_5_x/cluster/src/main/org/jboss/ha/jmx/HAServiceMBean.java
branches/Branch_5_x/cluster/src/main/org/jboss/ha/jndi/HAJNDI.java
Log:
[JBAS-5703] Implemented wait for first positive response filter and integrated it with HAJNDI. Also, I added methods that take ResponseFilter to HA service base classes.
Modified: branches/Branch_5_x/cluster/src/main/org/jboss/ha/framework/server/ClusterPartition.java
===================================================================
--- branches/Branch_5_x/cluster/src/main/org/jboss/ha/framework/server/ClusterPartition.java 2009-04-16 15:08:34 UTC (rev 87433)
+++ branches/Branch_5_x/cluster/src/main/org/jboss/ha/framework/server/ClusterPartition.java 2009-04-16 15:10:52 UTC (rev 87434)
@@ -103,7 +103,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>
+ * @author Galder Zamarreño
* @version $Revision$
*/
@ManagementObject(componentType=@ManagementComponent(type="MCBean", subtype="HAPartition"),
@@ -130,7 +130,7 @@
/**
* Returned when an RPC call arrives for a service that isn't registered.
*/
- private static class NoHandlerForRPC implements Serializable
+ public static class NoHandlerForRPC implements Serializable
{
static final long serialVersionUID = -1263095408483622838L;
}
Modified: branches/Branch_5_x/cluster/src/main/org/jboss/ha/jmx/AbstractHAServiceMBeanSupport.java
===================================================================
--- branches/Branch_5_x/cluster/src/main/org/jboss/ha/jmx/AbstractHAServiceMBeanSupport.java 2009-04-16 15:08:34 UTC (rev 87433)
+++ branches/Branch_5_x/cluster/src/main/org/jboss/ha/jmx/AbstractHAServiceMBeanSupport.java 2009-04-16 15:10:52 UTC (rev 87434)
@@ -33,6 +33,7 @@
import org.jboss.ha.framework.interfaces.DistributedState;
import org.jboss.ha.framework.interfaces.HAPartition;
import org.jboss.ha.framework.interfaces.HAService;
+import org.jboss.ha.framework.interfaces.ResponseFilter;
import org.jboss.ha.framework.server.ClusterPartitionMBean;
import org.jboss.ha.framework.server.EventFacility;
import org.jboss.ha.framework.server.EventFactory;
@@ -43,6 +44,7 @@
*
* @param S the class of the HAService delegate
* @author Paul Ferraro
+ * @author Galder Zamarreño
*/
@SuppressWarnings("deprecation")
public abstract class AbstractHAServiceMBeanSupport<S extends HAService<Notification>>
@@ -232,6 +234,12 @@
{
return this.getHAPartition().callMethodOnCluster(this.getHAServiceKey(), methodName, args, types, true);
}
+
+ @SuppressWarnings("unchecked")
+ public List callMethodOnPartition(String methodName, Object[] args, Class[] types, ResponseFilter filter) throws Exception
+ {
+ return this.getHAPartition().callMethodOnCluster(this.getHAServiceKey(), methodName, args, types, true, filter);
+ }
@SuppressWarnings("unchecked")
protected void callAsyncMethodOnPartition(String methodName, Object[] args, Class[] types) throws Exception
Modified: branches/Branch_5_x/cluster/src/main/org/jboss/ha/jmx/HAServiceMBean.java
===================================================================
--- branches/Branch_5_x/cluster/src/main/org/jboss/ha/jmx/HAServiceMBean.java 2009-04-16 15:08:34 UTC (rev 87433)
+++ branches/Branch_5_x/cluster/src/main/org/jboss/ha/jmx/HAServiceMBean.java 2009-04-16 15:10:52 UTC (rev 87434)
@@ -28,6 +28,7 @@
import javax.management.NotificationBroadcaster;
import org.jboss.ha.framework.interfaces.HAPartition;
+import org.jboss.ha.framework.interfaces.ResponseFilter;
import org.jboss.ha.framework.server.ClusterPartitionMBean;
/**
@@ -37,6 +38,7 @@
* </p>
*
* @author <a href="mailto:ivelin at apache.org">Ivelin Ivanov</a>
+ * @author Galder Zamarreño
* @version $Revision$
*
*/
@@ -81,6 +83,22 @@
*/
@SuppressWarnings("unchecked")
List callMethodOnPartition(String methodName, Object[] args, Class[] types) throws Exception;
+
+ /**
+ *
+ * Convenience method for broadcasting a call to all members of a partition with a given
+ * response filter.
+ *
+ * @param methodName
+ * @param args array of Java Object representing the set of parameters to be
+ * given to the remote method
+ * @param types The types of the parameters
+ * @param filter The response filter
+ * @return a list of responses from remote nodes
+ * @throws Exception
+ */
+ @SuppressWarnings("unchecked")
+ List callMethodOnPartition(String methodName, Object[] args, Class[] types, ResponseFilter filter) throws Exception;
/**
*
Modified: branches/Branch_5_x/cluster/src/main/org/jboss/ha/jndi/HAJNDI.java
===================================================================
--- branches/Branch_5_x/cluster/src/main/org/jboss/ha/jndi/HAJNDI.java 2009-04-16 15:08:34 UTC (rev 87433)
+++ branches/Branch_5_x/cluster/src/main/org/jboss/ha/jndi/HAJNDI.java 2009-04-16 15:10:52 UTC (rev 87434)
@@ -46,6 +46,7 @@
* @author <a href="mailto:bill at burkecentral.com">Bill Burke</a>
* @author Scott.Stark at jboss.org
* @author Brian Stansberry
+ * @author Galder Zamarreño
*
* @version $Revision$
*/
@@ -244,7 +245,7 @@
{
log.trace("calling lookupLocally(" + name + ") on HAJNDI cluster");
}
- rsp = this.partition.callMethodOnCluster("HAJNDI", "lookupLocally", args, new Class[] { Name.class }, true);
+ rsp = this.partition.callMethodOnCluster("HAJNDI", "lookupLocally", args, new Class[] { Name.class }, true, new LookupSucceededFilter());
}
catch (Exception ignored)
{
Added: branches/Branch_5_x/cluster/src/main/org/jboss/ha/jndi/LookupSucceededFilter.java
===================================================================
--- branches/Branch_5_x/cluster/src/main/org/jboss/ha/jndi/LookupSucceededFilter.java (rev 0)
+++ branches/Branch_5_x/cluster/src/main/org/jboss/ha/jndi/LookupSucceededFilter.java 2009-04-16 15:10:52 UTC (rev 87434)
@@ -0,0 +1,63 @@
+/*
+ * 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.jndi;
+
+import org.jboss.ha.framework.interfaces.ClusterNode;
+import org.jboss.ha.framework.interfaces.ResponseFilter;
+import org.jboss.ha.framework.server.ClusterPartition.NoHandlerForRPC;
+import org.jboss.logging.Logger;
+
+/**
+ * This is a response filter that will stop waiting for responses as soon as it has received a
+ * response that's neither null, nor Exception, nor NoHandlerForRPC. This allows for example
+ * HAJNDI calls to return as soon as cluster wide lookup has succeeded in a node.
+ *
+ * @author Galder Zamarreño
+ */
+public class LookupSucceededFilter implements ResponseFilter
+{
+ private static final Logger log = Logger.getLogger(LookupSucceededFilter.class);
+ private static final boolean trace = log.isTraceEnabled();
+ private boolean lookupSucceeded;
+
+ public boolean isAcceptable(Object response, ClusterNode sender)
+ {
+ if (trace)
+ {
+ log.trace("isAcceptable (" + response + ") from " + sender);
+ }
+
+ lookupSucceeded = (response != null) && !(response instanceof Exception) && !(response instanceof NoHandlerForRPC);
+
+ if (trace && lookupSucceeded)
+ {
+ log.trace("Lookup succeded from " + sender);
+ }
+
+ return true;
+ }
+
+ public boolean needMoreResponses()
+ {
+ return !(lookupSucceeded);
+ }
+}
More information about the jboss-cvs-commits
mailing list