[jboss-cvs] JBossAS SVN: r102689 - in projects/cluster/ha-server-cache-jbc/trunk: src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun Mar 21 14:23:24 EDT 2010
Author: bstansberry at jboss.com
Date: 2010-03-21 14:23:23 -0400 (Sun, 21 Mar 2010)
New Revision: 102689
Added:
projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl/TestDistributedCacheManagerFactoryImpl.java
Modified:
projects/cluster/ha-server-cache-jbc/trunk/pom.xml
Log:
[JBCLUSTER-251] Create SPI for use in AS testsuite web session tests
Modified: projects/cluster/ha-server-cache-jbc/trunk/pom.xml
===================================================================
--- projects/cluster/ha-server-cache-jbc/trunk/pom.xml 2010-03-21 18:21:56 UTC (rev 102688)
+++ projects/cluster/ha-server-cache-jbc/trunk/pom.xml 2010-03-21 18:23:23 UTC (rev 102689)
@@ -29,7 +29,7 @@
</scm>
<properties>
- <version.jboss.ha.server.cache.spi>2.0.0.GA</version.jboss.ha.server.cache.spi>
+ <version.jboss.ha.server.cache.spi>2.1.0-SNAPSHOT</version.jboss.ha.server.cache.spi>
<version.jboss.ha.server.api>1.1.0.GA</version.jboss.ha.server.api>
<version.jboss.common.core>2.2.12.GA</version.jboss.common.core>
<version.jboss.logging.spi>2.0.5.GA</version.jboss.logging.spi>
@@ -237,6 +237,13 @@
</dependency>
<dependency>
+ <groupId>org.jboss.aop</groupId>
+ <artifactId>jboss-aop</artifactId>
+ <version>2.0.0.GA</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.0.jboss</version>
Added: projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl/TestDistributedCacheManagerFactoryImpl.java
===================================================================
--- projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl/TestDistributedCacheManagerFactoryImpl.java (rev 0)
+++ projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl/TestDistributedCacheManagerFactoryImpl.java 2010-03-21 18:23:23 UTC (rev 102689)
@@ -0,0 +1,194 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.web.tomcat.service.session.distributedcache.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.cache.CacheStatus;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.buddyreplication.NextMemberBuddyLocatorConfig;
+import org.jboss.cache.config.BuddyReplicationConfig;
+import org.jboss.cache.config.CacheLoaderConfig;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.cache.config.Configuration.CacheMode;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.jboss.cache.loader.FileCacheLoaderConfig;
+import org.jboss.cache.lock.IsolationLevel;
+import org.jboss.cache.pojo.PojoCache;
+import org.jboss.cache.pojo.PojoCacheFactory;
+import org.jboss.cache.transaction.BatchModeTransactionManagerLookup;
+import org.jboss.logging.Logger;
+import org.jboss.web.tomcat.service.session.distributedcache.spi.ClusteringNotSupportedException;
+import org.jboss.web.tomcat.service.session.distributedcache.spi.DistributedCacheManager;
+import org.jboss.web.tomcat.service.session.distributedcache.spi.LocalDistributableSessionManager;
+import org.jboss.web.tomcat.service.session.distributedcache.spi.OutgoingDistributableSessionData;
+import org.jboss.web.tomcat.service.session.distributedcache.spi.TestDistributedCacheManagerFactory;
+
+/**
+ *
+ *
+ * @author Brian Stansberry
+ *
+ * @version $Revision$
+ */
+public class TestDistributedCacheManagerFactoryImpl implements TestDistributedCacheManagerFactory
+{
+ private static final Logger log = Logger.getLogger(TestDistributedCacheManagerFactoryImpl.class);
+
+ private DistributedCacheManagerFactoryImpl delegate = new DistributedCacheManagerFactoryImpl();
+
+ public void configure(boolean local, String passivationDir, boolean totalReplication, boolean marshalling,
+ boolean purgeCacheLoader)
+ {
+ PojoCache pc = createCache(local, passivationDir, totalReplication, marshalling, purgeCacheLoader);
+ delegate.setPojoCache(pc);
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T extends OutgoingDistributableSessionData> DistributedCacheManager<T> getDistributedCacheManager(
+ LocalDistributableSessionManager localManager) throws ClusteringNotSupportedException
+ {
+ return delegate.getDistributedCacheManager(localManager);
+ }
+
+ public void cleanup(boolean doRemove)
+ {
+ PojoCache cache = delegate.getPojoCache();
+ if (cache == null)
+ return;
+
+ if (doRemove && CacheStatus.STARTED.equals(cache.getCache().getCacheStatus()))
+ {
+ // Try to clean up so we avoid loading sessions
+ // from storage in later tests
+ try
+ {
+ log.info("Removing /JSESSION from " + cache.getCache().getLocalAddress());
+ cache.getCache().removeNode(Fqn.fromString("/JSESSION"));
+ }
+ catch (Exception e)
+ {
+ log.error("Cache " + cache + ": " + e.getMessage(), e);
+ }
+ }
+
+ try
+ {
+ cache.stop();
+ cache.destroy();
+ }
+ catch (Exception e)
+ {
+ log.error("Cache " + cache + ": " + e.getMessage(), e);
+ }
+
+ }
+
+
+
+
+ private static PojoCache createCache(boolean local, String passivationDir,
+ boolean totalReplication, boolean marshalling, boolean purgeCacheLoader)
+ {
+ Configuration cfg = getConfiguration(local, passivationDir, totalReplication, marshalling, purgeCacheLoader);
+ return PojoCacheFactory.createCache(cfg, true);
+ }
+
+ private static Configuration getConfiguration(boolean local, String passivationDir,
+ boolean totalReplication, boolean marshalling, boolean purgeCacheLoader)
+ {
+ Configuration config = new Configuration();
+ config.setClusterName("Tomcat-TestCluster");
+ config.setTransactionManagerLookupClass(BatchModeTransactionManagerLookup.class.getName());
+ config.setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
+ config.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
+ config.setSyncReplTimeout(20000);
+ config.setLockAcquisitionTimeout(15000);
+
+ config.setCacheMode(local ? CacheMode.LOCAL : CacheMode.REPL_SYNC);
+
+ config.setUseRegionBasedMarshalling(marshalling);
+ config.setInactiveOnStartup(marshalling);
+
+ // No async marshalling or notifications
+ config.setSerializationExecutorPoolSize(0);
+ config.setListenerAsyncPoolSize(0);
+
+ // Block for commits -- no races between test driver and replication
+ config.setSyncCommitPhase(true);
+ config.setSyncRollbackPhase(true);
+
+ if (passivationDir != null)
+ {
+ CacheLoaderConfig clc = new CacheLoaderConfig();
+ clc.setPassivation(true);
+ clc.setShared(false);
+ FileCacheLoaderConfig fclc = new FileCacheLoaderConfig();
+ fclc.setLocation(passivationDir);
+ fclc.setFetchPersistentState(true);
+ fclc.setPurgeOnStartup(purgeCacheLoader);
+ fclc.setAsync(false);
+ fclc.setIgnoreModifications(false);
+ ArrayList<IndividualCacheLoaderConfig> iclcs = new ArrayList<IndividualCacheLoaderConfig>();
+ iclcs.add(fclc);
+ clc.setIndividualCacheLoaderConfigs(iclcs);
+
+ config.setCacheLoaderConfig(clc);
+ }
+
+ if (!local && !totalReplication)
+ {
+ BuddyReplicationConfig brc = new BuddyReplicationConfig();
+ brc.setEnabled(true);
+ NextMemberBuddyLocatorConfig blc = new NextMemberBuddyLocatorConfig();
+ blc.setNumBuddies(1);
+ blc.setIgnoreColocatedBuddies(true);
+ brc.setBuddyLocatorConfig(blc);
+
+ brc.setBuddyPoolName("default");
+ brc.setBuddyCommunicationTimeout(20000);
+ brc.setAutoDataGravitation(false);
+ brc.setDataGravitationRemoveOnFind(true);
+ brc.setDataGravitationSearchBackupTrees(true);
+
+ config.setBuddyReplicationConfig(brc);
+ }
+
+ return config;
+ }
+
+ public Object getLocalAddress()
+ {
+ PojoCache pc = delegate.getPojoCache();
+ return pc == null ? null : pc.getCache().getLocalAddress();
+ }
+
+ public List<Object> getMembers()
+ {
+ PojoCache pc = delegate.getPojoCache();
+ return pc == null ? null : new ArrayList<Object>(pc.getCache().getMembers());
+ }
+
+}
More information about the jboss-cvs-commits
mailing list