[jboss-cvs] JBossAS SVN: r63967 - in trunk/cluster/src: main/org/jboss/cache/invalidation/bridges and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jul 11 08:29:54 EDT 2007


Author: jerrygauth
Date: 2007-07-11 08:29:54 -0400 (Wed, 11 Jul 2007)
New Revision: 63967

Modified:
   trunk/cluster/src/etc/cluster-beans.xml
   trunk/cluster/src/main/org/jboss/cache/invalidation/bridges/JGCacheInvalidationBridge.java
   trunk/cluster/src/main/org/jboss/cache/invalidation/bridges/JGCacheInvalidationBridgeMBean.java
Log:
JBAS-4276, partition injection changes for JGCacheInvalidationBridge

Modified: trunk/cluster/src/etc/cluster-beans.xml
===================================================================
--- trunk/cluster/src/etc/cluster-beans.xml	2007-07-11 08:37:54 UTC (rev 63966)
+++ trunk/cluster/src/etc/cluster-beans.xml	2007-07-11 12:29:54 UTC (rev 63967)
@@ -266,7 +266,7 @@
       <depends>HAPartition</depends>
       <depends>jboss.cache:service=InvalidationManager</depends>
          
-      <property name="clusterPartition"><inject bean="HAPartition"/></property>
+      <property name="HAPartition"><inject bean="HAPartition"/></property>
       <property name="invalidationManager">jboss.cache:service=InvalidationManager</property>
       <property name="bridgeName">DefaultJGBridge</property>
       

Modified: trunk/cluster/src/main/org/jboss/cache/invalidation/bridges/JGCacheInvalidationBridge.java
===================================================================
--- trunk/cluster/src/main/org/jboss/cache/invalidation/bridges/JGCacheInvalidationBridge.java	2007-07-11 08:37:54 UTC (rev 63966)
+++ trunk/cluster/src/main/org/jboss/cache/invalidation/bridges/JGCacheInvalidationBridge.java	2007-07-11 12:29:54 UTC (rev 63967)
@@ -25,8 +25,6 @@
 import java.util.ArrayList;
 import java.util.Vector;
 import java.util.Collection;
-import javax.management.MBeanServerInvocationHandler;
-import javax.management.ObjectName;
 
 import org.jboss.cache.invalidation.BatchInvalidation;
 import org.jboss.cache.invalidation.InvalidationManager;
@@ -37,7 +35,6 @@
 import org.jboss.ha.framework.interfaces.HAPartition;
 import org.jboss.ha.framework.interfaces.DistributedState;
 import org.jboss.ha.framework.interfaces.DistributedReplicantManager;
-import org.jboss.ha.framework.server.ClusterPartitionMBean;
 import org.jboss.system.server.ServerConfigUtil;
 
 /**
@@ -72,21 +69,19 @@
    /**
     * The ClusterPartition with which we are associated.
     */
-   protected ClusterPartitionMBean clusterPartition;
+   protected HAPartition partition;
    protected String invalidationManagerName = InvalidationManager.DEFAULT_JMX_SERVICE_NAME;
    protected String bridgeName = "DefaultJGCacheIB";
    
-   protected HAPartition partition = null;
    protected DistributedState ds = null;
    protected DistributedReplicantManager drm = null;
-   protected String RPC_HANLE_NAME = null;
+   protected String RPC_HANDLER_NAME = null;
    protected String nodeName = null;
    
    protected InvalidationManagerMBean invalMgr = null;
    protected BridgeInvalidationSubscription invalidationSubscription = null;
    protected Collection localGroups = null;
-   protected Vector bridgedGroups = new Vector ();
-   
+   protected Vector bridgedGroups = new Vector ();   
 
    protected final Class[] rpc_invalidate_types=new Class[]{String.class, Serializable.class};
    protected final Class[] rpc_invalidates_types=new Class[]{String.class, Serializable[].class};
@@ -111,14 +106,14 @@
       return this.invalidationManagerName;
    }
 
-   public ClusterPartitionMBean getClusterPartition()
+   public HAPartition getHAPartition()
    {
-      return clusterPartition;
+      return partition;
    }
 
