[jboss-cvs] JBossAS SVN: r75651 - in projects/cluster/ha-client/tags: 1.1.0.CR2 and 6 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jul 10 22:01:15 EDT 2008
Author: bstansberry at jboss.com
Date: 2008-07-10 22:01:14 -0400 (Thu, 10 Jul 2008)
New Revision: 75651
Added:
projects/cluster/ha-client/tags/1.1.0.CR2/
projects/cluster/ha-client/tags/1.1.0.CR2/pom.xml
projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/aspects/remoting/ClusterChooserInterceptor.java
projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/aspects/remoting/ClusterConstants.java
projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/aspects/remoting/ClusteredPojiProxy.java
projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/aspects/remoting/FamilyWrapper.java
projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/AopLoadBalancePolicy.java
projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/FirstAvailable.java
projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/FirstAvailableIdenticalAllProxies.java
projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/LoadBalancePolicy.java
projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/RandomRobin.java
projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/RoundRobin.java
projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/aop/FirstAvailable.java
projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/aop/FirstAvailableIdenticalAllProxies.java
projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/framework/interfaces/ClusteringTargetsRepository.java
projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/framework/interfaces/FamilyClusterInfo.java
projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/framework/interfaces/FamilyClusterInfoImpl.java
projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/framework/interfaces/GenericClusteringException.java
projects/cluster/ha-client/tags/1.1.0.CR2/src/test/java/org/jboss/test/aspects/remoting/ClusteredPojiProxyUnitTestCase.java
projects/cluster/ha-client/tags/1.1.0.CR2/src/test/java/org/jboss/test/ha/framework/interfaces/FamilyClusterInfoUnitTestCase.java
Removed:
projects/cluster/ha-client/tags/1.1.0.CR2/pom.xml
projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/aspects/remoting/ClusterChooserInterceptor.java
projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/aspects/remoting/ClusterConstants.java
projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/aspects/remoting/FamilyWrapper.java
projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/AopLoadBalancePolicy.java
projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/FirstAvailable.java
projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/FirstAvailableIdenticalAllProxies.java
projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/LoadBalancePolicy.java
projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/RandomRobin.java
projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/RoundRobin.java
projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/aop/FirstAvailable.java
projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/aop/FirstAvailableIdenticalAllProxies.java
projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/framework/interfaces/ClusteringTargetsRepository.java
projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/framework/interfaces/FamilyClusterInfo.java
projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/framework/interfaces/FamilyClusterInfoImpl.java
projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/framework/interfaces/GenericClusteringException.java
projects/cluster/ha-client/tags/1.1.0.CR2/src/test/java/org/jboss/test/ha/framework/interfaces/FamilyClusterInfoUnitTestCase.java
Log:
[maven-release-plugin] copy for tag 1.1.0.CR2
Copied: projects/cluster/ha-client/tags/1.1.0.CR2 (from rev 73569, projects/cluster/ha-client/trunk)
Deleted: projects/cluster/ha-client/tags/1.1.0.CR2/pom.xml
===================================================================
--- projects/cluster/ha-client/trunk/pom.xml 2008-05-21 23:22:01 UTC (rev 73569)
+++ projects/cluster/ha-client/tags/1.1.0.CR2/pom.xml 2008-07-11 02:01:14 UTC (rev 75651)
@@ -1,139 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>org.jboss.cluster</groupId>
- <artifactId>jboss-cluster</artifactId>
- <version>1.1.0.Beta1</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.jboss.cluster</groupId>
- <artifactId>jboss-ha-client</artifactId>
- <packaging>jar</packaging>
- <version>1.1.0.Beta2</version>
- <name>JBoss Cluster HA Client Classes</name>
- <url>http://www.jboss.org</url>
- <description>A set of client-side classes commonly used by applications that want HA</description>
- <licenses>
- <license>
- <name>lgpl</name>
- <url>http://repository.jboss.com/licenses/lgpl.txt</url>
- </license>
- </licenses>
- <organization>
- <name>JBoss, a division of Red Hat, Inc.</name>
- <url>http://www.jboss.org</url>
- </organization>
-
- <scm>
- <connection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/cluster/ha-client/trunk/</connection>
- </scm>
-
- <properties>
- <version.jboss.common.core>[2.2.5.GA,)</version.jboss.common.core>
- <version.jboss.remoting.aspects>1.0.0.Beta1</version.jboss.remoting.aspects>
- <version.jboss.remoting>[2.4.0.CR1,)</version.jboss.remoting>
- <version.jboss.aop>[2.0.0.CR8,)</version.jboss.aop>
- <version.junit>3.8.1</version.junit>
- </properties>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-release-plugin</artifactId>
- <configuration>
- <!-- The tagBase property is needed during the release process so that the maven release plugin
- will create the release tag in the appropriate location. -->
- <tagBase>https://svn.jboss.org/repos/jbossas/projects/cluster/ha-client/tags</tagBase>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <!-- Global dependencies -->
- <dependency>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-common-core</artifactId>
- <version>${version.jboss.common.core}</version>
- </dependency>
-
- <!-- Only needed if you are using the remoting based interceptors -->
- <dependency>
- <groupId>org.jboss.aspects</groupId>
- <artifactId>jboss-remoting-aspects</artifactId>
- <version>${version.jboss.remoting.aspects}</version>
- <!-- <optional>true</optional>-->
- <exclusions>
- <!-- Get logging via jboss-common-core -->
- <exclusion>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging-spi</artifactId>
- </exclusion>
- <!-- Don't pull in the other aspects libraries -->
- <exclusion>
- <groupId>org.jboss.aspects</groupId>
- <artifactId>jboss-transaction-aspects</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.jboss.aspects</groupId>
- <artifactId>jboss-security-aspects</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>jboss.remoting</groupId>
- <artifactId>jboss-remoting</artifactId>
- <version>${version.jboss.remoting}</version>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.jboss.aop</groupId>
- <artifactId>jboss-aop</artifactId>
- <version>${version.jboss.aop}</version>
- <optional>true</optional>
- <exclusions>
- <!-- Don't pull in all the stuff from aop -->
- <exclusion>
- <groupId>ant</groupId>
- <artifactId>ant</artifactId>
- </exclusion>
- <exclusion>
- <groupId>apache-xerces</groupId>
- <artifactId>xml-apis</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.jboss</groupId>
- <artifactId>javassist</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.jboss.microcontainer</groupId>
- <artifactId>jboss-container</artifactId>
- </exclusion>
- <exclusion>
- <groupId>jboss</groupId>
- <artifactId>jboss-common-logging-spi</artifactId>
- </exclusion>
- <exclusion>
- <groupId>jboss</groupId>
- <artifactId>jboss-common-logging-log4j</artifactId>
- </exclusion>
- <exclusion>
- <groupId>qdox</groupId>
- <artifactId>qdox</artifactId>
- </exclusion>
- <exclusion>
- <groupId>trove</groupId>
- <artifactId>trove</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <!-- Test dependencies -->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>${version.junit}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
-</project>
-
Copied: projects/cluster/ha-client/tags/1.1.0.CR2/pom.xml (from rev 75650, projects/cluster/ha-client/trunk/pom.xml)
===================================================================
--- projects/cluster/ha-client/tags/1.1.0.CR2/pom.xml (rev 0)
+++ projects/cluster/ha-client/tags/1.1.0.CR2/pom.xml 2008-07-11 02:01:14 UTC (rev 75651)
@@ -0,0 +1,140 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.jboss.cluster</groupId>
+ <artifactId>jboss-cluster</artifactId>
+ <version>1.1.0.GA</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.cluster</groupId>
+ <artifactId>jboss-ha-client</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.0.CR2</version>
+ <name>JBoss Cluster HA Client Classes</name>
+ <url>http://www.jboss.org</url>
+ <description>A set of client-side classes commonly used by applications that want HA</description>
+ <licenses>
+ <license>
+ <name>lgpl</name>
+ <url>http://repository.jboss.com/licenses/lgpl.txt</url>
+ </license>
+ </licenses>
+ <organization>
+ <name>JBoss, a division of Red Hat, Inc.</name>
+ <url>http://www.jboss.org</url>
+ </organization>
+
+ <scm>
+ <connection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/cluster/ha-client/tags/1.1.0.CR2</connection>
+ </scm>
+
+ <properties>
+ <version.jboss.common.core>2.2.7.GA</version.jboss.common.core>
+ <version.jboss.remoting.aspects>1.0.1.CR2</version.jboss.remoting.aspects>
+ <version.jboss.remoting>2.4.0.GA</version.jboss.remoting>
+ <version.jboss.aop>2.0.0.CR13</version.jboss.aop>
+ <version.junit>3.8.1</version.junit>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-release-plugin</artifactId>
+ <configuration>
+ <!-- The tagBase property is needed during the release process so that the maven release plugin
+ will create the release tag in the appropriate location. -->
+ <tagBase>https://svn.jboss.org/repos/jbossas/projects/cluster/ha-client/tags</tagBase>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <!-- Global dependencies -->
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-common-core</artifactId>
+ <version>${version.jboss.common.core}</version>
+ </dependency>
+
+ <!-- Only needed if you are using the remoting based interceptors -->
+ <dependency>
+ <groupId>org.jboss.aspects</groupId>
+ <artifactId>jboss-remoting-aspects</artifactId>
+ <version>${version.jboss.remoting.aspects}</version>
+ <!-- <optional>true</optional>-->
+ <exclusions>
+ <!-- Get logging via jboss-common-core -->
+ <exclusion>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ </exclusion>
+ <!-- Don't pull in the other aspects libraries -->
+ <exclusion>
+ <groupId>org.jboss.aspects</groupId>
+ <artifactId>jboss-transaction-aspects</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.aspects</groupId>
+ <artifactId>jboss-security-aspects</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.remoting</groupId>
+ <artifactId>jboss-remoting</artifactId>
+ <version>${version.jboss.remoting}</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.aop</groupId>
+ <artifactId>jboss-aop</artifactId>
+ <version>${version.jboss.aop}</version>
+ <optional>true</optional>
+ <exclusions>
+ <!-- Don't pull in all the stuff from aop -->
+ <exclusion>
+ <groupId>ant</groupId>
+ <artifactId>ant</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>apache-xerces</groupId>
+ <artifactId>xml-apis</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss</groupId>
+ <artifactId>javassist</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-container</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-common-logging-spi</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-common-logging-log4j</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>qdox</groupId>
+ <artifactId>qdox</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>trove</groupId>
+ <artifactId>trove</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <!-- Test dependencies -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${version.junit}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
+
Deleted: projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/aspects/remoting/ClusterChooserInterceptor.java
===================================================================
--- projects/cluster/ha-client/trunk/src/main/java/org/jboss/aspects/remoting/ClusterChooserInterceptor.java 2008-05-21 23:22:01 UTC (rev 73569)
+++ projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/aspects/remoting/ClusterChooserInterceptor.java 2008-07-11 02:01:14 UTC (rev 75651)
@@ -1,185 +0,0 @@
-/*
- * 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.aspects.remoting;
-
-import org.jboss.aop.DispatcherConnectException;
-import org.jboss.aop.util.PayloadKey;
-import org.jboss.ha.client.loadbalance.AopLoadBalancePolicy;
-import org.jboss.ha.client.loadbalance.LoadBalancePolicy;
-import org.jboss.ha.framework.interfaces.GenericClusteringException;
-import org.jboss.remoting.CannotConnectException;
-import org.jboss.remoting.InvokerLocator;
-
-import java.util.ArrayList;
-
-/**
- * Pick an invocation target
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision: 67153 $
- */
-public class ClusterChooserInterceptor implements org.jboss.aop.advice.Interceptor, ClusterConstants, java.io.Serializable
-{
- private static final long serialVersionUID = -8666382019058421135L;
-
- public static final ClusterChooserInterceptor singleton = new ClusterChooserInterceptor();
-
- public String getName()
- {
- return "ClusterChooserInterceptor";
- }
-
- public Object invoke(org.jboss.aop.joinpoint.Invocation invocation)
- throws Throwable
- {
- LoadBalancePolicy lb = (LoadBalancePolicy) invocation.getMetaData(CLUSTERED_REMOTING, LOADBALANCE_POLICY);
- FamilyWrapper family = (FamilyWrapper) invocation.getMetaData(CLUSTERED_REMOTING, CLUSTER_FAMILY_WRAPPER);
-
- // we give the opportunity, to any server interceptor, to know if this a
- // first invocation to a node or if it is a failovered call
- //
- int failoverCounter = 0;
- String familyName = family.get().getFamilyName();
- invocation.getMetaData().addMetaData(CLUSTERED_REMOTING, CLUSTER_FAMILY, familyName, PayloadKey.AS_IS);
- InvokerLocator target = null;
- if (lb instanceof AopLoadBalancePolicy)
- {
- target = (InvokerLocator) ((AopLoadBalancePolicy) lb).chooseTarget(family.get(), invocation);
- }
- else
- {
- target = (InvokerLocator) lb.chooseTarget(family.get());
- }
-
- Throwable lastException = null;
- while (target != null)
- {
- invocation.getMetaData().addMetaData(CLUSTERED_REMOTING, FAILOVER_COUNTER, new Integer(failoverCounter), PayloadKey.AS_IS);
- invocation.getMetaData().addMetaData(InvokeRemoteInterceptor.REMOTING, InvokeRemoteInterceptor.INVOKER_LOCATOR, target, PayloadKey.AS_IS);
- invocation.getMetaData().addMetaData(CLUSTERED_REMOTING, CLUSTER_VIEW_ID, new Long(family.get().getCurrentViewId()), PayloadKey.AS_IS);
-
- boolean definitivlyRemoveNodeOnFailure = true;
- lastException = null;
- try
- {
- Object rsp = invocation.invokeNext();
- ArrayList newReplicants = (ArrayList) invocation.getResponseAttachment("replicants");
- if (newReplicants != null)
- {
- long newViewId = ((Long) invocation.getResponseAttachment("viewId")).longValue();
- family.get().updateClusterInfo(newReplicants, newViewId);
- }
- return rsp;
- }
- catch(DispatcherConnectException dce)
- {
- //In case of graceful shutdown, the target object will no longer exist in the Dispatcher,
- //fail over to another server if we can...
- //For now remove the node "definitely"
- lastException = dce;
- }
- catch (CannotConnectException ex)
- {
- lastException = ex;
- }
- catch (GenericClusteringException gce)
- {
- lastException = gce;
- // this is a generic clustering exception that contain the
- // completion status: usefull to determine if we are authorized
- // to re-issue a query to another node
- //
- if (gce.getCompletionStatus() == GenericClusteringException.COMPLETED_NO)
- {
- // we don't want to remove the node from the list of failed
- // node UNLESS there is a risk to indefinitively loop
- //
- if (family.get().getTargets().size() >= failoverCounter)
- {
- if (!gce.isDefinitive())
- definitivlyRemoveNodeOnFailure = false;
- }
- }
- else
- {
- throw new RuntimeException("Clustering exception thrown", gce);
- }
- }
- catch (Throwable t)
- {
- // Just in case this get wrapped in a Throwable. This can happen when
- // the exception is generated inside the container and it is wrapped in
- // a ForwardId exception.
- if(t.getCause() instanceof GenericClusteringException)
- {
- GenericClusteringException gce = (GenericClusteringException)t.getCause();
- lastException = gce;
- // this is a generic clustering exception that contain the
- // completion status: usefull to determine if we are authorized
- // to re-issue a query to another node
- //
- if (gce.getCompletionStatus() == GenericClusteringException.COMPLETED_NO)
- {
- // we don't want to remove the node from the list of failed
- // node UNLESS there is a risk to indefinitively loop
- //
- if (family.get().getTargets().size() >= failoverCounter)
- {
- if (!gce.isDefinitive())
- definitivlyRemoveNodeOnFailure = false;
- }
- }
- else
- {
- throw new RuntimeException("Clustering exception thrown", gce);
- }
- } else
- {
- throw t;
- }
- }
-
- // If we reach here, this means that we must fail-over
- family.get().removeDeadTarget(target);
- if (!definitivlyRemoveNodeOnFailure)
- {
- family.get().resetView();
- }
-
- target = (InvokerLocator) lb.chooseTarget(family.get());
- if (target == null)
- {
- if (lastException != null)
- {
- throw new RuntimeException("cluster invocation failed, last exception was: ", lastException);
- }
- else
- {
- throw new RuntimeException("cluster invocation failed");
- }
- }
- failoverCounter++;
- }
- // if we get here this means list was exhausted
- throw new RuntimeException("Unreachable?: Service unavailable.");
- }
-}
Copied: projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/aspects/remoting/ClusterChooserInterceptor.java (from rev 74878, projects/cluster/ha-client/trunk/src/main/java/org/jboss/aspects/remoting/ClusterChooserInterceptor.java)
===================================================================
--- projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/aspects/remoting/ClusterChooserInterceptor.java (rev 0)
+++ projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/aspects/remoting/ClusterChooserInterceptor.java 2008-07-11 02:01:14 UTC (rev 75651)
@@ -0,0 +1,185 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.aspects.remoting;
+
+import org.jboss.aop.DispatcherConnectException;
+import org.jboss.aop.util.PayloadKey;
+import org.jboss.ha.client.loadbalance.AopLoadBalancePolicy;
+import org.jboss.ha.client.loadbalance.LoadBalancePolicy;
+import org.jboss.ha.framework.interfaces.GenericClusteringException;
+import org.jboss.remoting.CannotConnectException;
+import org.jboss.remoting.InvokerLocator;
+
+import java.util.ArrayList;
+
+/**
+ * Pick an invocation target
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @version $Revision: 67153 $
+ */
+public class ClusterChooserInterceptor implements org.jboss.aop.advice.Interceptor, ClusterConstants, java.io.Serializable
+{
+ private static final long serialVersionUID = -8666382019058421135L;
+
+ public static final ClusterChooserInterceptor singleton = new ClusterChooserInterceptor();
+
+ public String getName()
+ {
+ return "ClusterChooserInterceptor";
+ }
+
+ public Object invoke(org.jboss.aop.joinpoint.Invocation invocation)
+ throws Throwable
+ {
+ LoadBalancePolicy lb = (LoadBalancePolicy) invocation.getMetaData(CLUSTERED_REMOTING, LOADBALANCE_POLICY);
+ FamilyWrapper family = (FamilyWrapper) invocation.getMetaData(CLUSTERED_REMOTING, CLUSTER_FAMILY_WRAPPER);
+
+ // we give the opportunity, to any server interceptor, to know if this a
+ // first invocation to a node or if it is a failovered call
+ //
+ int failoverCounter = 0;
+ String familyName = family.get().getFamilyName();
+ invocation.getMetaData().addMetaData(CLUSTERED_REMOTING, CLUSTER_FAMILY, familyName, PayloadKey.AS_IS);
+ InvokerLocator target = null;
+ if (lb instanceof AopLoadBalancePolicy)
+ {
+ target = (InvokerLocator) ((AopLoadBalancePolicy) lb).chooseTarget(family.get(), invocation);
+ }
+ else
+ {
+ target = (InvokerLocator) lb.chooseTarget(family.get());
+ }
+
+ Throwable lastException = null;
+ while (target != null)
+ {
+ invocation.getMetaData().addMetaData(CLUSTERED_REMOTING, FAILOVER_COUNTER, new Integer(failoverCounter), PayloadKey.AS_IS);
+ invocation.getMetaData().addMetaData(InvokeRemoteInterceptor.REMOTING, InvokeRemoteInterceptor.INVOKER_LOCATOR, target, PayloadKey.AS_IS);
+ invocation.getMetaData().addMetaData(CLUSTERED_REMOTING, CLUSTER_VIEW_ID, new Long(family.get().getCurrentViewId()), PayloadKey.AS_IS);
+
+ boolean definitivlyRemoveNodeOnFailure = true;
+ lastException = null;
+ try
+ {
+ Object rsp = invocation.invokeNext();
+ ArrayList newReplicants = (ArrayList) invocation.getResponseAttachment("replicants");
+ if (newReplicants != null)
+ {
+ long newViewId = ((Long) invocation.getResponseAttachment("viewId")).longValue();
+ family.get().updateClusterInfo(newReplicants, newViewId);
+ }
+ return rsp;
+ }
+ catch(DispatcherConnectException dce)
+ {
+ //In case of graceful shutdown, the target object will no longer exist in the Dispatcher,
+ //fail over to another server if we can...
+ //For now remove the node "definitely"
+ lastException = dce;
+ }
+ catch (CannotConnectException ex)
+ {
+ lastException = ex;
+ }
+ catch (GenericClusteringException gce)
+ {
+ lastException = gce;
+ // this is a generic clustering exception that contain the
+ // completion status: usefull to determine if we are authorized
+ // to re-issue a query to another node
+ //
+ if (gce.getCompletionStatus() == GenericClusteringException.COMPLETED_NO)
+ {
+ // we don't want to remove the node from the list of failed
+ // node UNLESS there is a risk to indefinitively loop
+ //
+ if (family.get().getTargets().size() >= failoverCounter)
+ {
+ if (!gce.isDefinitive())
+ definitivlyRemoveNodeOnFailure = false;
+ }
+ }
+ else
+ {
+ throw new RuntimeException("Clustering exception thrown", gce);
+ }
+ }
+ catch (Throwable t)
+ {
+ // Just in case this get wrapped in a Throwable. This can happen when
+ // the exception is generated inside the container and it is wrapped in
+ // a ForwardId exception.
+ if(t.getCause() instanceof GenericClusteringException)
+ {
+ GenericClusteringException gce = (GenericClusteringException)t.getCause();
+ lastException = gce;
+ // this is a generic clustering exception that contain the
+ // completion status: usefull to determine if we are authorized
+ // to re-issue a query to another node
+ //
+ if (gce.getCompletionStatus() == GenericClusteringException.COMPLETED_NO)
+ {
+ // we don't want to remove the node from the list of failed
+ // node UNLESS there is a risk to indefinitively loop
+ //
+ if (family.get().getTargets().size() >= failoverCounter)
+ {
+ if (!gce.isDefinitive())
+ definitivlyRemoveNodeOnFailure = false;
+ }
+ }
+ else
+ {
+ throw new RuntimeException("Clustering exception thrown", gce);
+ }
+ } else
+ {
+ throw t;
+ }
+ }
+
+ // If we reach here, this means that we must fail-over
+ family.get().removeDeadTarget(target);
+ if (!definitivlyRemoveNodeOnFailure)
+ {
+ family.get().resetView();
+ }
+
+ target = (InvokerLocator) lb.chooseTarget(family.get());
+ if (target == null)
+ {
+ if (lastException != null)
+ {
+ throw new RuntimeException("cluster invocation failed, last exception was: ", lastException);
+ }
+ else
+ {
+ throw new RuntimeException("cluster invocation failed");
+ }
+ }
+ failoverCounter++;
+ }
+ // if we get here this means list was exhausted
+ throw new RuntimeException("Unreachable?: Service unavailable.");
+ }
+}
Deleted: projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/aspects/remoting/ClusterConstants.java
===================================================================
--- projects/cluster/ha-client/trunk/src/main/java/org/jboss/aspects/remoting/ClusterConstants.java 2008-05-21 23:22:01 UTC (rev 73569)
+++ projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/aspects/remoting/ClusterConstants.java 2008-07-11 02:01:14 UTC (rev 75651)
@@ -1,39 +0,0 @@
-/*
- * 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.aspects.remoting;
-
-/**
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision: 37406 $
- */
-
-public interface ClusterConstants
-{
- public static final String CLUSTERED_REMOTING = "CLUSTERED_REMOTING";
- public static final String LOADBALANCE_POLICY = "LOADBALANCE_POLICY";
- public static final String FAILOVER_COUNTER = "FAILOVER_COUNTER";
- public static final String CLUSTER_FAMILY_WRAPPER = "CLUSTER_FAMILY_WRAPPER";
- public static final String CLUSTER_FAMILY = "CLUSTER_FAMILY";
- public static final String CLUSTER_FAMILIES = "CLUSTER_FAMILIES";
- public static final String HA_TARGET = "HA_TARGET";
- public static final String CLUSTER_VIEW_ID = "CLUSTER_VIEW_ID";
-}
Copied: projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/aspects/remoting/ClusterConstants.java (from rev 73593, projects/cluster/ha-client/trunk/src/main/java/org/jboss/aspects/remoting/ClusterConstants.java)
===================================================================
--- projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/aspects/remoting/ClusterConstants.java (rev 0)
+++ projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/aspects/remoting/ClusterConstants.java 2008-07-11 02:01:14 UTC (rev 75651)
@@ -0,0 +1,42 @@
+/*
+ * 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.aspects.remoting;
+
+/**
+ * Set of constants used in remoting clustered objects (mostly
+ * as metadata keys in an Invocation).
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @version $Revision: 37406 $
+ */
+public interface ClusterConstants
+{
+ public static final String CLUSTERED_REMOTING = "CLUSTERED_REMOTING";
+ public static final String LOADBALANCE_POLICY = "LOADBALANCE_POLICY";
+ public static final String FAILOVER_COUNTER = "FAILOVER_COUNTER";
+ public static final String CLUSTER_FAMILY_WRAPPER = "CLUSTER_FAMILY_WRAPPER";
+ public static final String CLUSTER_FAMILY = "CLUSTER_FAMILY";
+ public static final String CLUSTER_FAMILIES = "CLUSTER_FAMILIES";
+ public static final String PARTITION_NAME = "PARTITION_NAME";
+ public static final String HA_TARGET = "HA_TARGET";
+ public static final String CLUSTER_VIEW_ID = "CLUSTER_VIEW_ID";
+}
Copied: projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/aspects/remoting/ClusteredPojiProxy.java (from rev 74878, projects/cluster/ha-client/trunk/src/main/java/org/jboss/aspects/remoting/ClusteredPojiProxy.java)
===================================================================
--- projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/aspects/remoting/ClusteredPojiProxy.java (rev 0)
+++ projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/aspects/remoting/ClusteredPojiProxy.java 2008-07-11 02:01:14 UTC (rev 75651)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.aspects.remoting;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import org.jboss.aop.Dispatcher;
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.MethodInvocation;
+import org.jboss.aop.util.MethodHashing;
+import org.jboss.aop.util.PayloadKey;
+import org.jboss.ha.client.loadbalance.LoadBalancePolicy;
+import org.jboss.remoting.InvokerLocator;
+
+/**
+ * InvocationHandler that generates an aop {@link MethodInvocation} and
+ * populates its metadata with a target URI as well as various pieces of
+ * clustering metadata.
+ *
+ * @author Brian Stansberry, based on work by Bill Burke
+ */
+public class ClusteredPojiProxy implements java.io.Serializable, InvocationHandler
+{
+ private static final long serialVersionUID = 8054816523858555978L;
+
+ private Object oid;
+ private InvokerLocator uri;
+ private Interceptor[] interceptors;
+ private FamilyWrapper family;
+ private LoadBalancePolicy lbPolicy;
+ private String partitionName;
+ private Object originTarget;
+
+ public ClusteredPojiProxy(Object oid, InvokerLocator uri, Interceptor[] interceptors,
+ FamilyWrapper family, LoadBalancePolicy lb,
+ String partitionName, Object originTarget)
+ {
+ this.oid = oid;
+ this.uri = uri;
+ this.interceptors = interceptors;
+ this.family = family;
+ this.lbPolicy = lb;
+ this.partitionName = partitionName;
+ this.originTarget = originTarget;
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
+ {
+ long hash = MethodHashing.calculateHash(method);
+ MethodInvocation sri = new MethodInvocation(interceptors, hash, method, method, null);
+ sri.setArguments(args);
+ sri.getMetaData().addMetaData(ClusterConstants.CLUSTERED_REMOTING, ClusterConstants.CLUSTER_FAMILY_WRAPPER, family, PayloadKey.TRANSIENT);
+ sri.getMetaData().addMetaData(ClusterConstants.CLUSTERED_REMOTING, ClusterConstants.LOADBALANCE_POLICY, lbPolicy, PayloadKey.TRANSIENT);
+ sri.getMetaData().addMetaData(ClusterConstants.CLUSTERED_REMOTING, ClusterConstants.PARTITION_NAME, partitionName, PayloadKey.TRANSIENT);
+ if (originTarget != null)
+ sri.getMetaData().addMetaData(ClusterConstants.CLUSTERED_REMOTING, ClusterConstants.HA_TARGET, originTarget, PayloadKey.TRANSIENT);
+ sri.getMetaData().addMetaData(Dispatcher.DISPATCHER, Dispatcher.OID, oid, PayloadKey.AS_IS);
+ sri.getMetaData().addMetaData(InvokeRemoteInterceptor.REMOTING, InvokeRemoteInterceptor.INVOKER_LOCATOR, uri, PayloadKey.AS_IS);
+ sri.getMetaData().addMetaData(InvokeRemoteInterceptor.REMOTING, InvokeRemoteInterceptor.SUBSYSTEM, "AOP", PayloadKey.AS_IS);
+ return sri.invokeNext();
+ }
+}
Deleted: projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/aspects/remoting/FamilyWrapper.java
===================================================================
--- projects/cluster/ha-client/trunk/src/main/java/org/jboss/aspects/remoting/FamilyWrapper.java 2008-05-21 23:22:01 UTC (rev 73569)
+++ projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/aspects/remoting/FamilyWrapper.java 2008-07-11 02:01:14 UTC (rev 75651)
@@ -1,70 +0,0 @@
-/*
- * 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.aspects.remoting;
-
-import org.jboss.ha.framework.interfaces.ClusteringTargetsRepository;
-import org.jboss.ha.framework.interfaces.FamilyClusterInfo;
-
-import java.io.IOException;
-import java.util.List;
-/**
- * Handles serialization of a {@link FamilyClusterInfo}.
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision: 67102 $
- */
-public class FamilyWrapper implements java.io.Externalizable
-{
- private static final long serialVersionUID = 3880844152274576311L;
-
- private FamilyClusterInfo info;
-
- public FamilyWrapper() {}
-
- public FamilyWrapper(String proxyFamilyName, List targets)
- {
- info = ClusteringTargetsRepository.initTarget(proxyFamilyName, targets);
- }
-
- public FamilyClusterInfo get() { return info; }
-
- public void writeExternal(final java.io.ObjectOutput out)
- throws IOException
- {
- out.writeObject(info.getFamilyName());
- out.writeObject(info.getTargets());
- }
-
- /**
- * Un-externalize this instance.
- */
- public void readExternal(final java.io.ObjectInput in)
- throws IOException, ClassNotFoundException
- {
- String proxyFamilyName = (String)in.readObject();
- List targets = (List)in.readObject();
- // keep a reference on our family object
- //
- this.info = ClusteringTargetsRepository.initTarget(proxyFamilyName, targets);
- }
-
-}
Copied: projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/aspects/remoting/FamilyWrapper.java (from rev 74878, projects/cluster/ha-client/trunk/src/main/java/org/jboss/aspects/remoting/FamilyWrapper.java)
===================================================================
--- projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/aspects/remoting/FamilyWrapper.java (rev 0)
+++ projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/aspects/remoting/FamilyWrapper.java 2008-07-11 02:01:14 UTC (rev 75651)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.aspects.remoting;
+
+import org.jboss.ha.framework.interfaces.ClusteringTargetsRepository;
+import org.jboss.ha.framework.interfaces.FamilyClusterInfo;
+
+import java.io.IOException;
+import java.util.List;
+/**
+ * Handles serialization of a {@link FamilyClusterInfo}.
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @version $Revision: 67102 $
+ */
+public class FamilyWrapper implements java.io.Externalizable
+{
+ private static final long serialVersionUID = 3880844152274576311L;
+
+ private FamilyClusterInfo info;
+
+ public FamilyWrapper() {}
+
+ public FamilyWrapper(String proxyFamilyName, List targets)
+ {
+ info = ClusteringTargetsRepository.initTarget(proxyFamilyName, targets);
+ }
+
+ public FamilyClusterInfo get() { return info; }
+
+ public void writeExternal(final java.io.ObjectOutput out)
+ throws IOException
+ {
+ out.writeObject(info.getFamilyName());
+ out.writeObject(info.getTargets());
+ }
+
+ /**
+ * Un-externalize this instance.
+ */
+ public void readExternal(final java.io.ObjectInput in)
+ throws IOException, ClassNotFoundException
+ {
+ String proxyFamilyName = (String)in.readObject();
+ List targets = (List)in.readObject();
+ // keep a reference on our family object
+ //
+ this.info = ClusteringTargetsRepository.initTarget(proxyFamilyName, targets);
+ }
+
+}
Deleted: projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/AopLoadBalancePolicy.java
===================================================================
--- projects/cluster/ha-client/trunk/src/main/java/org/jboss/ha/client/loadbalance/AopLoadBalancePolicy.java 2008-05-21 23:22:01 UTC (rev 73569)
+++ projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/AopLoadBalancePolicy.java 2008-07-11 02:01:14 UTC (rev 75651)
@@ -1,49 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, 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.client.loadbalance;
-
-import org.jboss.aop.joinpoint.Invocation;
-import org.jboss.ha.framework.interfaces.FamilyClusterInfo;
-
-
-/**
- * Extends the {@link LoadBalancePolicy parent interface}
- * by adding support for passing in an AOP {@link Invocation}
- * as an aid in making the choice of targets.
- *
- * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
- * @version $Revision: 1.1 $
- */
-public interface AopLoadBalancePolicy extends LoadBalancePolicy
-{
- /**
- * Called when the stub wishes to know on which node the next invocation must
- * be performed.
- * @param clusterFamily A list of potential target nodes
- * @param routingDecision The actual invocation object if the policy wants
- * to have some kind of invocation-based routing strategy
- * @return The selected target for the next invocation
- */
- public Object chooseTarget (FamilyClusterInfo clusterFamily, Invocation routingDecision);
-
-}
Copied: projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/AopLoadBalancePolicy.java (from rev 74878, projects/cluster/ha-client/trunk/src/main/java/org/jboss/ha/client/loadbalance/AopLoadBalancePolicy.java)
===================================================================
--- projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/AopLoadBalancePolicy.java (rev 0)
+++ projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/AopLoadBalancePolicy.java 2008-07-11 02:01:14 UTC (rev 75651)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.ha.client.loadbalance;
+
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.ha.framework.interfaces.FamilyClusterInfo;
+
+
+/**
+ * Extends the {@link LoadBalancePolicy parent interface}
+ * by adding support for passing in an AOP {@link Invocation}
+ * as an aid in making the choice of targets.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1 $
+ */
+public interface AopLoadBalancePolicy extends LoadBalancePolicy
+{
+ /**
+ * Called when the stub wishes to know on which node the next invocation must
+ * be performed.
+ * @param clusterFamily A list of potential target nodes
+ * @param routingDecision The actual invocation object if the policy wants
+ * to have some kind of invocation-based routing strategy
+ * @return The selected target for the next invocation
+ */
+ public Object chooseTarget (FamilyClusterInfo clusterFamily, Invocation routingDecision);
+
+}
Deleted: projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/FirstAvailable.java
===================================================================
--- projects/cluster/ha-client/trunk/src/main/java/org/jboss/ha/client/loadbalance/FirstAvailable.java 2008-05-21 23:22:01 UTC (rev 73569)
+++ projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/FirstAvailable.java 2008-07-11 02:01:14 UTC (rev 75651)
@@ -1,94 +0,0 @@
-/*
- * JBoss, a division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, 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.ha.client.loadbalance;
-
-import java.util.List;
-
-import org.jboss.ha.framework.interfaces.FamilyClusterInfo;
-
-
-
-/**
- * LoadBalancePolicy implementation that, once a target is chosen, always favors
- * that same target; i.e. no further load balancing occurs. Useful in cases where
- * "sticky session" behavior is desired. Initially the favored
- * target is randomly selected, so different instances of this class
- * will likely not all select the same target; thus load balancing does occur
- * across different proxies. Favoring the same target does not
- * mean that fail-over will not occur if the chosen target dies. In this case,
- * fail-over will occur, and a new favored target will be randomly chosen and
- * invocation will continously be invoked on this new target until its death.
- * <p>
- * Each proxy using this policy will choose its own
- * preferred target: the target is not shared accross the proxy family. For
- * shared behaviour please take a look at
- * {@link FirstAvailableIdenticalAllProxies}.
- * </p>
- *
- * @author <a href="mailto:bill at burkecentral.com">Bill Burke</a>.
- * @author <a href="mailto:sacha.labourey at cogito-info.ch">Sacha Labourey</a>.
- * @author brian.stansberry at jboss.com
- *
- * @version $Revision: 57642 $
- *
- * @see org.jboss.ha.client.loadbalance.LoadBalancePolicy
- */
-
-public class FirstAvailable implements LoadBalancePolicy
-{
- // Constants -----------------------------------------------------
-
- private static final long serialVersionUID = 2008524502721775114L;
-
- // Attributes ----------------------------------------------------
-
- protected Object electedTarget = null;
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- public Object chooseTarget (FamilyClusterInfo clusterFamily)
- {
- List targets = clusterFamily.getTargets ();
- if (targets.size () == 0)
- return null;
-
- if ( (this.electedTarget != null) && targets.contains (this.electedTarget) )
- {
- return this.electedTarget;
- }
- else
- {
- this.electedTarget = electTarget(targets);
- return this.electedTarget;
- }
- }
-
- protected Object electTarget(List targets)
- {
- int cursor = RandomRobin.localRandomizer.nextInt(targets.size());
- return targets.get(cursor);
- }
-}
Copied: projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/FirstAvailable.java (from rev 74878, projects/cluster/ha-client/trunk/src/main/java/org/jboss/ha/client/loadbalance/FirstAvailable.java)
===================================================================
--- projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/FirstAvailable.java (rev 0)
+++ projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/FirstAvailable.java 2008-07-11 02:01:14 UTC (rev 75651)
@@ -0,0 +1,94 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.ha.client.loadbalance;
+
+import java.util.List;
+
+import org.jboss.ha.framework.interfaces.FamilyClusterInfo;
+
+
+
+/**
+ * LoadBalancePolicy implementation that, once a target is chosen, always favors
+ * that same target; i.e. no further load balancing occurs. Useful in cases where
+ * "sticky session" behavior is desired. Initially the favored
+ * target is randomly selected, so different instances of this class
+ * will likely not all select the same target; thus load balancing does occur
+ * across different proxies. Favoring the same target does not
+ * mean that fail-over will not occur if the chosen target dies. In this case,
+ * fail-over will occur, and a new favored target will be randomly chosen and
+ * invocation will continously be invoked on this new target until its death.
+ * <p>
+ * Each proxy using this policy will choose its own
+ * preferred target: the target is not shared accross the proxy family. For
+ * shared behaviour please take a look at
+ * {@link FirstAvailableIdenticalAllProxies}.
+ * </p>
+ *
+ * @author <a href="mailto:bill at burkecentral.com">Bill Burke</a>.
+ * @author <a href="mailto:sacha.labourey at cogito-info.ch">Sacha Labourey</a>.
+ * @author brian.stansberry at jboss.com
+ *
+ * @version $Revision: 57642 $
+ *
+ * @see org.jboss.ha.client.loadbalance.LoadBalancePolicy
+ */
+
+public class FirstAvailable implements LoadBalancePolicy
+{
+ // Constants -----------------------------------------------------
+
+ private static final long serialVersionUID = 2008524502721775114L;
+
+ // Attributes ----------------------------------------------------
+
+ protected Object electedTarget = null;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ public Object chooseTarget (FamilyClusterInfo clusterFamily)
+ {
+ List targets = clusterFamily.getTargets ();
+ if (targets.size () == 0)
+ return null;
+
+ if ( (this.electedTarget != null) && targets.contains (this.electedTarget) )
+ {
+ return this.electedTarget;
+ }
+ else
+ {
+ this.electedTarget = electTarget(targets);
+ return this.electedTarget;
+ }
+ }
+
+ protected Object electTarget(List targets)
+ {
+ int cursor = RandomRobin.localRandomizer.nextInt(targets.size());
+ return targets.get(cursor);
+ }
+}
Deleted: projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/FirstAvailableIdenticalAllProxies.java
===================================================================
--- projects/cluster/ha-client/trunk/src/main/java/org/jboss/ha/client/loadbalance/FirstAvailableIdenticalAllProxies.java 2008-05-21 23:22:01 UTC (rev 73569)
+++ projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/FirstAvailableIdenticalAllProxies.java 2008-07-11 02:01:14 UTC (rev 75651)
@@ -1,85 +0,0 @@
-/*
- * JBoss, a division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, 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.ha.client.loadbalance;
-
-import java.util.List;
-
-import org.jboss.ha.framework.interfaces.FamilyClusterInfo;
-
-
-
-/**
- * Extends the "sticky session" behavior of {@link FirstAvailable} by caching
- * the favored target in the {@link FamilyClusterInfo}, thus allowing different
- * proxies for the same family to use the same favored target.
- * <p>
- * See {@link FirstAvailable} for the basic behavior.
- * </p>
- *
- * @see org.jboss.ha.client.loadbalance.LoadBalancePolicy
- * @see org.jboss.ha.framework.interfaces.FamilyClusterInfo#getObject()
- *
- * @author <a href="mailto:sacha.labourey at cogito-info.ch">Sacha Labourey</a>.
- * @author brian.stansberry at jboss.com
- *
- * @version $Revision: 57642 $
- */
-public class FirstAvailableIdenticalAllProxies implements LoadBalancePolicy
-{
- // Constants -----------------------------------------------------
- private static final long serialVersionUID = 2910756623413400467L;
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- public Object chooseTarget (FamilyClusterInfo clusterFamily)
- {
- Object target = clusterFamily.getObject ();
- List targets = clusterFamily.getTargets ();
-
- if (targets.size () == 0)
- return null;
-
- if (target != null && targets.contains (target) )
- {
- return target;
- }
- else
- {
- target = electTarget(targets);
- clusterFamily.setObject (target);
- return target;
- }
- }
-
- protected Object electTarget(List targets)
- {
- int cursor = RandomRobin.localRandomizer.nextInt(targets.size());
- return targets.get(cursor);
- }
-
-}
Copied: projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/FirstAvailableIdenticalAllProxies.java (from rev 74878, projects/cluster/ha-client/trunk/src/main/java/org/jboss/ha/client/loadbalance/FirstAvailableIdenticalAllProxies.java)
===================================================================
--- projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/FirstAvailableIdenticalAllProxies.java (rev 0)
+++ projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/FirstAvailableIdenticalAllProxies.java 2008-07-11 02:01:14 UTC (rev 75651)
@@ -0,0 +1,85 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.ha.client.loadbalance;
+
+import java.util.List;
+
+import org.jboss.ha.framework.interfaces.FamilyClusterInfo;
+
+
+
+/**
+ * Extends the "sticky session" behavior of {@link FirstAvailable} by caching
+ * the favored target in the {@link FamilyClusterInfo}, thus allowing different
+ * proxies for the same family to use the same favored target.
+ * <p>
+ * See {@link FirstAvailable} for the basic behavior.
+ * </p>
+ *
+ * @see org.jboss.ha.client.loadbalance.LoadBalancePolicy
+ * @see org.jboss.ha.framework.interfaces.FamilyClusterInfo#getObject()
+ *
+ * @author <a href="mailto:sacha.labourey at cogito-info.ch">Sacha Labourey</a>.
+ * @author brian.stansberry at jboss.com
+ *
+ * @version $Revision: 57642 $
+ */
+public class FirstAvailableIdenticalAllProxies implements LoadBalancePolicy
+{
+ // Constants -----------------------------------------------------
+ private static final long serialVersionUID = 2910756623413400467L;
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ public Object chooseTarget (FamilyClusterInfo clusterFamily)
+ {
+ Object target = clusterFamily.getObject ();
+ List targets = clusterFamily.getTargets ();
+
+ if (targets.size () == 0)
+ return null;
+
+ if (target != null && targets.contains (target) )
+ {
+ return target;
+ }
+ else
+ {
+ target = electTarget(targets);
+ clusterFamily.setObject (target);
+ return target;
+ }
+ }
+
+ protected Object electTarget(List targets)
+ {
+ int cursor = RandomRobin.localRandomizer.nextInt(targets.size());
+ return targets.get(cursor);
+ }
+
+}
Deleted: projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/LoadBalancePolicy.java
===================================================================
--- projects/cluster/ha-client/trunk/src/main/java/org/jboss/ha/client/loadbalance/LoadBalancePolicy.java 2008-05-21 23:22:01 UTC (rev 73569)
+++ projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/LoadBalancePolicy.java 2008-07-11 02:01:14 UTC (rev 75651)
@@ -1,59 +0,0 @@
-/*
- * JBoss, a division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, 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.ha.client.loadbalance;
-
-import java.io.Serializable;
-
-import org.jboss.ha.framework.interfaces.FamilyClusterInfo;
-
-
-/**
- * Base interface for load-balancing policies. It is possible to implement many
- * different load-balancing policies by implementing this simple interface and
- * using it in the different clustered services (home interface of SLSB for
- * example)
- *
- * @author <a href="mailto:bill at burkecentral.com">Bill Burke</a>.
- * @author <a href="mailto:sacha.labourey at cogito-info.ch">Sacha Labourey</a>.
- * @author brian.stansberry at jboss.com
- *
- * @version $Revision: 57642 $
- */
-public interface LoadBalancePolicy extends Serializable
-{
- /** The serialVersionUID
- * @since 1.3.4.2
- */
- static final long serialVersionUID = -5071668971774090555L;
-
- /**
- * Gets the target for the next remote call.
- * <p>
- * Called when the client wishes to know on which node the next invocation must
- * be performed.
- * </p>
- *
- * @param clusterFamily object encapsulating a list of potential target nodes
- * @return The selected target for the next invocation
- */
- public Object chooseTarget (FamilyClusterInfo clusterFamily);
-}
Copied: projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/LoadBalancePolicy.java (from rev 74878, projects/cluster/ha-client/trunk/src/main/java/org/jboss/ha/client/loadbalance/LoadBalancePolicy.java)
===================================================================
--- projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/LoadBalancePolicy.java (rev 0)
+++ projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/LoadBalancePolicy.java 2008-07-11 02:01:14 UTC (rev 75651)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.ha.client.loadbalance;
+
+import java.io.Serializable;
+
+import org.jboss.ha.framework.interfaces.FamilyClusterInfo;
+
+
+/**
+ * Base interface for load-balancing policies. It is possible to implement many
+ * different load-balancing policies by implementing this simple interface and
+ * using it in the different clustered services (home interface of SLSB for
+ * example)
+ *
+ * @author <a href="mailto:bill at burkecentral.com">Bill Burke</a>.
+ * @author <a href="mailto:sacha.labourey at cogito-info.ch">Sacha Labourey</a>.
+ * @author brian.stansberry at jboss.com
+ *
+ * @version $Revision: 57642 $
+ */
+public interface LoadBalancePolicy extends Serializable
+{
+ /** The serialVersionUID
+ * @since 1.3.4.2
+ */
+ static final long serialVersionUID = -5071668971774090555L;
+
+ /**
+ * Gets the target for the next remote call.
+ * <p>
+ * Called when the client wishes to know on which node the next invocation must
+ * be performed.
+ * </p>
+ *
+ * @param clusterFamily object encapsulating a list of potential target nodes
+ * @return The selected target for the next invocation
+ */
+ public Object chooseTarget (FamilyClusterInfo clusterFamily);
+}
Deleted: projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/RandomRobin.java
===================================================================
--- projects/cluster/ha-client/trunk/src/main/java/org/jboss/ha/client/loadbalance/RandomRobin.java 2008-05-21 23:22:01 UTC (rev 73569)
+++ projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/RandomRobin.java 2008-07-11 02:01:14 UTC (rev 75651)
@@ -1,77 +0,0 @@
-/*
- * 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.ha.client.loadbalance;
-
-import java.util.List;
-import java.util.Random;
-
-import org.jboss.ha.framework.interfaces.FamilyClusterInfo;
-
-
-
-/**
- * LoadBalancePolicy implementation that always fully randomly selects its target
- * (without basing its decision on any history).
- *
- * @author <a href="mailto:sacha.labourey at cogito-info.ch">Sacha Labourey</a>.
- * @author brian.stansberry at jboss.com
- *
- * @version $Revision: 57642 $
- *
- * @see org.jboss.ha.client.loadbalance.LoadBalancePolicy
- */
-public class RandomRobin implements LoadBalancePolicy
-{
- // Constants -----------------------------------------------------
- /** @since 1.1.2.3 */
- private static final long serialVersionUID = -3599638697906618428L;
-
- /**
- * <code>Random</code> used to pick the target.
- * This needs to be a class variable or else you end up with multiple
- * Random numbers with the same seed when many clients lookup a proxy.
- * We make this public so other LoadBalancePolicy implementations can
- * use it.
- */
- public static final Random localRandomizer = new Random (System.currentTimeMillis ());
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- // LoadBalancePolicy implementation ----------------------------------------------
-
- public Object chooseTarget (FamilyClusterInfo clusterFamily)
- {
- List targets = clusterFamily.getTargets ();
- int max = targets.size();
-
- if (max == 0)
- return null;
-
- int cursor = localRandomizer.nextInt (max);
- return targets.get(cursor);
- }
-
-}
Copied: projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/RandomRobin.java (from rev 74878, projects/cluster/ha-client/trunk/src/main/java/org/jboss/ha/client/loadbalance/RandomRobin.java)
===================================================================
--- projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/RandomRobin.java (rev 0)
+++ projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/RandomRobin.java 2008-07-11 02:01:14 UTC (rev 75651)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.ha.client.loadbalance;
+
+import java.util.List;
+import java.util.Random;
+
+import org.jboss.ha.framework.interfaces.FamilyClusterInfo;
+
+
+
+/**
+ * LoadBalancePolicy implementation that always fully randomly selects its target
+ * (without basing its decision on any history).
+ *
+ * @author <a href="mailto:sacha.labourey at cogito-info.ch">Sacha Labourey</a>.
+ * @author brian.stansberry at jboss.com
+ *
+ * @version $Revision: 57642 $
+ *
+ * @see org.jboss.ha.client.loadbalance.LoadBalancePolicy
+ */
+public class RandomRobin implements LoadBalancePolicy
+{
+ // Constants -----------------------------------------------------
+ /** @since 1.1.2.3 */
+ private static final long serialVersionUID = -3599638697906618428L;
+
+ /**
+ * <code>Random</code> used to pick the target.
+ * This needs to be a class variable or else you end up with multiple
+ * Random numbers with the same seed when many clients lookup a proxy.
+ * We make this public so other LoadBalancePolicy implementations can
+ * use it.
+ */
+ public static final Random localRandomizer = new Random (System.currentTimeMillis ());
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ // LoadBalancePolicy implementation ----------------------------------------------
+
+ public Object chooseTarget (FamilyClusterInfo clusterFamily)
+ {
+ List targets = clusterFamily.getTargets ();
+ int max = targets.size();
+
+ if (max == 0)
+ return null;
+
+ int cursor = localRandomizer.nextInt (max);
+ return targets.get(cursor);
+ }
+
+}
Deleted: projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/RoundRobin.java
===================================================================
--- projects/cluster/ha-client/trunk/src/main/java/org/jboss/ha/client/loadbalance/RoundRobin.java 2008-05-21 23:22:01 UTC (rev 73569)
+++ projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/RoundRobin.java 2008-07-11 02:01:14 UTC (rev 75651)
@@ -1,91 +0,0 @@
-/*
- * 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.ha.client.loadbalance;
-
-import java.util.List;
-
-import org.jboss.ha.framework.interfaces.FamilyClusterInfo;
-
-
-
-/**
- * LoadBalancePolicy implementation that always favors the next available
- * target in the list, ensuring maximum load balancing always occurs.
- * <p>
- * Different instances of this class will coordinate their target
- * selection via the
- * {@link FamilyClusterInfo#getCursor() FamilyClusterInfo cursor}, so if
- * proxy A makes the first call to target 1, and proxy B makes the next
- * call, it will invoke on target 2; the third call will go to
- * target 3 no matter which proxy makes it, and so on.
- * </p>
- * <p>
- * The first target in the round-robin is chosen randomly, ensuring that
- * proper load balancing occurs when many clients in different VM's download
- * the proxy.
- * </p>
- *
- * @see org.jboss.ha.client.loadbalance.LoadBalancePolicy
- * @see org.jboss.ha.framework.interfaces.FamilyClusterInfo#getCursor()
- *
- * @author <a href="mailto:sacha.labourey at cogito-info.ch">Sacha Labourey</a>.
- * @author <a href="mailto:bill at burkecentral.com">Bill Burke</a>.
- * @version $Revision: 57642 $
- */
-public class RoundRobin implements LoadBalancePolicy
-{
- // Constants -----------------------------------------------------
- /** @since 1.3.4.2 */
- private static final long serialVersionUID = 8660076707279597114L;
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- public Object chooseTarget (FamilyClusterInfo clusterFamily)
- {
- int cursor = clusterFamily.getCursor ();
- List targets = clusterFamily.getTargets ();
-
- if (targets.size () == 0)
- return null;
-
- if (cursor == FamilyClusterInfo.UNINITIALIZED_CURSOR)
- {
- // Obtain a random index into targets
- cursor = RandomRobin.localRandomizer.nextInt(targets.size());
- }
- else
- {
- // Choose the next target
- cursor = ( (cursor + 1) % targets.size() );
- }
- clusterFamily.setCursor (cursor);
-
- return targets.get(cursor);
- }
-
-}
Copied: projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/RoundRobin.java (from rev 74878, projects/cluster/ha-client/trunk/src/main/java/org/jboss/ha/client/loadbalance/RoundRobin.java)
===================================================================
--- projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/RoundRobin.java (rev 0)
+++ projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/RoundRobin.java 2008-07-11 02:01:14 UTC (rev 75651)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.ha.client.loadbalance;
+
+import java.util.List;
+
+import org.jboss.ha.framework.interfaces.FamilyClusterInfo;
+
+
+
+/**
+ * LoadBalancePolicy implementation that always favors the next available
+ * target in the list, ensuring maximum load balancing always occurs.
+ * <p>
+ * Different instances of this class will coordinate their target
+ * selection via the
+ * {@link FamilyClusterInfo#getCursor() FamilyClusterInfo cursor}, so if
+ * proxy A makes the first call to target 1, and proxy B makes the next
+ * call, it will invoke on target 2; the third call will go to
+ * target 3 no matter which proxy makes it, and so on.
+ * </p>
+ * <p>
+ * The first target in the round-robin is chosen randomly, ensuring that
+ * proper load balancing occurs when many clients in different VM's download
+ * the proxy.
+ * </p>
+ *
+ * @see org.jboss.ha.client.loadbalance.LoadBalancePolicy
+ * @see org.jboss.ha.framework.interfaces.FamilyClusterInfo#getCursor()
+ *
+ * @author <a href="mailto:sacha.labourey at cogito-info.ch">Sacha Labourey</a>.
+ * @author <a href="mailto:bill at burkecentral.com">Bill Burke</a>.
+ * @version $Revision: 57642 $
+ */
+public class RoundRobin implements LoadBalancePolicy
+{
+ // Constants -----------------------------------------------------
+ /** @since 1.3.4.2 */
+ private static final long serialVersionUID = 8660076707279597114L;
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ public Object chooseTarget (FamilyClusterInfo clusterFamily)
+ {
+ int cursor = clusterFamily.getCursor ();
+ List targets = clusterFamily.getTargets ();
+
+ if (targets.size () == 0)
+ return null;
+
+ if (cursor == FamilyClusterInfo.UNINITIALIZED_CURSOR)
+ {
+ // Obtain a random index into targets
+ cursor = RandomRobin.localRandomizer.nextInt(targets.size());
+ }
+ else
+ {
+ // Choose the next target
+ cursor = ( (cursor + 1) % targets.size() );
+ }
+ clusterFamily.setCursor (cursor);
+
+ return targets.get(cursor);
+ }
+
+}
Deleted: projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/aop/FirstAvailable.java
===================================================================
--- projects/cluster/ha-client/trunk/src/main/java/org/jboss/ha/client/loadbalance/aop/FirstAvailable.java 2008-05-21 23:22:01 UTC (rev 73569)
+++ projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/aop/FirstAvailable.java 2008-07-11 02:01:14 UTC (rev 75651)
@@ -1,95 +0,0 @@
-/*
- * JBoss, a division of Red Hat
- * Copyright 2008, Red Hat Middleware, LLC, 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.ha.client.loadbalance.aop;
-
-import java.util.List;
-
-import org.jboss.aop.joinpoint.Invocation;
-import org.jboss.aspects.remoting.ClusterConstants;
-import org.jboss.ha.client.loadbalance.AopLoadBalancePolicy;
-import org.jboss.ha.framework.interfaces.FamilyClusterInfo;
-
-
-/**
- * LoadBalancePolicy implementation that, once a target is chosen, always favors
- * that same target; i.e. no further load balancing occurs. Useful in cases where
- * "sticky session" behavior is desired. Differs from the
- * {@link org.jboss.ha.client.loadbalance.FirstAvailable superclass} in the way
- * that the {@link #chooseTarget(FamilyClusterInfo, Invocation)} method
- * initially selects the target. Instead of always randomly selecting the target,
- * the method will check the passed invocation's metadata for the
- * {@link ClusterConstants#HA_TARGET} key in the
- * {@link ClusterConstants#CLUSTERED_REMOTING} group. If an object is found
- * there and it is a valid target associated with the given FamilyClusterInfo,
- * that target will be used. Otherwise the target will be randomly chosen.
- * This mechanism allows the proxy that contains this policy to specify the
- * preferred target via invocation metadata.
- * <p>
- * Each proxy using this policy will choose its own
- * preferred target: the target is not shared accross the proxy family. For
- * shared behaviour please take a look at
- * {@link FirstAvailableIdenticalAllProxies}.
- * </p>
- *
- * @author Brian Stansberry
- *
- * @version $Revision: 57642 $
- */
-public class FirstAvailable
-extends org.jboss.ha.client.loadbalance.FirstAvailable
-implements AopLoadBalancePolicy
-{
- // Constants -----------------------------------------------------
-
- private static final long serialVersionUID = 2008524502721775114L;
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- public Object chooseTarget (FamilyClusterInfo clusterFamily, Invocation invocation)
- {
- List targets = clusterFamily.getTargets ();
- if (targets.size () == 0)
- return null;
-
- if ( (this.electedTarget != null) && targets.contains (this.electedTarget) )
- {
- return this.electedTarget;
- }
- else
- {
- this.electedTarget = electTarget(targets, invocation);
- return this.electedTarget;
- }
- }
-
- private Object electTarget(List targets, Invocation invocation)
- {
- Object target = invocation.getMetaData(ClusterConstants.CLUSTERED_REMOTING, ClusterConstants.HA_TARGET);
- if (target == null || !targets.contains(target))
- target = electTarget(targets);
- return target;
- }
-}
Copied: projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/aop/FirstAvailable.java (from rev 74878, projects/cluster/ha-client/trunk/src/main/java/org/jboss/ha/client/loadbalance/aop/FirstAvailable.java)
===================================================================
--- projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/aop/FirstAvailable.java (rev 0)
+++ projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/aop/FirstAvailable.java 2008-07-11 02:01:14 UTC (rev 75651)
@@ -0,0 +1,95 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.ha.client.loadbalance.aop;
+
+import java.util.List;
+
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aspects.remoting.ClusterConstants;
+import org.jboss.ha.client.loadbalance.AopLoadBalancePolicy;
+import org.jboss.ha.framework.interfaces.FamilyClusterInfo;
+
+
+/**
+ * LoadBalancePolicy implementation that, once a target is chosen, always favors
+ * that same target; i.e. no further load balancing occurs. Useful in cases where
+ * "sticky session" behavior is desired. Differs from the
+ * {@link org.jboss.ha.client.loadbalance.FirstAvailable superclass} in the way
+ * that the {@link #chooseTarget(FamilyClusterInfo, Invocation)} method
+ * initially selects the target. Instead of always randomly selecting the target,
+ * the method will check the passed invocation's metadata for the
+ * {@link ClusterConstants#HA_TARGET} key in the
+ * {@link ClusterConstants#CLUSTERED_REMOTING} group. If an object is found
+ * there and it is a valid target associated with the given FamilyClusterInfo,
+ * that target will be used. Otherwise the target will be randomly chosen.
+ * This mechanism allows the proxy that contains this policy to specify the
+ * preferred target via invocation metadata.
+ * <p>
+ * Each proxy using this policy will choose its own
+ * preferred target: the target is not shared accross the proxy family. For
+ * shared behaviour please take a look at
+ * {@link FirstAvailableIdenticalAllProxies}.
+ * </p>
+ *
+ * @author Brian Stansberry
+ *
+ * @version $Revision: 57642 $
+ */
+public class FirstAvailable
+extends org.jboss.ha.client.loadbalance.FirstAvailable
+implements AopLoadBalancePolicy
+{
+ // Constants -----------------------------------------------------
+
+ private static final long serialVersionUID = 2008524502721775114L;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ public Object chooseTarget (FamilyClusterInfo clusterFamily, Invocation invocation)
+ {
+ List targets = clusterFamily.getTargets ();
+ if (targets.size () == 0)
+ return null;
+
+ if ( (this.electedTarget != null) && targets.contains (this.electedTarget) )
+ {
+ return this.electedTarget;
+ }
+ else
+ {
+ this.electedTarget = electTarget(targets, invocation);
+ return this.electedTarget;
+ }
+ }
+
+ private Object electTarget(List targets, Invocation invocation)
+ {
+ Object target = invocation.getMetaData(ClusterConstants.CLUSTERED_REMOTING, ClusterConstants.HA_TARGET);
+ if (target == null || !targets.contains(target))
+ target = electTarget(targets);
+ return target;
+ }
+}
Deleted: projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/aop/FirstAvailableIdenticalAllProxies.java
===================================================================
--- projects/cluster/ha-client/trunk/src/main/java/org/jboss/ha/client/loadbalance/aop/FirstAvailableIdenticalAllProxies.java 2008-05-21 23:22:01 UTC (rev 73569)
+++ projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/aop/FirstAvailableIdenticalAllProxies.java 2008-07-11 02:01:14 UTC (rev 75651)
@@ -1,90 +0,0 @@
-/*
- * JBoss, a division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, 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.ha.client.loadbalance.aop;
-
-import java.util.List;
-
-import org.jboss.aop.joinpoint.Invocation;
-import org.jboss.aspects.remoting.ClusterConstants;
-import org.jboss.ha.client.loadbalance.AopLoadBalancePolicy;
-import org.jboss.ha.framework.interfaces.FamilyClusterInfo;
-
-
-
-/**
- * Extends the "sticky session" behavior of {@link FirstAvailable} by caching
- * the favored target in the {@link FamilyClusterInfo}, thus allowing different
- * proxies for the same family to use the same favored target.
- * <p>
- * See {@link FirstAvailable} for the basic behavior.
- * </p>
- *
- * @see org.jboss.ha.framework.interfaces.FamilyClusterInfo#getObject()
- *
- * @author Brian Stansberry
- *
- * @version $Revision: 57642 $
- */
-public class FirstAvailableIdenticalAllProxies
-extends org.jboss.ha.client.loadbalance.FirstAvailableIdenticalAllProxies
-implements AopLoadBalancePolicy
-{
- // Constants -----------------------------------------------------
- private static final long serialVersionUID = 2910756623413400467L;
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- public Object chooseTarget (FamilyClusterInfo clusterFamily, Invocation invocation)
- {
- Object target = clusterFamily.getObject ();
- List targets = clusterFamily.getTargets ();
-
- if (targets.size () == 0)
- return null;
-
- if (target != null && targets.contains (target) )
- {
- return target;
- }
- else
- {
- target = electTarget(targets, invocation);
- clusterFamily.setObject (target);
- return target;
- }
- }
-
- private Object electTarget(List targets, Invocation invocation)
- {
- Object target = invocation.getMetaData(ClusterConstants.CLUSTERED_REMOTING, ClusterConstants.HA_TARGET);
- if (target == null || !targets.contains(target))
- target = electTarget(targets);
- return target;
- }
-
-}
Copied: projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/aop/FirstAvailableIdenticalAllProxies.java (from rev 74878, projects/cluster/ha-client/trunk/src/main/java/org/jboss/ha/client/loadbalance/aop/FirstAvailableIdenticalAllProxies.java)
===================================================================
--- projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/aop/FirstAvailableIdenticalAllProxies.java (rev 0)
+++ projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/client/loadbalance/aop/FirstAvailableIdenticalAllProxies.java 2008-07-11 02:01:14 UTC (rev 75651)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.ha.client.loadbalance.aop;
+
+import java.util.List;
+
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aspects.remoting.ClusterConstants;
+import org.jboss.ha.client.loadbalance.AopLoadBalancePolicy;
+import org.jboss.ha.framework.interfaces.FamilyClusterInfo;
+
+
+
+/**
+ * Extends the "sticky session" behavior of {@link FirstAvailable} by caching
+ * the favored target in the {@link FamilyClusterInfo}, thus allowing different
+ * proxies for the same family to use the same favored target.
+ * <p>
+ * See {@link FirstAvailable} for the basic behavior.
+ * </p>
+ *
+ * @see org.jboss.ha.framework.interfaces.FamilyClusterInfo#getObject()
+ *
+ * @author Brian Stansberry
+ *
+ * @version $Revision: 57642 $
+ */
+public class FirstAvailableIdenticalAllProxies
+extends org.jboss.ha.client.loadbalance.FirstAvailableIdenticalAllProxies
+implements AopLoadBalancePolicy
+{
+ // Constants -----------------------------------------------------
+ private static final long serialVersionUID = 2910756623413400467L;
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ public Object chooseTarget (FamilyClusterInfo clusterFamily, Invocation invocation)
+ {
+ Object target = clusterFamily.getObject ();
+ List targets = clusterFamily.getTargets ();
+
+ if (targets.size () == 0)
+ return null;
+
+ if (target != null && targets.contains (target) )
+ {
+ return target;
+ }
+ else
+ {
+ target = electTarget(targets, invocation);
+ clusterFamily.setObject (target);
+ return target;
+ }
+ }
+
+ private Object electTarget(List targets, Invocation invocation)
+ {
+ Object target = invocation.getMetaData(ClusterConstants.CLUSTERED_REMOTING, ClusterConstants.HA_TARGET);
+ if (target == null || !targets.contains(target))
+ target = electTarget(targets);
+ return target;
+ }
+
+}
Deleted: projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/framework/interfaces/ClusteringTargetsRepository.java
===================================================================
--- projects/cluster/ha-client/trunk/src/main/java/org/jboss/ha/framework/interfaces/ClusteringTargetsRepository.java 2008-05-21 23:22:01 UTC (rev 73569)
+++ projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/framework/interfaces/ClusteringTargetsRepository.java 2008-07-11 02:01:14 UTC (rev 75651)
@@ -1,135 +0,0 @@
-/*
- * 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.ha.framework.interfaces;
-
-import java.util.Hashtable;
-import java.util.List;
-
-/**
- * JVM singleton that associates a list of targets (+ other info)
- * contained in a {@link FamilyClusterInfo} to a proxy family. For example,
- * all remote proxies for a given EJB in a given cluster are part of the
- * same proxy family. Note that home and remote for a same EJB form *2*
- * proxy families.
- *
- * @see org.jboss.ha.framework.interfaces.FamilyClusterInfo
- * @see org.jboss.ha.framework.interfaces.FamilyClusterInfoImpl
- *
- * @author <a href="mailto:sacha.labourey at cogito-info.ch">Sacha Labourey</a>.
- * @version $Revision$
- *
- * <p><b>Revisions:</b>
- *
- * <p><b>2002/08/23, Sacha Labourey:</b>
- * <ul>
- * <li> First implementation </li>
- * </ul>
- */
-
-public class ClusteringTargetsRepository
-{
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- protected static Hashtable families = new Hashtable ();
-
- // Static --------------------------------------------------------
-
- /**
- * Same as {@link #initTarget(String, List, long) initTarget(familyName, targets, 0L)}
- */
- public synchronized static FamilyClusterInfo initTarget (String familyName, List targets)
- {
- return initTarget (familyName, targets, 0L);
- }
-
- /**
- * Checks for the existence of a {@link FamilyClusterInfo} with the given name. If
- * found, {@link FamilyClusterInfo#updateClusterInfo(List, long) updates} it; otherwise
- * creates and caches a new FamilyClusterInfo.
- * <p>
- * This method must be synchronized to avoid race conditions leading to
- * multiple FamilyClusterInfo instances for the same <code>familyName</code>.
- * </p>
- *
- * @param familyName the name of the proxy family
- * @param targets the current list of targets for the proxy family
- * @param viewId long that can be used as a shorthand identifier
- * for the list of targets
- *
- * @return a {@link FamilyClusterInfo} encapsulating the current state of the <code>familyName</code>.
- */
- public synchronized static FamilyClusterInfo initTarget (String familyName, List targets, long viewId)
- {
- // this method must be somehow synchronized to avoid multiple FamilyClusterInfoImpl
- // for the same familyName in multi-threaded app accessing the same bean
- //
- FamilyClusterInfoImpl family = (FamilyClusterInfoImpl)families.get (familyName);
- if (family == null)
- {
- family = new FamilyClusterInfoImpl (familyName, targets, viewId);
- families.put (familyName, family);
- }
- else
- {
- // no need to initialize: it is already done: we keep the same object
- //
- family.updateClusterInfo (targets, viewId); // should not happen: possible if redeploy after undeploy fails
- }
-
- return family;
-
- }
-
- /**
- * Gets the {@link FamilyClusterInfo} registered under <code>familyName</code>.
- *
- * @param familyName the identifier of the FamilyClusterInfo
- *
- * @return the FamilyClusterInfo, or <code>null</code> if none is registered
- */
- public static FamilyClusterInfo getFamilyClusterInfo (String familyName)
- {
- return (FamilyClusterInfo)families.get (familyName);
- }
-
- // Constructors --------------------------------------------------
-
- /** Prevent external instantiation */
- private ClusteringTargetsRepository () {}
-
- // Public --------------------------------------------------------
-
- // Z implementation ----------------------------------------------
-
- // Y overrides ---------------------------------------------------
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
-}
Copied: projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/framework/interfaces/ClusteringTargetsRepository.java (from rev 74878, projects/cluster/ha-client/trunk/src/main/java/org/jboss/ha/framework/interfaces/ClusteringTargetsRepository.java)
===================================================================
--- projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/framework/interfaces/ClusteringTargetsRepository.java (rev 0)
+++ projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/framework/interfaces/ClusteringTargetsRepository.java 2008-07-11 02:01:14 UTC (rev 75651)
@@ -0,0 +1,135 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.ha.framework.interfaces;
+
+import java.util.Hashtable;
+import java.util.List;
+
+/**
+ * JVM singleton that associates a list of targets (+ other info)
+ * contained in a {@link FamilyClusterInfo} to a proxy family. For example,
+ * all remote proxies for a given EJB in a given cluster are part of the
+ * same proxy family. Note that home and remote for a same EJB form *2*
+ * proxy families.
+ *
+ * @see org.jboss.ha.framework.interfaces.FamilyClusterInfo
+ * @see org.jboss.ha.framework.interfaces.FamilyClusterInfoImpl
+ *
+ * @author <a href="mailto:sacha.labourey at cogito-info.ch">Sacha Labourey</a>.
+ * @version $Revision$
+ *
+ * <p><b>Revisions:</b>
+ *
+ * <p><b>2002/08/23, Sacha Labourey:</b>
+ * <ul>
+ * <li> First implementation </li>
+ * </ul>
+ */
+
+public class ClusteringTargetsRepository
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ protected static Hashtable families = new Hashtable ();
+
+ // Static --------------------------------------------------------
+
+ /**
+ * Same as {@link #initTarget(String, List, long) initTarget(familyName, targets, 0L)}
+ */
+ public synchronized static FamilyClusterInfo initTarget (String familyName, List targets)
+ {
+ return initTarget (familyName, targets, 0L);
+ }
+
+ /**
+ * Checks for the existence of a {@link FamilyClusterInfo} with the given name. If
+ * found, {@link FamilyClusterInfo#updateClusterInfo(List, long) updates} it; otherwise
+ * creates and caches a new FamilyClusterInfo.
+ * <p>
+ * This method must be synchronized to avoid race conditions leading to
+ * multiple FamilyClusterInfo instances for the same <code>familyName</code>.
+ * </p>
+ *
+ * @param familyName the name of the proxy family
+ * @param targets the current list of targets for the proxy family
+ * @param viewId long that can be used as a shorthand identifier
+ * for the list of targets
+ *
+ * @return a {@link FamilyClusterInfo} encapsulating the current state of the <code>familyName</code>.
+ */
+ public synchronized static FamilyClusterInfo initTarget (String familyName, List targets, long viewId)
+ {
+ // this method must be somehow synchronized to avoid multiple FamilyClusterInfoImpl
+ // for the same familyName in multi-threaded app accessing the same bean
+ //
+ FamilyClusterInfoImpl family = (FamilyClusterInfoImpl)families.get (familyName);
+ if (family == null)
+ {
+ family = new FamilyClusterInfoImpl (familyName, targets, viewId);
+ families.put (familyName, family);
+ }
+ else
+ {
+ // no need to initialize: it is already done: we keep the same object
+ //
+ family.updateClusterInfo (targets, viewId); // should not happen: possible if redeploy after undeploy fails
+ }
+
+ return family;
+
+ }
+
+ /**
+ * Gets the {@link FamilyClusterInfo} registered under <code>familyName</code>.
+ *
+ * @param familyName the identifier of the FamilyClusterInfo
+ *
+ * @return the FamilyClusterInfo, or <code>null</code> if none is registered
+ */
+ public static FamilyClusterInfo getFamilyClusterInfo (String familyName)
+ {
+ return (FamilyClusterInfo)families.get (familyName);
+ }
+
+ // Constructors --------------------------------------------------
+
+ /** Prevent external instantiation */
+ private ClusteringTargetsRepository () {}
+
+ // Public --------------------------------------------------------
+
+ // Z implementation ----------------------------------------------
+
+ // Y overrides ---------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Deleted: projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/framework/interfaces/FamilyClusterInfo.java
===================================================================
--- projects/cluster/ha-client/trunk/src/main/java/org/jboss/ha/framework/interfaces/FamilyClusterInfo.java 2008-05-21 23:22:01 UTC (rev 73569)
+++ projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/framework/interfaces/FamilyClusterInfo.java 2008-07-11 02:01:14 UTC (rev 75651)
@@ -1,167 +0,0 @@
-/*
- * 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.ha.framework.interfaces;
-
-import java.util.List;
-
-import org.jboss.ha.client.loadbalance.FirstAvailableIdenticalAllProxies;
-import org.jboss.ha.client.loadbalance.RoundRobin;
-
-/**
- * Maintain information for a given proxy family. Proxies can statically reference
- * objects implementing this interface: only the content will change as the
- * cluster topology changes, not the FamilyClusterInfo object itself.
- * Proxies or LoadBalancing policy implementations can use the cursor and object
- * attribute to store arbitrary data that is then shared accross all proxies belonging
- * to the same family.
- * Initial access to this object is done through the
- * {@link ClusteringTargetsRepository} singleton.
- *
- * @see org.jboss.ha.framework.interfaces.FamilyClusterInfoImpl
- * @see org.jboss.ha.framework.interfaces.ClusteringTargetsRepository
- *
- * @author <a href="mailto:sacha.labourey at cogito-info.ch">Sacha Labourey</a>.
- * @version $Revision$
- *
- * <p><b>Revisions:</b>
- *
- * <p><b>2002/08/23, Sacha Labourey:</b>
- * <ul>
- * <li> First implementation </li>
- * </ul>
- */
-
-public interface FamilyClusterInfo
-{
- public String getFamilyName ();
-
- /**
- * Gets the list of targets for this family.
- *
- * <strong>NOTE:</strong> Implementations should synchronize on themselves
- * when executing this method (see JBAS-2071).
- */
- public List getTargets ();
-
- /**
- * Gets a shorthand identifier for the current cluster topology for
- * the clustered service represented by this object. The identifer is
- * generated on the server side; clients can pass this view id to the
- * server side to check whether their current view of the service
- * topology matches what the server sees.
- */
- public long getCurrentViewId ();
-
- /**
- * Remove the given target from the list of targets.
- *
- * <strong>NOTE:</strong> Implementations should synchronize on themselves
- * when executing this method (see JBAS-2071).
- *
- * @param target the target
- * @return the updated list of targets
- */
- public List removeDeadTarget(Object target);
-
- /**
- * Updates the targets and the view id.
- *
- * <strong>NOTE:</strong> Implementations should synchronize on themselves
- * when executing this method (see JBAS-2071).
- */
- public List updateClusterInfo (List targets, long viewId);
-
- /**
- * Gets whether this object believes its current
- * {@link #getTargets() target list} matches what the server-side
- * used to generate the {@link #getCurrentViewId() view id}.
- * <p>
- * Generally, a call to {@link #removeDeadTarget(Object)} would cause
- * this method to return <code>false</code> until a subsequent call
- * to {@link #updateClusterInfo(List, long)} is made.
- * </p>
- */
- public boolean currentMembershipInSyncWithViewId();
-
- /**
- * Force a reload of the view at the next invocation.
- *
- * <strong>NOTE:</strong> Implementations should synchronize on themselves
- * when executing this method (see JBAS-2071).
- */
- public void resetView ();
-
- /**
- * Gets a cursor indicating a position in the current
- * {@link #getTargets() list of targets}. Useful for round-robin load
- * balancing strategies that wish to coordinate between instances.
- * <p>
- * It is not guaranteed that the returned value will be less than the size
- * of the target list; callers need to verify that themselves.
- * </p>
- *
- * @see #UNINITIALIZED_CURSOR
- * @see RoundRobin
- */
- public int getCursor();
-
- /**
- * Sets a cursor indicating a position in the current
- * {@link #getTargets() list of targets}. Useful for round-robin load
- * balancing strategies that wish to coordinate between instances.
- *
- * @param
- */
- public int setCursor (int cursor);
-
- /**
- * Gets an object that may be one of the members of the current
- * {@link #getTargets() list of targets}. Useful for "sticky" load
- * balancing strategies that wish to coordinate between instances.
- * <p>
- * It is not guaranteed that the returned object will be a current member of
- * the target list; callers need to verify that themselves.
- * </p>
- *
- * @return an object that *may* be an element in the target list, or
- * may be <code>null</code>
- *
- * @see FirstAvailableIdenticalAllProxies
- */
- public Object getObject();
-
- /**
- * Sets the member of the current {@link #getTargets() list of targets}
- * that "sticky" load balancing strategies that wish to coordinate between
- * instances should use.
- *
- * @param whatever *should* be a member of the current list of targets, or
- * <code>null</code>. However, this requirement is not
- * enforced.
- */
- public Object setObject(Object whatever);
-
- /**
- * Initial value returned by {@link #getCursor()}.
- */
- public final static int UNINITIALIZED_CURSOR = 999999999;
-}
Copied: projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/framework/interfaces/FamilyClusterInfo.java (from rev 74878, projects/cluster/ha-client/trunk/src/main/java/org/jboss/ha/framework/interfaces/FamilyClusterInfo.java)
===================================================================
--- projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/framework/interfaces/FamilyClusterInfo.java (rev 0)
+++ projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/framework/interfaces/FamilyClusterInfo.java 2008-07-11 02:01:14 UTC (rev 75651)
@@ -0,0 +1,167 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.ha.framework.interfaces;
+
+import java.util.List;
+
+import org.jboss.ha.client.loadbalance.FirstAvailableIdenticalAllProxies;
+import org.jboss.ha.client.loadbalance.RoundRobin;
+
+/**
+ * Maintain information for a given proxy family. Proxies can statically reference
+ * objects implementing this interface: only the content will change as the
+ * cluster topology changes, not the FamilyClusterInfo object itself.
+ * Proxies or LoadBalancing policy implementations can use the cursor and object
+ * attribute to store arbitrary data that is then shared accross all proxies belonging
+ * to the same family.
+ * Initial access to this object is done through the
+ * {@link ClusteringTargetsRepository} singleton.
+ *
+ * @see org.jboss.ha.framework.interfaces.FamilyClusterInfoImpl
+ * @see org.jboss.ha.framework.interfaces.ClusteringTargetsRepository
+ *
+ * @author <a href="mailto:sacha.labourey at cogito-info.ch">Sacha Labourey</a>.
+ * @version $Revision$
+ *
+ * <p><b>Revisions:</b>
+ *
+ * <p><b>2002/08/23, Sacha Labourey:</b>
+ * <ul>
+ * <li> First implementation </li>
+ * </ul>
+ */
+
+public interface FamilyClusterInfo
+{
+ public String getFamilyName ();
+
+ /**
+ * Gets the list of targets for this family.
+ *
+ * <strong>NOTE:</strong> Implementations should synchronize on themselves
+ * when executing this method (see JBAS-2071).
+ */
+ public List getTargets ();
+
+ /**
+ * Gets a shorthand identifier for the current cluster topology for
+ * the clustered service represented by this object. The identifer is
+ * generated on the server side; clients can pass this view id to the
+ * server side to check whether their current view of the service
+ * topology matches what the server sees.
+ */
+ public long getCurrentViewId ();
+
+ /**
+ * Remove the given target from the list of targets.
+ *
+ * <strong>NOTE:</strong> Implementations should synchronize on themselves
+ * when executing this method (see JBAS-2071).
+ *
+ * @param target the target
+ * @return the updated list of targets
+ */
+ public List removeDeadTarget(Object target);
+
+ /**
+ * Updates the targets and the view id.
+ *
+ * <strong>NOTE:</strong> Implementations should synchronize on themselves
+ * when executing this method (see JBAS-2071).
+ */
+ public List updateClusterInfo (List targets, long viewId);
+
+ /**
+ * Gets whether this object believes its current
+ * {@link #getTargets() target list} matches what the server-side
+ * used to generate the {@link #getCurrentViewId() view id}.
+ * <p>
+ * Generally, a call to {@link #removeDeadTarget(Object)} would cause
+ * this method to return <code>false</code> until a subsequent call
+ * to {@link #updateClusterInfo(List, long)} is made.
+ * </p>
+ */
+ public boolean currentMembershipInSyncWithViewId();
+
+ /**
+ * Force a reload of the view at the next invocation.
+ *
+ * <strong>NOTE:</strong> Implementations should synchronize on themselves
+ * when executing this method (see JBAS-2071).
+ */
+ public void resetView ();
+
+ /**
+ * Gets a cursor indicating a position in the current
+ * {@link #getTargets() list of targets}. Useful for round-robin load
+ * balancing strategies that wish to coordinate between instances.
+ * <p>
+ * It is not guaranteed that the returned value will be less than the size
+ * of the target list; callers need to verify that themselves.
+ * </p>
+ *
+ * @see #UNINITIALIZED_CURSOR
+ * @see RoundRobin
+ */
+ public int getCursor();
+
+ /**
+ * Sets a cursor indicating a position in the current
+ * {@link #getTargets() list of targets}. Useful for round-robin load
+ * balancing strategies that wish to coordinate between instances.
+ *
+ * @param
+ */
+ public int setCursor (int cursor);
+
+ /**
+ * Gets an object that may be one of the members of the current
+ * {@link #getTargets() list of targets}. Useful for "sticky" load
+ * balancing strategies that wish to coordinate between instances.
+ * <p>
+ * It is not guaranteed that the returned object will be a current member of
+ * the target list; callers need to verify that themselves.
+ * </p>
+ *
+ * @return an object that *may* be an element in the target list, or
+ * may be <code>null</code>
+ *
+ * @see FirstAvailableIdenticalAllProxies
+ */
+ public Object getObject();
+
+ /**
+ * Sets the member of the current {@link #getTargets() list of targets}
+ * that "sticky" load balancing strategies that wish to coordinate between
+ * instances should use.
+ *
+ * @param whatever *should* be a member of the current list of targets, or
+ * <code>null</code>. However, this requirement is not
+ * enforced.
+ */
+ public Object setObject(Object whatever);
+
+ /**
+ * Initial value returned by {@link #getCursor()}.
+ */
+ public final static int UNINITIALIZED_CURSOR = 999999999;
+}
Deleted: projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/framework/interfaces/FamilyClusterInfoImpl.java
===================================================================
--- projects/cluster/ha-client/trunk/src/main/java/org/jboss/ha/framework/interfaces/FamilyClusterInfoImpl.java 2008-05-21 23:22:01 UTC (rev 73569)
+++ projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/framework/interfaces/FamilyClusterInfoImpl.java 2008-07-11 02:01:14 UTC (rev 75651)
@@ -1,184 +0,0 @@
-/*
- * 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.ha.framework.interfaces;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * Default implementation of FamilyClusterInfo
- *
- * @see org.jboss.ha.framework.interfaces.FamilyClusterInfo
- * @see org.jboss.ha.framework.interfaces.ClusteringTargetsRepository
- *
- * @author <a href="mailto:sacha.labourey at cogito-info.ch">Sacha Labourey</a>.
- * @version $Revision$
- */
-public class FamilyClusterInfoImpl implements FamilyClusterInfo
-{
-
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- private String familyName = null;
- private ArrayList targets = null;
- private long currentViewId = 0;
- private boolean isViewMembersInSyncWithViewId = false;
-
- private int cursor = FamilyClusterInfo.UNINITIALIZED_CURSOR;
- private Object arbitraryObject = null;
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- protected FamilyClusterInfoImpl (String familyName, List targets, long viewId)
- {
- this.familyName = familyName;
- this.targets = cloneList(targets);
- this.currentViewId = viewId;
-
- this.isViewMembersInSyncWithViewId = true;
- }
-
- // Public --------------------------------------------------------
-
- // FamilyClusterInfo implementation ----------------------------------------------
-
- public String getFamilyName () { return this.familyName; }
-
- /**
- * Returns an unmodifiable view of the target list.
- *
- * @see Collections#unmodifiableList(List)
- */
- public synchronized List getTargets ()
- {
- return Collections.unmodifiableList(this.targets);
- }
- public long getCurrentViewId () { return this.currentViewId; }
- public int getCursor () { return this.cursor; }
- public int setCursor (int cursor) { return (this.cursor = cursor);}
- public Object getObject () { return this.arbitraryObject; }
- public Object setObject (Object whatever) { this.arbitraryObject = whatever; return this.arbitraryObject; }
-
- public List removeDeadTarget(Object target)
- {
- synchronized (this)
- {
- ArrayList tmp = (ArrayList) targets.clone();
- tmp.remove (target);
- this.targets = tmp;
- this.isViewMembersInSyncWithViewId = false;
- return Collections.unmodifiableList(this.targets);
- }
- }
-
- public List updateClusterInfo (List targets, long viewId)
- {
- synchronized (this)
- {
- this.targets = cloneList(targets);
- this.currentViewId = viewId;
- this.isViewMembersInSyncWithViewId = true;
- return Collections.unmodifiableList(this.targets);
- }
- }
-
- public boolean currentMembershipInSyncWithViewId ()
- {
- return this.isViewMembersInSyncWithViewId;
- }
-
- public void resetView ()
- {
- synchronized (this)
- {
- this.currentViewId = -1;
- this.isViewMembersInSyncWithViewId = false;
- }
- }
-
- // Object overrides ---------------------------------------------------
-
- public int hashCode()
- {
- return this.familyName.hashCode ();
- }
-
- public boolean equals (Object o)
- {
- if (o instanceof FamilyClusterInfoImpl)
- {
- FamilyClusterInfoImpl fr = (FamilyClusterInfoImpl)o;
- return fr.familyName == this.familyName;
- }
- else
- return false;
- }
-
- public String toString()
- {
- StringBuffer tmp = new StringBuffer(super.toString());
- tmp.append("{familyName=");
- tmp.append(familyName);
- tmp.append(",targets=");
- tmp.append(targets);
- tmp.append(",currentViewId=");
- tmp.append(currentViewId);
- tmp.append(",isViewMembersInSyncWithViewId=");
- tmp.append(isViewMembersInSyncWithViewId);
- tmp.append(",cursor=");
- tmp.append(cursor);
- tmp.append(",arbitraryObject=");
- tmp.append(arbitraryObject);
- tmp.append("}");
- return tmp.toString();
- }
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
- private static ArrayList cloneList(List toClone)
- {
- if (toClone instanceof ArrayList)
- {
- synchronized (toClone)
- {
- return (ArrayList) ((ArrayList) toClone).clone();
- }
- }
-
- ArrayList clone = new ArrayList(toClone.size());
- synchronized (toClone)
- {
- clone.addAll(toClone);
- }
- return clone;
- }
-}
Copied: projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/framework/interfaces/FamilyClusterInfoImpl.java (from rev 74878, projects/cluster/ha-client/trunk/src/main/java/org/jboss/ha/framework/interfaces/FamilyClusterInfoImpl.java)
===================================================================
--- projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/framework/interfaces/FamilyClusterInfoImpl.java (rev 0)
+++ projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/framework/interfaces/FamilyClusterInfoImpl.java 2008-07-11 02:01:14 UTC (rev 75651)
@@ -0,0 +1,184 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.ha.framework.interfaces;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Default implementation of FamilyClusterInfo
+ *
+ * @see org.jboss.ha.framework.interfaces.FamilyClusterInfo
+ * @see org.jboss.ha.framework.interfaces.ClusteringTargetsRepository
+ *
+ * @author <a href="mailto:sacha.labourey at cogito-info.ch">Sacha Labourey</a>.
+ * @version $Revision$
+ */
+public class FamilyClusterInfoImpl implements FamilyClusterInfo
+{
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ private String familyName = null;
+ private ArrayList targets = null;
+ private long currentViewId = 0;
+ private boolean isViewMembersInSyncWithViewId = false;
+
+ private int cursor = FamilyClusterInfo.UNINITIALIZED_CURSOR;
+ private Object arbitraryObject = null;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ protected FamilyClusterInfoImpl (String familyName, List targets, long viewId)
+ {
+ this.familyName = familyName;
+ this.targets = cloneList(targets);
+ this.currentViewId = viewId;
+
+ this.isViewMembersInSyncWithViewId = true;
+ }
+
+ // Public --------------------------------------------------------
+
+ // FamilyClusterInfo implementation ----------------------------------------------
+
+ public String getFamilyName () { return this.familyName; }
+
+ /**
+ * Returns an unmodifiable view of the target list.
+ *
+ * @see Collections#unmodifiableList(List)
+ */
+ public synchronized List getTargets ()
+ {
+ return Collections.unmodifiableList(this.targets);
+ }
+ public long getCurrentViewId () { return this.currentViewId; }
+ public int getCursor () { return this.cursor; }
+ public int setCursor (int cursor) { return (this.cursor = cursor);}
+ public Object getObject () { return this.arbitraryObject; }
+ public Object setObject (Object whatever) { this.arbitraryObject = whatever; return this.arbitraryObject; }
+
+ public List removeDeadTarget(Object target)
+ {
+ synchronized (this)
+ {
+ ArrayList tmp = (ArrayList) targets.clone();
+ tmp.remove (target);
+ this.targets = tmp;
+ this.isViewMembersInSyncWithViewId = false;
+ return Collections.unmodifiableList(this.targets);
+ }
+ }
+
+ public List updateClusterInfo (List targets, long viewId)
+ {
+ synchronized (this)
+ {
+ this.targets = cloneList(targets);
+ this.currentViewId = viewId;
+ this.isViewMembersInSyncWithViewId = true;
+ return Collections.unmodifiableList(this.targets);
+ }
+ }
+
+ public boolean currentMembershipInSyncWithViewId ()
+ {
+ return this.isViewMembersInSyncWithViewId;
+ }
+
+ public void resetView ()
+ {
+ synchronized (this)
+ {
+ this.currentViewId = -1;
+ this.isViewMembersInSyncWithViewId = false;
+ }
+ }
+
+ // Object overrides ---------------------------------------------------
+
+ public int hashCode()
+ {
+ return this.familyName.hashCode ();
+ }
+
+ public boolean equals (Object o)
+ {
+ if (o instanceof FamilyClusterInfoImpl)
+ {
+ FamilyClusterInfoImpl fr = (FamilyClusterInfoImpl)o;
+ return fr.familyName == this.familyName;
+ }
+ else
+ return false;
+ }
+
+ public String toString()
+ {
+ StringBuffer tmp = new StringBuffer(super.toString());
+ tmp.append("{familyName=");
+ tmp.append(familyName);
+ tmp.append(",targets=");
+ tmp.append(targets);
+ tmp.append(",currentViewId=");
+ tmp.append(currentViewId);
+ tmp.append(",isViewMembersInSyncWithViewId=");
+ tmp.append(isViewMembersInSyncWithViewId);
+ tmp.append(",cursor=");
+ tmp.append(cursor);
+ tmp.append(",arbitraryObject=");
+ tmp.append(arbitraryObject);
+ tmp.append("}");
+ return tmp.toString();
+ }
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+ private static ArrayList cloneList(List toClone)
+ {
+ if (toClone instanceof ArrayList)
+ {
+ synchronized (toClone)
+ {
+ return (ArrayList) ((ArrayList) toClone).clone();
+ }
+ }
+
+ ArrayList clone = new ArrayList(toClone.size());
+ synchronized (toClone)
+ {
+ clone.addAll(toClone);
+ }
+ return clone;
+ }
+}
Deleted: projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/framework/interfaces/GenericClusteringException.java
===================================================================
--- projects/cluster/ha-client/trunk/src/main/java/org/jboss/ha/framework/interfaces/GenericClusteringException.java 2008-05-21 23:22:01 UTC (rev 73569)
+++ projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/framework/interfaces/GenericClusteringException.java 2008-07-11 02:01:14 UTC (rev 75651)
@@ -1,154 +0,0 @@
-/*
- * 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.ha.framework.interfaces;
-
-import org.jboss.util.NestedException;
-
-/**
- * Generic clustering exception that can be used to replace other exceptions
- * that occur on the server. Thus, only this class is needed on the client side
- * and some specific server side exceptions classes are not needed on the client side
- * (such as JMX exceptions for example).
- * Furthermore, it has support for "COMPLETED" status flag a la IIOP.
- * <p>
- * When an invocation reaches a node, it may be invoked on the actual
- * target or not (or not completely). If {@link #COMPLETED_NO} and working in
- * a clustered environment, the client proxy is allowed to invoke
- * the same invocation on a different node. Otherwise, it will depend
- * if the target method is idempotent: this is no more the problem of
- * this class but rather the meta-data of the business environment
- * that can give this information
- * </p>
- *
- * @author <a href="mailto:sacha.labourey at cogito-info.ch">Sacha Labourey</a>.
- * @version $Revision$
- *
- * <p><b>Revisions:</b>
- *
- * <p><b>8 avril 2002 Sacha Labourey:</b>
- * <ul>
- * <li> First implementation </li>
- * </ul>
- */
-
-public class GenericClusteringException
- extends NestedException
-{
- // BES - 2007/11/12: This wasn't set in 4.x. If this causes a problem in a
- // compatibility test, just switch it to the old value; I didn't change
- // the serialized form of the class at all.
- /** The serialVersionUID */
- private static final long serialVersionUID = 3030093807459327632L;
-
- /** Means the invocation that generated this exception was invoked on the server-side target */
- public final static int COMPLETED_YES = 0;
- /** Means the invocation that generated this exception was *not* invoked on the server-side target */
- public final static int COMPLETED_NO = 1;
- /**
- * Means it is unclear whether the invocation that generated this exception
- * was invoked on the server-side target
- */
- public final static int COMPLETED_MAYBE = 2;
-
- public boolean isDefinitive = true;
-
- // if yes, then the invocation may be retried against another node
- // because the state has not been modified by the current invocation
- //
- public int completed;
-
- public GenericClusteringException ()
- {
- this.completed = COMPLETED_MAYBE;
- }
-
- public GenericClusteringException (int CompletionStatus)
- {
- this.completed = CompletionStatus;
- }
-
- public GenericClusteringException (int CompletionStatus, String s)
- {
- super(s);
- this.completed = CompletionStatus;
- }
-
- public GenericClusteringException (int CompletionStatus, String s, boolean isDefinitive)
- {
- super(s);
- this.completed = CompletionStatus;
- this.isDefinitive = isDefinitive;
- }
-
- public GenericClusteringException (int CompletionStatus, Throwable nested, boolean isDefinitive)
- {
- super(nested);
- this.completed = CompletionStatus;
- this.isDefinitive = isDefinitive;
- }
-
- public GenericClusteringException (int CompletionStatus, Throwable nested)
- {
- super(nested);
- this.completed = CompletionStatus;
- }
-
- /**
- * Gets whether the invocation that generated this exception was completely
- * invoked on the server side target.
- * <p>
- * When an invocation reaches a node, it may be invoked on the actual
- * target or not (or not completely). If COMPLETED_NO and working in
- * a clustered environment, the client proxy is allowed to invoke
- * the same invocation on a different node. Otherwise, it will depend
- * if the target method is idempotent: this is not the problem of
- * this class but rather the meta-data of the business environment
- * that can give this information
- * </p>
- *
- * @return {@link #COMPLETED_YES}, {@link #COMPLETED_NO} or
- * {@link #COMPLETED_MAYBE}.
- */
- public int getCompletionStatus ()
- {
- return this.completed;
- }
-
- public void setCompletionStatus (int completionStatus)
- {
- this.completed = completionStatus;
- }
-
- /**
- * Indicates if the exception will most probably be repetitive (definitive)
- * or if it is just a temporary failure and new attempts should be tried.
- */
- public boolean isDefinitive ()
- {
- return this.isDefinitive;
- }
-
- public void setIsDefinitive (boolean definitive)
- {
- this.isDefinitive = definitive;
- }
-}
Copied: projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/framework/interfaces/GenericClusteringException.java (from rev 74878, projects/cluster/ha-client/trunk/src/main/java/org/jboss/ha/framework/interfaces/GenericClusteringException.java)
===================================================================
--- projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/framework/interfaces/GenericClusteringException.java (rev 0)
+++ projects/cluster/ha-client/tags/1.1.0.CR2/src/main/java/org/jboss/ha/framework/interfaces/GenericClusteringException.java 2008-07-11 02:01:14 UTC (rev 75651)
@@ -0,0 +1,154 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.ha.framework.interfaces;
+
+import org.jboss.util.NestedException;
+
+/**
+ * Generic clustering exception that can be used to replace other exceptions
+ * that occur on the server. Thus, only this class is needed on the client side
+ * and some specific server side exceptions classes are not needed on the client side
+ * (such as JMX exceptions for example).
+ * Furthermore, it has support for "COMPLETED" status flag a la IIOP.
+ * <p>
+ * When an invocation reaches a node, it may be invoked on the actual
+ * target or not (or not completely). If {@link #COMPLETED_NO} and working in
+ * a clustered environment, the client proxy is allowed to invoke
+ * the same invocation on a different node. Otherwise, it will depend
+ * if the target method is idempotent: this is no more the problem of
+ * this class but rather the meta-data of the business environment
+ * that can give this information
+ * </p>
+ *
+ * @author <a href="mailto:sacha.labourey at cogito-info.ch">Sacha Labourey</a>.
+ * @version $Revision$
+ *
+ * <p><b>Revisions:</b>
+ *
+ * <p><b>8 avril 2002 Sacha Labourey:</b>
+ * <ul>
+ * <li> First implementation </li>
+ * </ul>
+ */
+
+public class GenericClusteringException
+ extends NestedException
+{
+ // BES - 2007/11/12: This wasn't set in 4.x. If this causes a problem in a
+ // compatibility test, just switch it to the old value; I didn't change
+ // the serialized form of the class at all.
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 3030093807459327632L;
+
+ /** Means the invocation that generated this exception was invoked on the server-side target */
+ public final static int COMPLETED_YES = 0;
+ /** Means the invocation that generated this exception was *not* invoked on the server-side target */
+ public final static int COMPLETED_NO = 1;
+ /**
+ * Means it is unclear whether the invocation that generated this exception
+ * was invoked on the server-side target
+ */
+ public final static int COMPLETED_MAYBE = 2;
+
+ public boolean isDefinitive = true;
+
+ // if yes, then the invocation may be retried against another node
+ // because the state has not been modified by the current invocation
+ //
+ public int completed;
+
+ public GenericClusteringException ()
+ {
+ this.completed = COMPLETED_MAYBE;
+ }
+
+ public GenericClusteringException (int CompletionStatus)
+ {
+ this.completed = CompletionStatus;
+ }
+
+ public GenericClusteringException (int CompletionStatus, String s)
+ {
+ super(s);
+ this.completed = CompletionStatus;
+ }
+
+ public GenericClusteringException (int CompletionStatus, String s, boolean isDefinitive)
+ {
+ super(s);
+ this.completed = CompletionStatus;
+ this.isDefinitive = isDefinitive;
+ }
+
+ public GenericClusteringException (int CompletionStatus, Throwable nested, boolean isDefinitive)
+ {
+ super(nested);
+ this.completed = CompletionStatus;
+ this.isDefinitive = isDefinitive;
+ }
+
+ public GenericClusteringException (int CompletionStatus, Throwable nested)
+ {
+ super(nested);
+ this.completed = CompletionStatus;
+ }
+
+ /**
+ * Gets whether the invocation that generated this exception was completely
+ * invoked on the server side target.
+ * <p>
+ * When an invocation reaches a node, it may be invoked on the actual
+ * target or not (or not completely). If COMPLETED_NO and working in
+ * a clustered environment, the client proxy is allowed to invoke
+ * the same invocation on a different node. Otherwise, it will depend
+ * if the target method is idempotent: this is not the problem of
+ * this class but rather the meta-data of the business environment
+ * that can give this information
+ * </p>
+ *
+ * @return {@link #COMPLETED_YES}, {@link #COMPLETED_NO} or
+ * {@link #COMPLETED_MAYBE}.
+ */
+ public int getCompletionStatus ()
+ {
+ return this.completed;
+ }
+
+ public void setCompletionStatus (int completionStatus)
+ {
+ this.completed = completionStatus;
+ }
+
+ /**
+ * Indicates if the exception will most probably be repetitive (definitive)
+ * or if it is just a temporary failure and new attempts should be tried.
+ */
+ public boolean isDefinitive ()
+ {
+ return this.isDefinitive;
+ }
+
+ public void setIsDefinitive (boolean definitive)
+ {
+ this.isDefinitive = definitive;
+ }
+}
Copied: projects/cluster/ha-client/tags/1.1.0.CR2/src/test/java/org/jboss/test/aspects/remoting/ClusteredPojiProxyUnitTestCase.java (from rev 74878, projects/cluster/ha-client/trunk/src/test/java/org/jboss/test/aspects/remoting/ClusteredPojiProxyUnitTestCase.java)
===================================================================
--- projects/cluster/ha-client/tags/1.1.0.CR2/src/test/java/org/jboss/test/aspects/remoting/ClusteredPojiProxyUnitTestCase.java (rev 0)
+++ projects/cluster/ha-client/tags/1.1.0.CR2/src/test/java/org/jboss/test/aspects/remoting/ClusteredPojiProxyUnitTestCase.java 2008-07-11 02:01:14 UTC (rev 75651)
@@ -0,0 +1,110 @@
+/*
+ * 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.aspects.remoting;
+
+import java.util.Arrays;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.jboss.aop.Dispatcher;
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.metadata.SimpleMetaData;
+import org.jboss.aspects.remoting.ClusterConstants;
+import org.jboss.aspects.remoting.ClusteredPojiProxy;
+import org.jboss.aspects.remoting.FamilyWrapper;
+import org.jboss.aspects.remoting.InvokeRemoteInterceptor;
+import org.jboss.ha.client.loadbalance.LoadBalancePolicy;
+import org.jboss.ha.client.loadbalance.RoundRobin;
+import org.jboss.remoting.InvokerLocator;
+
+/**
+ * Unit tests for {@link ClusteredPojiProxy}.
+ *
+ * @author Brian Stansberry
+ *
+ */
+public class ClusteredPojiProxyUnitTestCase extends TestCase
+{
+ protected static final String[] TARGETS = { "A", "B", "C" };
+ protected static final String FAMILY_BASE = "ClusteredPojiProxy";
+ protected static final String MOCK_URI = "http://localhost";
+ protected static final String OK = "OK";
+ protected static int testCount = 0;
+
+ /**
+ * Create a new ClusteredPojiProxyUnitTestCase.
+ *
+ * @param name
+ */
+ public ClusteredPojiProxyUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Tests that the proxy sets the expected metadata
+ */
+ public void testInvocationMetaData() throws Throwable
+ {
+ invocationMetaDataTest(TARGETS[0]);
+ }
+
+ /**
+ * Tests that the proxy sets the expected metadata when no originTarget
+ * is provided.
+ */
+ public void testNullOriginTarget() throws Throwable
+ {
+ invocationMetaDataTest(null);
+ }
+
+ private void invocationMetaDataTest(Object originTarget) throws Throwable
+ {
+ testCount++;
+ List<String> targets = Arrays.asList(TARGETS);
+ FamilyWrapper wrapper = new FamilyWrapper(FAMILY_BASE + testCount, targets);
+
+ MockNextInterceptor interceptor = new MockNextInterceptor();
+ interceptor.setReturnValue(OK);
+
+ Object oid = new Object();
+ LoadBalancePolicy lbp = new RoundRobin();
+ InvokerLocator uri = new InvokerLocator(MOCK_URI);
+ ClusteredPojiProxy proxy = new ClusteredPojiProxy(oid, uri, new Interceptor[]{interceptor}, wrapper, lbp, FAMILY_BASE, originTarget);
+
+ assertEquals(OK, proxy.invoke(this, Object.class.getDeclaredMethod("toString", new Class[]{}), new Object[]{}));
+
+ List<SimpleMetaData> history = interceptor.getInvocationHistory();
+ SimpleMetaData metadata = history.get(0);
+ assertSame(wrapper, metadata.getMetaData(ClusterConstants.CLUSTERED_REMOTING, ClusterConstants.CLUSTER_FAMILY_WRAPPER));
+ assertSame(lbp, metadata.getMetaData(ClusterConstants.CLUSTERED_REMOTING, ClusterConstants.LOADBALANCE_POLICY));
+ assertSame(FAMILY_BASE, metadata.getMetaData(ClusterConstants.CLUSTERED_REMOTING, ClusterConstants.PARTITION_NAME));
+ assertSame(originTarget, metadata.getMetaData(ClusterConstants.CLUSTERED_REMOTING, ClusterConstants.HA_TARGET));
+ assertSame(oid, metadata.getMetaData(Dispatcher.DISPATCHER, Dispatcher.OID));
+ assertSame(uri, metadata.getMetaData(InvokeRemoteInterceptor.REMOTING, InvokeRemoteInterceptor.INVOKER_LOCATOR));
+ assertEquals("AOP", metadata.getMetaData(InvokeRemoteInterceptor.REMOTING, InvokeRemoteInterceptor.SUBSYSTEM));
+
+ }
+
+}
Deleted: projects/cluster/ha-client/tags/1.1.0.CR2/src/test/java/org/jboss/test/ha/framework/interfaces/FamilyClusterInfoUnitTestCase.java
===================================================================
--- projects/cluster/ha-client/trunk/src/test/java/org/jboss/test/ha/framework/interfaces/FamilyClusterInfoUnitTestCase.java 2008-05-21 23:22:01 UTC (rev 73569)
+++ projects/cluster/ha-client/tags/1.1.0.CR2/src/test/java/org/jboss/test/ha/framework/interfaces/FamilyClusterInfoUnitTestCase.java 2008-07-11 02:01:14 UTC (rev 75651)
@@ -1,368 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2007, 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.ha.framework.interfaces;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.jboss.ha.framework.interfaces.ClusteringTargetsRepository;
-import org.jboss.ha.framework.interfaces.FamilyClusterInfo;
-
-import junit.framework.TestCase;
-
-/**
- * Test of FamilyClusterInfoImpl.
- *
- * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
- * @version $Revision$
- */
-public class FamilyClusterInfoUnitTestCase extends TestCase
-{
- private abstract class FCIChanger extends Thread
- {
- private boolean started;
- private boolean stopped;
- private Throwable caught;
-
- protected FamilyClusterInfo fci;
-
- FCIChanger(FamilyClusterInfo fci)
- {
- this.fci = fci;
- }
-
- abstract void update();
-
-
- public void run()
- {
- try
- {
- started = true;
-
- while (!stopped)
- {
- if (interrupted())
- throw new InterruptedException();
-
- update();
- }
-
- }
- catch (InterruptedException ie)
- {
- if (!stopped)
- caught = ie;
- }
- catch (Throwable t)
- {
- caught = t;
- }
- finally
- {
- started = false;
- }
- }
-
- void beginUpdates()
- {
- this.start();
- while (!started)
- {
- try
- {
- sleep(10);
- }
- catch (InterruptedException e)
- {
- caught = e;
- }
- }
- }
-
- void endUpdates()
- {
- if (started)
- {
- stopped = true;
- try
- {
- this.join(250);
- }
- catch (InterruptedException ignored) {}
- }
-
- if (started)
- interrupt();
- }
-
- Throwable getThrowable()
- {
- return caught;
- }
- }
-
- private class Updater extends FCIChanger
- {
- private ArrayList targets = new ArrayList();
- private int viewId;
-
- Updater(FamilyClusterInfo fci)
- {
- super(fci);
- }
-
- void update()
- {
- targets.add(new Object());
- viewId++;
- fci.updateClusterInfo((ArrayList) targets.clone(), viewId);
- }
- }
-
- private class Remover extends FCIChanger
- {
- Remover(FamilyClusterInfo fci)
- {
- super(fci);
- }
-
- void update()
- {
- List targets = fci.getTargets();
- if (targets.size() > 0)
- fci.removeDeadTarget(targets.get(0));
- }
-
- }
-
- private class Resetter extends FCIChanger
- {
- Resetter(FamilyClusterInfo fci)
- {
- super(fci);
- }
-
- void update()
- {
- fci.resetView();
- }
- }
-
- public void testSynchronization() throws Exception
- {
- ClusteringTargetsRepository.initTarget("testSynchronization", new ArrayList(), 0);
- FamilyClusterInfo fci = ClusteringTargetsRepository.getFamilyClusterInfo("testSynchronization");
-
- Updater updater = new Updater(fci);
- Remover remover = new Remover(fci);
- Resetter resetter = new Resetter(fci);
-
- updater.beginUpdates();
-
- checkFCIConsistency(fci, 150, false);
-
- remover.beginUpdates();
-
- checkFCIConsistency(fci, 150, true);
-
- resetter.beginUpdates();
-
- checkFCIConsistency(fci, 150, true);
-
- updater.endUpdates();
- remover.endUpdates();
- resetter.endUpdates();
-
- assertNull("Updater had no exceptions", updater.getThrowable());
- assertNull("Remover had no exceptions", remover.getThrowable());
- assertNull("Resetter had no exceptions", resetter.getThrowable());
-
- }
-
- public void testTargetListImmutability() throws Exception
- {
- ArrayList targets = new ArrayList();
- targets.add("ONE");
- targets.add("TWO");
- ClusteringTargetsRepository.initTarget("testImmutability", targets, 0);
- FamilyClusterInfo fci = ClusteringTargetsRepository.getFamilyClusterInfo("testImmutability");
-
- List fciTargets = fci.getTargets();
-
- // Confirm the targets are what we expect
- assertEquals("Expected number of targets", 2, fciTargets.size());
- assertEquals("First target as expected", "ONE", fciTargets.get(0));
- assertEquals("Second target as expected", "TWO", fciTargets.get(1));
-
- try
- {
- fciTargets.add("FAIL");
- fail("add call did not fail");
- }
- catch (UnsupportedOperationException good) {}
-
- try
- {
- fciTargets.addAll(targets);
- fail("addAll call did not fail");
- }
- catch (UnsupportedOperationException good) {}
-
- try
- {
- fciTargets.clear();
- fail("clear call did not fail");
- }
- catch (UnsupportedOperationException good) {}
-
- try
- {
- fciTargets.remove(0);
- fail("remove call did not fail");
- }
- catch (UnsupportedOperationException good) {}
-
- try
- {
- fciTargets.set(0, "FAIL");
- fail("set call did not fail");
- }
- catch (UnsupportedOperationException good) {}
-
- try
- {
- fciTargets.removeAll(targets);
- fail("removeAll call did not fail");
- }
- catch (UnsupportedOperationException good) {}
-
- try
- {
- fciTargets.retainAll(targets);
- fail("retainAll call did not fail");
- }
- catch (UnsupportedOperationException good) {}
-
- Iterator iter = fciTargets.iterator();
- int count = 0;
- while (iter.hasNext())
- {
- iter.next();
- count++;
- }
- assertEquals("Correct count", 2, count);
- try
- {
- iter.remove();
- fail("Iterator.remove call did not fail");
- }
- catch (UnsupportedOperationException good) {}
-
- ListIterator listIter = fciTargets.listIterator();
- count = 0;
- while (listIter.hasNext())
- {
- listIter.next();
- count++;
- }
- assertEquals("Correct count", 2, count);
- try
- {
- listIter.remove();
- fail("Iterator.remove call did not fail");
- }
- catch (UnsupportedOperationException good) {}
-
- while (listIter.hasPrevious())
- {
- listIter.previous();
- count--;
- }
- assertEquals("Correct count", 0, count);
-
- listIter = fciTargets.listIterator(1);
- while (listIter.hasNext())
- {
- listIter.next();
- count++;
- }
- assertEquals("Correct count", 1, count);
- try
- {
- listIter.remove();
- fail("Iterator.remove call did not fail");
- }
- catch (UnsupportedOperationException good) {}
-
- while (listIter.hasPrevious())
- {
- listIter.previous();
- count--;
- }
- assertEquals("Correct count", -1, count);
-
- // Check the lists returned by other methods
- fciTargets = fci.updateClusterInfo(targets, 0);
-
- try
- {
- fciTargets.add("FAIL");
- fail("add call did not fail");
- }
- catch (UnsupportedOperationException good) {}
-
- fciTargets = fci.removeDeadTarget(targets.get(0));
-
- try
- {
- fciTargets.add("FAIL");
- fail("add call did not fail");
- }
- catch (UnsupportedOperationException good) {}
-
- }
-
- private void checkFCIConsistency(FamilyClusterInfo fci, int checks, boolean allowOutOfSync)
- {
-
- for (int i = 0; i < checks; i++)
- {
- synchronized (fci)
- {
- if (fci.currentMembershipInSyncWithViewId())
- {
- List targets = fci.getTargets();
- long vid = fci.getCurrentViewId();
- assertEquals("targets and vid match", vid, targets.size());
- }
- else
- {
- assertTrue("OK for FCI view to be out of sync", allowOutOfSync);
- }
- }
- }
-
- }
-}
Copied: projects/cluster/ha-client/tags/1.1.0.CR2/src/test/java/org/jboss/test/ha/framework/interfaces/FamilyClusterInfoUnitTestCase.java (from rev 74878, projects/cluster/ha-client/trunk/src/test/java/org/jboss/test/ha/framework/interfaces/FamilyClusterInfoUnitTestCase.java)
===================================================================
--- projects/cluster/ha-client/tags/1.1.0.CR2/src/test/java/org/jboss/test/ha/framework/interfaces/FamilyClusterInfoUnitTestCase.java (rev 0)
+++ projects/cluster/ha-client/tags/1.1.0.CR2/src/test/java/org/jboss/test/ha/framework/interfaces/FamilyClusterInfoUnitTestCase.java 2008-07-11 02:01:14 UTC (rev 75651)
@@ -0,0 +1,368 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.test.ha.framework.interfaces;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+
+import org.jboss.ha.framework.interfaces.ClusteringTargetsRepository;
+import org.jboss.ha.framework.interfaces.FamilyClusterInfo;
+
+import junit.framework.TestCase;
+
+/**
+ * Test of FamilyClusterInfoImpl.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public class FamilyClusterInfoUnitTestCase extends TestCase
+{
+ private abstract class FCIChanger extends Thread
+ {
+ private boolean started;
+ private boolean stopped;
+ private Throwable caught;
+
+ protected FamilyClusterInfo fci;
+
+ FCIChanger(FamilyClusterInfo fci)
+ {
+ this.fci = fci;
+ }
+
+ abstract void update();
+
+
+ public void run()
+ {
+ try
+ {
+ started = true;
+
+ while (!stopped)
+ {
+ if (interrupted())
+ throw new InterruptedException();
+
+ update();
+ }
+
+ }
+ catch (InterruptedException ie)
+ {
+ if (!stopped)
+ caught = ie;
+ }
+ catch (Throwable t)
+ {
+ caught = t;
+ }
+ finally
+ {
+ started = false;
+ }
+ }
+
+ void beginUpdates()
+ {
+ this.start();
+ while (!started)
+ {
+ try
+ {
+ sleep(10);
+ }
+ catch (InterruptedException e)
+ {
+ caught = e;
+ }
+ }
+ }
+
+ void endUpdates()
+ {
+ if (started)
+ {
+ stopped = true;
+ try
+ {
+ this.join(250);
+ }
+ catch (InterruptedException ignored) {}
+ }
+
+ if (started)
+ interrupt();
+ }
+
+ Throwable getThrowable()
+ {
+ return caught;
+ }
+ }
+
+ private class Updater extends FCIChanger
+ {
+ private ArrayList targets = new ArrayList();
+ private int viewId;
+
+ Updater(FamilyClusterInfo fci)
+ {
+ super(fci);
+ }
+
+ void update()
+ {
+ targets.add(new Object());
+ viewId++;
+ fci.updateClusterInfo((ArrayList) targets.clone(), viewId);
+ }
+ }
+
+ private class Remover extends FCIChanger
+ {
+ Remover(FamilyClusterInfo fci)
+ {
+ super(fci);
+ }
+
+ void update()
+ {
+ List targets = fci.getTargets();
+ if (targets.size() > 0)
+ fci.removeDeadTarget(targets.get(0));
+ }
+
+ }
+
+ private class Resetter extends FCIChanger
+ {
+ Resetter(FamilyClusterInfo fci)
+ {
+ super(fci);
+ }
+
+ void update()
+ {
+ fci.resetView();
+ }
+ }
+
+ public void testSynchronization() throws Exception
+ {
+ ClusteringTargetsRepository.initTarget("testSynchronization", new ArrayList(), 0);
+ FamilyClusterInfo fci = ClusteringTargetsRepository.getFamilyClusterInfo("testSynchronization");
+
+ Updater updater = new Updater(fci);
+ Remover remover = new Remover(fci);
+ Resetter resetter = new Resetter(fci);
+
+ updater.beginUpdates();
+
+ checkFCIConsistency(fci, 150, false);
+
+ remover.beginUpdates();
+
+ checkFCIConsistency(fci, 150, true);
+
+ resetter.beginUpdates();
+
+ checkFCIConsistency(fci, 150, true);
+
+ updater.endUpdates();
+ remover.endUpdates();
+ resetter.endUpdates();
+
+ assertNull("Updater had no exceptions", updater.getThrowable());
+ assertNull("Remover had no exceptions", remover.getThrowable());
+ assertNull("Resetter had no exceptions", resetter.getThrowable());
+
+ }
+
+ public void testTargetListImmutability() throws Exception
+ {
+ ArrayList targets = new ArrayList();
+ targets.add("ONE");
+ targets.add("TWO");
+ ClusteringTargetsRepository.initTarget("testImmutability", targets, 0);
+ FamilyClusterInfo fci = ClusteringTargetsRepository.getFamilyClusterInfo("testImmutability");
+
+ List fciTargets = fci.getTargets();
+
+ // Confirm the targets are what we expect
+ assertEquals("Expected number of targets", 2, fciTargets.size());
+ assertEquals("First target as expected", "ONE", fciTargets.get(0));
+ assertEquals("Second target as expected", "TWO", fciTargets.get(1));
+
+ try
+ {
+ fciTargets.add("FAIL");
+ fail("add call did not fail");
+ }
+ catch (UnsupportedOperationException good) {}
+
+ try
+ {
+ fciTargets.addAll(targets);
+ fail("addAll call did not fail");
+ }
+ catch (UnsupportedOperationException good) {}
+
+ try
+ {
+ fciTargets.clear();
+ fail("clear call did not fail");
+ }
+ catch (UnsupportedOperationException good) {}
+
+ try
+ {
+ fciTargets.remove(0);
+ fail("remove call did not fail");
+ }
+ catch (UnsupportedOperationException good) {}
+
+ try
+ {
+ fciTargets.set(0, "FAIL");
+ fail("set call did not fail");
+ }
+ catch (UnsupportedOperationException good) {}
+
+ try
+ {
+ fciTargets.removeAll(targets);
+ fail("removeAll call did not fail");
+ }
+ catch (UnsupportedOperationException good) {}
+
+ try
+ {
+ fciTargets.retainAll(targets);
+ fail("retainAll call did not fail");
+ }
+ catch (UnsupportedOperationException good) {}
+
+ Iterator iter = fciTargets.iterator();
+ int count = 0;
+ while (iter.hasNext())
+ {
+ iter.next();
+ count++;
+ }
+ assertEquals("Correct count", 2, count);
+ try
+ {
+ iter.remove();
+ fail("Iterator.remove call did not fail");
+ }
+ catch (UnsupportedOperationException good) {}
+
+ ListIterator listIter = fciTargets.listIterator();
+ count = 0;
+ while (listIter.hasNext())
+ {
+ listIter.next();
+ count++;
+ }
+ assertEquals("Correct count", 2, count);
+ try
+ {
+ listIter.remove();
+ fail("Iterator.remove call did not fail");
+ }
+ catch (UnsupportedOperationException good) {}
+
+ while (listIter.hasPrevious())
+ {
+ listIter.previous();
+ count--;
+ }
+ assertEquals("Correct count", 0, count);
+
+ listIter = fciTargets.listIterator(1);
+ while (listIter.hasNext())
+ {
+ listIter.next();
+ count++;
+ }
+ assertEquals("Correct count", 1, count);
+ try
+ {
+ listIter.remove();
+ fail("Iterator.remove call did not fail");
+ }
+ catch (UnsupportedOperationException good) {}
+
+ while (listIter.hasPrevious())
+ {
+ listIter.previous();
+ count--;
+ }
+ assertEquals("Correct count", -1, count);
+
+ // Check the lists returned by other methods
+ fciTargets = fci.updateClusterInfo(targets, 0);
+
+ try
+ {
+ fciTargets.add("FAIL");
+ fail("add call did not fail");
+ }
+ catch (UnsupportedOperationException good) {}
+
+ fciTargets = fci.removeDeadTarget(targets.get(0));
+
+ try
+ {
+ fciTargets.add("FAIL");
+ fail("add call did not fail");
+ }
+ catch (UnsupportedOperationException good) {}
+
+ }
+
+ private void checkFCIConsistency(FamilyClusterInfo fci, int checks, boolean allowOutOfSync)
+ {
+
+ for (int i = 0; i < checks; i++)
+ {
+ synchronized (fci)
+ {
+ if (fci.currentMembershipInSyncWithViewId())
+ {
+ List targets = fci.getTargets();
+ long vid = fci.getCurrentViewId();
+ assertEquals("targets and vid match", vid, targets.size());
+ }
+ else
+ {
+ assertTrue("OK for FCI view to be out of sync", allowOutOfSync);
+ }
+ }
+ }
+
+ }
+}
More information about the jboss-cvs-commits
mailing list