JBoss Cache SVN: r7269 - in core/trunk: src/main/java/org/jboss/cache/notifications and 9 other directories.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-12-09 10:04:25 -0500 (Tue, 09 Dec 2008)
New Revision: 7269
Modified:
core/trunk/pom.xml
core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.java
core/trunk/src/main/resources/cache-jdbc.properties
core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/CacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/PassivationTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/CacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/PassivationTest.java
core/trunk/src/test/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderCompatibilityTest.java
core/trunk/src/test/java/org/jboss/cache/loader/BdbjeCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/C3p0ConnectionFactoryTest.java
core/trunk/src/test/java/org/jboss/cache/loader/C3p0JDBCCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java
core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderBasicTest.java
core/trunk/src/test/java/org/jboss/cache/loader/ClusteredCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/DataSourceIntegrationTest.java
core/trunk/src/test/java/org/jboss/cache/loader/DummyInMemoryCacheLoaderPessimisticTest.java
core/trunk/src/test/java/org/jboss/cache/loader/DummyInMemoryCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/FileCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderConfigTest.java
core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderDerbyDSTest.java
core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderStateTransferTest.java
core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/JdbmCacheLoader2Test.java
core/trunk/src/test/java/org/jboss/cache/loader/JdbmCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/LocalDelegatingCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/S3CacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/lock/IdentityLockTest.java
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToBdbjeCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToDummyInMemoryCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToFileCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToJDBCCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToLocalDelegatingCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/util/TestDbPropertiesFactory.java
core/trunk/src/test/resources/cache-jdbc.properties
Log:
switched to hsqldb instead of derby
Modified: core/trunk/pom.xml
===================================================================
--- core/trunk/pom.xml 2008-12-09 15:01:40 UTC (rev 7268)
+++ core/trunk/pom.xml 2008-12-09 15:04:25 UTC (rev 7269)
@@ -30,6 +30,13 @@
<version>2.6.7.GA</version>
</dependency>
+ <dependency>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>1.8.0.7</version>
+ <scope>test</scope>
+ </dependency>
+
<!-- For the JTA 1.1 API; consuming projects can safely
exclude this and replace with any valid source of this API -->
<dependency>
Modified: core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.java 2008-12-09 15:01:40 UTC (rev 7268)
+++ core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.java 2008-12-09 15:04:25 UTC (rev 7269)
@@ -147,8 +147,8 @@
@Stop
void stop()
{
- syncProcessor.shutdownNow();
- asyncProcessor.shutdownNow();
+ if (syncProcessor != null) syncProcessor.shutdownNow();
+ if (asyncProcessor != null) asyncProcessor.shutdownNow();
}
@Destroy
Modified: core/trunk/src/main/resources/cache-jdbc.properties
===================================================================
--- core/trunk/src/main/resources/cache-jdbc.properties 2008-12-09 15:01:40 UTC (rev 7268)
+++ core/trunk/src/main/resources/cache-jdbc.properties 2008-12-09 15:04:25 UTC (rev 7269)
@@ -11,7 +11,7 @@
cache.jdbc.fqn.column=fqn
cache.jdbc.fqn.type=varchar(255)
cache.jdbc.node.column=node
-cache.jdbc.node.type=blob
+cache.jdbc.node.type=BINARY
cache.jdbc.parent.column=parent
# Specify your DBMS's string concatenation function syntax in the following manner: concat(1 , 2) -> '12'.
# This syntax should work an most popular DBMS like oracle, db2, mssql, mysql, PostgreSQL. Derby - on which
@@ -63,7 +63,7 @@
#cache.jdbc.password=admin
## Derby
-cache.jdbc.driver = org.apache.derby.jdbc.EmbeddedDriver
-cache.jdbc.url=jdbc:derby:jbossdb;create=true
-cache.jdbc.user=user1
-cache.jdbc.password=user1
\ No newline at end of file
+cache.jdbc.driver = org.hsqldb.jdbcDriver
+cache.jdbc.url=jdbc:hsqldb:mem:jbosscache
+cache.jdbc.user=sa
+cache.jdbc.password=
\ No newline at end of file
Modified: core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java 2008-12-09 15:01:40 UTC (rev 7268)
+++ core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java 2008-12-09 15:04:25 UTC (rev 7269)
@@ -178,15 +178,14 @@
private void tryMCastAddress()
{
String useIpV4 = System.getProperty("java.net.preferIPv4Stack");
- log.error("++++++++++++++++++++++++++++++ useIpV4 property=" + useIpV4);
+ log.info("++++++++++++++++++++++++++++++ useIpV4 property=" + useIpV4);
SocketAddress socketAddress = new InetSocketAddress("224.10.10.10", 45588);
try
{
MulticastSocket ms = new MulticastSocket(socketAddress);
} catch (IOException e)
{
- System.err.println("+++++++++++++++++++++++++++ Error : " + e.getMessage());
- log.error("+++++++++++++++++++++++++++ Error : " + e.getMessage(), e);
+ log.info("+++++++++++++++++++++++++++ Error : " + e.getMessage(), e);
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/CacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/CacheLoaderTest.java 2008-12-09 15:01:40 UTC (rev 7268)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/CacheLoaderTest.java 2008-12-09 15:04:25 UTC (rev 7269)
@@ -18,7 +18,6 @@
@Override
protected void configureCache() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
super.configureCache();
cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.MVCC);
cache.getConfiguration().setIsolationLevel(IsolationLevel.READ_COMMITTED);
@@ -27,7 +26,6 @@
@AfterMethod
public void postTest()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
ComponentRegistry cr = TestingUtil.extractComponentRegistry(cache);
LockAssert.assertNoLocks(cr.getComponent(LockManager.class), cr.getComponent(InvocationContextContainer.class));
Modified: core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/PassivationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/PassivationTest.java 2008-12-09 15:01:40 UTC (rev 7268)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/PassivationTest.java 2008-12-09 15:04:25 UTC (rev 7269)
@@ -21,7 +21,6 @@
@Override
protected void configureCache() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.MVCC);
cache.getConfiguration().setIsolationLevel(IsolationLevel.READ_COMMITTED);
@@ -35,7 +34,6 @@
@AfterMethod
public void postTest()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
ComponentRegistry cr = TestingUtil.extractComponentRegistry(cache);
LockAssert.assertNoLocks(cr.getComponent(LockManager.class), cr.getComponent(InvocationContextContainer.class));
Modified: core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/CacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/CacheLoaderTest.java 2008-12-09 15:01:40 UTC (rev 7268)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/CacheLoaderTest.java 2008-12-09 15:04:25 UTC (rev 7269)
@@ -18,7 +18,6 @@
@Override
protected void configureCache() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
super.configureCache();
cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.MVCC);
cache.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE_READ);
@@ -27,7 +26,6 @@
@AfterMethod
public void postTest()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
ComponentRegistry cr = TestingUtil.extractComponentRegistry(cache);
LockAssert.assertNoLocks(cr.getComponent(LockManager.class), cr.getComponent(InvocationContextContainer.class));
Modified: core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/PassivationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/PassivationTest.java 2008-12-09 15:01:40 UTC (rev 7268)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/PassivationTest.java 2008-12-09 15:04:25 UTC (rev 7269)
@@ -20,7 +20,6 @@
@Override
protected void configureCache() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.MVCC);
cache.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE_READ);
CacheLoaderConfig clc = getSingleCacheLoaderConfig("", DummySharedInMemoryCacheLoader.class.getName(), "bin=" + Thread.currentThread().getName() + getClass().getName(), false, true, false);
@@ -31,7 +30,6 @@
@AfterMethod
public void postTest()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
ComponentRegistry cr = TestingUtil.extractComponentRegistry(cache);
LockAssert.assertNoLocks(cr.getComponent(LockManager.class), cr.getComponent(InvocationContextContainer.class));
Modified: core/trunk/src/test/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderCompatibilityTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderCompatibilityTest.java 2008-12-09 15:01:40 UTC (rev 7268)
+++ core/trunk/src/test/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderCompatibilityTest.java 2008-12-09 15:04:25 UTC (rev 7269)
@@ -11,9 +11,7 @@
import org.jboss.util.stream.MarshalledValueInputStream;
import org.jboss.util.stream.MarshalledValueOutputStream;
import static org.testng.AssertJUnit.*;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
+import org.testng.annotations.*;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -42,6 +40,23 @@
private CacheSPI cache, cache2;
+ private Properties props;
+ private long durration;
+
+ @BeforeTest
+ public void createDatabase()
+ {
+ durration = System.currentTimeMillis();
+ props = TestDbPropertiesFactory.getTestDbProperties();
+ }
+
+ @AfterTest
+ public void shutDownDatabase()
+ {
+ TestDbPropertiesFactory.shutdownInMemoryDatabase(props);
+ System.out.println("Test execution took: " + (System.currentTimeMillis() - durration)/1000);
+ }
+
/**
* Note : newImpl is not started here but in each individual test. That's because on start it performs
* some backward compatibility logic.
@@ -51,7 +66,6 @@
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- Properties props = TestDbPropertiesFactory.getTestDbProperties();
newImpl = getNewCacheLoader((Properties) props.clone());
oldImpl = getOldLoader((Properties) props.clone());
cache = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache();
@@ -72,8 +86,6 @@
TestingUtil.killCaches(cache, cache2);
cache = null;
cache2 = null;
- TestDbPropertiesFactory.shutdownInMemoryDatabase(oldImpl.getConfig().getProperties());
- TestDbPropertiesFactory.shutdownInMemoryDatabase(newImpl.getConfig().getProperties());
}
public void testCommonOperations() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/loader/BdbjeCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/BdbjeCacheLoaderTest.java 2008-12-09 15:01:40 UTC (rev 7268)
+++ core/trunk/src/test/java/org/jboss/cache/loader/BdbjeCacheLoaderTest.java 2008-12-09 15:04:25 UTC (rev 7269)
@@ -19,10 +19,8 @@
@Override
protected void configureCache() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
String tmpDir = TestingUtil.TEST_FILES;
- String threadId = Thread.currentThread().getName();
- String tmpCLLoc = tmpDir + "/JBossCache-BdbjeCacheLoaderTest-" + threadId;
+ String tmpCLLoc = tmpDir + "/JBossCache-BdbjeCacheLoaderTest";
cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("", "org.jboss.cache.loader.bdbje.BdbjeCacheLoader", "location=" + tmpCLLoc, false, true, false));
TestingUtil.recursiveFileRemove(tmpCLLoc);
@@ -31,7 +29,6 @@
public void testTransaction() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
// to help recreate the issue in
// http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4048003#4048003
Modified: core/trunk/src/test/java/org/jboss/cache/loader/C3p0ConnectionFactoryTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/C3p0ConnectionFactoryTest.java 2008-12-09 15:01:40 UTC (rev 7268)
+++ core/trunk/src/test/java/org/jboss/cache/loader/C3p0ConnectionFactoryTest.java 2008-12-09 15:04:25 UTC (rev 7269)
@@ -10,9 +10,7 @@
import org.jboss.cache.util.TestDbPropertiesFactory;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.fail;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
+import org.testng.annotations.*;
import java.sql.Connection;
import java.util.Properties;
@@ -28,19 +26,34 @@
private C3p0ConnectionFactory cf;
private AdjListJDBCCacheLoaderConfig config;
+ private Properties props;
+ private long durration;
+
+ @BeforeTest
+ public void createDatabase()
+ {
+ durration = System.currentTimeMillis();
+ props = TestDbPropertiesFactory.getTestDbProperties();
+ }
+
+ @AfterTest
+ public void shutDownDatabase()
+ {
+ TestDbPropertiesFactory.shutdownInMemoryDatabase(props);
+ System.out.println("Test execution took: " + (System.currentTimeMillis() - durration)/1000);
+ }
+
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- Properties prop = TestDbPropertiesFactory.getTestDbProperties();
config = new AdjListJDBCCacheLoaderConfig();
- config.setProperties(prop);
+ config.setProperties(props);
}
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
cf.stop();
- TestDbPropertiesFactory.shutdownInMemoryDatabase(config.getProperties());
}
public void testSetConfig() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/loader/C3p0JDBCCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/C3p0JDBCCacheLoaderTest.java 2008-12-09 15:01:40 UTC (rev 7268)
+++ core/trunk/src/test/java/org/jboss/cache/loader/C3p0JDBCCacheLoaderTest.java 2008-12-09 15:04:25 UTC (rev 7269)
@@ -11,6 +11,8 @@
import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.util.TestDbPropertiesFactory;
import org.testng.annotations.Test;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.AfterTest;
/**
* Unit test that runs the the tests defined JDBCCacheLoaderTest using a standalone
@@ -18,16 +20,20 @@
*
* @author <a href="mailto:galder.zamarreno@jboss.com">Galder Zamarreno</a>
*/
-@Test(groups = "functional", testName = "loader.JDBCCacheLoaderTest")
+@Test(groups = "functional", testName = "loader.C3p0JDBCCacheLoaderTest")
public class C3p0JDBCCacheLoaderTest extends JDBCCacheLoaderTest
{
private static final String CF_CLASS = "org.jboss.cache.loader.C3p0ConnectionFactory";
+ @BeforeTest
+ public void createDatabase()
+ {
+ super.createDatabase();
+ props.put("cache.jdbc.connection.factory", CF_CLASS);
+ }
+
protected void configureCache() throws Exception
{
- Properties prop = TestDbPropertiesFactory.getTestDbProperties();
- prop.put("cache.jdbc.connection.factory", CF_CLASS);
- CacheSPI<Object, Object> cache = cacheTL.get();
- cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("", "org.jboss.cache.loader.JDBCCacheLoader", prop, false, true, false));
+ cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("", "org.jboss.cache.loader.JDBCCacheLoader", props, false, true, false));
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java 2008-12-09 15:01:40 UTC (rev 7268)
+++ core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java 2008-12-09 15:04:25 UTC (rev 7269)
@@ -2,13 +2,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheException;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.Modification;
-import org.jboss.cache.Node;
-import org.jboss.cache.NodeSPI;
-import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.*;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.statetransfer.DefaultStateTransferManager;
@@ -26,13 +20,7 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-import java.util.Set;
+import java.util.*;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.CountDownLatch;
@@ -45,11 +33,8 @@
@Test(groups = {"functional"})
abstract public class CacheLoaderTestsBase extends AbstractCacheLoaderTestBase
{
- private static final Log log = LogFactory.getLog(CacheLoaderTestsBase.class);
+ static final Log log = LogFactory.getLog(CacheLoaderTestsBase.class);
- protected ThreadLocal<CacheSPI<Object, Object>> cacheTL = new ThreadLocal<CacheSPI<Object, Object>>();
- ThreadLocal<CacheLoader> loaderTL = new ThreadLocal<CacheLoader>();
-
static final Fqn FQN = Fqn.fromString("/key");
private static final Fqn SUBTREE_FQN = Fqn.fromRelativeElements(FQN, "subtree");
@@ -58,30 +43,20 @@
private static final Fqn BUDDY_PLUS_FQN = Fqn.fromRelativeFqn(BUDDY_BASE, FQN);
private static final Fqn BUDDY_PLUS_SUBTREE_FQN = Fqn.fromRelativeFqn(BUDDY_BASE, SUBTREE_FQN);
+ protected CacheSPI<Object, Object> cache;
+ protected CacheLoader loader;
- @BeforeMethod(alwaysRun = true)
+ @BeforeMethod
public void setUp() throws Exception
{
- try
- {
- CacheSPI<Object, Object> cache =
- (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(false);
- cacheTL.set(cache);
-
- Configuration c = cache.getConfiguration();
- c.setCacheMode(Configuration.CacheMode.LOCAL);
- c.setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
- configureCache();
- cache.start();
- CacheLoader loader = cache.getCacheLoaderManager().getCacheLoader();
- loaderTL.set(loader);
- postConfigure();
- }
- catch (Exception e)
- {
-// e.printStackTrace();
- throw e;
- }
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(false);
+ Configuration c = cache.getConfiguration();
+ c.setCacheMode(Configuration.CacheMode.LOCAL);
+ c.setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
+ configureCache();
+ cache.start();
+ loader = cache.getCacheLoaderManager().getCacheLoader();
+ postConfigure();
}
protected void postConfigure()
@@ -95,12 +70,8 @@
public void tearDown() throws Exception
{
cleanup();
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
//if (loader != null) loader.remove(Fqn.ROOT);
TestingUtil.killCaches(cache);
- cacheTL.set(null);
- loaderTL.set(null);
}
protected void cleanup()
@@ -121,7 +92,7 @@
*/
protected boolean exists(String fqn, String key)
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
NodeSPI n = cache.peek(Fqn.fromString(fqn), false, false);
if (key == null) return n != null;
return n != null && n.getKeysDirect().contains(key);
@@ -129,7 +100,7 @@
public void testPrint() throws CacheException
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
final Fqn NODE = Fqn.fromString("/test");
final String KEY = "key";
cache.put(NODE, KEY, 10);
@@ -141,7 +112,7 @@
public void testPut() throws CacheException
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
final String NODE = "/test";
final String KEY = "key";
Object retval;
@@ -162,8 +133,8 @@
public void testPut2() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
+
+
final String NODE = "/a/b/c";
assertNull(loader.get(Fqn.fromString(NODE)));
final String KEY = "key";
@@ -192,8 +163,7 @@
{
final Fqn NODE = Fqn.fromString("/a/b/c");
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
+
cache.removeNode(NODE);
addDelay();
Map<Object, Object> m = new HashMap<Object, Object>();
@@ -215,16 +185,17 @@
cache.get(NODE, "X");
assertEquals(m, cache.getNode(NODE).getData());
cache.evict(NODE, false);
+ assertEquals(m, cache.getNode(NODE).getData());
cache.get(NODE, "X");
cache.put(NODE, m2);
- assertEquals("combined", 4, cache.getNode(NODE).getData().size());
+ Map<Object, Object> data = cache.getNode(NODE).getData();
+ System.out.println("data = " + data);
+ assertEquals("combined", 4, data.size());
}
public void testPutNullDataMap() throws Exception
{
Fqn f = Fqn.fromString("/a");
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
assert !cache.exists(f);
assert !loader.exists(f);
cache.put(f, null);
@@ -236,8 +207,8 @@
public void testPutNullDataMapNodeHasData() throws Exception
{
Fqn f = Fqn.fromString("/a");
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
+
+
cache.put(f, "key", "value");
assert cache.exists(f);
assert loader.exists(f);
@@ -250,7 +221,7 @@
public void testShallowMove() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
Fqn a = Fqn.fromString("/a");
Fqn b = Fqn.fromString("/b");
Fqn a_b = Fqn.fromString("/a/b");
@@ -280,8 +251,8 @@
public void testDeepMove() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
Fqn a = Fqn.fromString("/a");
Fqn b = Fqn.fromString("/b");
Fqn a_b = Fqn.fromString("/a/b");
@@ -320,9 +291,8 @@
*/
public void testPutRemoveCombos() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
+
final String NODE = "/a/b/c";
cache.removeNode(NODE);
Fqn fqn = Fqn.fromString(NODE);
@@ -343,8 +313,8 @@
public void testGet() throws CacheException
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
final String NODE = "/a/b/c";
Object retval;
cache.removeNode(NODE);
@@ -364,8 +334,8 @@
public void testGetNode() throws CacheException
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
final String NODE = "/a/b/c";
Node<Object, Object> retval;
cache.removeNode(NODE);
@@ -384,8 +354,8 @@
public void testSerialization() throws CacheException
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
SamplePojo pojo = new SamplePojo(39, "Bela");
pojo.getHobbies().add("Running");
pojo.getHobbies().add("Beerathlon");
@@ -407,7 +377,7 @@
*/
public void testPopulate()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
try
{
Map<Object, Object> m = new HashMap<Object, Object>();
@@ -445,7 +415,7 @@
public void testPreloading() throws CacheException
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
cache.removeNode(Fqn.ROOT);
cache.put("1/2/3/4/5/d", "key", "val");
cache.evict(Fqn.fromString("1/2/3/4/5/d"));
@@ -461,7 +431,7 @@
@SuppressWarnings("unchecked")
public void testCacheLoading2() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
Set keys = null;
cache.put("/a/b/c", "key", "val");
keys = cache.getNode("/a/b/c").getKeys();
@@ -472,7 +442,7 @@
public void testExists()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
cache.put("/eins/zwei/drei", "key1", "val1");
assertTrue(cache.exists("/eins/zwei/drei"));
assert (exists("/eins/zwei/drei", "key1"));
@@ -483,7 +453,7 @@
public void testGetChildren()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
try
{
cache.put("/1/2/3/4/5/d/one", null);
@@ -505,7 +475,7 @@
public void testGetChildrenWithEviction() throws CacheException
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
cache.put("/a/b/c/1", null);
cache.put("/a/b/c/2", null);
cache.put("/a/b/c/3", null);
@@ -527,7 +497,7 @@
public void testGetChildren2()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
try
{
cache.put("/1", null);
@@ -546,7 +516,7 @@
public void testGetChildren3()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
try
{
cache.put("/1", null);
@@ -565,7 +535,7 @@
public void testGetChildren4()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
try
{
if (!cache.exists("/a/b/c"))
@@ -584,7 +554,7 @@
public void testGetChildren5()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
try
{
cache.put("/a/1", null);
@@ -607,7 +577,7 @@
public void testGetChildren6()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
try
{
cache.put("/a/1", null);
@@ -633,7 +603,7 @@
public void testGetChildren7()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
try
{
cache.put("/a/1", null);
@@ -661,7 +631,7 @@
public void testGetChildren8()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
cache.put("/a/1", null);
cache.put("/a/2", null);
cache.put("/a/3", null);
@@ -681,7 +651,7 @@
public void testGetChildren9()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
try
{
cache.put("/a/1", null);
@@ -722,7 +692,7 @@
public void testGetChildren10()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
try
{
cache.put("/a/1", null);
@@ -755,7 +725,7 @@
public void testGetChildren11()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
Set children;
try
{
@@ -798,7 +768,7 @@
public void testGetChildren12()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
Set children;
cache.put("/a/b", "key", "val");
cache.put("/a/b/1", "key", "val");
@@ -830,8 +800,8 @@
public void testLoaderGetChildrenNames() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
+
+
Fqn f = Fqn.fromString("/a");
cache.put(f, "k", "v");
assertEquals("v", loader.get(f).get("k"));
@@ -840,7 +810,7 @@
public void testGetKeys() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
Fqn f = Fqn.fromString("/a");
cache.put(f, "one", "one");
cache.put(f, "two", "two");
@@ -853,8 +823,8 @@
public void testGetData() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
+
+
Fqn f = Fqn.fromString("/a");
assert !cache.exists(f);
assert !loader.exists(f);
@@ -871,7 +841,7 @@
public void testRemoveData()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
String key = "/x/y/z/";
cache.put(key, "keyA", "valA");
cache.put(key, "keyB", "valB");
@@ -888,7 +858,7 @@
public void testRemoveData2()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
Set keys;
Fqn key = Fqn.fromString("/x/y/z/");
cache.put(key, "keyA", "valA");
@@ -907,7 +877,7 @@
public void testRemoveData3()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
Set keys;
Fqn key = Fqn.fromString("/x/y/z/");
cache.put(key, "keyA", "valA");
@@ -923,8 +893,8 @@
public void testRemoveData4() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
+
+
Set keys;
Fqn key = Fqn.fromString("/x/y/z/");
cache.put(key, "keyA", "valA");
@@ -945,8 +915,8 @@
public void testReplaceAll() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
+
+
Set keys;
Fqn key = Fqn.fromString("/x/y/z/");
cache.put(key, "keyA", "valA");
@@ -972,7 +942,7 @@
public void testRemoveKey()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
String key = "/x/y/z/";
cache.put(key, "keyA", "valA");
assertEquals(1, cache.getNode(key).getKeys().size());
@@ -988,7 +958,7 @@
public void testRemoveKey2() throws CacheException
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
final String NODE = "/test";
final String KEY = "key";
Object retval;
@@ -1005,7 +975,7 @@
public void testRemoveKey3() throws CacheException
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
final String NODE = "/test";
final String KEY = "key";
Object retval;
@@ -1027,7 +997,7 @@
public void testRemove()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
String key = "/x/y/z/";
cache.put(key, "keyA", "valA");
cache.put(key, "keyB", "valB");
@@ -1043,7 +1013,7 @@
public void testRemoveRoot()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
assertEquals(0, cache.getRoot().getKeys().size());
cache.put("/1/2/3/4/5", null);
cache.put("uno/due/tre", null);
@@ -1056,8 +1026,8 @@
public void testLoaderRemoveRoot() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
+
+
Fqn f = Fqn.fromString("/a");
loader.put(f, "k", "v");
assertTrue(loader.get(f).containsKey("k"));
@@ -1071,7 +1041,7 @@
public void testEvictionWithCacheLoader()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
cache.put("/first/second", "key1", "val1");// stored in cache loader
cache.put("/first/second/third", "key2", "val2");// stored in cache loader
cache.evict(Fqn.fromString("/first/second"));// doesn't remove node, just data !
@@ -1089,7 +1059,7 @@
public void testEvictionWithCacheLoader2()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
cache.put("/first/second/third", "key1", "val1");// stored in cache loader
cache.evict(Fqn.fromString("/first/second/third"));// removes node, because there are no children
addDelay();
@@ -1106,7 +1076,7 @@
public void testEvictionWithGetChildrenNames() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
cache.put("/a/1", null);
cache.put("/a/2", null);
cache.put("/a/3", null);
@@ -1136,8 +1106,7 @@
TransactionManager mgr = getTransactionManager();
mgr.begin();
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
+
cache.put("/one/two/three", "key1", "val1");
cache.put("/one/two/three/four", "key2", "val2");
mgr.commit();
@@ -1154,8 +1123,7 @@
{
TransactionManager mgr = getTransactionManager();
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
+
cache.removeNode("/one");
addDelay();
mgr.begin();
@@ -1206,8 +1174,6 @@
private void doTestBasicOperations() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
/* One FQN only. */
doPutTests(Fqn.fromString("/key"));
doRemoveTests(Fqn.fromString("/key"));
@@ -1238,7 +1204,7 @@
throws Exception
{
- CacheLoader loader = loaderTL.get();
+
assertTrue(!loader.exists(fqn));
/* put(Fqn,Object,Object) and get(Fqn,Object) */
@@ -1285,7 +1251,6 @@
throws Exception
{
- CacheLoader loader = loaderTL.get();
/* remove(Fqn,Object) */
Object oldVal;
oldVal = loader.remove(fqn, "one");
@@ -1320,8 +1285,6 @@
throws Exception
{
- CacheLoader loader = loaderTL.get();
-
/* Create top level node implicitly. */
assertTrue(!loader.exists(Fqn.fromString("/key0")));
loader.put(Fqn.fromString("/key0/level1/level2"), null);
@@ -1485,7 +1448,6 @@
throws Exception
{
- CacheLoader loader = loaderTL.get();
checkChildren(Fqn.ROOT, null);
checkChildren(Fqn.fromString("/key0"), null);
@@ -1556,7 +1518,6 @@
throws Exception
{
- CacheLoader loader = loaderTL.get();
Set set = loader.getChildrenNames(fqn);
if (names != null)
@@ -1566,8 +1527,7 @@
{
assertTrue(set.contains(names[i]));
}
- }
- else
+ } else
{
assertNull(set);
}
@@ -1603,8 +1563,6 @@
throws Exception
{
- CacheLoader loader = loaderTL.get();
-
/* PUT_KEY_VALUE, PUT_DATA */
List<Modification> list = createUpdates();
loader.put(list);
@@ -1652,7 +1610,6 @@
throws Exception
{
- CacheLoader loader = loaderTL.get();
List<Modification> mods = createUpdates();
loader.prepare(null, mods, true);
@@ -1666,8 +1623,6 @@
throws Exception
{
- CacheLoader loader = loaderTL.get();
-
// Object txnKey = new Object();
TransactionManager mgr = getTransactionManager();
mgr.begin();
@@ -1686,7 +1641,7 @@
*/
public void testTransactionRollback() throws Exception
{
- CacheLoader loader = loaderTL.get();
+
loader.remove(Fqn.fromString("/"));
int num;
try
@@ -1717,7 +1672,7 @@
*/
public void testIntegratedTransactionRollback() throws Exception
{
- CacheLoader loader = loaderTL.get();
+
loader.remove(Fqn.fromString("/"));
int num = 0;
try
@@ -1785,8 +1740,8 @@
*/
private void checkModifications(List<Modification> list) throws Exception
{
- CacheLoader loader = loaderTL.get();
+
for (Modification mod : list)
{
Fqn fqn = mod.getFqn();
@@ -1827,7 +1782,6 @@
throws Exception
{
- CacheLoader loader = loaderTL.get();
loader.put(FQN, null, "x");
addDelay();
@@ -1887,7 +1841,7 @@
throws Exception
{
- CacheLoader loader = loaderTL.get();
+
loader.put(FQN, "one", "two");
addDelay();
assertEquals("two", loader.get(FQN).get("one"));
@@ -1900,8 +1854,6 @@
throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
// Empty state
loader.remove(Fqn.fromString("/"));
@@ -1997,8 +1949,7 @@
if (nested == null)
{
return super.hashCode();
- }
- else
+ } else
{
return 13 + nested.hashCode();
}
@@ -2007,8 +1958,8 @@
public void testRemoveInTransactionCommit() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
+
+
Fqn fqn = Fqn.fromString("/a/b");
loader.remove(fqn);
String key = "key";
@@ -2034,8 +1985,8 @@
public void testRemoveInTransactionRollback() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
+
+
Fqn fqn = Fqn.fromString("/a/b");
loader.remove(fqn);
String key = "key";
@@ -2063,7 +2014,7 @@
*/
public void testRemoveAndGetInTransaction() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
Fqn fqn = Fqn.fromString("/a/b");
String key = "key";
String value = "value";
@@ -2086,8 +2037,8 @@
public void testPutAllAfterEvict() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
+
+
Fqn fqn = Fqn.fromString("/a/b");
Map<String, String> original = new HashMap<String, String>();
Map<String, String> toAdd = new HashMap<String, String>();
@@ -2113,8 +2064,8 @@
public void testPutAllAfterEvictWithChild() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
+
+
Fqn fqn = Fqn.fromString("/a/b");
Map<String, String> original = new HashMap<String, String>();
Map<String, String> toAdd = new HashMap<String, String>();
@@ -2146,8 +2097,6 @@
public void testPartialLoadAndStore()
throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
/* Empty state. */
loader.remove(Fqn.fromString("/"));
@@ -2203,8 +2152,7 @@
public void testBuddyBackupStore() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
+
/* Empty state. */
loader.remove(Fqn.ROOT);
@@ -2252,8 +2200,6 @@
public void testIgnoreModifications() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
Fqn fqn = Fqn.fromString("/a");
cache.put(fqn, "k", "v");
assert "v".equals(cache.get(fqn, "k"));
@@ -2302,7 +2248,6 @@
protected void threadSafetyTest(final boolean singleFqn) throws Exception
{
- final CacheLoader loader = loaderTL.get();
final CountDownLatch latch = new CountDownLatch(1);
final Fqn fqn = Fqn.fromString("/a/b/c");
final List<Fqn> fqns = new ArrayList<Fqn>(30);
@@ -2315,8 +2260,7 @@
fqns.add(f);
loader.put(f, "k", "v");
}
- }
- else
+ } else
{
loader.put(fqn, "k", "v");
}
@@ -2461,18 +2405,16 @@
protected TransactionManager getTransactionManager()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
return cache.getConfiguration().getRuntimeConfig().getTransactionManager();
}
public void testSetData() throws Exception
{
log.info("testSetData");
- CacheSPI<Object, Object> cache = cacheTL.get();
Fqn key = Fqn.fromElements("key");
Map<Object, Object> map = new HashMap<Object, Object>();
Map<Object, Object> loaderMap;
- CacheLoader loader = loaderTL.get();
map.put("a", "a");
map.put("c", "c");
log.info("PUT");
Modified: core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderBasicTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderBasicTest.java 2008-12-09 15:01:40 UTC (rev 7268)
+++ core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderBasicTest.java 2008-12-09 15:04:25 UTC (rev 7269)
@@ -36,7 +36,6 @@
protected void configureCache() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
cache.getConfiguration().setCacheLoaderConfig(getCacheLoaderConfig(loc1, loc2));
TestingUtil.recursiveFileRemove(loc1);
TestingUtil.recursiveFileRemove(loc2);
Modified: core/trunk/src/test/java/org/jboss/cache/loader/ClusteredCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/ClusteredCacheLoaderTest.java 2008-12-09 15:01:40 UTC (rev 7268)
+++ core/trunk/src/test/java/org/jboss/cache/loader/ClusteredCacheLoaderTest.java 2008-12-09 15:04:25 UTC (rev 7269)
@@ -268,7 +268,7 @@
latch.await();
for (int i = 0; i < loops; i++)
{
- System.out.println("Evict in loop " + i);
+// System.out.println("Evict in loop " + i);
Fqn f = singleFqn ? fqn : fqns.get(r.nextInt(fqns.size()));
cache1.evict(f);
TestingUtil.sleepRandom(50);
@@ -296,7 +296,7 @@
latch.await();
for (int i = 0; i < loops; i++)
{
- System.out.println("Write in loop " + i);
+// System.out.println("Write in loop " + i);
Fqn f = singleFqn ? fqn : fqns.get(r.nextInt(fqns.size()));
cache2.put(f, "k", "v");
TestingUtil.sleepRandom(50);
@@ -321,7 +321,7 @@
latch.await();
for (int i = 0; i < loops; i++)
{
- System.out.println("R1 in loop " + i);
+// System.out.println("R1 in loop " + i);
loader1.get(singleFqn ? fqn : fqns.get(r.nextInt(fqns.size())));
TestingUtil.sleepRandom(50);
}
@@ -343,7 +343,7 @@
latch.await();
for (int i = 0; i < loops; i++)
{
- System.out.println("R2 in loop " + i);
+// System.out.println("R2 in loop " + i);
loader1.getChildrenNames(singleFqn ? fqn.getParent() : fqns.get(r.nextInt(fqns.size())).getParent());
TestingUtil.sleepRandom(50);
}
@@ -365,7 +365,7 @@
latch.await();
for (int i = 0; i < loops; i++)
{
- System.out.println("R3 in loop " + i);
+// System.out.println("R3 in loop " + i);
loader1.getChildrenNames(singleFqn ? fqn : fqns.get(r.nextInt(fqns.size())));
TestingUtil.sleepRandom(50);
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/DataSourceIntegrationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/DataSourceIntegrationTest.java 2008-12-09 15:01:40 UTC (rev 7268)
+++ core/trunk/src/test/java/org/jboss/cache/loader/DataSourceIntegrationTest.java 2008-12-09 15:04:25 UTC (rev 7269)
@@ -36,6 +36,7 @@
private final String FACTORY = "org.jboss.cache.transaction.DummyContextFactory";
private final String JNDI_NAME = "java:/MockDS";
private CacheSPI cache;
+ private Properties props;
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
@@ -62,37 +63,31 @@
*/
public void testDataSourceIntegration() throws Exception
{
- Properties props = null;
+ props = null;
+ Context context = new InitialContext();
try
{
- Context context = new InitialContext();
- try
- {
Object obj = context.lookup(JNDI_NAME);
- assertNull(JNDI_NAME + " not bound", obj);
- }
- catch (NameNotFoundException n)
- {
- // expected
- }
- props = TestDbPropertiesFactory.getTestDbProperties();
- cache = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(false);
- cache.getConfiguration().setCacheMode("local");
- cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
- cache.getConfiguration().setCacheLoaderConfig(getCacheLoaderConfig(props));
- cache.create();
-
-
- context.bind(JNDI_NAME, new MockDataSource(props));
- assertNotNull(JNDI_NAME + " bound", context.lookup(JNDI_NAME));
- cache.start();
-
- assertNotNull("Cache has a cache loader", cache.getCacheLoaderManager().getCacheLoader());
+ assertNull(JNDI_NAME + " not bound", obj);
}
- finally
+ catch (NameNotFoundException n)
{
- TestDbPropertiesFactory.shutdownInMemoryDatabase(props);
+ // expected
}
+ props = TestDbPropertiesFactory.getTestDbProperties();
+ cache = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(false);
+ cache.getConfiguration().setCacheMode("local");
+ cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+ cache.getConfiguration().setCacheLoaderConfig(getCacheLoaderConfig(props));
+ cache.create();
+
+
+ MockDataSource ds = new MockDataSource(props);
+ context.bind(JNDI_NAME, ds);
+ assertNotNull(JNDI_NAME + " bound", context.lookup(JNDI_NAME));
+ cache.start();
+
+ assertNotNull("Cache has a cache loader", cache.getCacheLoaderManager().getCacheLoader());
}
@AfterMethod(alwaysRun = true)
@@ -103,6 +98,7 @@
if (cache != null)
{
TestingUtil.killCaches(cache);
+ TestDbPropertiesFactory.shutdownInMemoryDatabase(props);
cache = null;
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/DummyInMemoryCacheLoaderPessimisticTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/DummyInMemoryCacheLoaderPessimisticTest.java 2008-12-09 15:01:40 UTC (rev 7268)
+++ core/trunk/src/test/java/org/jboss/cache/loader/DummyInMemoryCacheLoaderPessimisticTest.java 2008-12-09 15:04:25 UTC (rev 7269)
@@ -16,7 +16,6 @@
{
// use the shared variation of the DIMCL so that state is persisted in a static variable in memory rather than an
// instance one.
- CacheSPI<Object, Object> cache = cacheTL.get();
CacheLoaderConfig clc = getSingleCacheLoaderConfig("", DummySharedInMemoryCacheLoader.class.getName(), "debug=true \n bin=" + getClass().getName(), false, true, false);
cache.getConfiguration().setCacheLoaderConfig(clc);
cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
Modified: core/trunk/src/test/java/org/jboss/cache/loader/DummyInMemoryCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/DummyInMemoryCacheLoaderTest.java 2008-12-09 15:01:40 UTC (rev 7268)
+++ core/trunk/src/test/java/org/jboss/cache/loader/DummyInMemoryCacheLoaderTest.java 2008-12-09 15:04:25 UTC (rev 7269)
@@ -11,25 +11,37 @@
@Test(groups = {"functional"}, testName = "loader.DummyInMemoryCacheLoaderTest")
public class DummyInMemoryCacheLoaderTest extends CacheLoaderTestsBase
{
+
+ DummySharedInMemoryCacheLoader dimCl;
+
protected void configureCache() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
-
// use the shared variation of the DIMCL so that state is persisted in a static variable in memory rather than an
// instance one.
String bin = "DummyInMemoryCacheLoader-" + Thread.currentThread().getName();
CacheLoaderConfig clc = getSingleCacheLoaderConfig("", DummySharedInMemoryCacheLoader.class.getName(), "bin=" + bin, false, true, false);
cache.getConfiguration().setCacheLoaderConfig(clc);
}
-
+
+ protected void postConfigure()
+ {
+ CacheLoader loader = cache.getCacheLoaderManager().getCacheLoader();
+ if (loader instanceof AbstractDelegatingCacheLoader)
+ {
+ dimCl = (DummySharedInMemoryCacheLoader) ((ReadOnlyDelegatingCacheLoader)loader).getCacheLoader();
+ }
+ else
+ {
+ dimCl = (DummySharedInMemoryCacheLoader) loader;
+ }
+ }
+
@Override
protected void cleanup()
{
- DummySharedInMemoryCacheLoader loader = (DummySharedInMemoryCacheLoader) loaderTL.get();
- if (loader != null) {
- loader.wipeBin();
- loaderTL.set(null);
+ if (dimCl != null) {
+ dimCl.wipeBin();
}
}
-
+
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/FileCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/FileCacheLoaderTest.java 2008-12-09 15:01:40 UTC (rev 7268)
+++ core/trunk/src/test/java/org/jboss/cache/loader/FileCacheLoaderTest.java 2008-12-09 15:04:25 UTC (rev 7269)
@@ -11,7 +11,6 @@
{
protected void configureCache() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
String threadId = Thread.currentThread().getName();
String tmpCLLoc = TestingUtil.TEST_FILES + "/JBossCache-FileCacheLoaderTest-" + threadId;
cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("", "org.jboss.cache.loader.FileCacheLoader", "location=" + tmpCLLoc, false, true, false));
Modified: core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderConfigTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderConfigTest.java 2008-12-09 15:01:40 UTC (rev 7268)
+++ core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderConfigTest.java 2008-12-09 15:04:25 UTC (rev 7269)
@@ -21,7 +21,7 @@
*
* @author <a href="mailto:galder.zamarreno@jboss.com">Galder Zamarreno</a>
*/
-@Test(groups = {"unit"}, sequential = true, testName = "loader.JDBCCacheLoaderConfigTest")
+@Test(groups = {"unit"}, testName = "loader.JDBCCacheLoaderConfigTest")
public class JDBCCacheLoaderConfigTest
{
private AdjListJDBCCacheLoaderConfig cacheLoaderConfig;
Modified: core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderDerbyDSTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderDerbyDSTest.java 2008-12-09 15:01:40 UTC (rev 7268)
+++ core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderDerbyDSTest.java 2008-12-09 15:04:25 UTC (rev 7269)
@@ -6,21 +6,20 @@
*/
package org.jboss.cache.loader;
-import org.apache.derby.jdbc.EmbeddedXADataSource;
import org.jboss.cache.Fqn;
+import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.transaction.DummyTransactionManager;
+import org.jboss.cache.util.TestDbPropertiesFactory;
+import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
+import org.hsqldb.jdbc.jdbcDataSource;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NameNotFoundException;
import java.util.Properties;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.util.TestingUtil;
-import org.jboss.cache.util.TestDbPropertiesFactory;
/**
* This test runs cache loader tests using Database as the cache loader store.
@@ -41,7 +40,7 @@
private final String FACTORY = "org.jboss.cache.transaction.DummyContextFactory";
private final String JNDI_NAME = "java:/DerbyDS";
private Properties prop;
- private EmbeddedXADataSource ds;
+ private jdbcDataSource ds;
protected void configureCache() throws Exception
{
@@ -62,20 +61,16 @@
prop = TestDbPropertiesFactory.getTestDbProperties();
- ds = new EmbeddedXADataSource();
- ds.setDatabaseName(TestDbPropertiesFactory.getDatabaseName(prop));
- ds.setCreateDatabase("create");
- ds.setUser(prop.getProperty("cache.jdbc.user"));
- ds.setPassword(prop.getProperty("cache.jdbc.password"));
+ ds = new jdbcDataSource();
+ ds.setDatabase(prop.getProperty("cache.jdbc.url"));
+ ds.setUser("sa");
-
String props = "cache.jdbc.datasource =" + JNDI_NAME + "\n" +
"cache.jdbc.node.type=" + prop.getProperty("cache.jdbc.node.type") + "\n" +
"cache.jdbc.sql-concat= 1 || 2" + "\n" +
- "cache.jdbc.table.name=jbosscache" + TestingUtil.getThreadId() + "\n" +
- "cache.jdbc.table.primarykey=jbosscache_pk" + TestingUtil.getThreadId();
+ "cache.jdbc.table.name=jbosscache" + "\n" +
+ "cache.jdbc.table.primarykey=jbosscache_pk";
- CacheSPI<Object, Object> cache = cacheTL.get();
CacheLoaderConfig config = getSingleCacheLoaderConfig("", "org.jboss.cache.loader.JDBCCacheLoader", props, false, true, false);
cache.getConfiguration().setCacheLoaderConfig(config);
cache.create();
@@ -87,13 +82,12 @@
protected void cleanup()
{
- ds.setShutdownDatabase("shutdown");
+// ds.setShutdownDatabase("shutdown");
TestDbPropertiesFactory.shutdownInMemoryDatabase(prop);
}
public void testLargeObject()
{
- CacheLoader loader = loaderTL.get();
try
{
String key = "LargeObj";
@@ -153,4 +147,9 @@
}
*/
}
+
+ public void testRemoveData()
+ {
+ super.testRemoveData();
+ }
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderStateTransferTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderStateTransferTest.java 2008-12-09 15:01:40 UTC (rev 7268)
+++ core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderStateTransferTest.java 2008-12-09 15:04:25 UTC (rev 7269)
@@ -25,12 +25,15 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.util.TestDbPropertiesFactory;
+import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.transaction.GenericTransactionManagerLookup;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.AfterTest;
import java.util.Properties;
@@ -46,22 +49,39 @@
CacheSPI first;
CacheSPI second;
+ private Properties props1;
+ private Properties props2;
+ private long durration;
+
+ @BeforeTest
+ public void createDatabase()
+ {
+ durration = System.currentTimeMillis();
+ props1 = TestDbPropertiesFactory.getTestDbProperties();
+ props2 = TestDbPropertiesFactory.getTestDbProperties();
+ }
+
+ @AfterTest
+ public void shutDownDatabase()
+ {
+ TestDbPropertiesFactory.shutdownInMemoryDatabase(props1);
+ TestDbPropertiesFactory.shutdownInMemoryDatabase(props2);
+ System.out.println("Test execution took: " + (System.currentTimeMillis() - durration)/1000);
+ }
+
+
+
@AfterMethod
public void tearDown()
{
- if (first != null) first.stop();
- if (second != null) second.stop();
- Properties props = first.getCacheLoaderManager().getCacheLoaderConfig().getFirstCacheLoaderConfig().getProperties();
- TestDbPropertiesFactory.shutdownInMemoryDatabase(props);
- props = second.getCacheLoaderManager().getCacheLoaderConfig().getFirstCacheLoaderConfig().getProperties();
- TestDbPropertiesFactory.shutdownInMemoryDatabase(props);
+ if (first != null) TestingUtil.killCaches(first);
+ if (second != null) TestingUtil.killCaches(second);
}
- private Configuration getConfiguration() throws Exception
+ private Configuration getConfiguration(Properties props) throws Exception
{
Configuration c = new Configuration();
c.setTransactionManagerLookupClass(GenericTransactionManagerLookup.class.getName());
- Properties props = TestDbPropertiesFactory.getTestDbProperties();
CacheLoaderConfig clc = getSingleCacheLoaderConfig("/", JDBCCacheLoader.class.getName(), props, false, true, false);
clc.setPassivation(false);
clc.getFirstCacheLoaderConfig().setPurgeOnStartup(true);
@@ -73,11 +93,11 @@
public void testSimpleStateTransfer() throws Exception
{
- first = (CacheSPI) new UnitTestCacheFactory().createCache(getConfiguration());
+ first = (CacheSPI) new UnitTestCacheFactory().createCache(getConfiguration(props1));
first.put("/a/b/c", "key", "value");
first.put("/a/b/d", "key", "value");
first.put("/a/b/e", "key", "value");
- second = (CacheSPI) new UnitTestCacheFactory().createCache(getConfiguration());
+ second = (CacheSPI) new UnitTestCacheFactory().createCache(getConfiguration(props2));
assert second.get("/a/b/c","key").equals("value");
assert second.get("/a/b/d","key").equals("value");
assert second.get("/a/b/e","key").equals("value");
@@ -91,7 +111,7 @@
{
long startTime = System.currentTimeMillis();
- first = (CacheSPI) new UnitTestCacheFactory().createCache(getConfiguration());
+ first = (CacheSPI) new UnitTestCacheFactory().createCache(getConfiguration(props1));
long cacheStartTime = System.currentTimeMillis() - startTime;
System.out.println("cacheStartTime = " + cacheStartTime);
for (int i = 0; i < 5012; i++)
@@ -100,7 +120,7 @@
if (i%1000 == 0) System.out.println(i + " operations executed so far");
}
startTime = System.currentTimeMillis();
- second = (CacheSPI) new UnitTestCacheFactory().createCache(getConfiguration());
+ second = (CacheSPI) new UnitTestCacheFactory().createCache(getConfiguration(props2));
long stateTranferTime = System.currentTimeMillis() - startTime - cacheStartTime;
for (int i = 0; i < 5012; i+=100)
Modified: core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderTest.java 2008-12-09 15:01:40 UTC (rev 7268)
+++ core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderTest.java 2008-12-09 15:04:25 UTC (rev 7269)
@@ -10,9 +10,13 @@
import static org.testng.AssertJUnit.*;
import org.testng.annotations.Test;
import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.AfterTest;
import java.util.Properties;
import java.sql.DriverManager;
+import java.sql.Connection;
+import java.sql.Statement;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.util.TestDbPropertiesFactory;
@@ -35,11 +39,27 @@
@Test(groups = {"functional"}, testName = "loader.JDBCCacheLoaderTest")
public class JDBCCacheLoaderTest extends CacheLoaderTestsBase
{
+
+ protected Properties props;
+ private long durration;
+
+ @BeforeTest
+ public void createDatabase()
+ {
+ durration = System.currentTimeMillis();
+ props = TestDbPropertiesFactory.getTestDbProperties();
+ }
+
+ @AfterTest
+ public void shutDownDatabase()
+ {
+ TestDbPropertiesFactory.shutdownInMemoryDatabase(props);
+ System.out.println("Test execution took: " + (System.currentTimeMillis() - durration)/1000);
+ }
+
protected void configureCache() throws Exception
{
- String props = props2String(TestDbPropertiesFactory.getTestDbProperties());
-
- CacheSPI<Object, Object> cache = cacheTL.get();
+ String props = props2String(this.props);
cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("", JDBCCacheLoader.class.getName(), props, false, true, false));
}
@@ -60,9 +80,7 @@
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
TestingUtil.killCaches(cache);
- Properties props = cacheTL.get().getConfiguration().getCacheLoaderConfig().getIndividualCacheLoaderConfigs().get(0).getProperties();
TestDbPropertiesFactory.shutdownInMemoryDatabase(props);
}
@@ -74,7 +92,6 @@
public void testLargeObject()
{
- CacheLoader loader = loaderTL.get();
try
{
String key = "LargeObj";
@@ -107,8 +124,9 @@
public void testRootIsCreated() throws Exception
{
- CacheLoader loader = loaderTL.get();
loader.put(Fqn.fromString("/a/b/c"), "a", "b");
assertTrue(loader.exists(Fqn.ROOT));
}
+
+
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/JdbmCacheLoader2Test.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/JdbmCacheLoader2Test.java 2008-12-09 15:01:40 UTC (rev 7268)
+++ core/trunk/src/test/java/org/jboss/cache/loader/JdbmCacheLoader2Test.java 2008-12-09 15:04:25 UTC (rev 7269)
@@ -16,7 +16,6 @@
@Override
protected void configureCache() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
String tmpDir = System.getProperty("java.io.tmpdir", "/tmp");
String threadId = Thread.currentThread().getName();
String tmpCLLoc = tmpDir + "/JBossCache-JdbmCacheLoader2Test-" + threadId;
Modified: core/trunk/src/test/java/org/jboss/cache/loader/JdbmCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/JdbmCacheLoaderTest.java 2008-12-09 15:01:40 UTC (rev 7268)
+++ core/trunk/src/test/java/org/jboss/cache/loader/JdbmCacheLoaderTest.java 2008-12-09 15:04:25 UTC (rev 7269)
@@ -15,7 +15,6 @@
{
protected void configureCache() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
String tmpDir = TestingUtil.TEST_FILES;
String threadId = Thread.currentThread().getName();
String tmpCLLoc = tmpDir + "/JBossCache-JdbmCacheLoaderTest-" + threadId;
Modified: core/trunk/src/test/java/org/jboss/cache/loader/LocalDelegatingCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/LocalDelegatingCacheLoaderTest.java 2008-12-09 15:01:40 UTC (rev 7268)
+++ core/trunk/src/test/java/org/jboss/cache/loader/LocalDelegatingCacheLoaderTest.java 2008-12-09 15:04:25 UTC (rev 7269)
@@ -14,8 +14,6 @@
protected void configureCache() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
-
delegating_cache = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(false);
delegating_cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
delegating_cache.create();
@@ -32,7 +30,7 @@
protected void postConfigure()
{
- CacheLoader ldr = loaderTL.get();
+ CacheLoader ldr = loader;
LocalDelegatingCacheLoader ldcl = null;
do
{
Modified: core/trunk/src/test/java/org/jboss/cache/loader/S3CacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/S3CacheLoaderTest.java 2008-12-09 15:01:40 UTC (rev 7268)
+++ core/trunk/src/test/java/org/jboss/cache/loader/S3CacheLoaderTest.java 2008-12-09 15:04:25 UTC (rev 7269)
@@ -35,8 +35,6 @@
@Override
protected void configureCache() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
-
String accessKey = System.getProperty("accessKey");
String properties;
if (accessKey == null)
@@ -85,7 +83,6 @@
protected void postConfigure()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
cache.removeNode(Fqn.root());
}
Modified: core/trunk/src/test/java/org/jboss/cache/lock/IdentityLockTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/IdentityLockTest.java 2008-12-09 15:01:40 UTC (rev 7268)
+++ core/trunk/src/test/java/org/jboss/cache/lock/IdentityLockTest.java 2008-12-09 15:04:25 UTC (rev 7269)
@@ -546,7 +546,7 @@
{
for (int i = 0; i < opCount; i++)
{
- if (i % 10 == 0) System.out.println("readLockChanger loop# " + i);
+// if (i % 10 == 0) System.out.println("readLockChanger loop# " + i);
lockMap.addReader(new Object());
}
}
@@ -562,7 +562,7 @@
{
if (i % 10 == 0)
{
- System.out.println("toStringProcessor loop# " + i + ", " + (System.currentTimeMillis() - initialTime));
+// System.out.println("toStringProcessor loop# " + i + ", " + (System.currentTimeMillis() - initialTime));
initialTime = System.currentTimeMillis();
}
try
Modified: core/trunk/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java 2008-12-09 15:01:40 UTC (rev 7268)
+++ core/trunk/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java 2008-12-09 15:04:25 UTC (rev 7269)
@@ -2,13 +2,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheException;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.Modification;
-import org.jboss.cache.Node;
-import org.jboss.cache.NodeSPI;
-import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.*;
import org.jboss.cache.loader.AbstractCacheLoaderTestBase;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.SamplePojo;
@@ -26,11 +20,7 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
/**
* Base tests for passivation using any of the cache loaders
@@ -45,26 +35,22 @@
Log log = LogFactory.getLog(getClass());
//Cache Loader fields
- protected ThreadLocal<CacheSPI<Object, Object>> cacheTL = new ThreadLocal<CacheSPI<Object, Object>>();
- ThreadLocal<CacheLoader> loaderTL = new ThreadLocal<CacheLoader>();
static final Fqn FQN = Fqn.fromString("/key");
+ protected CacheLoader loader;
+ protected CacheSPI<Object, Object> cache;
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(false);
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(false);
cache.getConfiguration().setCacheMode("local");
- cacheTL.set(cache);
-
configureCache();
cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
cache.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZABLE);
cache.create();
cache.start();
- CacheLoader loader = cache.getCacheLoaderManager().getCacheLoader();
-
- loaderTL.set(loader);
+ loader = cache.getCacheLoaderManager().getCacheLoader();
}
abstract protected void configureCache() throws Exception;
@@ -73,9 +59,6 @@
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
log.info("**** TEARING DOWN ****");
if (loader != null) loader.remove(Fqn.ROOT);
TestingUtil.killCaches(cache);
@@ -95,7 +78,6 @@
*/
protected boolean exists(String fqn, String key)
{
- CacheSPI<Object, Object> cache = cacheTL.get();
NodeSPI n = cache.peek(Fqn.fromString(fqn), false, false);
if (key == null) return n != null;
return n != null && n.getKeysDirect().contains(key);
@@ -108,9 +90,6 @@
public void testPutPassivation() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
final Fqn NODE = Fqn.fromString("/test");
final String KEY = "key";
Object retval;
@@ -130,9 +109,6 @@
public void testPut2Passivation() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
final Fqn NODE = Fqn.fromString("/a/b/c");
final String KEY = "key";
Object retval;
@@ -156,9 +132,6 @@
public void testSerializationPassivation() throws CacheException
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
Fqn fqn = Fqn.fromString("/mypojo");
SamplePojo pojo = new SamplePojo(39, "Hany");
pojo.getHobbies().add("Running");
@@ -196,8 +169,6 @@
*/
public void testPopulate()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
-
try
{
Map<Object, Object> m = new HashMap<Object, Object>();
@@ -235,9 +206,6 @@
public void testPreloadingPassivation() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
cache.removeNode(Fqn.ROOT);// remove nothing
cache.put("1/2/3/4/5/d", "key", "val");// put in memory
cache.evict(Fqn.fromString("1/2/3/4/5/d"));// passivate node
@@ -262,8 +230,6 @@
public void testCacheLoading2() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
-
Set<Object> keys = null;
cache.put("/a/b/c", "key", "val");
keys = cache.getNode(Fqn.fromString("/a/b/c")).getKeys();
@@ -274,8 +240,6 @@
public void testExists() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
-
cache.put("/eins/zwei/drei", "key1", "val1");
assert (exists("/eins/zwei/drei"));
assert (exists("/eins/zwei/drei", "key1"));
@@ -286,8 +250,6 @@
public void testGetChildren() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
-
cache.put("/d/one", null);
cache.put("/d/two", null);
cache.put("/d/three", null);
@@ -303,9 +265,6 @@
public void testGetChildrenWithEvictionPassivation() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
cache.put("/a/b/c/1", null);
cache.put("/a/b/c/2", null);
cache.put("/a/b/c/3", null);
@@ -339,7 +298,6 @@
public void testGetChildren2()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
try
{
cache.put("/1", null);
@@ -358,7 +316,6 @@
public void testGetChildren3()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
try
{
cache.put("/1", null);
@@ -377,8 +334,6 @@
public void testGetChildren4()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
-
if (!cache.exists("/a/b/c"))
{
cache.put("/a/b/c", null);
@@ -390,7 +345,7 @@
public void testGetChildren5()
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
try
{
cache.put("/a/1", null);
@@ -413,9 +368,6 @@
public void testGetChildren6Passivation() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
cache.put("/a/1", null);// put node in memory
cache.put("/a/2", null);// put node in memory
cache.put("/a/3", null);// put node in memory
@@ -443,9 +395,6 @@
public void testGetChildren7Passivation() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
cache.put("/a/1", null);
cache.put("/a/2", null);
cache.put("/a/3", null);
@@ -475,9 +424,6 @@
public void testGetChildren8Passivation() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
cache.put("/a/1", null);
cache.put("/a/2", null);
cache.put("/a/3", null);
@@ -501,9 +447,6 @@
public void testGetChildren9Passivation() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
cache.put("/a/1", null);
cache.put("/a/2", null);
cache.put("/a/3", null);
@@ -550,9 +493,6 @@
public void testGetChildren10Passivation() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
cache.put("/a/1", null);
cache.put("/a/2", null);
cache.put("/a/3", null);
@@ -583,8 +523,8 @@
public void testRemoveData() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
+
String key = "/x/y/z/";
cache.put(key, "keyA", "valA");
cache.put(key, "keyB", "valB");
@@ -601,9 +541,6 @@
public void testRemoveData2Passivation() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
Set<Object> keys;
Fqn key = Fqn.fromString("/x/y/z/");
cache.put(key, "keyA", "valA");
@@ -623,9 +560,6 @@
public void testRemoveData3Passivation() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
Set<Object> keys;
Fqn key = Fqn.fromString("/x/y/z/");
cache.put(key, "keyA", "valA");
@@ -643,8 +577,6 @@
public void testRemoveKey() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
-
String key = "/x/y/z/";
cache.put(key, "keyA", "valA");
cache.put(key, "keyB", "valB");
@@ -657,8 +589,6 @@
public void testRemoveKey2() throws CacheException
{
- CacheSPI<Object, Object> cache = cacheTL.get();
-
final Fqn NODE = Fqn.fromString("/test");
final String KEY = "key";
Object retval = null;
@@ -675,9 +605,6 @@
public void testRemoveKey3Passivation() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
final Fqn NODE = Fqn.fromString("/test");
final String KEY = "key";
Object retval = null;
@@ -703,8 +630,6 @@
public void testRemove() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
-
String key = "/x/y/z/";
cache.put(key, "keyA", "valA");
cache.put(key, "keyB", "valB");
@@ -720,8 +645,6 @@
public void testRemoveRoot() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
-
assertEquals(0, cache.getRoot().getKeys().size());
cache.put("/1/2/3/4/5", null);
cache.put("uno/due/tre", null);
@@ -735,9 +658,6 @@
public void testEvictionWithCacheLoaderPassivation() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
cache.put("/first/second", "key1", "val1");
cache.put("/first/second/third", "key2", "val2");
cache.evict(Fqn.fromString("/first/second"));// pasivate node to cache loader
@@ -758,9 +678,6 @@
public void testEvictionWithCacheLoaderPassivation2() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
cache.put("/first/second/third", "key1", "val1");// stored in cache loader
cache.evict(Fqn.fromString("/first/second/third"));// passivate node, note: it has no children
addDelay();
@@ -778,9 +695,6 @@
public void testEvictionWithGetChildrenNamesPassivation() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
cache.put("/a/1", null);
cache.put("/a/2", null);
cache.put("/a/3", null);
@@ -807,9 +721,6 @@
public void testPutDataMapAfterPassivation() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
Fqn f = Fqn.fromString("/a");
assert !cache.exists(f);
assert !loader.exists(f);
@@ -835,9 +746,6 @@
public void testTxPutCommit() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
DummyTransactionManager mgr = DummyTransactionManager.getInstance();
mgr.begin();
@@ -864,9 +772,6 @@
public void testTxReadCommit() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
DummyTransactionManager mgr = DummyTransactionManager.getInstance();
mgr.begin();
@@ -899,9 +804,6 @@
public void testTxPutRollback() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
DummyTransactionManager mgr = DummyTransactionManager.getInstance();
cache.removeNode("/one");
@@ -922,9 +824,6 @@
public void testPassivationAndActivation() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
Object val, val2;
Fqn NODE = Fqn.fromString("/test");
loader.remove(Fqn.fromString("/"));
@@ -973,8 +872,6 @@
*/
private void doTestBasicOperations() throws Exception
{
- CacheLoader loader = loaderTL.get();
-
/* One FQN only. */
doPutTests(Fqn.fromString("/key"));
doRemoveTests(Fqn.fromString("/key"));
@@ -1004,8 +901,6 @@
private void doPutTests(Fqn fqn)
throws Exception
{
- CacheLoader loader = loaderTL.get();
-
assertTrue(!loader.exists(fqn));
/* put(Fqn,Object,Object) and get(Fqn,Object) */
@@ -1052,8 +947,6 @@
private void doRemoveTests(Fqn fqn)
throws Exception
{
- CacheLoader loader = loaderTL.get();
-
/* remove(Fqn,Object) */
Object oldVal;
oldVal = loader.remove(fqn, "one");
@@ -1086,8 +979,6 @@
public void testMultiLevelTree()
throws Exception
{
- CacheLoader loader = loaderTL.get();
-
/* Create top level node implicitly. */
Fqn k0 = Fqn.fromString("/key0");
@@ -1253,8 +1144,6 @@
public void testGetChildrenNames()
throws Exception
{
- CacheLoader loader = loaderTL.get();
-
checkChildren(Fqn.ROOT, null);
checkChildren(Fqn.fromString("/key0"), null);
@@ -1295,26 +1184,6 @@
checkChildren(Fqn.fromString("/key0/a"), new String[]{"1", "2"});
checkChildren(Fqn.fromString("/key0"),
new String[]{"a", "ab", "abc", "x", "xx", "xxx"});
- //
- // loader.put(Fqn.fromString("/key0/\u0000"), null);
- // loader.put(Fqn.fromString("/key0/\u0001"), null);
- // checkChildren(Fqn.fromString("/key0"),
- // new String[] { "a", "ab", "abc", "x", "xx", "xxx",
- // "\u0000", "\u0001"});
- //
- // loader.put(Fqn.fromString("/\u0001"), null);
- // checkChildren(new Fqn(), new String[] { "key0", "key1", "\u0001" });
- //
- // loader.put(Fqn.fromString("/\u0001/\u0001"), null);
- // checkChildren(Fqn.fromString("/\u0001"), new String[] { "\u0001" });
- //
- // loader.put(Fqn.fromString("/\u0001/\uFFFF"), null);
- // checkChildren(Fqn.fromString("/\u0001"),
- // new String[] { "\u0001", "\uFFFF" });
- //
- // loader.put(Fqn.fromString("/\u0001/\uFFFF/\u0001"), null);
- // checkChildren(Fqn.fromString("/\u0001/\uFFFF"),
- // new String[] { "\u0001" });
}
/**
@@ -1323,8 +1192,6 @@
private void checkChildren(Fqn fqn, String[] names)
throws Exception
{
- CacheLoader loader = loaderTL.get();
-
Set set = loader.getChildrenNames(fqn);
if (names != null)
{
@@ -1368,8 +1235,6 @@
private void doTestModifications()
throws Exception
{
- CacheLoader loader = loaderTL.get();
-
/* PUT_KEY_VALUE, PUT_DATA */
List<Modification> list = createUpdates();
loader.put(list);
@@ -1416,8 +1281,6 @@
public void testOnePhaseTransaction()
throws Exception
{
- CacheLoader loader = loaderTL.get();
-
List<Modification> mods = createUpdates();
loader.prepare(null, mods, true);
checkModifications(mods);
@@ -1429,15 +1292,9 @@
public void testTwoPhaseTransactionPassivation()
throws Exception
{
- CacheLoader loader = loaderTL.get();
-
Object txnKey = new Object();
List<Modification> mods = createUpdates();
loader.prepare(txnKey, mods, false);
- // try {
- // checkModifications(mods);
- // // fail("Expected lock timeout");
- // } catch (DeadlockException expected) {}
loader.commit(txnKey);
addDelay();
checkModifications(mods);
@@ -1449,8 +1306,6 @@
public void testTransactionRollbackPassivation()
throws Exception
{
- CacheLoader loader = loaderTL.get();
-
loader.remove(Fqn.fromString("/"));
ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
@@ -1477,7 +1332,6 @@
*/
private List<Modification> createUpdates()
{
-
List<Modification> list = new ArrayList<Modification>();
Map<String, String> map = new HashMap<String, String>();
@@ -1512,8 +1366,6 @@
private void checkModifications(List<Modification> list)
throws Exception
{
- CacheLoader loader = loaderTL.get();
-
for (Modification mod : list)
{
Fqn fqn = mod.getFqn();
@@ -1553,8 +1405,6 @@
public void testNullKeysAndValues()
throws Exception
{
- CacheLoader loader = loaderTL.get();
-
loader.put(FQN, null, "x");
addDelay();
assertEquals("x", loader.get(FQN).get(null));
@@ -1609,8 +1459,6 @@
public void testDatabaseNamePassivation()
throws Exception
{
- CacheLoader loader = loaderTL.get();
-
loader.put(FQN, "one", "two");
addDelay();
assertEquals("two", loader.get(FQN).get("one"));
@@ -1622,17 +1470,8 @@
public void testLoadAndStore()
throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
-
/* Empty state. */
loader.remove(Fqn.fromString("/"));
- // assertEquals(0, loader.loadEntireState().length);
- // loader.storeEntireState(new byte[0]);
- // assertEquals(0, loader.loadEntireState().length);
- // loader.storeEntireState(null);
- // assertEquals(0, loader.loadEntireState().length);
- // assertEquals(null, loader.get(FQN));
/* Use a complex object to ensure that the class catalog is used. */
Complex c1 = new Complex();
Modified: core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToBdbjeCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToBdbjeCacheLoaderTest.java 2008-12-09 15:01:40 UTC (rev 7268)
+++ core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToBdbjeCacheLoaderTest.java 2008-12-09 15:04:25 UTC (rev 7269)
@@ -56,8 +56,6 @@
String tmpDir = TestingUtil.TEST_FILES;
String threadId = Thread.currentThread().getName();
String tmpCLLoc = tmpDir + "/JBossCache-PassivationToBdbjeCacheLoaderTest-" + threadId;
-
- CacheSPI<Object, Object> cache = cacheTL.get();
cache.getConfiguration().setCacheLoaderConfig(buildSingleCacheLoaderConfig(true, null, "org.jboss.cache.loader.bdbje.BdbjeCacheLoader", "location=" + tmpCLLoc, false, false, false, false, false));
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToDummyInMemoryCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToDummyInMemoryCacheLoaderTest.java 2008-12-09 15:01:40 UTC (rev 7268)
+++ core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToDummyInMemoryCacheLoaderTest.java 2008-12-09 15:04:25 UTC (rev 7269)
@@ -10,7 +10,6 @@
{
protected void configureCache() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
CacheLoaderConfig clc = new CacheLoaderConfig();
cache.getConfiguration().setCacheLoaderConfig(clc);
CacheLoaderConfig.IndividualCacheLoaderConfig iclc = new CacheLoaderConfig.IndividualCacheLoaderConfig();
Modified: core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToFileCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToFileCacheLoaderTest.java 2008-12-09 15:01:40 UTC (rev 7268)
+++ core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToFileCacheLoaderTest.java 2008-12-09 15:04:25 UTC (rev 7269)
@@ -31,7 +31,6 @@
String threadId = Thread.currentThread().getName();
String tmpCLLoc = tmpLocation + "/JBossCache-PassivationToFileCacheLoaderTest-" + threadId;
- CacheSPI<Object, Object> cache = cacheTL.get();
cache.getConfiguration().setCacheLoaderConfig(buildSingleCacheLoaderConfig(true, null, "org.jboss.cache.loader.FileCacheLoader", "location=" + tmpCLLoc, false, false, false, false, false));
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToJDBCCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToJDBCCacheLoaderTest.java 2008-12-09 15:01:40 UTC (rev 7268)
+++ core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToJDBCCacheLoaderTest.java 2008-12-09 15:04:25 UTC (rev 7269)
@@ -7,15 +7,16 @@
package org.jboss.cache.passivation;
import java.util.Properties;
-import org.jboss.cache.CacheSPI;
+
import org.jboss.cache.Fqn;
-import org.jboss.cache.loader.CacheLoader;
import static org.jboss.cache.factories.UnitTestCacheConfigurationFactory.*;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.util.TestDbPropertiesFactory;
import org.testng.annotations.Test;
import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.AfterTest;
/**
* Tests passivation using JDBC Cache Loader.
@@ -27,29 +28,35 @@
@Test(groups = "functional", testName = "passivation.PassivationToJDBCCacheLoaderTest")
public class PassivationToJDBCCacheLoaderTest extends PassivationTestsBase
{
- private String getJDBCProps()
+
+ private Properties props;
+ private long durration;
+
+ @BeforeTest
+ public void createDatabase()
{
- Properties prop = TestDbPropertiesFactory.getTestDbProperties();
- return "cache.jdbc.driver =" + prop.getProperty("cache.jdbc.driver") + "\n" +
- "cache.jdbc.url=" + prop.getProperty("cache.jdbc.url") + "\n" +
- "cache.jdbc.user=" + prop.getProperty("cache.jdbc.user") + "\n" +
- "cache.jdbc.password=" + prop.getProperty("cache.jdbc.password") + "\n" +
- "cache.jdbc.node.type=" + prop.getProperty("cache.jdbc.node.type") + "\n" +
- "cache.jdbc.sql-concat=" + prop.getProperty("cache.jdbc.sql-concat") + "\n" +
- "cache.jdbc.table.name=passivationtojdbc" + TestingUtil.getThreadId() + "\n" +
- "cache.jdbc.table.primarykey=passivationtojdbc_pk" + TestingUtil.getThreadId();
-
+ durration = System.currentTimeMillis();
+ props = TestDbPropertiesFactory.getTestDbProperties();
}
+ @AfterTest
+ public void shutDownDatabase()
+ {
+ TestDbPropertiesFactory.shutdownInMemoryDatabase(props);
+ System.out.println("Test execution took: " + (System.currentTimeMillis() - durration)/1000);
+ }
+
+ private Properties getJDBCProps()
+ {
+ return props;
+ }
+
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- CacheSPI<Object, Object> cache = cacheTL.get();
- CacheLoader loader = loaderTL.get();
log.info("**** TEARING DOWN ****");
if (loader != null) loader.remove(Fqn.ROOT);
TestingUtil.killCaches(cache);
- Properties props = loader.getConfig().getProperties();
TestDbPropertiesFactory.shutdownInMemoryDatabase(props);
}
@@ -58,7 +65,6 @@
{
CacheLoaderConfig loaderConfig = buildSingleCacheLoaderConfig(true, null, "org.jboss.cache.loader.JDBCCacheLoader",
getJDBCProps(), false, false, false, false, false);
- CacheSPI<Object, Object> cache = cacheTL.get();
cache.getConfiguration().setCacheLoaderConfig(loaderConfig);
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToLocalDelegatingCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToLocalDelegatingCacheLoaderTest.java 2008-12-09 15:01:40 UTC (rev 7268)
+++ core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToLocalDelegatingCacheLoaderTest.java 2008-12-09 15:04:25 UTC (rev 7269)
@@ -37,7 +37,6 @@
CacheLoaderConfig cacheLoaderConfig = new CacheLoaderConfig();
cacheLoaderConfig.addIndividualCacheLoaderConfig(cfg);
cacheLoaderConfig.setPassivation(true);
- CacheSPI<Object, Object> cache = cacheTL.get();
cache.getConfiguration().setCacheLoaderConfig(cacheLoaderConfig);
}
Modified: core/trunk/src/test/java/org/jboss/cache/util/TestDbPropertiesFactory.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/util/TestDbPropertiesFactory.java 2008-12-09 15:01:40 UTC (rev 7268)
+++ core/trunk/src/test/java/org/jboss/cache/util/TestDbPropertiesFactory.java 2008-12-09 15:04:25 UTC (rev 7269)
@@ -8,6 +8,9 @@
import java.io.IOException;
import java.io.File;
import java.sql.DriverManager;
+import java.sql.Connection;
+import java.sql.Statement;
+import java.sql.SQLException;
/**
* @author Mircea.Markus(a)jboss.com
@@ -41,19 +44,37 @@
public static void shutdownInMemoryDatabase(Properties props)
{
+ Connection conn = null;
+ Statement st = null;
try
{
String shutDownConnection = getShutdownUrl(props);
+ String url = props.getProperty("cache.jdbc.url");
+ assert url != null;
System.out.println("shutDownConnection = " + shutDownConnection);
- DriverManager.getConnection(shutDownConnection);
- assert false: "Exception should be raised to confirm the DB is closed";
- //here is why: Important: The XJ015 error (successful shutdown of the Derby engine) and the 08006 error
- //(successful shutdown of a single database) are the *only exceptions thrown by Derby that might indicate that an operation succeeded*.
+ conn = DriverManager.getConnection(shutDownConnection);
+ st = conn.createStatement();
+ st.execute("SHUTDOWN");
}
catch (Throwable e)
{
- //expected
+ throw new IllegalStateException(e);
}
+ finally
+ {
+ try
+ {
+ conn.close();
+ st.close();
+ } catch (SQLException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public static void clearDatabaseFiles(Properties props)
+ {
//now delete the disk folder
String dbName = getDatabaseName(props);
String toDel = TestingUtil.TEST_FILES + File.separator + dbName;
@@ -63,10 +84,11 @@
public static String getDatabaseName(Properties prop)
{
- //jdbc:derby:jbossdb;create=true
- StringTokenizer tokenizer = new StringTokenizer(prop.getProperty("cache.jdbc.url"), ":;");
+ //jdbc:hsqldb:mem:jbosscache
+ StringTokenizer tokenizer = new StringTokenizer(prop.getProperty("cache.jdbc.url"), ":");
tokenizer.nextToken();
tokenizer.nextToken();
+ tokenizer.nextToken();
return tokenizer.nextToken();
}
@@ -83,18 +105,33 @@
private static Properties returnBasedOnDifferentInstance()
{
+ //jdbc:hsqldb:mem:jbosscache
Properties toReturn = (Properties) realProps.clone();
String jdbcUrl = toReturn.getProperty("cache.jdbc.url");
- Pattern pattern = Pattern.compile("jbossdb");
+ Pattern pattern = Pattern.compile("jbosscache");
Matcher matcher = pattern.matcher(jdbcUrl);
boolean found = matcher.find();
assert found;
- String newJdbcUrl = matcher.replaceFirst("jbossdb" + userIndex.incrementAndGet());
+ String newJdbcUrl = matcher.replaceFirst(extractTestName() + userIndex.incrementAndGet());
System.out.println("newJdbcUrl = " + newJdbcUrl);
toReturn.put("cache.jdbc.url", newJdbcUrl);
return toReturn;
}
+ private static String extractTestName()
+ {
+ StackTraceElement[] stack = Thread.currentThread().getStackTrace();
+ if (stack.length == 0) return null;
+ for (int i = stack.length - 1; i > 0; i--)
+ {
+ StackTraceElement e = stack[i];
+ String className = e.getClassName();
+ if (className.indexOf("org.jboss.cache") != -1) return className.replace('.','_') + "_" + e.getMethodName();
+ }
+ return null;
+ }
+
+
private static Properties returnBasedOnDifferentTables()
{
Properties toReturn = (Properties) realProps.clone();
Modified: core/trunk/src/test/resources/cache-jdbc.properties
===================================================================
--- core/trunk/src/test/resources/cache-jdbc.properties 2008-12-09 15:01:40 UTC (rev 7268)
+++ core/trunk/src/test/resources/cache-jdbc.properties 2008-12-09 15:04:25 UTC (rev 7269)
@@ -11,7 +11,7 @@
cache.jdbc.fqn.column=fqn
cache.jdbc.fqn.type=varchar(255)
cache.jdbc.node.column=node
-cache.jdbc.node.type=blob
+cache.jdbc.node.type=BINARY
cache.jdbc.parent.column=parent
# Specify your DBMS's string concatenation function syntax in the following manner: concat(1 , 2) -> '12'.
# This syntax should work an most popular DBMS like oracle, db2, mssql, mysql, PostgreSQL. Derby - on which
@@ -63,7 +63,8 @@
#cache.jdbc.password=admin
## Derby
-cache.jdbc.driver = org.apache.derby.jdbc.EmbeddedDriver
-cache.jdbc.url=jdbc:derby:jbossdb;create=true
-cache.jdbc.user=user1
-cache.jdbc.password=user1
+cache.jdbc.driver = org.hsqldb.jdbcDriver
+cache.jdbc.url=jdbc:hsqldb:mem:jbosscache
+cache.jdbc.user=sa
+cache.jdbc.password=
+
16 years, 3 months
JBoss Cache SVN: r7268 - core/trunk/src/main/java/org/jboss/cache/invocation.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-12-09 10:01:40 -0500 (Tue, 09 Dec 2008)
New Revision: 7268
Modified:
core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
Log:
bug fix: simple put does not overwrite values
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-12-09 12:01:25 UTC (rev 7267)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-12-09 15:01:40 UTC (rev 7268)
@@ -520,7 +520,7 @@
public void put(Fqn fqn, Map<? extends K, ? extends V> data)
{
- invokePut(fqn, data, true);
+ invokePut(fqn, data, false);
}
public void put(String fqn, Map<? extends K, ? extends V> data)
16 years, 3 months
JBoss Cache SVN: r7267 - core/branches/flat/src/main/java/org/jboss/starobrno/atomic.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-12-09 07:01:25 -0500 (Tue, 09 Dec 2008)
New Revision: 7267
Modified:
core/branches/flat/src/main/java/org/jboss/starobrno/atomic/AtomicHashMapDelta.java
Log:
Back to a LL for deltas
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/atomic/AtomicHashMapDelta.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/atomic/AtomicHashMapDelta.java 2008-12-08 23:07:39 UTC (rev 7266)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/atomic/AtomicHashMapDelta.java 2008-12-09 12:01:25 UTC (rev 7267)
@@ -27,7 +27,7 @@
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
-import java.util.ArrayList;
+import java.util.LinkedList;
import java.util.List;
/**
@@ -59,7 +59,7 @@
if (changelog == null)
{
// lazy init
- changelog = new ArrayList<Operation>();
+ changelog = new LinkedList<Operation>();
}
changelog.add(o);
}
16 years, 3 months
JBoss Cache SVN: r7266 - in pojo/trunk: src/main/java/org/jboss/cache/pojo/impl and 2 other directories.
by jbosscache-commits@lists.jboss.org
Author: jason.greene(a)jboss.com
Date: 2008-12-08 18:07:39 -0500 (Mon, 08 Dec 2008)
New Revision: 7266
Modified:
pojo/trunk/pom.xml
pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/CachedType.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/memory/FieldPersistentReference.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/memory/MethodPersistentReference.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/util/Instantiator.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/util/PrivilegedCode.java
Log:
Use propper permissions
Modified: pojo/trunk/pom.xml
===================================================================
--- pojo/trunk/pom.xml 2008-12-08 18:59:07 UTC (rev 7265)
+++ pojo/trunk/pom.xml 2008-12-08 23:07:39 UTC (rev 7266)
@@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<properties>
<jbosscache-pojo-version>3.0.0.CR3</jbosscache-pojo-version>
- <jbosscache-core-version>3.0.0-SNAPSHOT</jbosscache-core-version>
+ <jbosscache-core-version>3.0.1.GA</jbosscache-core-version>
<jboss.aop.version>2.0.0.GA</jboss.aop.version>
</properties>
<parent>
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/CachedType.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/CachedType.java 2008-12-08 18:59:07 UTC (rev 7265)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/CachedType.java 2008-12-08 23:07:39 UTC (rev 7266)
@@ -8,14 +8,10 @@
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.WeakHashMap;
-import org.jboss.aop.Advisor;
-import org.jboss.aop.joinpoint.FieldInvocation;
import org.jboss.cache.pojo.memory.FieldPersistentReference;
import org.jboss.cache.pojo.memory.PersistentReference;
import org.jboss.cache.pojo.util.PrivilegedCode;
@@ -30,6 +26,8 @@
public class CachedType
{
+ private static PrivilegedCode priv = new PrivilegedCode();
+
// Types that are considered "primitive".
private static final Set<Object> immediates =
new HashSet<Object>(Arrays.asList(new Object[]{
@@ -97,7 +95,7 @@
{
return fields;
}
-
+
public List<FieldPersistentReference> getFinalFields()
{
return finalFields;
@@ -217,13 +215,13 @@
Field f = classFields[i];
if (isNonReplicable(f)) continue;
- PrivilegedCode.setAccessible(f);
+ priv.setAccessible(f);
FieldPersistentReference persistentRef = new FieldPersistentReference(f, PersistentReference.REFERENCE_SOFT);
fields.add(persistentRef);
fieldMap.put(f.getName(), persistentRef);
-
+
if (Modifier.isFinal(f.getModifiers()))
finalFields.add(persistentRef);
}
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/memory/FieldPersistentReference.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/memory/FieldPersistentReference.java 2008-12-08 18:59:07 UTC (rev 7265)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/memory/FieldPersistentReference.java 2008-12-08 23:07:39 UTC (rev 7266)
@@ -33,6 +33,7 @@
*/
public class FieldPersistentReference extends PersistentReference
{
+ private static PrivilegedCode priv = new PrivilegedCode();
private String name;
@@ -50,7 +51,7 @@
if ((returnValue = internalGet()) != null) return returnValue;
Field field = getMappedClass().getDeclaredField(name);
- PrivilegedCode.setAccessible(field);
+ priv.setAccessible(field);
buildReference(field);
return field;
}
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/memory/MethodPersistentReference.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/memory/MethodPersistentReference.java 2008-12-08 18:59:07 UTC (rev 7265)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/memory/MethodPersistentReference.java 2008-12-08 23:07:39 UTC (rev 7266)
@@ -32,6 +32,8 @@
*/
public class MethodPersistentReference extends ArgumentPersistentReference
{
+ private static PrivilegedCode priv = new PrivilegedCode();
+
public MethodPersistentReference(Method method, int referenceType)
{
super(method != null ? method.getDeclaringClass() : null, method, referenceType);
@@ -52,7 +54,7 @@
if ((returnValue = internalGet()) != null) return returnValue;
Method aMethod = getMappedClass().getDeclaredMethod(name, getArguments());
- PrivilegedCode.setAccessible(aMethod);
+ priv.setAccessible(aMethod);
buildReference(aMethod);
return aMethod;
}
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/util/Instantiator.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/util/Instantiator.java 2008-12-08 18:59:07 UTC (rev 7265)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/util/Instantiator.java 2008-12-08 23:07:39 UTC (rev 7266)
@@ -8,12 +8,14 @@
public class Instantiator
{
+ private static PrivilegedCode priv = new PrivilegedCode();
+
private static abstract class Allocator
{
public Object allocate(Class<?> c) throws Exception
{
Constructor<?> constructor = c.getDeclaredConstructor();
- PrivilegedCode.setAccessible(constructor);
+ priv.setAccessible(constructor);
return constructor.newInstance();
}
}
@@ -47,7 +49,7 @@
{
final Class<?> clazz = Class.forName("sun.misc.Unsafe");
final Field field = clazz.getDeclaredField("theUnsafe");
- PrivilegedCode.setAccessible(field);
+ priv.setAccessible(field);
final Object object = field.get(null);
final Method method = clazz.getMethod("allocateInstance", Class.class);
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/util/PrivilegedCode.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/util/PrivilegedCode.java 2008-12-08 18:59:07 UTC (rev 7265)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/util/PrivilegedCode.java 2008-12-08 23:07:39 UTC (rev 7266)
@@ -1,6 +1,7 @@
package org.jboss.cache.pojo.util;
import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.ReflectPermission;
import java.security.AccessController;
import java.security.PrivilegedAction;
@@ -9,10 +10,19 @@
*
* @author Jason T. Greene
*/
-public class PrivilegedCode
+public final class PrivilegedCode
{
- public static void setAccessible(final AccessibleObject object)
+ private static final java.security.Permission ACCESS = new ReflectPermission("suppressAccessChecks");
+
+ public PrivilegedCode()
{
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPermission(ACCESS);
+ }
+
+ public void setAccessible(final AccessibleObject object)
+ {
if (object.isAccessible())
return;
16 years, 3 months
JBoss Cache SVN: r7265 - in core/branches/flat/src: test/java/org/jboss/starobrno/atomic and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-12-08 13:59:07 -0500 (Mon, 08 Dec 2008)
New Revision: 7265
Modified:
core/branches/flat/src/main/java/org/jboss/starobrno/atomic/AtomicHashMap.java
core/branches/flat/src/main/java/org/jboss/starobrno/atomic/AtomicHashMapDelta.java
core/branches/flat/src/test/java/org/jboss/starobrno/atomic/AtomicHashMapTest.java
core/branches/flat/src/test/java/org/jboss/starobrno/profiling/TreeProfileTest.java
Log:
Perf improvements
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/atomic/AtomicHashMap.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/atomic/AtomicHashMap.java 2008-12-08 18:24:10 UTC (rev 7264)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/atomic/AtomicHashMap.java 2008-12-08 18:59:07 UTC (rev 7265)
@@ -97,7 +97,7 @@
op.key = key;
op.newValue = value;
op.oldValue = delegate.put(key, value);
- delta.changelog.add(op);
+ delta.addOperation(op);
return op.oldValue;
}
@@ -106,7 +106,7 @@
RemoveOperation<K, V> op = new RemoveOperation<K, V>();
op.key = (K) key;
op.oldValue = delegate.remove(key);
- delta.changelog.add(op);
+ delta.addOperation(op);
return op.oldValue;
}
@@ -120,7 +120,7 @@
{
ClearOperation<K, V> op = new ClearOperation<K, V>();
op.originalEntries = (FastCopyHashMap<K, V>) delegate.clone();
- delta.changelog.add(op);
+ delta.addOperation(op);
delegate.clear();
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/atomic/AtomicHashMapDelta.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/atomic/AtomicHashMapDelta.java 2008-12-08 18:24:10 UTC (rev 7264)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/atomic/AtomicHashMapDelta.java 2008-12-08 18:59:07 UTC (rev 7265)
@@ -27,7 +27,7 @@
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
-import java.util.LinkedList;
+import java.util.ArrayList;
import java.util.List;
/**
@@ -37,7 +37,7 @@
*/
public class AtomicHashMapDelta implements Delta
{
- List<Operation> changelog = new LinkedList<Operation>();
+ private List<Operation> changelog;
private static final Log log = LogFactory.getLog(AtomicHashMapDelta.class);
private static final boolean trace = log.isTraceEnabled();
@@ -54,6 +54,16 @@
return other;
}
+ public void addOperation(Operation o)
+ {
+ if (changelog == null)
+ {
+ // lazy init
+ changelog = new ArrayList<Operation>();
+ }
+ changelog.add(o);
+ }
+
public void writeExternal(ObjectOutput out) throws IOException
{
if (trace) log.trace("Serializing changelog " + changelog);
@@ -73,4 +83,9 @@
"changelog=" + changelog +
'}';
}
+
+ public int getChangeLogSize()
+ {
+ return changelog == null ? 0 : changelog.size();
+ }
}
\ No newline at end of file
Modified: core/branches/flat/src/test/java/org/jboss/starobrno/atomic/AtomicHashMapTest.java
===================================================================
--- core/branches/flat/src/test/java/org/jboss/starobrno/atomic/AtomicHashMapTest.java 2008-12-08 18:24:10 UTC (rev 7264)
+++ core/branches/flat/src/test/java/org/jboss/starobrno/atomic/AtomicHashMapTest.java 2008-12-08 18:59:07 UTC (rev 7265)
@@ -87,7 +87,7 @@
m.put("k1", "v3");
assert m.size() == 1;
AtomicHashMapDelta d = (AtomicHashMapDelta) m.delta();
- assert !d.changelog.isEmpty();
+ assert d.getChangeLogSize() != 0;
AtomicHashMap newMap = new AtomicHashMap();
newMap.initForWriting();
Modified: core/branches/flat/src/test/java/org/jboss/starobrno/profiling/TreeProfileTest.java
===================================================================
--- core/branches/flat/src/test/java/org/jboss/starobrno/profiling/TreeProfileTest.java 2008-12-08 18:24:10 UTC (rev 7264)
+++ core/branches/flat/src/test/java/org/jboss/starobrno/profiling/TreeProfileTest.java 2008-12-08 18:59:07 UTC (rev 7265)
@@ -3,6 +3,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.lock.IsolationLevel;
+import org.jboss.cache.transaction.DummyTransactionManager;
import org.jboss.starobrno.Cache;
import org.jboss.starobrno.UnitTestCacheFactory;
import org.jboss.starobrno.config.Configuration;
@@ -43,7 +44,7 @@
Test configuration options
*/
protected static final long NUM_OPERATIONS = 1000000; // DURATION is replaced with a fixed number of operations instead.
- protected static final int NUM_THREADS = 25;
+ protected static final int NUM_THREADS = 50;
protected static final int MAX_RANDOM_SLEEP_MILLIS = 1;
protected static final int MAX_OVERALL_FQNS = 2000;
protected static final int TREE_DEPTH = 2;
@@ -59,7 +60,8 @@
cfg.setInvocationBatchingEnabled(true);
cfg.setCacheMode(Configuration.CacheMode.LOCAL);
cfg.setConcurrencyLevel(2000);
- cfg.setLockAcquisitionTimeout(60000);
+ cfg.setLockAcquisitionTimeout(120000);
+ cfg.setLockParentForChildInsertRemove(true);
cfg.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
Cache c = new UnitTestCacheFactory().createCache(cfg);
cache = new TreeCacheImpl(c);
@@ -147,8 +149,15 @@
{
public void run()
{
- // this will create the necessary nodes.
- cache.put(fqn, "key", Collections.emptyMap());
+ try
+ {
+ // this will create the necessary nodes.
+ cache.put(fqn, "key", Collections.emptyMap());
+ }
+ catch (Exception e)
+ {
+ log.warn("Caught Exception", e);
+ }
}
});
}
@@ -160,10 +169,23 @@
{
public void run()
{
- Fqn fqn = fqns.get(r.nextInt(MAX_OVERALL_FQNS));
- cache.get(fqn, "key");
- cache.put(fqn, "key", "Value");
- cache.remove(fqn, "key");
+ try
+ {
+ Fqn fqn = fqns.get(r.nextInt(MAX_OVERALL_FQNS));
+ DummyTransactionManager.getInstance().begin();
+ cache.get(fqn, "key");
+ DummyTransactionManager.getInstance().commit();
+ DummyTransactionManager.getInstance().begin();
+ cache.put(fqn, "key", "Value");
+ DummyTransactionManager.getInstance().commit();
+ DummyTransactionManager.getInstance().begin();
+ cache.remove(fqn, "key");
+ DummyTransactionManager.getInstance().commit();
+ }
+ catch (Exception e)
+ {
+ log.warn("Caught Exception", e);
+ }
}
});
}
@@ -258,25 +280,38 @@
{
Fqn fqn = fqns.get(r.nextInt(MAX_OVERALL_FQNS));
long d = 0, st = 0;
- switch (mode)
+ try
{
- case PUT:
- Object value = getRandomString();
- st = System.nanoTime();
- cache.put(fqn, "key", value);
- d = System.nanoTime() - st;
- break;
- case GET:
- st = System.nanoTime();
- cache.get(fqn, "key");
- d = System.nanoTime() - st;
- break;
- case REMOVE:
- st = System.nanoTime();
- cache.remove(fqn, "key");
- d = System.nanoTime() - st;
- break;
+ switch (mode)
+ {
+ case PUT:
+ Object value = getRandomString();
+ st = System.nanoTime();
+ DummyTransactionManager.getInstance().begin();
+ cache.put(fqn, "key", value);
+ DummyTransactionManager.getInstance().commit();
+ d = System.nanoTime() - st;
+ break;
+ case GET:
+ st = System.nanoTime();
+ DummyTransactionManager.getInstance().begin();
+ cache.get(fqn, "key");
+ DummyTransactionManager.getInstance().commit();
+ d = System.nanoTime() - st;
+ break;
+ case REMOVE:
+ st = System.nanoTime();
+ DummyTransactionManager.getInstance().begin();
+ cache.remove(fqn, "key");
+ DummyTransactionManager.getInstance().commit();
+ d = System.nanoTime() - st;
+ break;
+ }
}
+ catch (Exception e)
+ {
+ d = 0;
+ }
duration.getAndAdd(d);
}
}
16 years, 3 months
JBoss Cache SVN: r7263 - benchmarks/benchmark-fwk/trunk/cache-products/starobrno/lib.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-12-08 11:05:00 -0500 (Mon, 08 Dec 2008)
New Revision: 7263
Modified:
benchmarks/benchmark-fwk/trunk/cache-products/starobrno/lib/starobrno.jar
Log:
Modified: benchmarks/benchmark-fwk/trunk/cache-products/starobrno/lib/starobrno.jar
===================================================================
(Binary files differ)
16 years, 3 months
JBoss Cache SVN: r7262 - in benchmarks/benchmark-fwk/trunk: cache-products/ehcache-1.5.0/src/org/cachebench/cachewrappers and 14 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-12-08 09:13:38 -0500 (Mon, 08 Dec 2008)
New Revision: 7262
Added:
benchmarks/benchmark-fwk/trunk/lib/jta-1.1.jar
Modified:
benchmarks/benchmark-fwk/trunk/cache-products/coherence-3.3.1/src/org/cachebench/cachewrappers/Coherence331Wrapper.java
benchmarks/benchmark-fwk/trunk/cache-products/ehcache-1.5.0/src/org/cachebench/cachewrappers/EHCacheWrapper.java
benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-1.4.1/src/org/cachebench/cachewrappers/JBossCacheWrapper.java
benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.0.0/src/org/cachebench/cachewrappers/JBossCache200Wrapper.java
benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/src/org/cachebench/cachewrappers/JBossCache210Wrapper.java
benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.2.0/src/org/cachebench/cachewrappers/JBossCache220Wrapper.java
benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/src/org/cachebench/cachewrappers/JBossCache300Wrapper.java
benchmarks/benchmark-fwk/trunk/cache-products/pojocache-2.2.0/src/org/cachebench/cachewrappers/PojoCache220Wrapper.java
benchmarks/benchmark-fwk/trunk/cache-products/starobrno/src/org/cachebench/cachewrappers/StarobrnoWrapper.java
benchmarks/benchmark-fwk/trunk/cache-products/terracotta-2.5.0/src/org/cachebench/cachewrappers/TerracottaWrapper.java
benchmarks/benchmark-fwk/trunk/cache-products/whirlycache-1.0.1/src/org/cachebench/cachewrappers/WhirlyCacheWrapper.java
benchmarks/benchmark-fwk/trunk/conf/cachebench-local.xml
benchmarks/benchmark-fwk/trunk/conf/cachebench.xml
benchmarks/benchmark-fwk/trunk/src/org/cachebench/CacheWrapper.java
benchmarks/benchmark-fwk/trunk/src/org/cachebench/config/Configuration.java
benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/simpletests/SimpleTest.java
Log:
Now transactional too!
Modified: benchmarks/benchmark-fwk/trunk/cache-products/coherence-3.3.1/src/org/cachebench/cachewrappers/Coherence331Wrapper.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/cache-products/coherence-3.3.1/src/org/cachebench/cachewrappers/Coherence331Wrapper.java 2008-12-07 18:53:38 UTC (rev 7261)
+++ benchmarks/benchmark-fwk/trunk/cache-products/coherence-3.3.1/src/org/cachebench/cachewrappers/Coherence331Wrapper.java 2008-12-08 14:13:38 UTC (rev 7262)
@@ -7,6 +7,7 @@
import org.apache.commons.logging.LogFactory;
import org.cachebench.CacheWrapper;
+import javax.transaction.Transaction;
import java.util.List;
import java.util.Map;
@@ -122,4 +123,14 @@
result.append(key);
return result.toString();
}
+
+ public Transaction startTransaction()
+ {
+ throw new UnsupportedOperationException("Does not support JTA!");
+ }
+
+ public void endTransaction(boolean successful)
+ {
+ throw new UnsupportedOperationException("Does not support JTA!");
+ }
}
Modified: benchmarks/benchmark-fwk/trunk/cache-products/ehcache-1.5.0/src/org/cachebench/cachewrappers/EHCacheWrapper.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/cache-products/ehcache-1.5.0/src/org/cachebench/cachewrappers/EHCacheWrapper.java 2008-12-07 18:53:38 UTC (rev 7261)
+++ benchmarks/benchmark-fwk/trunk/cache-products/ehcache-1.5.0/src/org/cachebench/cachewrappers/EHCacheWrapper.java 2008-12-08 14:13:38 UTC (rev 7262)
@@ -19,7 +19,7 @@
* An implementation of SerializableCacheWrapper that uses EHCache as an underlying implementation.
* <p/>
* Pass in a -Dbind.address=IP_ADDRESS
- * ehcache propery files allows referencing system properties through syntax ${bind.address}.
+ * ehcache propery files allows referencing system properties through syntax ${bind.address}.
*
* @author Manik Surtani (manik(a)surtani.org)
* @version $Id: EHCacheWrapper.java,v 1.6 2007/05/21 16:17:56 msurtani Exp $
@@ -136,4 +136,14 @@
}
return o;
}
+
+ public Object startTransaction()
+ {
+ throw new UnsupportedOperationException("Does not support JTA!");
+ }
+
+ public void endTransaction(boolean successful)
+ {
+ throw new UnsupportedOperationException("Does not support JTA!");
+ }
}
Modified: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-1.4.1/src/org/cachebench/cachewrappers/JBossCacheWrapper.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-1.4.1/src/org/cachebench/cachewrappers/JBossCacheWrapper.java 2008-12-07 18:53:38 UTC (rev 7261)
+++ benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-1.4.1/src/org/cachebench/cachewrappers/JBossCacheWrapper.java 2008-12-08 14:13:38 UTC (rev 7262)
@@ -5,7 +5,8 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.PropertyConfigurator;
import org.jboss.cache.TreeCache;
-
+import javax.transaction.*;
+import org.jboss.cache.transaction.*;
import java.util.*;
@@ -74,4 +75,32 @@
return null;
}
+ public Transaction startTransaction()
+ {
+ try
+ {
+ DummyTransactionManager.getInstance().begin();
+ return DummyTransactionManager.getInstance().getTransaction();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void endTransaction(boolean successful)
+ {
+ try
+ {
+ if (successful)
+ DummyTransactionManager.getInstance().commit();
+ else
+ DummyTransactionManager.getInstance().rollback();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
}
Modified: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.0.0/src/org/cachebench/cachewrappers/JBossCache200Wrapper.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.0.0/src/org/cachebench/cachewrappers/JBossCache200Wrapper.java 2008-12-07 18:53:38 UTC (rev 7261)
+++ benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.0.0/src/org/cachebench/cachewrappers/JBossCache200Wrapper.java 2008-12-08 14:13:38 UTC (rev 7262)
@@ -9,7 +9,8 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.buddyreplication.GravitateResult;
import org.jboss.cache.marshall.NodeData;
-
+import javax.transaction.*;
+import org.jboss.cache.transaction.*;
import java.net.URL;
import java.util.List;
import java.util.Map;
@@ -79,4 +80,34 @@
NodeData nodeData = result.getNodeData().get(0);
return nodeData.getAttributes().get(key);
}
+
+ public Transaction startTransaction()
+ {
+ try
+ {
+ DummyTransactionManager.getInstance().begin();
+ return DummyTransactionManager.getInstance().getTransaction();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void endTransaction(boolean successful)
+ {
+ try
+ {
+ if (successful)
+ DummyTransactionManager.getInstance().commit();
+ else
+ DummyTransactionManager.getInstance().rollback();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+
}
Modified: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/src/org/cachebench/cachewrappers/JBossCache210Wrapper.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/src/org/cachebench/cachewrappers/JBossCache210Wrapper.java 2008-12-07 18:53:38 UTC (rev 7261)
+++ benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/src/org/cachebench/cachewrappers/JBossCache210Wrapper.java 2008-12-08 14:13:38 UTC (rev 7262)
@@ -9,7 +9,8 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.buddyreplication.GravitateResult;
import org.jboss.cache.marshall.NodeData;
-
+import javax.transaction.*;
+import org.jboss.cache.transaction.*;
import java.util.List;
import java.util.Map;
@@ -81,4 +82,33 @@
NodeData nodeData = result.getNodeData().get(0);
return nodeData.getAttributes().get(key);
}
+
+
+ public Transaction startTransaction()
+ {
+ try
+ {
+ DummyTransactionManager.getInstance().begin();
+ return DummyTransactionManager.getInstance().getTransaction();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void endTransaction(boolean successful)
+ {
+ try
+ {
+ if (successful)
+ DummyTransactionManager.getInstance().commit();
+ else
+ DummyTransactionManager.getInstance().rollback();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
}
Modified: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.2.0/src/org/cachebench/cachewrappers/JBossCache220Wrapper.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.2.0/src/org/cachebench/cachewrappers/JBossCache220Wrapper.java 2008-12-07 18:53:38 UTC (rev 7261)
+++ benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.2.0/src/org/cachebench/cachewrappers/JBossCache220Wrapper.java 2008-12-08 14:13:38 UTC (rev 7262)
@@ -10,7 +10,8 @@
import org.jboss.cache.InvocationContext;
import org.jboss.cache.buddyreplication.GravitateResult;
import org.jboss.cache.marshall.NodeData;
-
+import javax.transaction.*;
+import org.jboss.cache.transaction.*;
import java.util.List;
import java.util.Map;
@@ -81,4 +82,33 @@
NodeData nodeData = result.getNodeData().get(0);
return nodeData.getAttributes().get(key);
}
+
+
+ public Transaction startTransaction()
+ {
+ try
+ {
+ DummyTransactionManager.getInstance().begin();
+ return DummyTransactionManager.getInstance().getTransaction();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void endTransaction(boolean successful)
+ {
+ try
+ {
+ if (successful)
+ DummyTransactionManager.getInstance().commit();
+ else
+ DummyTransactionManager.getInstance().rollback();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
}
Modified: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/src/org/cachebench/cachewrappers/JBossCache300Wrapper.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/src/org/cachebench/cachewrappers/JBossCache300Wrapper.java 2008-12-07 18:53:38 UTC (rev 7261)
+++ benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/src/org/cachebench/cachewrappers/JBossCache300Wrapper.java 2008-12-08 14:13:38 UTC (rev 7262)
@@ -8,7 +8,8 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Option;
import org.jboss.cache.util.Caches;
-
+import javax.transaction.Transaction;
+import org.jboss.cache.transaction.*;
import java.util.List;
import java.util.Map;
@@ -100,4 +101,33 @@
option.setForceDataGravitation(true);
return get(path, key);
}
+
+
+ public Transaction startTransaction()
+ {
+ try
+ {
+ DummyTransactionManager.getInstance().begin();
+ return DummyTransactionManager.getInstance().getTransaction();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void endTransaction(boolean successful)
+ {
+ try
+ {
+ if (successful)
+ DummyTransactionManager.getInstance().commit();
+ else
+ DummyTransactionManager.getInstance().rollback();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
}
Modified: benchmarks/benchmark-fwk/trunk/cache-products/pojocache-2.2.0/src/org/cachebench/cachewrappers/PojoCache220Wrapper.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/cache-products/pojocache-2.2.0/src/org/cachebench/cachewrappers/PojoCache220Wrapper.java 2008-12-07 18:53:38 UTC (rev 7261)
+++ benchmarks/benchmark-fwk/trunk/cache-products/pojocache-2.2.0/src/org/cachebench/cachewrappers/PojoCache220Wrapper.java 2008-12-08 14:13:38 UTC (rev 7262)
@@ -11,7 +11,8 @@
import org.jboss.cache.pojo.PojoCacheFactory;
import org.jboss.cache.buddyreplication.GravitateResult;
import org.jboss.cache.marshall.NodeData;
-
+import javax.transaction.*;
+import org.jboss.cache.transaction.*;
import java.net.URL;
import java.util.List;
import java.util.Map;
@@ -89,4 +90,34 @@
//we assume that full replication is in use!!!
return replicatedData.get(key);
}
+
+
+ public Transaction startTransaction()
+ {
+ try
+ {
+ DummyTransactionManager.getInstance().begin();
+ return DummyTransactionManager.getInstance().getTransaction();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void endTransaction(boolean successful)
+ {
+ try
+ {
+ if (successful)
+ DummyTransactionManager.getInstance().commit();
+ else
+ DummyTransactionManager.getInstance().rollback();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
}
Modified: benchmarks/benchmark-fwk/trunk/cache-products/starobrno/src/org/cachebench/cachewrappers/StarobrnoWrapper.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/cache-products/starobrno/src/org/cachebench/cachewrappers/StarobrnoWrapper.java 2008-12-07 18:53:38 UTC (rev 7261)
+++ benchmarks/benchmark-fwk/trunk/cache-products/starobrno/src/org/cachebench/cachewrappers/StarobrnoWrapper.java 2008-12-08 14:13:38 UTC (rev 7262)
@@ -4,11 +4,13 @@
import org.apache.commons.logging.LogFactory;
import org.cachebench.CacheWrapper;
import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.transaction.DummyTransactionManager;
import org.jboss.starobrno.Cache;
+import org.jboss.starobrno.tree.Fqn;
import org.jboss.starobrno.tree.TreeCache;
import org.jboss.starobrno.tree.TreeCacheImpl;
-import org.jboss.starobrno.tree.Fqn;
+import javax.transaction.Transaction;
import java.util.List;
import java.util.Map;
@@ -94,4 +96,32 @@
// option.setForceDataGravitation(true);
// return get(path, key);
}
+
+ public Transaction startTransaction()
+ {
+ try
+ {
+ DummyTransactionManager.getInstance().begin();
+ return DummyTransactionManager.getInstance().getTransaction();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void endTransaction(boolean successful)
+ {
+ try
+ {
+ if (successful)
+ DummyTransactionManager.getInstance().commit();
+ else
+ DummyTransactionManager.getInstance().rollback();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
}
\ No newline at end of file
Modified: benchmarks/benchmark-fwk/trunk/cache-products/terracotta-2.5.0/src/org/cachebench/cachewrappers/TerracottaWrapper.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/cache-products/terracotta-2.5.0/src/org/cachebench/cachewrappers/TerracottaWrapper.java 2008-12-07 18:53:38 UTC (rev 7261)
+++ benchmarks/benchmark-fwk/trunk/cache-products/terracotta-2.5.0/src/org/cachebench/cachewrappers/TerracottaWrapper.java 2008-12-08 14:13:38 UTC (rev 7262)
@@ -99,4 +99,13 @@
return "There are " + sz + " objects in cache";
}
+ public Object startTransaction()
+ {
+ throw new UnsupportedOperationException("Does not support JTA!");
+ }
+
+ public void endTransaction(boolean successful)
+ {
+ throw new UnsupportedOperationException("Does not support JTA!");
+ }
}
Modified: benchmarks/benchmark-fwk/trunk/cache-products/whirlycache-1.0.1/src/org/cachebench/cachewrappers/WhirlyCacheWrapper.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/cache-products/whirlycache-1.0.1/src/org/cachebench/cachewrappers/WhirlyCacheWrapper.java 2008-12-07 18:53:38 UTC (rev 7261)
+++ benchmarks/benchmark-fwk/trunk/cache-products/whirlycache-1.0.1/src/org/cachebench/cachewrappers/WhirlyCacheWrapper.java 2008-12-08 14:13:38 UTC (rev 7262)
@@ -75,4 +75,14 @@
{
return get(path, key);
}
+
+ public Object startTransaction()
+ {
+ throw new UnsupportedOperationException("Does not support JTA!");
+ }
+
+ public void endTransaction(boolean successful)
+ {
+ throw new UnsupportedOperationException("Does not support JTA!");
+ }
}
\ No newline at end of file
Modified: benchmarks/benchmark-fwk/trunk/conf/cachebench-local.xml
===================================================================
--- benchmarks/benchmark-fwk/trunk/conf/cachebench-local.xml 2008-12-07 18:53:38 UTC (rev 7261)
+++ benchmarks/benchmark-fwk/trunk/conf/cachebench-local.xml 2008-12-08 14:13:38 UTC (rev 7262)
@@ -9,69 +9,69 @@
numThreads - the number of executor threads to use to perform the required number of operations.
-->
<cachebench sampleSize="500000" gcBetweenTestsEnabled="true" sleepBetweenTests="1000" emptyCacheBetweenTests="true"
- numThreads="25">
+ useTransactions="false" numThreads="25">
- <!--
- There are various steps we want to start executing at once: e.g. all the tests should start at the same time,
- otherwise (part of) cluster operations do not replicate on all instances. We configure here one socket addresses
- on each cluster node, so that the framework can communicate with all the nodes and barrier whenever needed.
- - for each node instance socket address is specified. You can make sure that addresses are available by using
- checkClusterAddresses ant target
- -->
- <!--<cluster>-->
- <!--<member host="cluster01" port="17900"/>-->
- <!--<member host="cluster02" port="17900"/>-->
- <!--<member host="cluster03" port="17900"/>-->
- <!--<member host="cluster04" port="17900"/>-->
- <!--<member host="cluster05" port="17900"/>-->
- <!--<member host="cluster06" port="17900"/>-->
- <!--<member host="cluster07" port="17900"/>-->
- <!--<member host="cluster08" port="17900"/>-->
- <!--<member host="cluster09" port="17900"/>-->
- <!--<member host="cluster10" port="17900"/>-->
- <!--</cluster>-->
+ <!--
+ There are various steps we want to start executing at once: e.g. all the tests should start at the same time,
+ otherwise (part of) cluster operations do not replicate on all instances. We configure here one socket addresses
+ on each cluster node, so that the framework can communicate with all the nodes and barrier whenever needed.
+ - for each node instance socket address is specified. You can make sure that addresses are available by using
+ checkClusterAddresses ant target
+ -->
+ <!--<cluster>-->
+ <!--<member host="cluster01" port="17900"/>-->
+ <!--<member host="cluster02" port="17900"/>-->
+ <!--<member host="cluster03" port="17900"/>-->
+ <!--<member host="cluster04" port="17900"/>-->
+ <!--<member host="cluster05" port="17900"/>-->
+ <!--<member host="cluster06" port="17900"/>-->
+ <!--<member host="cluster07" port="17900"/>-->
+ <!--<member host="cluster08" port="17900"/>-->
+ <!--<member host="cluster09" port="17900"/>-->
+ <!--<member host="cluster10" port="17900"/>-->
+ <!--</cluster>-->
- <!--
- Locagically groups multiple tests.
- param stopOnFailre : if true and one of the tests fails unexpectedly then the fwk will not run any other tests in
- testcase. By default set to true.
- -->
+ <!--
+ Locagically groups multiple tests.
+ param stopOnFailre : if true and one of the tests fails unexpectedly then the fwk will not run any other tests in
+ testcase. By default set to true.
+ -->
- <testcase name="NonClusteredTest" stopOnFailure="true">
+ <testcase name="NonClusteredTest" stopOnFailure="true">
- <!-- org.cachebench.warmup.PutGetCacheWarmup warms up the cache by doing operation on it; simulates a real-world environment.
- If no warmup is needed use org.cachebench.warmup.NoCacheWarmup
- -->
- <warmup warmupClass="org.cachebench.warmup.PutGetCacheWarmup">
- <param name="operationCount" value="50000"/>
- </warmup>
+ <!-- org.cachebench.warmup.PutGetCacheWarmup warms up the cache by doing operation on it; simulates a real-world environment.
+ If no warmup is needed use org.cachebench.warmup.NoCacheWarmup
+ -->
+ <warmup warmupClass="org.cachebench.warmup.PutGetCacheWarmup">
+ <param name="operationCount" value="50000"/>
+ </warmup>
- <!--
- validates that replication is enabled and works. If repl does not occur and the stopOnFailure is set to true then exists.
- Should be used to make sure that replication is enabled; see javadoc for more details
- -->
- <!--<test name="replicationOccurrsTest" testClass="org.cachebench.tests.ReplicationOccursTest">-->
- <!--<param name="partialReplication" value="true"/>-->
- <!--</test>-->
+ <!--
+ validates that replication is enabled and works. If repl does not occur and the stopOnFailure is set to true then exists.
+ Should be used to make sure that replication is enabled; see javadoc for more details
+ -->
+ <!--<test name="replicationOccurrsTest" testClass="org.cachebench.tests.ReplicationOccursTest">-->
+ <!--<param name="partialReplication" value="true"/>-->
+ <!--</test>-->
- <!--
- * The "name" attrib is just used for display in the reports.
- * You can write your own custom testClass.
- * weight is currently unused.
- -->
- <test name="Strings" testClass="org.cachebench.tests.simpletests.StringTest" weight="2.0" repeat="20">
- <param name="writePercentage" value="20"/>
- </test>
+ <!--
+ * The "name" attrib is just used for display in the reports.
+ * You can write your own custom testClass.
+ * weight is currently unused.
+ -->
+ <test name="Strings" testClass="org.cachebench.tests.simpletests.StringTest" weight="2.0" repeat="20">
+ <param name="writePercentage" value="20"/>
+ </test>
- <!--<test name="SessionSimulator" testClass="org.cachebench.tests.SessionSimulatorTest" weight="2.0">-->
- <!--<param name="numberOfRequest" value="100000"/>-->
- <!--<param name="numberOfAttributes" value="100"/>-->
- <!--<param name="writePercentage" value="20"/>-->
- <!--<param name="sizeOfAnAttribute" value="1000"/>-->
- <!--</test>-->
+ <!--<test name="SessionSimulator" testClass="org.cachebench.tests.SessionSimulatorTest" weight="2.0">-->
+ <!--<param name="numberOfRequest" value="100000"/>-->
+ <!--<param name="numberOfAttributes" value="100"/>-->
+ <!--<param name="writePercentage" value="20"/>-->
+ <!--<param name="sizeOfAnAttribute" value="1000"/>-->
+ <!--</test>-->
- <!--
+ <!--
<test name="Primitive Wrappers" testClass="org.cachebench.tests.simpletests.PrimitiveTest" weight="1.0" />
<test name="Custom Class Types" testClass="org.cachebench.tests.simpletests.CustomClassTest" weight="1.0" />
<test name="Custom Subclasses of Abstracts" testClass="org.cachebench.tests.simpletests.SubclassTest" weight="1.5" />
@@ -80,19 +80,19 @@
<test name="Custom Types With Associations" testClass="org.cachebench.tests.simpletests.AssociationsTest" weight="2.0" />
-->
- <!-- WARNING - Configuration file name is now DEPRECATED and will be ignored. Please pass in your cache config
+ <!-- WARNING - Configuration file name is now DEPRECATED and will be ignored. Please pass in your cache config
file name that you wish to use with the -DcacheBenchFwk.cacheConfigFile JVM parameter. The runNode.sh
and cluster.sh scripts will also do this for you. -->
- </testcase>
+ </testcase>
- <!--
- Available generators are: CSVReportGenerator and ClusterReportGenerator.
- See javadocs for org.cachebench.reportgenerators.ReportGenerator for writing your
- own report generators such as XML generators, graphic generators, etc
- -->
- <!-- The CSV report generated can be plugged in to a spreadsheet to generate graphs. If 'outputFile is set to
- '-generic-' then the name would be generated as follows: 'data_<cache-product>_<configuration>_<cluster-size>.csv' -->
- <report outputFile="-generic-" generator="org.cachebench.reportgenerators.CsvStatisticReportGenerator"/>
+ <!--
+ Available generators are: CSVReportGenerator and ClusterReportGenerator.
+ See javadocs for org.cachebench.reportgenerators.ReportGenerator for writing your
+ own report generators such as XML generators, graphic generators, etc
+ -->
+ <!-- The CSV report generated can be plugged in to a spreadsheet to generate graphs. If 'outputFile is set to
+'-generic-' then the name would be generated as follows: 'data_<cache-product>_<configuration>_<cluster-size>.csv' -->
+ <report outputFile="-generic-" generator="org.cachebench.reportgenerators.CsvStatisticReportGenerator"/>
</cachebench>
Modified: benchmarks/benchmark-fwk/trunk/conf/cachebench.xml
===================================================================
--- benchmarks/benchmark-fwk/trunk/conf/cachebench.xml 2008-12-07 18:53:38 UTC (rev 7261)
+++ benchmarks/benchmark-fwk/trunk/conf/cachebench.xml 2008-12-08 14:13:38 UTC (rev 7262)
@@ -9,73 +9,73 @@
numThreads - the number of executor threads to use to perform the required number of operations.
-->
<cachebench sampleSize="500000" gcBetweenTestsEnabled="true" sleepBetweenTests="1000" emptyCacheBetweenTests="true"
- numThreads="10">
+ useTransactions="false" numThreads="10">
- <!--
- There are various steps we want to start executing at once: e.g. all the tests should start at the same time,
- otherwise (part of) cluster operations do not replicate on all instances. We configure here one socket addresses
- on each cluster node, so that the framework can communicate with all the nodes and barrier whenever needed.
- - for each node instance socket address is specified. You can make sure that addresses are available by using
- checkClusterAddresses ant target
- -->
- <cluster>
- <member host="cluster01" port="17900"/>
- <member host="cluster02" port="17900"/>
- <member host="cluster03" port="17900"/>
- <member host="cluster04" port="17900"/>
- <member host="cluster05" port="17900"/>
- <member host="cluster06" port="17900"/>
- <member host="cluster07" port="17900"/>
- <member host="cluster08" port="17900"/>
- <member host="cluster09" port="17900"/>
- <member host="cluster10" port="17900"/>
- </cluster>
+ <!--
+ There are various steps we want to start executing at once: e.g. all the tests should start at the same time,
+ otherwise (part of) cluster operations do not replicate on all instances. We configure here one socket addresses
+ on each cluster node, so that the framework can communicate with all the nodes and barrier whenever needed.
+ - for each node instance socket address is specified. You can make sure that addresses are available by using
+ checkClusterAddresses ant target
+ -->
+ <cluster>
+ <member host="cluster01" port="17900"/>
+ <member host="cluster02" port="17900"/>
+ <member host="cluster03" port="17900"/>
+ <member host="cluster04" port="17900"/>
+ <member host="cluster05" port="17900"/>
+ <member host="cluster06" port="17900"/>
+ <member host="cluster07" port="17900"/>
+ <member host="cluster08" port="17900"/>
+ <member host="cluster09" port="17900"/>
+ <member host="cluster10" port="17900"/>
+ </cluster>
- <!--
- Locagically groups multiple tests.
- param stopOnFailre : if true and one of the tests fails unexpectedly then the fwk will not run any other tests in
- testcase. By default set to true.
- -->
+ <!--
+ Locagically groups multiple tests.
+ param stopOnFailre : if true and one of the tests fails unexpectedly then the fwk will not run any other tests in
+ testcase. By default set to true.
+ -->
- <testcase name="WebSessionReplicationTest" stopOnFailure="true">
+ <testcase name="WebSessionReplicationTest" stopOnFailure="true">
- <!-- org.cachebench.warmup.PutGetCacheWarmup warms up the cache by doing operation on it; simulates a real-world environment.
- If no warmup is needed use org.cachebench.warmup.NoCacheWarmup
- -->
- <warmup warmupClass="org.cachebench.warmup.PutGetCacheWarmup">
- <param name="operationCount" value="10000"/>
- </warmup>
+ <!-- org.cachebench.warmup.PutGetCacheWarmup warms up the cache by doing operation on it; simulates a real-world environment.
+ If no warmup is needed use org.cachebench.warmup.NoCacheWarmup
+ -->
+ <warmup warmupClass="org.cachebench.warmup.PutGetCacheWarmup">
+ <param name="operationCount" value="10000"/>
+ </warmup>
- <!--
- validates that replication is enabled and works. If repl does not occur and the stopOnFailure is set to true then exists.
- Should be used to make sure that replication is enabled; see javadoc for more details
- -->
- <test name="replicationOccurrsTest" testClass="org.cachebench.tests.ReplicationOccursTest">
- <param name="partialReplication" value="true"/>
- </test>
+ <!--
+ validates that replication is enabled and works. If repl does not occur and the stopOnFailure is set to true then exists.
+ Should be used to make sure that replication is enabled; see javadoc for more details
+ -->
+ <test name="replicationOccurrsTest" testClass="org.cachebench.tests.ReplicationOccursTest">
+ <param name="partialReplication" value="true"/>
+ </test>
- <!--
- * The "name" attrib is just used for display in the reports.
- * You can write your own custom testClass.
- * weight is currently unused.
- * repeat allows you to specify how many times this test is to be run. Average results are used.
- -->
- <!--
- <test name="Strings" testClass="org.cachebench.tests.simpletests.StringTest" weight="2.0" repeat="10">
- <param name="writePercentage" value="20"/>
- </test>
- -->
+ <!--
+ * The "name" attrib is just used for display in the reports.
+ * You can write your own custom testClass.
+ * weight is currently unused.
+ * repeat allows you to specify how many times this test is to be run. Average results are used.
+ -->
+ <!--
+ <test name="Strings" testClass="org.cachebench.tests.simpletests.StringTest" weight="2.0" repeat="10">
+ <param name="writePercentage" value="20"/>
+ </test>
+ -->
- <test name="SessionSimulator" testClass="org.cachebench.tests.SessionSimulatorTest" weight="2.0">
- <param name="numberOfRequest" value="500000"/>
- <param name="numberOfAttributes" value="100"/>
- <param name="writePercentage" value="10"/>
- <param name="sizeOfAnAttribute" value="10000"/>
- </test>
+ <test name="SessionSimulator" testClass="org.cachebench.tests.SessionSimulatorTest" weight="2.0">
+ <param name="numberOfRequest" value="500000"/>
+ <param name="numberOfAttributes" value="100"/>
+ <param name="writePercentage" value="10"/>
+ <param name="sizeOfAnAttribute" value="10000"/>
+ </test>
- <!--
+ <!--
<test name="Primitive Wrappers" testClass="org.cachebench.tests.simpletests.PrimitiveTest" weight="1.0" />
<test name="Custom Class Types" testClass="org.cachebench.tests.simpletests.CustomClassTest" weight="1.0" />
<test name="Custom Subclasses of Abstracts" testClass="org.cachebench.tests.simpletests.SubclassTest" weight="1.5" />
@@ -84,19 +84,19 @@
<test name="Custom Types With Associations" testClass="org.cachebench.tests.simpletests.AssociationsTest" weight="2.0" />
-->
- <!-- WARNING - Configuration file name is now DEPRECATED and will be ignored. Please pass in your cache config
+ <!-- WARNING - Configuration file name is now DEPRECATED and will be ignored. Please pass in your cache config
file name that you wish to use with the -DcacheBenchFwk.cacheConfigFile JVM parameter. The runNode.sh
and cluster.sh scripts will also do this for you. -->
- </testcase>
+ </testcase>
- <!--
- Available generators are: CSVReportGenerator and ClusterReportGenerator.
- See javadocs for org.cachebench.reportgenerators.ReportGenerator for writing your
- own report generators such as XML generators, graphic generators, etc
- -->
- <!-- The CSV report generated can be plugged in to a spreadsheet to generate graphs. If 'outputFile is set to
- '-generic-' then the name would be generated as follows: 'data_<cache-product>_<configuration>_<cluster-size>.csv' -->
- <report outputFile="-generic-" generator="org.cachebench.reportgenerators.ClusterReportGenerator"/>
+ <!--
+ Available generators are: CSVReportGenerator and ClusterReportGenerator.
+ See javadocs for org.cachebench.reportgenerators.ReportGenerator for writing your
+ own report generators such as XML generators, graphic generators, etc
+ -->
+ <!-- The CSV report generated can be plugged in to a spreadsheet to generate graphs. If 'outputFile is set to
+'-generic-' then the name would be generated as follows: 'data_<cache-product>_<configuration>_<cluster-size>.csv' -->
+ <report outputFile="-generic-" generator="org.cachebench.reportgenerators.ClusterReportGenerator"/>
</cachebench>
Added: benchmarks/benchmark-fwk/trunk/lib/jta-1.1.jar
===================================================================
(Binary files differ)
Property changes on: benchmarks/benchmark-fwk/trunk/lib/jta-1.1.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: benchmarks/benchmark-fwk/trunk/src/org/cachebench/CacheWrapper.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/src/org/cachebench/CacheWrapper.java 2008-12-07 18:53:38 UTC (rev 7261)
+++ benchmarks/benchmark-fwk/trunk/src/org/cachebench/CacheWrapper.java 2008-12-08 14:13:38 UTC (rev 7262)
@@ -78,5 +78,10 @@
* structure, but use some additional structure to do this (replication tree, in the case of buddy replication).
* This method is a hook for handling this situations.
*/
- public Object getReplicatedData(List<String> path, String key) throws Exception;
+ Object getReplicatedData(List<String> path, String key) throws Exception;
+
+ Object startTransaction();
+
+ void endTransaction(boolean successful);
+
}
Modified: benchmarks/benchmark-fwk/trunk/src/org/cachebench/config/Configuration.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/src/org/cachebench/config/Configuration.java 2008-12-07 18:53:38 UTC (rev 7261)
+++ benchmarks/benchmark-fwk/trunk/src/org/cachebench/config/Configuration.java 2008-12-08 14:13:38 UTC (rev 7262)
@@ -16,6 +16,7 @@
private boolean gcBetweenTestsEnabled;
private boolean emptyCacheBetweenTests;
private boolean localOnly;
+ private boolean useTransactions;
private ClusterConfig clusterConfig;
@@ -124,6 +125,16 @@
this.maxTreeDepth = maxTreeDepth;
}
+ public boolean isUseTransactions()
+ {
+ return useTransactions;
+ }
+
+ public void setUseTransactions(boolean useTransactions)
+ {
+ this.useTransactions = useTransactions;
+ }
+
public TestCase getTestCase(String testCaseName)
{
for (TestCase testCase : getTestCases())
Modified: benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/simpletests/SimpleTest.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/simpletests/SimpleTest.java 2008-12-07 18:53:38 UTC (rev 7261)
+++ benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/simpletests/SimpleTest.java 2008-12-08 14:13:38 UTC (rev 7262)
@@ -158,14 +158,18 @@
String attributeKey = key + cycleNumber;
// start your timer...
+ boolean transactional = configuration.isUseTransactions();
long startTime = System.nanoTime();
+ if (transactional) cache.startTransaction();
cache.put(path, attributeKey, value);
+ if (transactional) cache.endTransaction(true);
long statValue = (System.nanoTime() - startTime);
putStats.addValue(statValue);
logOperation(cycleNumber, "PUTS", statValue);
}
catch (Exception e)
{
+ if (configuration.isUseTransactions()) cache.endTransaction(false);
// how should we handle this? Log for now...
log.error("Operation failed!", e);
}
@@ -186,14 +190,18 @@
String attributeKey = key + cycleNumber;
// start your timer...
+ boolean transactional = configuration.isUseTransactions();
long startTime = System.nanoTime();
+ if (transactional) cache.startTransaction();
cache.get(path, attributeKey);
+ if (transactional) cache.endTransaction(true);
long statValue = (System.nanoTime() - startTime);
getStats.addValue(statValue);
logOperation(cycleNumber, "GETS", statValue);
}
catch (Exception e)
{
+ if (configuration.isUseTransactions()) cache.endTransaction(false);
// how should we handle this? Log for now...
log.error("Operation failed!", e);
}
16 years, 3 months
JBoss Cache SVN: r7261 - in core/trunk/src: main/java/org/jboss/cache/loader/jdbm and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: genman
Date: 2008-12-07 13:53:38 -0500 (Sun, 07 Dec 2008)
New Revision: 7261
Added:
core/trunk/src/test/java/org/jboss/cache/loader/UnnecessaryLoadingSetDataTest.java
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
core/trunk/src/main/java/org/jboss/cache/loader/jdbm/JdbmCacheLoader.java
core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java
core/trunk/src/test/java/org/jboss/cache/loader/JdbmCacheLoader2Test.java
core/trunk/src/test/java/org/jboss/cache/loader/JdbmCacheLoaderTest.java
Log:
JBCACHE-1442
Test for unncessary loading of setData for MVCC (Pessimistic is a TODO)
Fix issue with JDBM not clearing existing keys with put(Map) call
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java 2008-12-06 00:47:32 UTC (rev 7260)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java 2008-12-07 18:53:38 UTC (rev 7261)
@@ -113,9 +113,16 @@
@Override
public Object visitPutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
{
- if (command.getFqn() != null && !command.isErase())
+ if (command.getFqn() != null)
{
- loadIfNeeded(ctx, command.getFqn(), null, true, true, false, false, false, false, true);
+ if (command.isErase())
+ {
+ replace(ctx, command.getFqn());
+ }
+ else
+ {
+ loadIfNeeded(ctx, command.getFqn(), null, true, true, false, false, false, false, true);
+ }
}
return invokeNextInterceptor(ctx, command);
}
@@ -261,6 +268,17 @@
}
return invokeNextInterceptor(ctx, command);
}
+
+ private void replace(InvocationContext ctx, Fqn fqn) throws InterruptedException
+ {
+ NodeSPI n = helper.wrapNodeForReading(ctx, fqn, true);
+ if (n instanceof NullMarkerNode)
+ {
+ ctx.getLookedUpNodes().remove(fqn);
+ }
+ n = helper.wrapNodeForWriting(ctx, fqn, true, true, true, false, false);
+ n.setDataLoaded(true);
+ }
private void loadIfNeeded(InvocationContext ctx, Fqn fqn, Object key, boolean allKeys, boolean initNode, boolean acquireWriteLock, boolean recursive, boolean isMove, boolean bypassLoadingData, boolean shouldLoadIfNodeIsNull) throws Throwable
{
Modified: core/trunk/src/main/java/org/jboss/cache/loader/jdbm/JdbmCacheLoader.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/jdbm/JdbmCacheLoader.java 2008-12-06 00:47:32 UTC (rev 7260)
+++ core/trunk/src/main/java/org/jboss/cache/loader/jdbm/JdbmCacheLoader.java 2008-12-07 18:53:38 UTC (rev 7261)
@@ -462,12 +462,35 @@
{
return;
}
+
+ Fqn keys = keys(name);
+ Tuple t = new Tuple();
+ List<Object> removeList = new ArrayList<Object>();
+ synchronized (tree)
+ {
+ TupleBrowser browser = tree.browse(keys);
+ while (browser.getNext(t))
+ {
+ Fqn fqn = (Fqn) t.getKey();
+ if (!fqn.isChildOf(keys))
+ {
+ break;
+ }
+ Object k = fqn.getLastElement();
+ if (!values.containsKey(nullUnmask(k)))
+ removeList.add(fqn);
+ }
+ }
for (Map.Entry me : values.entrySet())
{
Fqn rec = key(name, me.getKey());
insert(rec, nullMask(me.getValue()));
}
+ for (Object o : removeList)
+ {
+ tree.remove(o);
+ }
}
/**
Modified: core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java 2008-12-06 00:47:32 UTC (rev 7260)
+++ core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java 2008-12-07 18:53:38 UTC (rev 7261)
@@ -2467,19 +2467,26 @@
public void testSetData() throws Exception
{
+ log.info("testSetData");
CacheSPI<Object, Object> cache = cacheTL.get();
Fqn key = Fqn.fromElements("key");
Map<Object, Object> map = new HashMap<Object, Object>();
+ Map<Object, Object> loaderMap;
+ CacheLoader loader = loaderTL.get();
map.put("a", "a");
map.put("c", "c");
+ log.info("PUT");
cache.put(key, "x", "x");
cache.setData(key, map);
+ assertEquals(map, cache.getData(key));
+ log.info("GET");
+ loaderMap = loader.get(key);
+ assertEquals(map, loaderMap);
assertNull(cache.get(key, "x"));
assertEquals("c", cache.get(key, "c"));
assertEquals("a", cache.get(key, "a"));
- CacheLoader loader = loaderTL.get();
- Map<Object, Object> loaderMap = loader.get(key);
+ loaderMap = loader.get(key);
assertEquals(map, loaderMap);
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/JdbmCacheLoader2Test.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/JdbmCacheLoader2Test.java 2008-12-06 00:47:32 UTC (rev 7260)
+++ core/trunk/src/test/java/org/jboss/cache/loader/JdbmCacheLoader2Test.java 2008-12-07 18:53:38 UTC (rev 7261)
@@ -20,7 +20,7 @@
String tmpDir = System.getProperty("java.io.tmpdir", "/tmp");
String threadId = Thread.currentThread().getName();
String tmpCLLoc = tmpDir + "/JBossCache-JdbmCacheLoader2Test-" + threadId;
- cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("", "org.jboss.cache.loader.jdbm.JdbmCacheLoader",
+ cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("", "org.jboss.cache.loader.jdbm.JdbmCacheLoader2",
"location=" + tmpCLLoc, false, true, false));
TestingUtil.recursiveFileRemove(tmpCLLoc);
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/JdbmCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/JdbmCacheLoaderTest.java 2008-12-06 00:47:32 UTC (rev 7260)
+++ core/trunk/src/test/java/org/jboss/cache/loader/JdbmCacheLoaderTest.java 2008-12-07 18:53:38 UTC (rev 7261)
@@ -22,4 +22,12 @@
cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("", "org.jboss.cache.loader.jdbm.JdbmCacheLoader", "location=" + tmpCLLoc, false, true, false));
TestingUtil.recursiveFileRemove(tmpCLLoc);
}
+
+ public void testCacheLoaderThreadSafety() throws Exception
+ {
+ }
+
+ public void testCacheLoaderThreadSafetyMultipleFqns() throws Exception
+ {
+ }
}
Added: core/trunk/src/test/java/org/jboss/cache/loader/UnnecessaryLoadingSetDataTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/UnnecessaryLoadingSetDataTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/loader/UnnecessaryLoadingSetDataTest.java 2008-12-07 18:53:38 UTC (rev 7261)
@@ -0,0 +1,153 @@
+package org.jboss.cache.loader;
+
+import static org.easymock.EasyMock.*;
+import static org.testng.AssertJUnit.assertFalse;
+import static org.testng.AssertJUnit.assertTrue;
+import static org.testng.AssertJUnit.assertEquals;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.NodeSPI;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.config.CacheLoaderConfig;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.jboss.cache.util.CachePrinter;
+import org.jboss.cache.util.TestingUtil;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+/**
+ * TODO merge with {@link UnnecessaryLoadingTest}.
+ * @author Elias Ross
+ * @since 3.0.0
+ */
+@Test(groups = {"functional", "mvcc"})
+public class UnnecessaryLoadingSetDataTest
+{
+ private CacheSPI<Object, Object> cache;
+ private CacheLoader mockCacheLoader;
+ private Fqn parent = Fqn.fromString("/parent");
+
+ @DataProvider(name = "locking")
+ public Object[][] createData1() {
+ return new Object[][] {
+ // TODO
+ // { NodeLockingScheme.PESSIMISTIC },
+ { NodeLockingScheme.MVCC },
+ };
+ }
+
+ private void setUp(NodeLockingScheme locking) throws Exception
+ {
+ cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(false);
+ CacheLoaderConfig clc = new CacheLoaderConfig();
+ CacheLoaderConfig.IndividualCacheLoaderConfig iclc = new CacheLoaderConfig.IndividualCacheLoaderConfig();
+ clc.addIndividualCacheLoaderConfig(iclc);
+ cache.getConfiguration().setCacheLoaderConfig(clc);
+ cache.getConfiguration().setNodeLockingScheme(locking);
+ mockCacheLoader = createMockCacheLoader();
+
+ iclc.setCacheLoader(mockCacheLoader);
+ cache.start();
+
+ reset(mockCacheLoader);
+ }
+
+ public static CacheLoader createMockCacheLoader() throws Exception {
+ CacheLoader mockCacheLoader = createMock(CacheLoader.class);
+
+ expect(mockCacheLoader.getConfig()).andReturn(null).anyTimes();
+ mockCacheLoader.setCache((CacheSPI) anyObject());
+ expectLastCall().anyTimes();
+ mockCacheLoader.setConfig((CacheLoaderConfig.IndividualCacheLoaderConfig) anyObject());
+ expectLastCall().anyTimes();
+ mockCacheLoader.create();
+ expectLastCall().anyTimes();
+ mockCacheLoader.start();
+ expectLastCall().anyTimes();
+ mockCacheLoader.stop();
+ expectLastCall().anyTimes();
+ mockCacheLoader.destroy();
+ expectLastCall().anyTimes();
+ replay(mockCacheLoader);
+ return mockCacheLoader;
+ }
+
+ @AfterMethod(alwaysRun = true)
+ public void tearDown() throws Exception
+ {
+ reset(mockCacheLoader);
+ expect(mockCacheLoader.getConfig()).andReturn(null).anyTimes();
+ mockCacheLoader.setCache((CacheSPI) anyObject());
+ expectLastCall().anyTimes();
+ mockCacheLoader.setConfig((CacheLoaderConfig.IndividualCacheLoaderConfig) anyObject());
+ expectLastCall().anyTimes();
+ mockCacheLoader.create();
+ expectLastCall().anyTimes();
+ mockCacheLoader.start();
+ expectLastCall().anyTimes();
+ mockCacheLoader.stop();
+ expectLastCall().anyTimes();
+ mockCacheLoader.destroy();
+ expectLastCall().anyTimes();
+ replay(mockCacheLoader);
+
+ TestingUtil.killCaches(cache);
+ cache = null;
+ }
+
+ protected void assertDataLoaded(Fqn f)
+ {
+ assertTrue("Data should be loaded for node " + f, cache.peek(f, false).isDataLoaded());
+ }
+
+ protected void assertDataNotLoaded(Fqn f)
+ {
+ NodeSPI n = cache.peek(f, true);
+ assertFalse("Data should not be loaded for node " + f, n != null && n.isDataLoaded());
+ }
+
+ @Test(dataProvider="locking")
+ public void testDontLoadWithSetData(NodeLockingScheme locking) throws Exception
+ {
+ System.err.println(locking);
+ System.err.println(locking);
+ setUp(locking);
+
+ Map<Object, Object> m0 = new HashMap<Object, Object>();
+ m0.put("replace", "replace");
+ Map<Object, Object> m1 = new HashMap<Object, Object>();
+ m1.put("new", "new");
+
+ mockCacheLoader.put(eq(parent), eq(m0));
+ mockCacheLoader.put(eq(parent), eq(m1));
+ mockCacheLoader.put(eq(parent), eq(m0));
+ mockCacheLoader.get(parent);
+ expectLastCall().andStubThrow(new IllegalStateException("no need to call get()"));
+ mockCacheLoader.exists(parent);
+ expectLastCall().andStubThrow(new IllegalStateException("no need to call exists()"));
+ replay(mockCacheLoader);
+
+ assertDataNotLoaded(parent);
+ cache.setData(parent, m0);
+ assertDataLoaded(parent);
+ cache.setData(parent, m1);
+ assertEquals(m1, cache.peek(parent, false).getData());
+
+ // force removal, see if load happens
+ cache.evict(parent);
+ cache.setData(parent, m0);
+ // assertDataLoaded(parent);
+ assertEquals(m0, cache.peek(parent, false).getData());
+
+ verify(mockCacheLoader);
+ CachePrinter.printCacheDetails(cache);
+ cache.toString();
+ }
+
+}
\ No newline at end of file
Property changes on: core/trunk/src/test/java/org/jboss/cache/loader/UnnecessaryLoadingSetDataTest.java
___________________________________________________________________
Name: svn:mergeinfo
+
16 years, 3 months
JBoss Cache SVN: r7260 - core/trunk/src/main/java/org/jboss/cache/commands/write.
by jbosscache-commits@lists.jboss.org
Author: genman
Date: 2008-12-05 19:47:32 -0500 (Fri, 05 Dec 2008)
New Revision: 7260
Modified:
core/trunk/src/main/java/org/jboss/cache/commands/write/PutDataMapCommand.java
Log:
JBCACHE-1442 - Add "setData()" call
Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/PutDataMapCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/PutDataMapCommand.java 2008-12-06 00:45:08 UTC (rev 7259)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/PutDataMapCommand.java 2008-12-06 00:47:32 UTC (rev 7260)
@@ -53,6 +53,9 @@
/* parameters*/
protected Map data;
+
+ /* true to erase existing data */
+ protected boolean erase;
public PutDataMapCommand(GlobalTransaction globalTransaction, Fqn fqn, Map data)
{
@@ -84,6 +87,10 @@
notifier.notifyNodeModified(fqn, true, NodeModifiedEvent.ModificationType.PUT_MAP, existingData == null ? Collections.emptyMap() : existingData, ctx);
}
+ if (erase)
+ {
+ nodeSPI.clearDataDirect();
+ }
nodeSPI.putAllDirect(data);
if (notifier.shouldNotifyOnNodeModified())
{
@@ -111,11 +118,11 @@
{
if (isVersioned())
{
- return VERSIONED_METHOD_ID;
+ return erase ? ERASE_VERSIONED_METHOD_ID : VERSIONED_METHOD_ID;
}
else
{
- return METHOD_ID;
+ return erase ? ERASE_METHOD_ID : METHOD_ID;
}
}
@@ -151,6 +158,7 @@
if (!super.equals(o)) return false;
PutDataMapCommand that = (PutDataMapCommand) o;
if (data != null ? !data.equals(that.data) : that.data != null) return false;
+ if (erase != that.erase) return false;
if (globalTransaction != null ? !globalTransaction.equals(that.globalTransaction) : that.globalTransaction != null)
return false;
@@ -163,9 +171,27 @@
int result = super.hashCode();
result = 31 * result + (globalTransaction != null ? globalTransaction.hashCode() : 0);
result = 31 * result + (data != null ? data.hashCode() : 0);
+ if (erase)
+ result++;
return result;
}
+ /**
+ * Sets a flag indicating the node data should be erased.
+ */
+ public void setErase(boolean erase)
+ {
+ this.erase = erase;
+ }
+
+ /**
+ * Returns a flag indicating the node data should be erased.
+ */
+ public boolean isErase()
+ {
+ return erase;
+ }
+
@Override
public String toString()
{
@@ -174,6 +200,8 @@
", dataVersion=" + dataVersion +
", data=" + data +
", globalTransaction=" + globalTransaction +
+ ", erase=" + erase +
'}';
}
+
}
16 years, 3 months
JBoss Cache SVN: r7259 - core/trunk/src/test/java/org/jboss/cache/loader.
by jbosscache-commits@lists.jboss.org
Author: genman
Date: 2008-12-05 19:45:08 -0500 (Fri, 05 Dec 2008)
New Revision: 7259
Modified:
core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java
Log:
JBCACHE-1442 - Add "setData()" call
Modified: core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java 2008-12-06 00:33:01 UTC (rev 7258)
+++ core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java 2008-12-06 00:45:08 UTC (rev 7259)
@@ -2464,4 +2464,23 @@
CacheSPI<Object, Object> cache = cacheTL.get();
return cache.getConfiguration().getRuntimeConfig().getTransactionManager();
}
+
+ public void testSetData() throws Exception
+ {
+ CacheSPI<Object, Object> cache = cacheTL.get();
+ Fqn key = Fqn.fromElements("key");
+ Map<Object, Object> map = new HashMap<Object, Object>();
+ map.put("a", "a");
+ map.put("c", "c");
+ cache.put(key, "x", "x");
+ cache.setData(key, map);
+
+ assertNull(cache.get(key, "x"));
+ assertEquals("c", cache.get(key, "c"));
+ assertEquals("a", cache.get(key, "a"));
+ CacheLoader loader = loaderTL.get();
+ Map<Object, Object> loaderMap = loader.get(key);
+ assertEquals(map, loaderMap);
+ }
+
}
16 years, 3 months