[jboss-cvs] JBossAS SVN: r105671 - in projects/cluster/ha-server-cache-jbc/trunk: src/main/java/org/jboss/ha/framework/server and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jun 3 12:46:38 EDT 2010
Author: bstansberry at jboss.com
Date: 2010-06-03 12:46:37 -0400 (Thu, 03 Jun 2010)
New Revision: 105671
Modified:
projects/cluster/ha-server-cache-jbc/trunk/pom.xml
projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/ha/framework/server/DistributedStateImpl.java
projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/ha/framework/server/HAPartitionCacheHandlerImpl.java
Log:
[JBCLUSTER-281] Improve the channel management
Modified: projects/cluster/ha-server-cache-jbc/trunk/pom.xml
===================================================================
--- projects/cluster/ha-server-cache-jbc/trunk/pom.xml 2010-06-03 16:38:23 UTC (rev 105670)
+++ projects/cluster/ha-server-cache-jbc/trunk/pom.xml 2010-06-03 16:46:37 UTC (rev 105671)
@@ -32,7 +32,7 @@
<properties>
<version.jboss.ha.server.cache.spi>2.2.0.Final</version.jboss.ha.server.cache.spi>
<version.jboss.ha.server.api>2.0.0.Alpha4</version.jboss.ha.server.api>
- <version.jboss.ha.server.core>1.0.0.Alpha1</version.jboss.ha.server.core>
+ <version.jboss.ha.server.core>1.0.0.Alpha2</version.jboss.ha.server.core>
<version.jboss.common.core>2.2.17.GA</version.jboss.common.core>
<version.jboss.logging>3.0.0.Beta2</version.jboss.logging>
<version.jboss.cache>3.2.5.GA</version.jboss.cache>
Modified: projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/ha/framework/server/DistributedStateImpl.java
===================================================================
--- projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/ha/framework/server/DistributedStateImpl.java 2010-06-03 16:38:23 UTC (rev 105670)
+++ projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/ha/framework/server/DistributedStateImpl.java 2010-06-03 16:46:37 UTC (rev 105671)
@@ -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/trunk/src/main/java/org/jboss/ha/framework/server/HAPartitionCacheHandlerImpl.java
===================================================================
--- projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/ha/framework/server/HAPartitionCacheHandlerImpl.java 2010-06-03 16:38:23 UTC (rev 105670)
+++ projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/ha/framework/server/HAPartitionCacheHandlerImpl.java 2010-06-03 16:46:37 UTC (rev 105671)
@@ -27,6 +27,7 @@
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;
@@ -36,13 +37,12 @@
*
* @author Brian Stansberry
*/
-public class HAPartitionCacheHandlerImpl implements HAPartitionCacheHandler
+public class HAPartitionCacheHandlerImpl implements HAPartitionCacheHandler, ChannelSource
{
private CacheManager cacheManager;
private String cacheConfigName;
private Cache<Object, Object> cache;
private AtomicInteger acquireCount = new AtomicInteger();
- private boolean startCacheInStart = false;
// CacheHandler ------------------------------------------------------------
@@ -105,16 +105,12 @@
return cache.getConfiguration().getRuntimeConfig().getMuxChannelFactory();
}
- public synchronized Channel getCacheChannel()
+ public synchronized Channel getChannel()
{
if (cache == null)
{
throw new IllegalStateException("Must acquire cache before getting cache channel");
}
- if (cache.getCacheStatus() != CacheStatus.STARTED)
- {
- throw new IllegalStateException("Must start cache before getting cache channel");
- }
return cache.getConfiguration().getRuntimeConfig().getChannel();
}
@@ -139,37 +135,15 @@
{
return cache;
}
-
- public boolean isStartCacheInStart()
- {
- return startCacheInStart;
- }
-
- public void setStartCacheInStart(boolean startCacheInStart)
- {
- this.startCacheInStart = startCacheInStart;
- }
// Public ------------------------------------------------------------------
public synchronized void start() throws Exception
{
- if (startCacheInStart)
- {
- if (cache == null)
- {
- acquireCache();
- }
- startCache();
- }
}
public synchronized void stop() throws Exception
{
- if (startCacheInStart)
- {
- releaseCache();
- }
}
// Private -----------------------------------------------------------------
More information about the jboss-cvs-commits
mailing list