[jboss-cvs] JBossAS SVN: r71994 - in trunk/cluster/src: main/org/jboss/ha/cachemanager and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Apr 10 23:40:01 EDT 2008
Author: bstansberry at jboss.com
Date: 2008-04-10 23:40:00 -0400 (Thu, 10 Apr 2008)
New Revision: 71994
Added:
trunk/cluster/src/etc/jboss-cache-manager-beans.xml
trunk/cluster/src/main/org/jboss/ha/cachemanager/DependencyInjectedConfigurationRegistry.java
Log:
[JBAS-5377] Deploy a CacheManager
Added: trunk/cluster/src/etc/jboss-cache-manager-beans.xml
===================================================================
--- trunk/cluster/src/etc/jboss-cache-manager-beans.xml (rev 0)
+++ trunk/cluster/src/etc/jboss-cache-manager-beans.xml 2008-04-11 03:40:00 UTC (rev 71994)
@@ -0,0 +1,234 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <!-- Factory/registry for JBoss Cache and PojoCache instances used in the AS -->
+ <bean name="CacheManager" class="org.jboss.ha.cachemanager.CacheManager">
+
+ <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.cache:service=CacheManager", exposedInterface=org.jboss.ha.cachemanager.CacheManagerMBean.class, registerDirectly=true)</annotation>
+
+ <!-- This doesn't seem to work, so the service binds itself for now
+ <annotation>@org.jboss.aop.microcontainer.aspects.jndi.JndiBinding(name="java:CacheManager")</annotation>
+ -->
+ <property name="jndiName">java:CacheManager</property>
+
+ <property name="configurationRegistry"><inject bean="CacheConfigurationRegistry"/></property>
+ <property name="channelFactory"><inject bean="JChannelFactory"/></property>
+ </bean>
+
+ <!-- Provides batching functionality for caches that don't want to interact with regular JTA Transactions -->
+ <bean name="StandardJBossCacheBatchManager" class="org.jboss.cache.transaction.BatchModeTransactionManager"/>
+
+ <!--
+ | Registry of named JBoss Cache configurations. Users of the CacheManager
+ | request a cache with a particular configuration by providing the name
+ | of one of these configurations.
+ -->
+ <bean name="CacheConfigurationRegistry" class="org.jboss.ha.cachemanager.DependencyInjectedConfigurationRegistry">
+
+ <!-- The configurations. A Map<String name, Configuration config> -->
+ <property name="newConfigurations">
+ <map keyClass="java.lang.String" valueClass="org.jboss.cache.config.Configuration">
+
+ <!-- The standard configurations follow. You can add your own and/or edit these. -->
+
+ <!-- Standard cache used for web sessions and EBJ3 SFSBs -->
+ <entry><key>standard-session-cache</key>
+ <value>
+ <bean name="StandardSessionCacheConfig" class="org.jboss.cache.config.Configuration">
+
+ <property name="runtimeConfig">
+ <bean class="org.jboss.cache.config.RuntimeConfig">
+ <property name="transactionManager"><jnject bean="StandardJBossCacheBatchManager"/></property>
+ </bean>
+ </property>
+
+ <property name="multiplexerStack">${jboss.default.jgroups.stack:udp}</property>
+
+ <property name="clusterName">${jboss.partition.name:DefaultPartition}-SessionCache</property>
+
+ <property name="nodeLockingScheme">PESSIMISTIC</property>
+ <property name="isolationLevel">REPEATABLE_READ</property>
+ <property name="cacheMode">REPL_ASYNC</property>
+
+ <property name="syncReplTimeout">17500</property>
+ <property name="lockAcquisitionTimeout">15000</property>
+ <property name="stateRetrievalTimeout">60000</property>
+
+ <property name="useRegionBasedMarshalling">false</property>
+ <property name="inactiveOnStartup">false</property>
+
+ <property name="exposeManagementStatistics">true</property>
+
+ <property name="buddyReplicationConfig">
+ <bean class="org.jboss.cache.config.BuddyReplicationConfig">
+
+ <property name="enabled">false</property>
+ <property name="buddyPoolName">default</property>
+ <property name="buddyCommunicationTimeout">17500</property>
+
+ <property name="autoDataGravitation">false</property>
+ <property name="dataGravitationRemoveOnFind">true</property>
+ <property name="dataGravitationSearchBackupTrees">true</property>
+
+ <property name="buddyLocatorConfig">
+ <bean class="org.jboss.cache.buddyreplication.NextMemberBuddyLocatorConfig">
+ <property name="numBuddies">1</property>
+ <property name="ignoreColocatedBuddies">true</property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ <property name="cacheLoaderConfig">
+ <bean class="org.jboss.cache.config.CacheLoaderConfig">
+ <property name="passivation">true</property>
+ <property name="preload">/</property>
+ <property name="shared">false</property>
+ <property name="individualCacheLoaderConfigs">
+ <list>
+ <bean class="org.jboss.cache.loader.FileCacheLoaderConfig">
+ <property name="location">${jboss.server.data.dir}${/}sessions</property>
+ <property name="async">false</property>
+ <property name="fetchPersistentState">true</property>
+ <property name="ignoreModifications">false</property>
+ <property name="checkCharacterPortability">false</property>
+ </bean>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </value>
+ </entry>
+
+ <!-- Appropriate for web sessions with FIELD granularity -->
+ <entry><key>field-granularity-session-cache</key>
+ <value>
+
+ <bean name="FieldSessionCacheConfig" class="org.jboss.cache.config.Configuration">
+
+ <property name="runtimeConfig">
+ <bean class="org.jboss.cache.config.RuntimeConfig">
+ <property name="transactionManager"><inject bean="StandardJBossCacheBatchManager"/></property>
+ </bean>
+ </property>
+
+ <property name="multiplexerStack">${jboss.default.jgroups.stack:udp}</property>
+
+ <property name="clusterName">${jboss.partition.name:DefaultPartition}-FieldSessionCache</property>
+
+ <property name="nodeLockingScheme">PESSIMISTIC</property>
+ <property name="isolationLevel">REPEATABLE_READ</property>
+ <property name="cacheMode">REPL_ASYNC</property>
+
+ <property name="syncReplTimeout">17500</property>
+ <property name="lockAcquisitionTimeout">15000</property>
+ <property name="stateRetrievalTimeout">60000</property>
+
+ <!-- Field granularity requires region-based marshalling -->
+ <property name="useRegionBasedMarshalling">true</property>
+ <property name="inactiveOnStartup">true</property>
+
+ <property name="exposeManagementStatistics">true</property>
+
+ <property name="buddyReplicationConfig">
+ <bean class="org.jboss.cache.config.BuddyReplicationConfig">
+
+ <property name="enabled">false</property>
+ <property name="buddyPoolName">default</property>
+ <property name="buddyCommunicationTimeout">17500</property>
+
+ <property name="autoDataGravitation">false</property>
+ <property name="dataGravitationRemoveOnFind">true</property>
+ <property name="dataGravitationSearchBackupTrees">true</property>
+
+ <property name="buddyLocatorConfig">
+ <bean class="org.jboss.cache.buddyreplication.NextMemberBuddyLocatorConfig">
+ <property name="numBuddies">1</property>
+ <property name="ignoreColocatedBuddies">true</property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ <property name="cacheLoaderConfig">
+ <bean class="org.jboss.cache.config.CacheLoaderConfig">
+ <property name="passivation">true</property>
+ <property name="preload">/</property>
+ <property name="shared">false</property>
+ <property name="individualCacheLoaderConfigs">
+ <list>
+ <bean class="org.jboss.cache.loader.FileCacheLoaderConfig">
+ <property name="location">${jboss.server.data.dir}${/}field-session</property>
+ <property name="async">false</property>
+ <property name="fetchPersistentState">true</property>
+ <property name="ignoreModifications">false</property>
+ <property name="checkCharacterPortability">false</property>
+ </bean>
+ </list>
+ </property>
+ </bean>
+ </property>
+
+ <!-- FIELD granularity webapps use JBoss Cache eviction -->
+ <property name="evictionConfig">
+ <bean class="org.jboss.cache.config.EvictionConfig">
+ <property name="defaultEvictionPolicyClass">org.jboss.cache.eviction.LRUPolicy</property>
+ <property name="wakeupIntervalSeconds">5</property>
+ <property name="evictionRegionConfigs">
+ <list>
+ <!-- Default region will never timeout. Do not change this -->
+ <bean class="org.jboss.cache.config.EvictionRegionConfig">
+ <property name="regionName">/_default_</property>
+ <property name="evictionPolicyConfig">
+ <bean class="org.jboss.cache.eviction.NullEvictionPolicyConfig"/>
+ </property>
+ </bean>
+ <!-- JBossWeb integration code may programatically create other
+ regions as webapps are deployed -->
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </value>
+ </entry>
+
+ <!-- Cache for clustered single sign on entries
+ FIXME Uncomment when the jbossweb-clustered-sso-beans.xml file is gone
+ <entry><key>clustered-sso</key>
+ <value>
+
+ <bean name="ClusteredSSOCache" class="org.jboss.cache.config.Configuration">
+
+ <property name="runtimeConfig">
+ <bean class="org.jboss.cache.config.RuntimeConfig">
+ <property name="transactionManager"><inject bean="StandardJBossCacheBatchManager"/></property>
+ </bean>
+ </property>
+
+ <property name="multiplexerStack">${jboss.default.jgroups.stack:udp}</property>
+
+ <property name="clusterName">${jboss.partition.name:DefaultPartition}-ClusteredSSOCache</property>
+
+ <property name="nodeLockingSchemeString" class="java.lang.String">PESSIMISTIC</property>
+ <property name="isolationLevelString" class="java.lang.String">REPEATABLE_READ</property>
+ <property name="cacheModeString">REPL_ASYNC</property>
+
+ <property name="syncReplTimeout">20000</property>
+ <property name="lockAcquisitionTimeout">15000</property>
+ <property name="stateRetrievalTimeout">60000</property>
+
+ <property name="useRegionBasedMarshalling">false</property>
+ <property name="inactiveOnStartup">false</property>
+
+ <property name="exposeManagementStatistics">true</property>
+ </bean>
+ </value>
+ </entry>
+ -->
+
+ </map>
+ </property>
+ </bean>
+
+</deployment>
\ No newline at end of file
Added: trunk/cluster/src/main/org/jboss/ha/cachemanager/DependencyInjectedConfigurationRegistry.java
===================================================================
--- trunk/cluster/src/main/org/jboss/ha/cachemanager/DependencyInjectedConfigurationRegistry.java (rev 0)
+++ trunk/cluster/src/main/org/jboss/ha/cachemanager/DependencyInjectedConfigurationRegistry.java 2008-04-11 03:40:00 UTC (rev 71994)
@@ -0,0 +1,156 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.ha.cachemanager;
+
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.ConfigurationRegistry;
+import org.jboss.cache.factories.CacheConfigsXmlParser;
+
+/**
+ * {@link ConfigurationRegistry} that can obtain its initial set of
+ * configurations via dependency injection.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1 $
+ */
+public class DependencyInjectedConfigurationRegistry implements ConfigurationRegistry
+{
+ private CacheConfigsXmlParser parser;
+ private String configResource;
+ private Map<String, Configuration> configs = new Hashtable<String, Configuration>();
+ private boolean started;
+
+ public DependencyInjectedConfigurationRegistry()
+ {
+ parser = new CacheConfigsXmlParser();
+ }
+
+ public void start() throws Exception
+ {
+ if (!started)
+ {
+ loadConfigResource(configResource);
+ started = true;
+ }
+ }
+
+ private void loadConfigResource(String resource) throws CloneNotSupportedException
+ {
+ if (resource != null)
+ {
+ Map<String, Configuration> parsed = parser.parseConfigs(resource);
+ for (Map.Entry<String, Configuration> entry : parsed.entrySet())
+ {
+ registerConfiguration(entry.getKey(), entry.getValue());
+ }
+ }
+ }
+
+ public void stop()
+ {
+ if (started)
+ {
+ synchronized (configs)
+ {
+ configs.clear();
+ }
+ started = false;
+ }
+ }
+
+ public void setConfigResource(String resource)
+ {
+ if (started)
+ {
+ try
+ {
+ loadConfigResource(resource);
+ }
+ catch (CloneNotSupportedException e)
+ {
+ throw new RuntimeException("Configuration in " + resource +
+ " does not properly support cloning", e);
+ }
+ }
+ else
+ {
+ this.configResource = resource;
+ }
+ }
+
+ public void setNewConfigurations(Map<String, Configuration> newConfigs)
+ {
+ if (newConfigs != null)
+ {
+
+ for (Map.Entry<String, Configuration> entry : newConfigs.entrySet())
+ {
+ try
+ {
+ registerConfiguration(entry.getKey(), entry.getValue());
+ }
+ catch (CloneNotSupportedException e)
+ {
+ throw new RuntimeException("Configuration " + entry.getKey() +
+ " does not properly support cloning", e);
+ }
+ }
+ }
+ }
+
+ public Set<String> getConfigurationNames()
+ {
+ return new HashSet<String>(configs.keySet());
+ }
+
+ public void registerConfiguration(String configName, Configuration config)
+ throws CloneNotSupportedException
+ {
+ synchronized (configs) {
+ if (configs.containsKey(configName))
+ throw new IllegalStateException(configName + " already registered");
+ configs.put(configName, config.clone());
+ }
+ }
+
+ public void unregisterConfiguration(String configName)
+ {
+ synchronized (configs) {
+ if (configs.remove(configName) == null)
+ throw new IllegalStateException(configName + " not registered");
+ }
+ }
+
+ public Configuration getConfiguration(String configName)
+ {
+ Configuration config = null;
+ synchronized (configs)
+ {
+ config = configs.get(configName);
+ }
+
+ if (config == null)
+ throw new IllegalArgumentException("unknown config " + configName);
+
+ // Don't hand out a ref to our master copy
+ try
+ {
+ return config.clone();
+ }
+ catch (CloneNotSupportedException e)
+ {
+ // This should not happen, as we already cloned the config
+ throw new RuntimeException("Could not clone configuration " + configName, e);
+ }
+ }
+}
Property changes on: trunk/cluster/src/main/org/jboss/ha/cachemanager/DependencyInjectedConfigurationRegistry.java
___________________________________________________________________
Name: svn:executable
+ *
More information about the jboss-cvs-commits
mailing list