[jboss-cvs] JBossAS SVN: r57642 - projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/client

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Oct 12 23:30:24 EDT 2006


Author: bstansberry at jboss.com
Date: 2006-10-12 23:30:22 -0400 (Thu, 12 Oct 2006)
New Revision: 57642

Modified:
   projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/client/FirstAvailable.java
   projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/client/FirstAvailableIdenticalAllProxies.java
   projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/client/LoadBalancePolicy.java
   projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/client/RandomRobin.java
   projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/client/RoundRobin.java
Log:
Fix license and package
Remove usage of the invocation package

Modified: projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/client/FirstAvailable.java
===================================================================
--- projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/client/FirstAvailable.java	2006-10-13 03:26:49 UTC (rev 57641)
+++ projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/client/FirstAvailable.java	2006-10-13 03:30:22 UTC (rev 57642)
@@ -1,44 +1,54 @@
 /*
-  * 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;
+ * 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;
 
 import java.util.List;
 
-import org.jboss.invocation.Invocation;
 
+
 /**
- * LoadBalancingPolicy implementation that always favor the first available target i.e.
- * no load balancing occurs. Nevertheless, the first target is randomly selected.
- * This does not mean that fail-over will not occur if the
- * first member in the list dies. In this case, fail-over will occur, and a new target
- * will become the first member and invocation will continously be invoked on the same
- * new target until its death. Each proxy using this policy will elect its own
- * prefered target: the target is not shared accross the proxy family (for this
- * behaviour please take a look at FirstAvailableIdenticalAllProxies)
- *
+ * 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$
- * @see org.jboss.ha.framework.interfaces.LoadBalancePolicy
+ * 
+ * @see org.jboss.ha.client.LoadBalancePolicy
  *
  * <p><b>Revisions:</b><br>
  * <p><b>2002/08/24: Sacha Labourey</b>
@@ -56,6 +66,7 @@
 public class FirstAvailable implements LoadBalancePolicy
 {
    // Constants -----------------------------------------------------
+   
    private static final long serialVersionUID = 2008524502721775114L;
 
    // Attributes ----------------------------------------------------
@@ -67,19 +78,9 @@
    // Constructors --------------------------------------------------
        
     // Public --------------------------------------------------------
-   
-   public void init (HARMIClient father)
-   {
-      // do not use the HARMIClient in this policy
-   }
 
    public Object chooseTarget (FamilyClusterInfo clusterFamily)
    {
-      return chooseTarget(clusterFamily, null);
-   }
-
-   public Object chooseTarget (FamilyClusterInfo clusterFamily, Invocation routingDecision)
-   {
       List targets = clusterFamily.getTargets ();
       if (targets.size () == 0)
          return null;

Modified: projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/client/FirstAvailableIdenticalAllProxies.java
===================================================================
--- projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/client/FirstAvailableIdenticalAllProxies.java	2006-10-13 03:26:49 UTC (rev 57641)
+++ projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/client/FirstAvailableIdenticalAllProxies.java	2006-10-13 03:30:22 UTC (rev 57642)
@@ -1,43 +1,44 @@
 /*
-  * 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;
+ * 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;
 
 import java.util.List;
 
-import org.jboss.invocation.Invocation;
 
+
 /**
- * LoadBalancingPolicy implementation that always favor the first available target i.e.
- * no load balancing occurs. Nevertheless, the first target is randomly selected.
- * This does not mean that fail-over will not occur if the
- * first member in the list dies. In this case, fail-over will occur, and a new target
- * will become the first member and invocation will continously be invoked on the same
- * new target until its death. Each proxy using this policy will *not* elect its own
- * prefered target: the target *is* shared with all proxies that belong to the same family 
- * (for a different behaviour please take a look at FirstAvailable)
+ * 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.LoadBalancePolicy
+ * @see org.jboss.ha.client.FamilyClusterInfo#getObject()
  *
- * @see org.jboss.ha.framework.interfaces.LoadBalancePolicy
- *
  * @author <a href="mailto:sacha.labourey at cogito-info.ch">Sacha Labourey</a>.
+ * @author brian.stansberry at jboss.com
+ * 
  * @version $Revision$
  */
 public class FirstAvailableIdenticalAllProxies implements LoadBalancePolicy
@@ -52,18 +53,9 @@
    // Constructors --------------------------------------------------
        
     // Public --------------------------------------------------------
