[jboss-cvs] JBossAS SVN: r100437 - in projects/cluster/ha-server-cache-jbc/trunk/src: test/java/org/jboss/ha/cachemanager and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Feb 4 15:20:10 EST 2010
Author: bstansberry at jboss.com
Date: 2010-02-04 15:20:10 -0500 (Thu, 04 Feb 2010)
New Revision: 100437
Added:
projects/cluster/ha-server-cache-jbc/trunk/src/test/java/org/jboss/ha/cachemanager/CacheManagerUnitTestCase.java
projects/cluster/ha-server-cache-jbc/trunk/src/test/resources/jbc3-registry-configs.xml
Modified:
projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/ha/cachemanager/CacheManager.java
projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/ha/cachemanager/CacheManagerManagedCache.java
Log:
[JBCLUSTER-249] Don't destroy caches in stop()
Modified: projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/ha/cachemanager/CacheManager.java
===================================================================
--- projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/ha/cachemanager/CacheManager.java 2010-02-04 20:08:46 UTC (rev 100436)
+++ projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/ha/cachemanager/CacheManager.java 2010-02-04 20:20:10 UTC (rev 100437)
@@ -24,7 +24,6 @@
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.Map;
import java.util.Set;
@@ -41,9 +40,12 @@
import javax.naming.StringRefAddr;
import org.jboss.cache.Cache;
+import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheStatus;
+import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.ConfigurationRegistry;
+import org.jboss.cache.config.XmlParsingConfigurationRegistry;
import org.jboss.cache.notifications.annotation.CacheListener;
import org.jboss.cache.notifications.annotation.CacheStarted;
import org.jboss.cache.notifications.annotation.CacheStopped;
@@ -60,7 +62,7 @@
import org.jgroups.ChannelFactory;
/**
- * JBoss AS specific {@link CacheManager}. Extends the core JBoss Cache
+ * JBoss AS specific implementation of {@link CacheManager}. Extends the core JBoss Cache
* cache manager by also handling, PojoCache, by registering created caches
* in JMX, and by registering itself in JNDI.
*
@@ -68,8 +70,7 @@
* @version $Revision: 1.1 $
*/
public class CacheManager
- extends org.jboss.cache.CacheManagerImpl
- implements PojoCacheManager, MBeanRegistration, CacheManagerMBean
+ implements org.jboss.cache.CacheManager, PojoCacheManager, MBeanRegistration, CacheManagerMBean
{
private static final Logger log = Logger.getLogger(CacheManager.class);
@@ -79,8 +80,18 @@
private MBeanServer mbeanServer;
private String jmxDomain;
private String coreCacheJmxAttributes = DEFAULT_CORE_CACHE_JMX_ATTRIBUTES;
- private String pojoCacheJmxAttributes = DEFAULT_POJO_CACHE_JMX_ATTRIBUTES;
+ private String pojoCacheJmxAttributes = DEFAULT_POJO_CACHE_JMX_ATTRIBUTES;
+
+ private ConfigurationRegistry configRegistry;
+ private boolean configRegistryInjected;
+
+ private ChannelFactory channelFactory;
+
+ private final Map<String, Cache<Object, Object>> plainCaches = new HashMap<String, Cache<Object, Object>>();
+
+ private final Map<String, Integer> plainCacheCheckouts = new HashMap<String, Integer>();
+
private Map<String, PojoCache> pojoCaches = new HashMap<String, PojoCache>();
private Map<String, Integer> pojoCacheCheckouts = new HashMap<String, Integer>();
@@ -95,49 +106,40 @@
private boolean started;
/**
- * Create a new CacheManagerImpl.
+ * Create a new CacheManager.
*
*/
public CacheManager()
{
- super();
}
/**
- * Create a new CacheManagerImpl.
+ * Create a new CacheManager.
*
* @param configRegistry
* @param factory
*/
public CacheManager(ConfigurationRegistry configRegistry, ChannelFactory factory)
{
- super(configRegistry, factory);
+ this.configRegistry = configRegistry;
+ this.configRegistryInjected = true;
+ this.channelFactory = factory;
}
/**
- * Create a new CacheManagerImpl.
+ * Create a new CacheManager.
*
* @param configFileName
* @param factory
*/
public CacheManager(String configFileName, ChannelFactory factory)
{
- super(configFileName, factory);
+ configRegistry = new XmlParsingConfigurationRegistry(configFileName);
+ this.channelFactory = factory;
}
// -------------------------------------------------------- PojoCacheManager
- public Set<String> getConfigurationNames()
- {
- synchronized (pojoCaches)
- {
- Set<String> configNames = super.getConfigurationNames();
- configNames.addAll(getPojoCacheNames());
- configNames.addAll(configAliases.keySet());
- return configNames;
- }
- }
-
public Set<String> getPojoCacheNames()
{
synchronized (pojoCaches)
@@ -148,6 +150,11 @@
public PojoCache getPojoCache(String configName, boolean create) throws Exception
{
+ if (create)
+ {
+ checkStarted();
+ }
+
// Check if there's an alias involved
configName = resolveAlias(configName);
@@ -177,21 +184,11 @@
// Wrap the pojocache to control classloading and disable stop/destroy
return cache == null ? null : new PojoCacheManagerManagedPojoCache(cache);
}
-
- /**
- * Extension point for subclasses, where we actually use a
- * {@link PojoCacheFactory} to create a PojoCache.
- *
- * @param config the Configuration for the cache
- * @return the PojoCache
- */
- protected PojoCache createPojoCache(Configuration config)
- {
- return PojoCacheFactory.createCache(config, false);
- }
public void registerPojoCache(PojoCache cache, String configName)
{
+ checkStarted();
+
synchronized (pojoCaches)
{
if (pojoCaches.containsKey(configName) || getCacheNames().contains(configName))
@@ -219,11 +216,39 @@
}
}
- // ------------------------------------------------------------- Overrides
+ // ------------------------------------------------------------ CacheManager
+
+ public ChannelFactory getChannelFactory()
+ {
+ return channelFactory;
+ }
+
+ public Set<String> getConfigurationNames()
+ {
+ synchronized (pojoCaches)
+ {
+ Set<String> configNames = getPlainCacheConfigurationNames();
+ configNames.addAll(getPojoCacheNames());
+ configNames.addAll(configAliases.keySet());
+ return configNames;
+ }
+ }
+
+ public Set<String> getCacheNames()
+ {
+ synchronized (plainCaches)
+ {
+ return new HashSet<String>(plainCaches.keySet());
+ }
+ }
- @Override
public Cache<Object, Object> getCache(String configName, boolean create) throws Exception
{
+ if (create)
+ {
+ checkStarted();
+ }
+
// Check if there's an alias involved
configName = resolveAlias(configName);
@@ -241,24 +266,24 @@
}
}
- return wrapCache(super.getCache(configName, create));
+ return wrapCache(getPlainCache(configName, create));
}
}
- @Override
public void registerCache(Cache<Object, Object> cache, String configName)
{
+ checkStarted();
+
synchronized (pojoCaches)
{
if (pojoCaches.containsKey(configName))
throw new IllegalStateException(configName + " already registered");
- super.registerCache(cache, configName);
+ registerPlainCache(cache, configName);
if (registerCachesInJmx && mbeanServer != null)
{
String oName = getObjectName(getCoreCacheJmxAttributes(), configName);
- @SuppressWarnings("deprecation")
org.jboss.cache.jmx.CacheJmxWrapper<Object, Object> wrapper =
new org.jboss.cache.jmx.CacheJmxWrapper<Object, Object>(cache);
try
@@ -276,7 +301,6 @@
}
}
- @Override
public void releaseCache(String configName)
{
// Check if there's an alias involved
@@ -294,35 +318,35 @@
}
else
{
- super.releaseCache(configName);
-
- if (registerCachesInJmx && mbeanServer != null && !getCacheNames().contains(configName))
+ synchronized (plainCaches)
{
- String oNameStr = getObjectName(getCoreCacheJmxAttributes(), configName);
- try
+ if (!plainCaches.containsKey(configName))
+ throw new IllegalStateException(configName + " not registered");
+ if (decrementPlainCacheCheckout(configName) == 0)
{
- ObjectName oName = new ObjectName(oNameStr);
- if (mbeanServer.isRegistered(oName))
- {
- mbeanServer.unregisterMBean(oName);
- }
+ Cache<Object, Object> cache = plainCaches.remove(configName);
+ destroyPlainCache(cache, configName);
}
- catch (JMException e)
- {
- log.error("Problem unregistering CacheJmxWrapper " + oNameStr, e);
- }
-
- }
+ };
}
}
}
- @Override
+ // ----------------------------------------------------------------- Public
+
public void start() throws Exception
{
if (!started)
{
- super.start();
+ if (configRegistry == null)
+ throw new IllegalStateException("Must configure a ConfigurationRegistry before calling start()");
+ if (channelFactory == null)
+ throw new IllegalStateException("Must provide a ChannelFactory before calling start()");
+
+ if (!configRegistryInjected)
+ {
+ ((XmlParsingConfigurationRegistry) configRegistry).start();
+ }
startEagerStartCaches();
@@ -346,27 +370,41 @@
}
}
- @Override
public void stop()
{
if (started)
{
releaseEagerStartCaches();
- synchronized (pojoCaches)
+// synchronized (pojoCaches)
+// {
+// for (Iterator<Map.Entry<String, PojoCache>> it = pojoCaches.entrySet().iterator(); it.hasNext();)
+// {
+// Map.Entry<String, PojoCache> entry = it.next();
+// destroyPojoCache(entry.getKey(), entry.getValue());
+// it.remove();
+// }
+// pojoCaches.clear();
+// pojoCacheCheckouts.clear();
+// }
+
+// synchronized (plainCaches)
+// {
+// for (Iterator<Map.Entry<String, Cache<Object, Object>>> it = plainCaches.entrySet().iterator(); it.hasNext();)
+// {
+// Map.Entry<String, Cache<Object, Object>> entry = it.next();
+// destroyPlainCache(entry.getValue(), entry.getKey());
+// it.remove();
+// }
+// plainCaches.clear();
+// plainCacheCheckouts.clear();
+// }
+
+ if (!configRegistryInjected)
{
- for (Iterator<Map.Entry<String, PojoCache>> it = pojoCaches.entrySet().iterator(); it.hasNext();)
- {
- Map.Entry<String, PojoCache> entry = it.next();
- destroyPojoCache(entry.getKey(), entry.getValue());
- it.remove();
- }
- pojoCaches.clear();
- pojoCacheCheckouts.clear();
+ ((XmlParsingConfigurationRegistry) configRegistry).stop();
}
- super.stop();
-
if (jndiName != null)
{
InitialContext ctx = null;
@@ -416,10 +454,24 @@
}
}
-
-
// ------------------------------------------------------------- Properties
+ public ConfigurationRegistry getConfigurationRegistry()
+ {
+ return configRegistry;
+ }
+
+ public void setConfigurationRegistry(ConfigurationRegistry configRegistry)
+ {
+ this.configRegistry = configRegistry;
+ this.configRegistryInjected = true;
+ }
+
+ public void setChannelFactory(ChannelFactory channelFactory)
+ {
+ this.channelFactory = channelFactory;
+ }
+
public String getJmxDomain()
{
return jmxDomain;
@@ -532,8 +584,7 @@
public void preDeregister() throws Exception
{
- // TODO Auto-generated method stub
-
+ // no-op
}
public void postRegister(Boolean registrationDone)
@@ -541,8 +592,149 @@
// no-op
}
+ // -------------------------------------------------------------- Protected
+
+
+ /**
+ * Extension point for subclasses, where we actually use a
+ * {@link PojoCacheFactory} to create a PojoCache.
+ *
+ * @param config the Configuration for the cache
+ * @return the PojoCache
+ */
+ protected PojoCache createPojoCache(Configuration config)
+ {
+ return PojoCacheFactory.createCache(config, false);
+ }
+
+ /**
+ * Extension point for subclasses, where we actually use a
+ * {@link CacheFactory} to create a cache. This default implementation
+ * uses {@link DefaultCacheFactory}.
+ *
+ * @param config the Configuration for the cache
+ * @return the Cache
+ */
+ protected Cache<Object, Object> createCache(Configuration config)
+ {
+ return new DefaultCacheFactory<Object, Object>().createCache(config, false);
+ }
+
+
// ---------------------------------------------------------------- Private
+ private void checkStarted()
+ {
+ if (!started)
+ {
+ throw new IllegalStateException(getClass().getSimpleName() + " is not started.");
+ }
+ }
+
+ private int incrementCheckout(String configName)
+ {
+ synchronized (plainCacheCheckouts)
+ {
+ Integer count = plainCacheCheckouts.get(configName);
+ if (count == null)
+ count = Integer.valueOf(0);
+ Integer newVal = Integer.valueOf(count.intValue() + 1);
+ plainCacheCheckouts.put(configName, newVal);
+ return newVal;
+ }
+ }
+
+ private int decrementPlainCacheCheckout(String configName)
+ {
+ synchronized (plainCacheCheckouts)
+ {
+ Integer count = plainCacheCheckouts.get(configName);
+ if (count == null || count.intValue() < 1)
+ throw new IllegalStateException("invalid count of " + count + " for " + configName);
+
+ Integer newVal = Integer.valueOf(count.intValue() - 1);
+ plainCacheCheckouts.put(configName, newVal);
+ return newVal;
+ }
+ }
+
+ private void destroyPlainCache(Cache<Object, Object> cache, String configName)
+ {
+ if (cache.getCacheStatus() == CacheStatus.STARTED)
+ {
+ cache.stop();
+ }
+ if (cache.getCacheStatus() != CacheStatus.DESTROYED && cache.getCacheStatus() != CacheStatus.INSTANTIATED)
+ {
+ cache.destroy();
+ }
+
+ if (registerCachesInJmx && mbeanServer != null && !getCacheNames().contains(configName))
+ {
+ String oNameStr = getObjectName(getCoreCacheJmxAttributes(), configName);
+ try
+ {
+ ObjectName oName = new ObjectName(oNameStr);
+ if (mbeanServer.isRegistered(oName))
+ {
+ mbeanServer.unregisterMBean(oName);
+ }
+ }
+ catch (JMException e)
+ {
+ log.error("Problem unregistering CacheJmxWrapper " + oNameStr, e);
+ }
+
+ }
+ }
+
+ private void registerPlainCache(Cache<Object, Object> cache, String configName)
+ {
+ synchronized (plainCaches)
+ {
+ if (plainCaches.containsKey(configName))
+ throw new IllegalStateException(configName + " already registered");
+ plainCaches.put(configName, cache);
+ incrementCheckout(configName);
+ }
+ }
+
+ private Cache<Object, Object> getPlainCache(String configName, boolean create) throws Exception
+ {
+ Cache<Object, Object> cache;
+ synchronized (plainCaches)
+ {
+ cache = plainCaches.get(configName);
+ if (cache == null && create)
+ {
+ Configuration config = configRegistry.getConfiguration(configName);
+ if (channelFactory != null && config.getMultiplexerStack() != null)
+ {
+ config.getRuntimeConfig().setMuxChannelFactory(channelFactory);
+ }
+ cache = createCache(config);
+ registerCache(cache, configName);
+ }
+ else if (cache != null)
+ {
+ incrementCheckout(configName);
+ }
+ }
+
+ return cache;
+ }
+
+ private Set<String> getPlainCacheConfigurationNames()
+ {
+ synchronized (plainCaches)
+ {
+ Set<String> configNames = configRegistry == null ? new HashSet<String>()
+ : configRegistry.getConfigurationNames();
+ configNames.addAll(getCacheNames());
+ return configNames;
+ }
+ }
+
/**
* Wrap the pojocache to control classloading and disable stop/destroy
*/
@@ -614,7 +806,6 @@
return base + ":" + attributesBase + configName;
}
- @SuppressWarnings("deprecation")
@CacheListener
public static class StartStopListener
{
Modified: projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/ha/cachemanager/CacheManagerManagedCache.java
===================================================================
--- projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/ha/cachemanager/CacheManagerManagedCache.java 2010-02-04 20:08:46 UTC (rev 100436)
+++ projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/ha/cachemanager/CacheManagerManagedCache.java 2010-02-04 20:20:10 UTC (rev 100437)
@@ -66,6 +66,12 @@
ContextClassLoaderSwitcher unchecked = (ContextClassLoaderSwitcher) AccessController.doPrivileged(ContextClassLoaderSwitcher.INSTANTIATOR);
this.switcher = unchecked;
}
+
+ /** For unit testing */
+ Cache<K, V> getDelegate()
+ {
+ return delegate;
+ }
/**
* Switches the TCCL to the delegate's classloader before calling create()
Added: projects/cluster/ha-server-cache-jbc/trunk/src/test/java/org/jboss/ha/cachemanager/CacheManagerUnitTestCase.java
===================================================================
--- projects/cluster/ha-server-cache-jbc/trunk/src/test/java/org/jboss/ha/cachemanager/CacheManagerUnitTestCase.java (rev 0)
+++ projects/cluster/ha-server-cache-jbc/trunk/src/test/java/org/jboss/ha/cachemanager/CacheManagerUnitTestCase.java 2010-02-04 20:20:10 UTC (rev 100437)
@@ -0,0 +1,173 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.ha.cachemanager;
+
+
+import org.jboss.cache.Cache;
+import org.jboss.cache.CacheStatus;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.ConfigurationRegistry;
+import org.jgroups.JChannelFactory;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests CacheManager.
+ *
+ * @author Brian Stansberry
+ */
+public class CacheManagerUnitTestCase extends TestCase
+{
+ /**
+ * A file that includes every configuration element I could think of
+ */
+ public static final String DEFAULT_CONFIGURATION_FILE = "jbc3-registry-configs.xml";
+
+ private Set<Cache<Object, Object>> caches = new HashSet<Cache<Object, Object>>();
+
+ public void tearDown() throws Exception
+ {
+ for (Cache<Object, Object> cache : caches)
+ {
+ try
+ {
+ cache.destroy();
+ }
+ catch (Exception ignored)
+ {
+ }
+ }
+ caches.clear();
+ }
+
+ /**
+ * A test that instantiates a CacheManager and cycles through all its
+ * configs, creating and releasing each.
+ * <p/>
+ * TODO: Break this up into more fine-grained tests
+ *
+ * @throws Exception
+ */
+ public void testBasic() throws Exception
+ {
+ JChannelFactory cf = new JChannelFactory();
+ cf.setMultiplexerConfig("stacks.xml"); // the default stacks in jgroups.jar
+ CacheManager registry = new CacheManager(DEFAULT_CONFIGURATION_FILE, cf);
+ registry.start();
+
+ ConfigurationRegistry configRegistry = registry.getConfigurationRegistry();
+
+ Set<String> configNames = registry.getConfigurationNames();
+ assertEquals(7, configNames.size());
+ Set<String> cacheNames = registry.getCacheNames();
+ assertEquals(0, cacheNames.size());
+
+ for (String configName : configNames)
+ {
+ assertNull(configName + " not created", registry.getCache(configName, false));
+ Cache<Object, Object> cache = registry.getCache(configName, true);
+ caches.add(cache);
+
+ // Cache shouldn't be started
+ assertEquals(CacheStatus.INSTANTIATED, cache.getCacheStatus());
+ cache.create();
+ cache.start();
+
+ // Config should be a clone
+ Configuration rawConfig = configRegistry.getConfiguration(configName);
+ Configuration realConfig = cache.getConfiguration();
+ assertFalse(rawConfig == realConfig);
+ assertEquals(rawConfig.getClusterName(), realConfig.getClusterName());
+ }
+
+ cacheNames = registry.getCacheNames();
+ assertEquals(configNames, cacheNames);
+
+ // Test basic releasing of caches
+ for (String configName : configNames)
+ {
+ registry.releaseCache(configName);
+ }
+
+ cacheNames = registry.getCacheNames();
+ assertEquals(0, cacheNames.size());
+
+ // We shouldn't have affected configuration set
+ Set<String> configNames2 = registry.getConfigurationNames();
+ assertEquals(configNames, configNames2);
+
+ // Releasing only checkout of cache should have destroyed it
+ for (Iterator<Cache<Object, Object>> it = caches.iterator(); it.hasNext();)
+ {
+ assertEquals(CacheStatus.DESTROYED, it.next().getCacheStatus());
+ it.remove();
+ }
+
+ // Get cache w/o asking to create returns null
+ String configName = configNames.iterator().next();
+ assertNull(configName + " not created", registry.getCache(configName, false));
+ // Get cache w/ asking to create returns cache
+ Cache<Object, Object> cache = registry.getCache(configName, true);
+ assertFalse(null == cache);
+ caches.add(cache);
+
+ cache.create();
+ cache.start();
+
+ // Test 2 checkouts of the same cache
+ Cache<Object, Object> cache2 = registry.getCache(configName, true);
+ assertTrue(areCachesEquivalent(cache, cache2));
+
+ registry.releaseCache(configName);
+
+ // One release does not cause registry to stop cache
+ assertEquals(CacheStatus.STARTED, cache.getCacheStatus());
+
+ registry.stop();
+
+ // Should still not be stopped
+ assertEquals(CacheStatus.STARTED, cache.getCacheStatus());
+
+ registry.releaseCache(configName);
+
+ // Now it should be stopped
+ assertEquals(CacheStatus.DESTROYED, cache.getCacheStatus());
+ caches.remove(cache);
+
+ cacheNames = registry.getCacheNames();
+ assertEquals(0, cacheNames.size());
+ assertEquals(cacheNames, registry.getConfigurationNames());
+ }
+
+ public void testNullConfigResource() throws Exception
+ {
+ JChannelFactory cf = new JChannelFactory();
+ cf.setMultiplexerConfig("stacks.xml"); // the default stacks in jgroups.jar
+ String configResource = null;
+ CacheManager registry = new CacheManager(configResource, cf);
+ registry.start();
+
+ assertEquals("No configs", 0, registry.getConfigurationNames().size());
+ }
+
+ @SuppressWarnings("unchecked")
+ private boolean areCachesEquivalent(Cache<Object, Object> a, Cache<Object, Object> b)
+ {
+ boolean equiv = a == b;
+ if (!equiv && a instanceof CacheManagerManagedCache && b instanceof CacheManagerManagedCache)
+ {
+ CacheManagerManagedCache cast_a = (CacheManagerManagedCache) a;
+ CacheManagerManagedCache cast_b = (CacheManagerManagedCache) b;
+ equiv = (cast_a.getDelegate() == cast_b.getDelegate());
+ }
+ return equiv;
+ }
+}
Property changes on: projects/cluster/ha-server-cache-jbc/trunk/src/test/java/org/jboss/ha/cachemanager/CacheManagerUnitTestCase.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Id Revision
Added: projects/cluster/ha-server-cache-jbc/trunk/src/test/resources/jbc3-registry-configs.xml
===================================================================
--- projects/cluster/ha-server-cache-jbc/trunk/src/test/resources/jbc3-registry-configs.xml (rev 0)
+++ projects/cluster/ha-server-cache-jbc/trunk/src/test/resources/jbc3-registry-configs.xml 2010-02-04 20:20:10 UTC (rev 100437)
@@ -0,0 +1,187 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<registry:cache-configs xmlns="urn:jboss:jbosscache-core:config:3.2" xmlns:registry="urn:jboss:jbosscache-core:cache-repo:3.2">
+
+ <!--
+ Various JBoss Cache configurations, suitable for different caching
+ uses (e.g. entities vs. queries).
+
+ In all cases, TransactionManager configuration not required.
+ Hibernate will plug in its own transaction manager integration.
+ -->
+
+
+ <!-- A config appropriate for entity/collection caching. -->
+ <registry:cache-config name="optimistic-entity">
+ <locking lockAcquisitionTimeout="15000" nodeLockingScheme="optimistic"/>
+ <transaction syncCommitPhase="true" syncRollbackPhase="true"
+ transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
+ <serialization useRegionBasedMarshalling="true"/>
+ <startup regionsInactiveOnStartup="true"/>
+ <clustering mode="i" clusterName="optimistic-entity">
+ <stateRetrieval fetchInMemoryState="false" timeout="20000"/>
+ <jgroupsConfig multiplexerStack="udp-sync"/>
+ <sync replTimeout="20000"/>
+ </clustering>
+
+ <eviction wakeUpInterval="5000">
+ <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm">
+ <property name="maxNodes" value="5000" />
+ <property name="timeToLive" value="1000" />
+ </default>
+ <region name="/TS">
+ <property name="maxNodes" value="0" />
+ <property name="timeToLive" value="0" />
+ </region>
+ </eviction>
+ </registry:cache-config>
+
+ <!-- A config appropriate for entity/collection caching that
+ uses pessimistic locking -->
+ <registry:cache-config name="pessimistic-entity">
+ <locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000" nodeLockingScheme="pessimistic"/>
+ <serialization useRegionBasedMarshalling="true"/>
+ <startup regionsInactiveOnStartup="true"/>
+ <clustering clusterName="pessimistic-entity" mode="i">
+ <stateRetrieval fetchInMemoryState="false" timeout="20000"/>
+ <jgroupsConfig multiplexerStack="udp-sync"/>
+ <sync replTimeout="20000"/>
+ </clustering>
+
+ <eviction wakeUpInterval="5000">
+ <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm">
+ <property name="maxNodes" value="5000" />
+ <property name="timeToLive" value="1000" />
+ </default>
+ <region name="/TS">
+ <property name="maxNodes" value="0" />
+ <property name="timeToLive" value="0" />
+ </region>
+ </eviction>
+ </registry:cache-config>
+
+ <!-- A config appropriate for query caching. Does not replicate
+ queries. DO NOT STORE TIMESTAMPS IN THIS CACHE.
+ -->
+ <registry:cache-config name="local-query">
+ <locking lockAcquisitionTimeout="15000" nodeLockingScheme="optimistic"/>
+ <transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
+ <eviction wakeUpInterval="5000">
+ <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm">
+ <property name="maxNodes" value="5000" />
+ <property name="timeToLive" value="1000" />
+ </default>
+ <region name="/TS">
+ <property name="maxNodes" value="0" />
+ <property name="timeToLive" value="0" />
+ </region>
+ </eviction>
+ </registry:cache-config>
+
+ <!-- A query cache that replicates queries. Replication is asynchronous.
+ DO NOT STORE TIMESTAMPS IN THIS CACHE.
+ -->
+ <registry:cache-config name="replicated-query">
+ <locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000" nodeLockingScheme="optimistic"/>
+ <transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
+ <serialization useRegionBasedMarshalling="false"/>
+ <startup regionsInactiveOnStartup="false"/>
+ <clustering clusterName="replicated-query" mode="r">
+ <stateRetrieval fetchInMemoryState="false" timeout="20000"/>
+ <jgroupsConfig multiplexerStack="udp"/>
+ <async />
+ </clustering>
+ <eviction wakeUpInterval="5000">
+ <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm">
+ <property name="maxNodes" value="5000" />
+ <property name="timeToLive" value="1000" />
+ </default>
+ <region name="/TS" >
+ <property name="maxNodes" value="0" />
+ <property name="timeToLive" value="0" />
+ </region>
+ </eviction>
+ </registry:cache-config>
+
+ <!-- Optimized for timestamp caching. A clustered timestamp cache
+ is required if query caching is used, even if the query cache
+ itself is configured with CacheMode=LOCAL.
+ -->
+ <registry:cache-config name="timestamps-cache">
+ <locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000" nodeLockingScheme="pessimistic"/>
+ <serialization useRegionBasedMarshalling="true"/>
+ <startup regionsInactiveOnStartup="true"/>
+ <clustering clusterName="timestamps-cache" mode="r">
+ <stateRetrieval fetchInMemoryState="true" timeout="20000"/>
+ <jgroupsConfig multiplexerStack="udp"/>
+ <async />
+ </clustering>
+ <eviction wakeUpInterval="5000">
+ <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm">
+ <property name="maxNodes" value="5000" />
+ <property name="timeToLive" value="1000" />
+ </default>
+ <region name="/TS">
+ <property name="maxNodes" value="0" />
+ <property name="timeToLive" value="0" />
+ </region>
+ </eviction>
+ </registry:cache-config>
+
+ <!-- A config appropriate for a cache that's shared for
+ entity, collection, query and timestamp caching. Not an advised
+ configuration, since it requires cache mode REPL_SYNC, which is the
+ least efficient mode. Also requires a full state transfer at startup,
+ which can be expensive. Uses optimistic locking. -->
+ <registry:cache-config name="optimistic-shared">
+ <locking lockAcquisitionTimeout="15000" nodeLockingScheme="optimistic"/>
+ <transaction syncCommitPhase="true" syncRollbackPhase="true"
+ transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
+ <serialization useRegionBasedMarshalling="true"/>
+ <startup regionsInactiveOnStartup="true"/>
+ <clustering clusterName="optimistic-shared" mode="r">
+ <stateRetrieval fetchInMemoryState="true" timeout="20000"/>
+ <jgroupsConfig multiplexerStack="udp"/>
+ <sync replTimeout="20000"/>
+ </clustering>
+ <eviction wakeUpInterval="5000">
+ <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm">
+ <property name="maxNodes" value="5000" />
+ <property name="timeToLive" value="1000" />
+ </default>
+ <region name="/TS">
+ <property name="maxNodes" value="0" />
+ <property name="timeToLive" value="0" />
+ </region>
+ </eviction>
+ </registry:cache-config>
+
+
+
+ <!-- A config appropriate for a cache that's shared for
+ entity, collection, query and timestamp caching. Not an advised
+ configuration, since it requires cache mode REPL_SYNC, which is the
+ least efficient mode. Also requires a full state transfer at startup,
+ which can be expensive. Uses pessmistic locking.
+ -->
+ <registry:cache-config name="pessimistic-shared">
+
+ <locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000" nodeLockingScheme="pessimistic"/>
+ <serialization useRegionBasedMarshalling="true"/>
+ <startup regionsInactiveOnStartup="true"/>
+ <clustering clusterName="pessimistic-shared" mode="r">
+ <stateRetrieval fetchInMemoryState="true" timeout="20000"/>
+ <jgroupsConfig multiplexerStack="udp"/>
+ <sync replTimeout="20000"/>
+ </clustering>
+ <eviction wakeUpInterval="5000">
+ <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm">
+ <property name="maxNodes" value="5000" />
+ <property name="timeToLive" value="1000" />
+ </default>
+ <region name="/TS">
+ <property name="maxNodes" value="0" />
+ <property name="timeToLive" value="0" />
+ </region>
+ </eviction>
+ </registry:cache-config>
+</registry:cache-configs>
Property changes on: projects/cluster/ha-server-cache-jbc/trunk/src/test/resources/jbc3-registry-configs.xml
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Id Revision
More information about the jboss-cvs-commits
mailing list