[Jboss-cvs] JBossAS SVN: r54918 - in branches/Branch_4_0/cluster/src/main/org/jboss: ha/framework/interfaces invocation/http/interfaces invocation/jrmp/interfaces invocation/unified/interfaces

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Jul 31 12:12:15 EDT 2006


Author: bstansberry at jboss.com
Date: 2006-07-31 12:12:12 -0400 (Mon, 31 Jul 2006)
New Revision: 54918

Modified:
   branches/Branch_4_0/cluster/src/main/org/jboss/ha/framework/interfaces/FamilyClusterInfo.java
   branches/Branch_4_0/cluster/src/main/org/jboss/ha/framework/interfaces/FamilyClusterInfoImpl.java
   branches/Branch_4_0/cluster/src/main/org/jboss/ha/framework/interfaces/HARMIClient.java
   branches/Branch_4_0/cluster/src/main/org/jboss/invocation/http/interfaces/HttpInvokerProxyHA.java
   branches/Branch_4_0/cluster/src/main/org/jboss/invocation/jrmp/interfaces/JRMPInvokerProxyHA.java
   branches/Branch_4_0/cluster/src/main/org/jboss/invocation/unified/interfaces/UnifiedInvokerHAProxy.java
Log:
[JBAS-2071] Control access to FamilyClusterInfo when serializing proxies

Modified: branches/Branch_4_0/cluster/src/main/org/jboss/ha/framework/interfaces/FamilyClusterInfo.java
===================================================================
--- branches/Branch_4_0/cluster/src/main/org/jboss/ha/framework/interfaces/FamilyClusterInfo.java	2006-07-31 16:04:50 UTC (rev 54917)
+++ branches/Branch_4_0/cluster/src/main/org/jboss/ha/framework/interfaces/FamilyClusterInfo.java	2006-07-31 16:12:12 UTC (rev 54918)
@@ -49,15 +49,43 @@
 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 ArrayList 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 ArrayList 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 ArrayList updateClusterInfo (ArrayList targets, long viewId);
    
    public boolean currentMembershipInSyncWithViewId();
    
-   // force a reload of the view at the next invocation
+   /**
+    * 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

Modified: branches/Branch_4_0/cluster/src/main/org/jboss/ha/framework/interfaces/FamilyClusterInfoImpl.java
===================================================================
--- branches/Branch_4_0/cluster/src/main/org/jboss/ha/framework/interfaces/FamilyClusterInfoImpl.java	2006-07-31 16:04:50 UTC (rev 54917)
+++ branches/Branch_4_0/cluster/src/main/org/jboss/ha/framework/interfaces/FamilyClusterInfoImpl.java	2006-07-31 16:12:12 UTC (rev 54918)
@@ -105,8 +105,11 @@
    
    public void resetView ()
    {
-      this.currentViewId = -1;
-      this.isViewMembersInSyncWithViewId = false;
+      synchronized (this)
+      {
+         this.currentViewId = -1;
+         this.isViewMembersInSyncWithViewId = false;
+      }
    }
       
    // Object overrides ---------------------------------------------------

Modified: branches/Branch_4_0/cluster/src/main/org/jboss/ha/framework/interfaces/HARMIClient.java
===================================================================
--- branches/Branch_4_0/cluster/src/main/org/jboss/ha/framework/interfaces/HARMIClient.java	2006-07-31 16:04:50 UTC (rev 54917)
+++ branches/Branch_4_0/cluster/src/main/org/jboss/ha/framework/interfaces/HARMIClient.java	2006-07-31 16:12:12 UTC (rev 54918)
@@ -316,9 +316,14 @@
    private void writeObject (ObjectOutputStream stream)
       throws IOException
    {
-      ArrayList currentTargets = this.familyClusterInfo.getTargets ();
-      long vid = this.familyClusterInfo.getCurrentViewId ();
-
+      // JBAS-2071 - sync on FCI to ensure targets and vid are consistent
+      ArrayList currentTargets = null;
+      long vid = 0;
+      synchronized (this.familyClusterInfo)
+      {
+         currentTargets = this.familyClusterInfo.getTargets ();
+         vid = this.familyClusterInfo.getCurrentViewId ();
+      }
       stream.writeUTF(key);
       stream.writeObject(currentTargets);
       stream.writeLong(vid);

Modified: branches/Branch_4_0/cluster/src/main/org/jboss/invocation/http/interfaces/HttpInvokerProxyHA.java
===================================================================
--- branches/Branch_4_0/cluster/src/main/org/jboss/invocation/http/interfaces/HttpInvokerProxyHA.java	2006-07-31 16:04:50 UTC (rev 54917)
+++ branches/Branch_4_0/cluster/src/main/org/jboss/invocation/http/interfaces/HttpInvokerProxyHA.java	2006-07-31 16:12:12 UTC (rev 54918)
@@ -247,8 +247,16 @@
    public void writeExternal(final ObjectOutput out)
       throws IOException
    { 
-      out.writeObject(this.familyClusterInfo.getTargets());
-      out.writeLong(this.familyClusterInfo.getCurrentViewId ());
+      // JBAS-2071 - sync on FCI to ensure targets and vid are consistent
+      ArrayList currentTargets = null;
+      long vid = 0;
+      synchronized (this.familyClusterInfo)
+      {
+         currentTargets = this.familyClusterInfo.getTargets ();
+         vid = this.familyClusterInfo.getCurrentViewId ();
+      }
+      out.writeObject(currentTargets);
+      out.writeLong(vid);
       out.writeObject(this.loadBalancePolicy);
       out.writeObject(this.proxyFamilyName);
    }

Modified: branches/Branch_4_0/cluster/src/main/org/jboss/invocation/jrmp/interfaces/JRMPInvokerProxyHA.java
===================================================================
--- branches/Branch_4_0/cluster/src/main/org/jboss/invocation/jrmp/interfaces/JRMPInvokerProxyHA.java	2006-07-31 16:04:50 UTC (rev 54917)
+++ branches/Branch_4_0/cluster/src/main/org/jboss/invocation/jrmp/interfaces/JRMPInvokerProxyHA.java	2006-07-31 16:12:12 UTC (rev 54918)
@@ -312,9 +312,15 @@
    */
    public void writeExternal(final ObjectOutput out)
       throws IOException
