[jboss-cvs] JBossAS SVN: r67104 - in projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha: client and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Nov 14 18:50:42 EST 2007


Author: bstansberry at jboss.com
Date: 2007-11-14 18:50:42 -0500 (Wed, 14 Nov 2007)
New Revision: 67104

Added:
   projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/framework/
   projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/framework/interfaces/
   projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/framework/interfaces/ClusteringTargetsRepository.java
   projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/framework/interfaces/FamilyClusterInfo.java
   projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/framework/interfaces/FamilyClusterInfoImpl.java
   projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/framework/interfaces/GenericClusteringException.java
Removed:
   projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/client/ClusteringTargetsRepository.java
   projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/client/FamilyClusterInfo.java
   projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/client/FamilyClusterInfoImpl.java
   projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/client/GenericClusteringException.java
Log:
Use the package names from cluster module to ease compatibility issues

Deleted: projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/client/ClusteringTargetsRepository.java
===================================================================
--- projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/client/ClusteringTargetsRepository.java	2007-11-14 23:33:39 UTC (rev 67103)
+++ projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/client/ClusteringTargetsRepository.java	2007-11-14 23:50:42 UTC (rev 67104)
@@ -1,137 +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;
-
-import java.util.Hashtable;
-import java.util.List;
-
-
-/**
- * JVM singleton that associates a list of targets (+ other info) 
- * contained in a 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 the same EJB form *2*
- * proxy families.
- *
- * @see org.jboss.ha.client.FamilyClusterInfo
- * @see org.jboss.ha.client.FamilyClusterInfoImpl
- *
- * @author  <a href="mailto:sacha.labourey at cogito-info.ch">Sacha Labourey</a>.
- * @author brian.stansberry at jboss.com
- * 
- * @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 somehow 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/trunk/ha-client/src/main/java/org/jboss/ha/client/FamilyClusterInfo.java
===================================================================
--- projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/client/FamilyClusterInfo.java	2007-11-14 23:33:39 UTC (rev 67103)
+++ projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/client/FamilyClusterInfo.java	2007-11-14 23:50:42 UTC (rev 67104)
@@ -1,133 +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;
-
-import java.util.List;
-
-/**
- * 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 LoadBalancePolicy 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 ClusteringTargetsRepository singleton.
- * @see org.jboss.ha.client.FamilyClusterInfoImpl
- * @see org.jboss.ha.client.ClusteringTargetsRepository
- * @author   <a href="mailto:sacha.labourey at cogito-info.ch">Sacha Labourey</a>.
- * @author  brian.stansberry at jboss.com
- * @version  $Revision$  <p><b>Revisions:</b>  <p><b>2002/08/23, Sacha Labourey:</b>  <ul>  <li> First implementation </li>  </ul>
- */
-
-public interface FamilyClusterInfo
-{
-   /** Value returned by {@link #getCursor()} to indicate no cursor has been set */
-   public final static int UNINITIALIZED_CURSOR = 999999999;
-   
-   /**
-    * Gets the name of the proxy family.
-    */
-   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).
-    * 
-    * @return an unmodifiable view of the target list
-    */
-   public List getTargets ();
-   
-   /**
-    * Gets a hash of the cluster topology for this family.
-    * This value can be passed back to the server as a shorthand for
-    * the current client-side view of the cluster, allowing the server
-    * to provide a new list of targets if the client is out of sync
-    * with the current topology.
-    */
-   public long getCurrentViewId ();
-   
-   /**
-    * Remove the given target from the list of targets. Does not
-    * update the view id.
-    * 
-    * <strong>NOTE:</strong> Implementations should synchronize on themselves 
-    * when executing this method (see JBAS-2071).
-    * 
-    * @param target the target to remove
-    * 
-    * @return an unmodifiable view of the updated target list
-    */
-   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).
-    * 
-    * @return an unmodifiable view of the updated target list
-    */
-   public List updateClusterInfo (List targets, long viewId);
-   
-   /**
-    * Gets whether the current view id is in sync with the current list of
-    * targets.  Will be <code>false</code> if {@link #removeDeadTarget} or
-    * {@link #resetView()} has been called since the last call to 
-    * {@link #updateClusterInfo(List, long)}.
-    */
-   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 the index of the current cursor in the list of targets, if any. <p> For use by  {@link LoadBalancePolicy}  implementations like  {@link RoundRobin} that sequentially move through the list of targets.  Storing the index in the FamilyClusterInfo allows multiple LoadBalancePolicy instances to coordinate their target selections. </p> <p> This information could also be stored in a static map in RoundRobin, but the map lookup would be slower. </p>
-    * @return  the current cursor or  {@link #UNINITIALIZED_CURSOR}  if there  is no valid cursor.
-    * @uml.property  name="cursor"
-    */
-   public int getCursor();
-   
-   /**
-    * Sets the index of the current cursor in the list of targets, if any.
-    * @param cursor  the new cursor position
-    * @return  the cursor position after this call
-    * @see  #getCursor()
-    * @uml.property  name="cursor"
-    */
-   public int setCursor (int cursor);
-   
-   /**
-    * Gets an object arbitrarily cached in this object.  The expected use is that one of the targets in the list of targets would be stored by a  {@link LoadBalancePolicy}  implementation like  {@link FirstAvailableIdenticalAllProxies} .  Storing the target in the FamilyClusterInfo allows multiple LoadBalancePolicy instances to ensure they use the same target. <p> This information could also be stored in a static map in  FirstAvailableIdenticalAllProxies, but the map lookup would be slower. </p>
-    * @return  whatever was last passed to  {@link #setObject(Object)}  , or   <code>null</code> if nothing was.
-    * @uml.property  name="object"
-    */
-   public Object getObject ();
-   
-   /**
-    * Sets an arbitrary object for caching in this object.  The expected use is that one of the targets in the list of targets would be stored by a  {@link LoadBalancePolicy}  implementation like  {@link FirstAvailableIdenticalAllProxies} .  Storing the target in the FamilyClusterInfo allows multiple LoadBalancePolicy instances to ensure they use the same target.
-    * @param whatever    the object to cache
-    * @return  the object that is now cached.
-    * @uml.property  name="object"
-    */
-   public Object setObject (Object whatever);
-}