-   public void setClusterPartition(ClusterPartitionMBean clusterPartition)
+   public void setHAPartition(HAPartition clusterPartition)
    {
-      this.clusterPartition = clusterPartition;
+      this.partition = clusterPartition;
    }
    
    public String getPartitionName ()
@@ -131,11 +126,6 @@
       this.invalidationManagerName = objectName;
    }
    
-   public void setPartitionName (String partitionName)
-   {
-      this.partitionName = partitionName;
-   }
-   
    public String getBridgeName ()
    {
       return this.bridgeName;
@@ -157,23 +147,23 @@
     */
    public synchronized void replicantsChanged (String key, java.util.List newReplicants, int newReplicantsViewId)
    {
-      if (key.equals (this.RPC_HANLE_NAME) && this.drm.isMasterReplica (this.RPC_HANLE_NAME))
+      if (key.equals (this.RPC_HANDLER_NAME) && this.drm.isMasterReplica (this.RPC_HANDLER_NAME))
       {
-         log.debug ("The list of replicant for the JG bridge has changed, computing and updating local info...");
+         log.debug ("The list of replicants for the JG bridge has changed, computing and updating local info...");
          
          // we remove any entry from the DS whose node is dead
          //
-         java.util.Collection coll = this.ds.getAllKeys (this.RPC_HANLE_NAME);                  
+         java.util.Collection coll = this.ds.getAllKeys (this.RPC_HANDLER_NAME);                  
          if (coll == null) 
          {
-            log.debug ("... No bridge info was associated to this node");
+            log.debug ("... No bridge info was associated with this node");
             return;
          }
          
          // to avoid ConcurrentModificationException, we copy the list of keys in a new structure
          //
          ArrayList collCopy = new java.util.ArrayList (coll);
-         java.util.List newReplicantsNodeNames = this.drm.lookupReplicantsNodeNames (this.RPC_HANLE_NAME);
+         java.util.List newReplicantsNodeNames = this.drm.lookupReplicantsNodeNames (this.RPC_HANDLER_NAME);
          
 
          for (int i = 0; i < collCopy.size(); i++)
@@ -185,8 +175,8 @@
                //
                try
                {
-                  log.debug ("removing bridge information associated to this node from the DS");
-                  this.ds.remove (this.RPC_HANLE_NAME, nodeEntry, true);
+                  log.debug ("removing bridge information associated with this node from the DS");
+                  this.ds.remove (this.RPC_HANDLER_NAME, nodeEntry, true);
                }
                catch (Exception e)
                {
@@ -297,31 +287,23 @@
    
    public void startService () throws Exception
    {
-      RPC_HANLE_NAME = "DCacheBridge-" + this.bridgeName;
-      
-      // Support old-style partition lookup for configs that don't
-      // inject the partition.
-      // TODO remove this after a while; deprecated in 4.0.4
-      if (this.clusterPartition == null)
+      if (partition == null)
       {
-         javax.naming.Context ctx = new javax.naming.InitialContext ();
-         this.partition = (HAPartition)ctx.lookup("/HAPartition/" + this.partitionName); 
+         throw new IllegalStateException("HAPartition property must be set before starting InvalidationBridge service");
       }
-      else
-      {
-         this.partition = this.clusterPartition.getHAPartition();
-         this.partitionName = this.partition.getPartitionName();
-      }
-         
-      this.ds = this.partition.getDistributedStateService ();
-      this.drm = this.partition.getDistributedReplicantManager ();
-      this.nodeName = this.partition.getNodeName();
       
-      this.drm.add (this.RPC_HANLE_NAME, "");
-      this.drm.registerListener (this.RPC_HANLE_NAME, this);      
-      this.ds.registerDSListenerEx (RPC_HANLE_NAME, this);
-      this.partition.registerRPCHandler(RPC_HANLE_NAME, this);   
+      RPC_HANDLER_NAME = "DCacheBridge-" + this.bridgeName;
+
+      this.partitionName = partition.getPartitionName();       
+      this.ds = partition.getDistributedStateService ();
+      this.drm = partition.getDistributedReplicantManager ();
+      this.nodeName = partition.getNodeName();
       
+      this.drm.add (this.RPC_HANDLER_NAME, "");
+      this.drm.registerListener (this.RPC_HANDLER_NAME, this);      
+      this.ds.registerDSListenerEx (RPC_HANDLER_NAME, this);
+      partition.registerRPCHandler(RPC_HANDLER_NAME, this);   
+      
       // we now publish the list of caches we have access to
       //
       this.invalMgr = (org.jboss.cache.invalidation.InvalidationManagerMBean)
@@ -340,21 +322,21 @@
    {
       try
       {
-         this.partition.unregisterRPCHandler (this.RPC_HANLE_NAME, this);
-         this.ds.unregisterDSListenerEx (this.RPC_HANLE_NAME, this);
-         this.drm.unregisterListener (this.RPC_HANLE_NAME, this);
-         this.drm.remove (this.RPC_HANLE_NAME);
+         partition.unregisterRPCHandler (this.RPC_HANDLER_NAME, this);
+         this.ds.unregisterDSListenerEx (this.RPC_HANDLER_NAME, this);
+         this.drm.unregisterListener (this.RPC_HANDLER_NAME, this);
+         this.drm.remove (this.RPC_HANDLER_NAME);
          
          this.invalidationSubscription.unregister ();
                   
-         this.ds.remove (this.RPC_HANLE_NAME, this.nodeName, true);
+         this.ds.remove (this.RPC_HANDLER_NAME, this.nodeName, true);
          
          this.invalMgr = null;
-         this.partition = null;
+         partition = null;
          this.drm = null;
          this.ds = null;
          this.invalidationSubscription = null;
-         this.RPC_HANLE_NAME = null;
+         this.RPC_HANDLER_NAME = null;
          this.nodeName = null;
          this.localGroups = null;
          this.bridgedGroups = new Vector ();                  
@@ -405,11 +387,11 @@
       try
       {         
          if (asynch)
-            this.partition.callAsynchMethodOnCluster (this.RPC_HANLE_NAME,
+            partition.callAsynchMethodOnCluster (this.RPC_HANDLER_NAME,
                                                       "_rpc_invalidate",
                                                       params, rpc_invalidate_types, true);
          else
-            this.partition.callMethodOnCluster (this.RPC_HANLE_NAME,
+            partition.callMethodOnCluster (this.RPC_HANDLER_NAME,
                                                 "_rpc_invalidate",
                                                 params, rpc_invalidate_types, true);
       }
@@ -426,10 +408,10 @@
       try
       {         
          if (asynch)
-            this.partition.callAsynchMethodOnCluster (this.RPC_HANLE_NAME,
+            partition.callAsynchMethodOnCluster (this.RPC_HANDLER_NAME,
                                                       "_rpc_invalidates", params, rpc_invalidates_types, true);
          else
-            this.partition.callMethodOnCluster (this.RPC_HANLE_NAME,
+            partition.callMethodOnCluster (this.RPC_HANDLER_NAME,
                                                 "_rpc_invalidates", params, rpc_invalidates_types, true);
       }
       catch (Exception e)
@@ -445,10 +427,10 @@
       try
       {
          if (asynch)
-            this.partition.callAsynchMethodOnCluster (this.RPC_HANLE_NAME,
+            partition.callAsynchMethodOnCluster (this.RPC_HANDLER_NAME,
                                                       "_rpc_invalidate_all", params, rpc_invalidate_all_types, true);
          else
-            this.partition.callMethodOnCluster (this.RPC_HANLE_NAME,
+            partition.callMethodOnCluster (this.RPC_HANDLER_NAME,
                                                 "_rpc_invalidate_all", params, rpc_invalidate_all_types, true);
       }
       catch (Exception e)
@@ -464,10 +446,10 @@
       try
       {         
          if (asynch)
-            this.partition.callAsynchMethodOnCluster (this.RPC_HANLE_NAME,
+            partition.callAsynchMethodOnCluster (this.RPC_HANDLER_NAME,
                                                       "_rpc_batchInvalidate", params, rpc_batch_invalidate_types, true);
          else
-            this.partition.callMethodOnCluster (this.RPC_HANLE_NAME,
+            partition.callMethodOnCluster (this.RPC_HANDLER_NAME,
                                                 "_rpc_batchInvalidate", params, rpc_batch_invalidate_types, true);
       }
       catch (Exception e)
@@ -500,15 +482,15 @@
       if (result.size () > 0)       
       {
          NodeInfo info = new NodeInfo (result, this.nodeName);
-         this.ds.set (this.RPC_HANLE_NAME, this.nodeName, info, true);
+         this.ds.set (this.RPC_HANDLER_NAME, this.nodeName, info, true);
       }
       else
-         this.ds.remove (this.RPC_HANLE_NAME, this.nodeName, true);
+         this.ds.remove (this.RPC_HANDLER_NAME, this.nodeName, true);
    }
    
    protected void updatedBridgedInvalidationGroupsInfo ()
    {
-      Collection bridgedByNode = this.ds.getAllValues (this.RPC_HANLE_NAME);
+      Collection bridgedByNode = this.ds.getAllValues (this.RPC_HANDLER_NAME);
       
       log.debug ("Updating list of invalidation groups that are bridged...");
       

Modified: trunk/cluster/src/main/org/jboss/cache/invalidation/bridges/JGCacheInvalidationBridgeMBean.java
===================================================================
--- trunk/cluster/src/main/org/jboss/cache/invalidation/bridges/JGCacheInvalidationBridgeMBean.java	2007-07-11 08:37:54 UTC (rev 63966)
+++ trunk/cluster/src/main/org/jboss/cache/invalidation/bridges/JGCacheInvalidationBridgeMBean.java	2007-07-11 12:29:54 UTC (rev 63967)
@@ -21,7 +21,7 @@
   */
 package org.jboss.cache.invalidation.bridges;
 
-import org.jboss.ha.framework.server.ClusterPartitionMBean;
+import org.jboss.ha.framework.interfaces.HAPartition;
 import org.jboss.system.ServiceMBean;
 
 /**
@@ -50,34 +50,22 @@
 public interface JGCacheInvalidationBridgeMBean extends ServiceMBean
 {
    /** 
-    * Gets the name of the Clustering partition to be used to exchange
-    * invalidation messages and discover which caches (i.e., InvalidationGroup)
-    * are available
+    * Gets the name of the partition to be used to exchange invalidation messages 
+    * and discover which caches (i.e., InvalidationGroup)are available.  This is a 
+    * convenience method as the partition name is an attribute of HAPartition.
     * 
     * @return the name of the partition
-    * 
-    * @deprecated use {@link #getClusterPartition()}
     */
    String getPartitionName();
-   /**
-    * Sets the name of the Clustering partition to be used to exchange
-    * invalidation messages and discover which caches (i.e., InvalidationGroup)
-    * are available
-    * 
-    * @param name the name of the partition
-    * 
-    * @deprecated use {@link #setClusterPartition(ClusterPartitionMBean)}
-    */
-   void setPartitionName(String name);
    
    /**
     * Get the underlying partition used by this service to exchange
     * invalidation messages and discover which caches (i.e., InvalidationGroup)
-    * are available
+    * are available.
     * 
     * @return the partition
     */
-   ClusterPartitionMBean getClusterPartition();
+   HAPartition getHAPartition();
    
    /**
     * Sets the underlying partition used by this service to exchange
@@ -86,16 +74,35 @@
     * 
     * @param clusterPartition the partition
     */
-   void setClusterPartition(ClusterPartitionMBean clusterPartition);
+   void setHAPartition(HAPartition clusterPartition);
    
    /**
-    * ObjectName of the InvalidationManager to be used. Optional: in this
-    * case, the default InvalidationManager is used.
+    * Get the invalidation manager name.
+    * 
+    * @return the name of the invalidation manager
     */
-   public String getInvalidationManager ();
-   public void setInvalidationManager (String objectName);
+   public String getInvalidationManager();
    
-   public String getBridgeName ();
-   public void setBridgeName (String name);
+   /**
+    * Set the invalidation manager name.  If not set, the default name of
+    * InvalidationManager.DEFAULT_JMX_SERVICE_NAME is used.
+    * 
+    * @param objectName the name of the invalidation manager
+    */
+   public void setInvalidationManager(String objectName);
    
+   /**
+    * Get the invalidation bridge name.
+    * 
+    * @return the invalidation bridge name
+    */
+   public String getBridgeName();
+   
+   /**
+    * Set the invalidation bridge name
+    * 
+    * @param name of the bridge
+    */
+   public void setBridgeName(String name);
+   
 }




More information about the jboss-cvs-commits mailing list