Author: bdaw
Date: 2011-04-06 09:39:23 -0400 (Wed, 06 Apr 2011)
New Revision: 6168
Added:
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/picketlink-idm/jboss-cache-api-cluster.xml
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/picketlink-idm/jboss-cache-store-cluster.xml
Modified:
portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/PicketLinkIDMServiceImpl.java
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/idm-configuration.xml
Log:
GTNPORTAL-1853 - IDM caching improvements for cluster
Modified:
portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/PicketLinkIDMServiceImpl.java
===================================================================
---
portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/PicketLinkIDMServiceImpl.java 2011-04-06
13:31:47 UTC (rev 6167)
+++
portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/PicketLinkIDMServiceImpl.java 2011-04-06
13:39:23 UTC (rev 6168)
@@ -29,6 +29,8 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheFactory;
import org.jboss.cache.DefaultCacheFactory;
+
+import org.jgroups.JChannelFactory;
import org.picketlink.idm.api.IdentitySession;
import org.picketlink.idm.api.IdentitySessionFactory;
import org.picketlink.idm.api.cfg.IdentityConfiguration;
@@ -52,7 +54,7 @@
public class PicketLinkIDMServiceImpl implements PicketLinkIDMService, Startable
{
- private static Log log_ = ExoLogger.getLogger(PicketLinkIDMServiceImpl.class);
+ private static Log log = ExoLogger.getLogger(PicketLinkIDMServiceImpl.class);
public static final String PARAM_CONFIG_OPTION = "config";
@@ -70,6 +72,10 @@
public static final String CACHE_CONFIG_STORE_OPTION = "storeCacheConfig";
+ public static final String JGROUPS_CONFIG = "jgroups-configuration";
+
+ public static final String JGROUPS_MUX_ENABLED =
"jgroups-multiplexer-stack";
+
private IdentitySessionFactory identitySessionFactory;
private String config;
@@ -80,6 +86,8 @@
private IntegrationCache integrationCache;
+ private static final JChannelFactory CHANNEL_FACTORY = new JChannelFactory();
+
private PicketLinkIDMServiceImpl()
{
}
@@ -96,6 +104,8 @@
ValueParam realmName = initParams.getValueParam(REALM_NAME_OPTION);
ValueParam apiCacheConfig = initParams.getValueParam(CACHE_CONFIG_API_OPTION);
ValueParam storeCacheConfig = initParams.getValueParam(CACHE_CONFIG_STORE_OPTION);
+ ValueParam jgroupsStack = initParams.getValueParam(JGROUPS_MUX_ENABLED);
+ ValueParam jgroupsConfig = initParams.getValueParam(JGROUPS_CONFIG);
if (config == null && jndiName == null)
{
@@ -128,9 +138,9 @@
if (apiCacheConfig != null)
{
+
InputStream configStream =
confManager.getInputStream(apiCacheConfig.getValue());
- // Create common JBoss Cache instance
CacheFactory factory = new DefaultCacheFactory();
if (configStream == null)
@@ -140,6 +150,8 @@
Cache cache = factory.createCache(configStream);
+ applyJGroupsConfig(cache, confManager, jgroupsStack, jgroupsConfig);
+
cache.create();
cache.start();
@@ -157,12 +169,30 @@
picketLinkIDMCache.register(apiCacheProvider);
}
+
+
if (storeCacheConfig != null)
{
InputStream configStream =
confManager.getInputStream(storeCacheConfig.getValue());
+ CacheFactory factory = new DefaultCacheFactory();
+
+ if (configStream == null)
+ {
+ throw new IllegalArgumentException("JBoss Cache configuration
InputStream is null");
+ }
+
+ Cache cache = factory.createCache(configStream);
+
+ applyJGroupsConfig(cache, confManager, jgroupsStack, jgroupsConfig);
+
+ cache.create();
+ cache.start();
+
+ configStream.close();
+
JBossCacheIdentityStoreCacheProviderImpl storeCacheProvider = new
JBossCacheIdentityStoreCacheProviderImpl();
- storeCacheProvider.initialize(configStream);
+ storeCacheProvider.initialize(cache);
picketLinkIDMCache.register(storeCacheProvider);
identityConfiguration.getIdentityConfigurationRegistry().register(storeCacheProvider,
"storeCacheProvider");
@@ -225,4 +255,61 @@
{
return realmName;
}
+
+ /**
+ * Applying JGroups configuration for JBossCache.
+ * Code forked from org.exoplatform.services.jcr.jbosscacheExoJBossCacheFactory
+ *
+ * @param cache
+ * @param configurationManager
+ * @param jgroupsEnabledParam
+ * @param jgroupsConfigurationParam
+ */
+ private void applyJGroupsConfig(Cache cache,
+ ConfigurationManager configurationManager,
+ ValueParam jgroupsEnabledParam,
+ ValueParam jgroupsConfigurationParam)
+ {
+
+ String jgroupsEnabled = jgroupsEnabledParam != null ?
jgroupsEnabledParam.getValue() : null;
+ String jgroupsConfiguration = jgroupsConfigurationParam != null ?
jgroupsConfigurationParam.getValue() : null;
+
+ // JGroups multiplexer configuration if enabled
+ if (jgroupsEnabled != null &&
jgroupsEnabled.equalsIgnoreCase("true"))
+ {
+ try
+ {
+ if (jgroupsConfiguration != null)
+ {
+ // Create and inject multiplexer factory
+
CHANNEL_FACTORY.setMultiplexerConfig(configurationManager.getResource(jgroupsConfiguration));
+
cache.getConfiguration().getRuntimeConfig().setMuxChannelFactory(CHANNEL_FACTORY);
+ log.info("Multiplexer stack successfully enabled for the
cache.");
+ }
+ }
+ catch (Exception e)
+ {
+ // exception occurred setting mux factory
+ throw new IllegalStateException("Error setting multiplexer
configuration.", e);
+ }
+ }
+ else
+ {
+ // Multiplexer is not enabled. If jGroups configuration preset it is applied
+ if (jgroupsConfiguration != null)
+ {
+ try
+ {
+ cache.getConfiguration().setJgroupsConfigFile(
+ configurationManager.getResource(jgroupsConfiguration));
+ log.info("Custom JGroups configuration set:"
+ + configurationManager.getResource(jgroupsConfiguration));
+ }
+ catch (Exception e)
+ {
+ throw new IllegalStateException("Error setting JGroups
configuration.", e);
+ }
+ }
+ }
+ }
}
Modified:
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/idm-configuration.xml
===================================================================
---
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/idm-configuration.xml 2011-04-06
13:31:47 UTC (rev 6167)
+++
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/idm-configuration.xml 2011-04-06
13:39:23 UTC (rev 6168)
@@ -96,7 +96,7 @@
<value-param profiles="cluster">
<name>apiCacheConfig</name>
-
<value>war:/conf/organization/picketlink-idm/jboss-cache-cluster.xml</value>
+
<value>war:/conf/organization/picketlink-idm/jboss-cache-api-cluster.xml</value>
</value-param>
<value-param>
@@ -106,9 +106,19 @@
<value-param profiles="cluster">
<name>storeCacheConfig</name>
-
<value>war:/conf/organization/picketlink-idm/jboss-cache-cluster.xml</value>
+
<value>war:/conf/organization/picketlink-idm/jboss-cache-store-cluster.xml</value>
</value-param>
+ <value-param profiles="cluster">
+ <name>jgroups-configuration</name>
+ <value>${gatein.jcr.jgroups.config}</value>
+ </value-param>
+
+ <value-param profiles="cluster">
+ <name>jgroups-multiplexer-stack</name>
+ <value>true</value>
+ </value-param>
+
</init-params>
</component>
Copied:
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/picketlink-idm/jboss-cache-api-cluster.xml
(from rev 6164,
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/picketlink-idm/jboss-cache-cluster.xml)
===================================================================
---
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/picketlink-idm/jboss-cache-api-cluster.xml
(rev 0)
+++
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/picketlink-idm/jboss-cache-api-cluster.xml 2011-04-06
13:39:23 UTC (rev 6168)
@@ -0,0 +1,19 @@
+<jbosscache
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:jboss:jbosscache-core:config:3.1">
+
+ <clustering mode="replication"
clusterName="${jboss.partition.name:DefaultPartition}-idm-api-cluster">
+ <stateRetrieval timeout="20000" fetchInMemoryState="false"
/>
+ <jgroupsConfig multiplexerStack="jcr.stack" />
+ <sync />
+ </clustering>
+
+ <!-- Eviction configuration -->
+ <eviction wakeUpInterval="5000">
+ <default algorithmClass="org.jboss.cache.eviction.ExpirationAlgorithm"
+ eventQueueSize="1000000">
+ <property name="maxNodes" value="100000" />
+ <property name="timeToLive" value="120000" />
+ <property name="warnNoExpirationKey" value="false" />
+ </default>
+ </eviction>
+
+</jbosscache>
Copied:
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/picketlink-idm/jboss-cache-store-cluster.xml
(from rev 6164,
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/picketlink-idm/jboss-cache-cluster.xml)
===================================================================
---
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/picketlink-idm/jboss-cache-store-cluster.xml
(rev 0)
+++
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/picketlink-idm/jboss-cache-store-cluster.xml 2011-04-06
13:39:23 UTC (rev 6168)
@@ -0,0 +1,19 @@
+<jbosscache
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:jboss:jbosscache-core:config:3.1">
+
+ <clustering mode="replication"
clusterName="${jboss.partition.name:DefaultPartition}-idm-store-cluster">
+ <stateRetrieval timeout="20000" fetchInMemoryState="false"
/>
+ <jgroupsConfig multiplexerStack="jcr.stack" />
+ <sync />
+ </clustering>
+
+ <!-- Eviction configuration -->
+ <eviction wakeUpInterval="5000">
+ <default algorithmClass="org.jboss.cache.eviction.ExpirationAlgorithm"
+ eventQueueSize="1000000">
+ <property name="maxNodes" value="100000" />
+ <property name="timeToLive" value="120000" />
+ <property name="warnNoExpirationKey" value="false" />
+ </default>
+ </eviction>
+
+</jbosscache>