-   {
-      ArrayList targets = this.familyClusterInfo.getTargets();
-      long vid = this.familyClusterInfo.getCurrentViewId ();
+   { 
+      // JBAS-2071 - sync on FCI to ensure targets and vid are consistent
+      ArrayList targets = null;
+      long vid = 0;
+      synchronized (this.familyClusterInfo)
+      {
+         targets = this.familyClusterInfo.getTargets ();
+         vid = this.familyClusterInfo.getCurrentViewId ();
+      }
       out.writeObject(targets);
       out.writeObject(this.loadBalancePolicy);
       out.writeObject (this.proxyFamilyName);

Modified: branches/Branch_4_0/cluster/src/main/org/jboss/invocation/unified/interfaces/UnifiedInvokerHAProxy.java
===================================================================
--- branches/Branch_4_0/cluster/src/main/org/jboss/invocation/unified/interfaces/UnifiedInvokerHAProxy.java	2006-07-31 16:04:50 UTC (rev 54917)
+++ branches/Branch_4_0/cluster/src/main/org/jboss/invocation/unified/interfaces/UnifiedInvokerHAProxy.java	2006-07-31 16:12:12 UTC (rev 54918)
@@ -402,9 +402,15 @@
       out.writeInt(CURRENT_VERSION);
 
       out.writeUTF(getLocator().getOriginalURI());
-      out.writeBoolean(isStrictRMIException());
-      ArrayList targets = this.familyClusterInfo.getTargets();
-      long vid = this.familyClusterInfo.getCurrentViewId();
+      out.writeBoolean(isStrictRMIException()); 
+      // JBAS-2071 - sync on FCI to ensure targets and vid are consistent
+      ArrayList targets = null;
+      long vid = 0;
+      synchronized (this.familyClusterInfo)
+      {
+         targets = this.familyClusterInfo.getTargets ();
+         vid = this.familyClusterInfo.getCurrentViewId ();
+      }
       out.writeObject(targets);
       out.writeObject(this.loadBalancePolicy);
       out.writeObject(this.proxyFamilyName);




More information about the jboss-cvs-commits mailing list