-   
-   public void init (HARMIClient father)
-   {
-      // do not use the HARMIClient in this policy
-   }
 
    public Object chooseTarget (FamilyClusterInfo clusterFamily)
    {
-      return chooseTarget(clusterFamily, null);
-   }
-   public Object chooseTarget (FamilyClusterInfo clusterFamily, Invocation routingDecision)
-   {
       Object target = clusterFamily.getObject ();
       List targets = clusterFamily.getTargets ();
 

Modified: projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/client/LoadBalancePolicy.java
===================================================================
--- projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/client/LoadBalancePolicy.java	2006-10-13 03:26:49 UTC (rev 57641)
+++ projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/client/LoadBalancePolicy.java	2006-10-13 03:30:22 UTC (rev 57642)
@@ -1,28 +1,29 @@
 /*
-  * 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;
+ * 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;
 
-import org.jboss.invocation.Invocation;
+import java.io.Serializable;
 
+
 /**
  * Base interface for load-balancing policies. It is possible to implement many
  * different load-balancing policies by implementing this simple interface and
@@ -31,36 +32,26 @@
  *
  * @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$
  */
-public interface LoadBalancePolicy extends java.io.Serializable
+public interface LoadBalancePolicy extends Serializable
 {
    /** The serialVersionUID
     * @since 1.3.4.2
     */ 
    static final long serialVersionUID = -5071668971774090555L;
-   /**
-    * Initialize the policy with a reference to its parent stub. the load-balancing policy
-    * implementation can use HARMIClient data to take its decision
-    * @param father The stub that owns the policy
-    */   
-   public void init (HARMIClient father);
 
    /**
-    * Called when the stub wishes to know on which node the next invocation must
+    * 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.
-    * @param clusterFamily A list of potential target nodes
+    * </p>
+    * 
+    * @param clusterFamily object encapsulating a list of potential target nodes
     * @return The selected target for the next invocation
     */   
    public Object chooseTarget (FamilyClusterInfo clusterFamily);
-
-   /**
-    * 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);
 }

Modified: projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/client/RandomRobin.java
===================================================================
--- projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/client/RandomRobin.java	2006-10-13 03:26:49 UTC (rev 57641)
+++ projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/client/RandomRobin.java	2006-10-13 03:30:22 UTC (rev 57642)
@@ -19,28 +19,35 @@
   * 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;
+package org.jboss.ha.client;
 
 import java.util.List;
 import java.util.Random;
 
-import org.jboss.invocation.Invocation;
 
+
 /**
- * LoadBalancingPolicy implementation that always fully randomly select its target
- * (without basing its decision on any historic).
+ * 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$
- * @see org.jboss.ha.framework.interfaces.LoadBalancePolicy
+ * @see org.jboss.ha.client.LoadBalancePolicy
  */
 public class RandomRobin implements LoadBalancePolicy
 {
    // Constants -----------------------------------------------------
    /** @since 1.1.2.3 */
    private static final long serialVersionUID = -3599638697906618428L;
-   /** This needs to be a class variable or else you end up with multiple
+   
+   /** 
+    * <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 ());
 
@@ -52,17 +59,8 @@
    
    // LoadBalancePolicy implementation ----------------------------------------------
 
-   public void init (HARMIClient father)
-   {
-      // do not use the HARMIClient in this policy
-   }
-
    public Object chooseTarget (FamilyClusterInfo clusterFamily)
    {
-      return chooseTarget(clusterFamily, null);
-   }
-   public Object chooseTarget (FamilyClusterInfo clusterFamily, Invocation routingDecision)
-   {
       List targets = clusterFamily.getTargets ();
       int max = targets.size();
 

Modified: projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/client/RoundRobin.java
===================================================================
--- projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/client/RoundRobin.java	2006-10-13 03:26:49 UTC (rev 57641)
+++ projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/client/RoundRobin.java	2006-10-13 03:30:22 UTC (rev 57642)
@@ -19,17 +19,26 @@
   * 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;
+package org.jboss.ha.client;
 
 import java.util.List;
 
-import org.jboss.invocation.Invocation;
 
+
 /**
- * LoadBalancingPolicy implementation that always favor the next available
- * target load balancing always occurs.
+ * LoadBalancingPolicy 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>
  *
- * @see org.jboss.ha.framework.interfaces.LoadBalancePolicy
+ * @see org.jboss.ha.client.LoadBalancePolicy
+ * @see org.jboss.ha.client.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>.
@@ -49,17 +58,8 @@
        
    // Public --------------------------------------------------------
    
-   public void init (HARMIClient father)
-   {
-      // do not use the HARMIClient in this policy
-   }
-
    public Object chooseTarget (FamilyClusterInfo clusterFamily)
    {
-      return this.chooseTarget(clusterFamily, null);
-   }
-   public Object chooseTarget (FamilyClusterInfo clusterFamily, Invocation routingDecision)
-   {
       int cursor = clusterFamily.getCursor ();
       List targets = clusterFamily.getTargets ();
 




More information about the jboss-cvs-commits mailing list