Deleted: projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/client/FamilyClusterInfoImpl.java
===================================================================
--- projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/client/FamilyClusterInfoImpl.java	2007-11-14 23:33:39 UTC (rev 67103)
+++ projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/client/FamilyClusterInfoImpl.java	2007-11-14 23:50:42 UTC (rev 67104)
@@ -1,212 +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;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-
-/**
- * Default implementation of  {@link FamilyClusterInfo} .
- * @see org.jboss.ha.client.ClusteringTargetsRepository
- * @author   <a href="mailto:sacha.labourey at cogito-info.ch">Sacha Labourey</a>.
- * @author  brian.stansberry at jboss.com
- * @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 --------------------------------------------------------
-
-   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;      
-   }
-    
-   // Constructors --------------------------------------------------
-   
-   private FamilyClusterInfoImpl (){ }
-   
-   protected FamilyClusterInfoImpl (String familyName, List targets, long viewId)
-   {
-      this.familyName = familyName;
-      this.targets = cloneList(targets);
-      this.currentViewId = viewId;
-      
-      //TODO shouldn't this be true??
-      this.isViewMembersInSyncWithViewId = false;
-   }
-
-   // Public --------------------------------------------------------
-   
-   // FamilyClusterInfo implementation ----------------------------------------------
-   
-   /**
-    * Get the familyName.
-    * @return  the familyName.
-    * @uml.property  name="familyName"
-    */
-   public String getFamilyName () { return this.familyName; }
-   
-   /**
-    * @see  Collections#unmodifiableList(List)
-    * @uml.property  name="targets"
-    */
-   public synchronized List getTargets () 
-   { 
-      return Collections.unmodifiableList(this.targets); 
-   }
-   /**
-    * Get the currentViewId.
-    * @return  the currentViewId.
-    * @uml.property  name="currentViewId"
-    */
-   public long getCurrentViewId () { return this.currentViewId; }
-   /**
-    * Get the cursor.
-    * @return  the cursor.
-    * @uml.property  name="cursor"
-    */
-   public int getCursor () { return this.cursor; }
-   /**
-    * Set the cursor.
-    * @param cursor  The cursor to set.
-    * @uml.property  name="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; }
-   
-   /** 
-    * @see Collections#unmodifiableList(List)
-    */
-   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);
-      }      
-   }
-   
-   /** 
-    * @see Collections#unmodifiableList(List)
-    */
-   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 -------------------------------------------------
-   
-}

