[jboss-cvs] JBossAS SVN: r106459 - projects/cluster/ha-server-cache-jbc/branches/Session_Ownership/src/main/java/org/jboss/ha/framework/server.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jul 6 14:15:37 EDT 2010


Author: bstansberry at jboss.com
Date: 2010-07-06 14:15:37 -0400 (Tue, 06 Jul 2010)
New Revision: 106459

Modified:
   projects/cluster/ha-server-cache-jbc/branches/Session_Ownership/src/main/java/org/jboss/ha/framework/server/DistributedStateImpl.java
   projects/cluster/ha-server-cache-jbc/branches/Session_Ownership/src/main/java/org/jboss/ha/framework/server/HAPartitionCacheHandlerImpl.java
Log:
Sync to trunk

Modified: projects/cluster/ha-server-cache-jbc/branches/Session_Ownership/src/main/java/org/jboss/ha/framework/server/DistributedStateImpl.java
===================================================================
--- projects/cluster/ha-server-cache-jbc/branches/Session_Ownership/src/main/java/org/jboss/ha/framework/server/DistributedStateImpl.java	2010-07-06 17:43:46 UTC (rev 106458)
+++ projects/cluster/ha-server-cache-jbc/branches/Session_Ownership/src/main/java/org/jboss/ha/framework/server/DistributedStateImpl.java	2010-07-06 18:15:37 UTC (rev 106459)
@@ -41,8 +41,10 @@
 import org.jboss.cache.notifications.annotation.NodeModified;
 import org.jboss.cache.notifications.event.NodeModifiedEvent;
 import org.jboss.cache.notifications.event.NodeModifiedEvent.ModificationType;
+import org.jboss.ha.core.framework.server.ChannelSource;
 import org.jboss.ha.framework.server.spi.ManagedDistributedState;
 import org.jboss.logging.Logger;
+import org.jgroups.Channel;
 
 /**
  *   This class manages distributed state across the cluster.
@@ -54,7 +56,7 @@
  */
 @CacheListener
 public class DistributedStateImpl 
-   implements ManagedDistributedState, DistributedStateImplMBean
+   implements ManagedDistributedState, DistributedStateImplMBean, ChannelSource
 {
    // Constants -----------------------------------------------------
 
@@ -104,7 +106,7 @@
          cacheHandler.startCache();
          @SuppressWarnings("unchecked")
          Cache<Serializable, Serializable> unchecked = c;
-         setClusteredCache(unchecked);
+         internalSetClusteredCache(unchecked);
       }
 
       this.cache.addCacheListener(this);
@@ -117,6 +119,8 @@
       if (acquiredCache)
       {
          cacheHandler.releaseCache();
+         cache = null;
+         acquiredCache = false;
       }
    }
 
@@ -202,25 +206,8 @@
     */
    public void setClusteredCache(Cache<Serializable, Serializable> cache)
    {
-      this.cache = cache;
-      if (this.cache != null)
-      {        
-      	CacheMode cm = cache.getConfiguration().getCacheMode();
-      	if (CacheMode.REPL_ASYNC == cm)
-      	{
-      	   this.replAsync = true;
-      	}
-      	else if (CacheMode.REPL_SYNC == cm)
-      	{
-      	   this.replAsync = false;
-      	}
-      	else
-      	{
-      	   throw new IllegalStateException("Cache must be configured for replication, not " + cm);
-      	}
-      	
-      	acquiredCache = false;
-      }
+      internalSetClusteredCache(cache);
+      acquiredCache = false;
    }
 
    public HAPartitionCacheHandlerImpl getCacheHandler()
@@ -418,6 +405,18 @@
       this.unregisterListener(category, subscriber);
    }
 
+   // ChannelSource -------------------------------------------------
+
+   public Channel getChannel()
+   {
+      Channel result = null;
+      if (cache != null)
+      {
+         result = cache.getConfiguration().getRuntimeConfig().getChannel();
+      }
+      return result;
+   }
+   
    // Package protected ---------------------------------------------
 
    // Protected -----------------------------------------------------
@@ -567,5 +566,28 @@
          DistributedStateImpl.this.notifyKeyListenersOfRemove((String) fqn.get(ROOTFQNSIZE), key, value, event.isOriginLocal());
       }
    }
+   
+   // Private ------------------------------------------------------------
+   
+   private void internalSetClusteredCache(Cache<Serializable, Serializable> cache)
+   {
+      this.cache = cache;
+      if (this.cache != null)
+      {        
+        CacheMode cm = cache.getConfiguration().getCacheMode();
+        if (CacheMode.REPL_ASYNC == cm)
+        {
+           this.replAsync = true;
+        }
+        else if (CacheMode.REPL_SYNC == cm)
+        {
+           this.replAsync = false;
+        }
+        else
+        {
+           throw new IllegalStateException("Cache must be configured for replication, not " + cm);
+        }
+      }
+   }
 
 }

Modified: projects/cluster/ha-server-cache-jbc/branches/Session_Ownership/src/main/java/org/jboss/ha/framework/server/HAPartitionCacheHandlerImpl.java
===================================================================
--- projects/cluster/ha-server-cache-jbc/branches/Session_Ownership/src/main/java/org/jboss/ha/framework/server/HAPartitionCacheHandlerImpl.java	2010-07-06 17:43:46 UTC (rev 106458)
+++ projects/cluster/ha-server-cache-jbc/branches/Session_Ownership/src/main/java/org/jboss/ha/framework/server/HAPartitionCacheHandlerImpl.java	2010-07-06 18:15:37 UTC (rev 106459)
@@ -27,7 +27,9 @@
 import org.jboss.cache.Cache;
 import org.jboss.cache.CacheManager;
 import org.jboss.cache.CacheStatus;
+import org.jboss.ha.core.framework.server.ChannelSource;
 import org.jboss.ha.framework.server.spi.HAPartitionCacheHandler;
+import org.jgroups.Channel;
 import org.jgroups.ChannelFactory;
 
 /**
@@ -35,7 +37,7 @@
  * 
  * @author Brian Stansberry
  */
-public class HAPartitionCacheHandlerImpl implements HAPartitionCacheHandler
+public class HAPartitionCacheHandlerImpl implements HAPartitionCacheHandler, ChannelSource
 {
    private CacheManager cacheManager;
    private String cacheConfigName;
@@ -103,6 +105,15 @@
       return cache.getConfiguration().getRuntimeConfig().getMuxChannelFactory();
    }
    
+   public synchronized Channel getChannel()
+   {
+      if (cache == null)
+      {
+         throw new IllegalStateException("Must acquire cache before getting cache channel");
+      }
+      return cache.getConfiguration().getRuntimeConfig().getChannel();
+   }
+   
    // Properties -------------------------------------------------------------
 
    public synchronized void setCacheConfigName(String cacheConfigName)
@@ -125,6 +136,16 @@
       return cache;
    }
    
+   // Public ------------------------------------------------------------------
+   
+   public synchronized void start() throws Exception
+   {
+   }
+   
+   public synchronized void stop() throws Exception
+   {
+   }
+   
    // Private -----------------------------------------------------------------
 
    private void validateState()



More information about the jboss-cvs-commits mailing list