Deleted: projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/client/GenericClusteringException.java
===================================================================
--- projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/client/GenericClusteringException.java	2007-11-14 23:33:39 UTC (rev 67103)
+++ projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/client/GenericClusteringException.java	2007-11-14 23:50:42 UTC (rev 67104)
@@ -1,125 +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;
-
-/**
- * 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.
- * @author   <a href="mailto:sacha.labourey at cogito-info.ch">Sacha Labourey</a>.
- * @author  brian.stansberry at jboss.com
- * @version  $Revision$  <p><b>Revisions:</b>  <p><b>8 avril 2002 Sacha Labourey:</b>  <ul>  <li> First implementation </li>  </ul>
- */
-
-public class GenericClusteringException
-   extends Exception
-{
-   /** The serialVersionUID */
-   private static final long serialVersionUID = 7008819559854309729L;
-   
-   /** 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;
-   
-   private boolean isDefinitive = true;
-   private 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
-    * @uml.property  name="isDefinitive"
-    */
-   public boolean isDefinitive ()
-   {
-      return this.isDefinitive;      
-   }
-   
-   public void setIsDefinitive (boolean definitive)
-   {
-      this.isDefinitive = definitive;
-   }
-}

Copied: projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/framework/interfaces/ClusteringTargetsRepository.java (from rev 67098, trunk/cluster/src/main/org/jboss/ha/framework/interfaces/ClusteringTargetsRepository.java)
===================================================================
--- projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/framework/interfaces/ClusteringTargetsRepository.java	                        (rev 0)
+++ projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/framework/interfaces/ClusteringTargetsRepository.java	2007-11-14 23:50:42 UTC (rev 67104)
@@ -0,0 +1,135 @@
+/*
+  * 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 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/trunk/ha-client/src/main/java/org/jboss/ha/framework/interfaces/FamilyClusterInfo.java (from rev 67098, trunk/cluster/src/main/org/jboss/ha/framework/interfaces/FamilyClusterInfo.java)
===================================================================
--- projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/framework/interfaces/FamilyClusterInfo.java	                        (rev 0)
+++ projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/framework/interfaces/FamilyClusterInfo.java	2007-11-14 23:50:42 UTC (rev 67104)
@@ -0,0 +1,102 @@
+/*
+  * 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;
+
+/**
+ * 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 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 ();
+   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);
+   
+   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 ();
+   
+   // arbitrary usage by the LoadBalancePolicy implementation
+   // We could have used an HashMap but the lookup would have taken
+   // much more time and we probably don't need as much flexibility
+   // (+ it is slow for a simple int)
+   //
+   public int getCursor();
+   public int setCursor (int cursor);
+   public Object getObject ();
+   public Object setObject (Object whatever);
+   
+   public final static int UNINITIALIZED_CURSOR = 999999999;
+}

Copied: projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/framework/interfaces/FamilyClusterInfoImpl.java (from rev 67098, trunk/cluster/src/main/org/jboss/ha/framework/interfaces/FamilyClusterInfoImpl.java)
===================================================================
--- projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/framework/interfaces/FamilyClusterInfoImpl.java	                        (rev 0)
+++ projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/framework/interfaces/FamilyClusterInfoImpl.java	2007-11-14 23:50:42 UTC (rev 67104)
@@ -0,0 +1,184 @@
+/*
+  * 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 = false;
+   }
+
+   // 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/trunk/ha-client/src/main/java/org/jboss/ha/framework/interfaces/GenericClusteringException.java (from rev 67098, trunk/cluster/src/main/org/jboss/ha/framework/interfaces/GenericClusteringException.java)
===================================================================
--- projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/framework/interfaces/GenericClusteringException.java	                        (rev 0)
+++ projects/cluster/trunk/ha-client/src/main/java/org/jboss/ha/framework/interfaces/GenericClusteringException.java	2007-11-14 23:50:42 UTC (rev 67104)
@@ -0,0 +1,154 @@
+/*
+  * 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 class 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;
+   }
+}




More information about the jboss-cvs-commits mailing list