Follow-up on ALF-765 by upgrading EHCache to 2.0.0

- Fixed CacheTest to avoid disk flushes (configuration issues)
 - Allows Cache statistics to be turned off (done)
 - Added explicit switch to LruMemoryStore (raised https://jira.terracotta.org/jira/browse/EHC-652)
 - Removed EHCache usage within TransactionalCache (replaced with LruMap and Set)
 - Even with 'statistics=false' the EHCache code still messes about too much, but it's much better
 - TODO: Leave ripping out of ehcache-transactional.xml until DAO synch


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@19324 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2010-03-17 04:53:04 +00:00
parent 4c8f94071c
commit 733cd6e02d
8 changed files with 354 additions and 148 deletions

View File

@@ -36,7 +36,6 @@ import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.transaction.TransactionService;
import org.alfresco.util.ApplicationContextHelper;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
* @see org.alfresco.repo.cache.EhCacheAdapter
@@ -45,9 +44,10 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
*/
public class CacheTest extends TestCase
{
private static ApplicationContext ctx =new ClassPathXmlApplicationContext(
new String[] {"classpath:cache-test-context.xml", ApplicationContextHelper.CONFIG_LOCATIONS[0]}
);
private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext(
new String[] {
"classpath:cache-test/cache-test-context.xml",
ApplicationContextHelper.CONFIG_LOCATIONS[0]});
private ServiceRegistry serviceRegistry;
private SimpleCache<String, Object> standaloneCache;
@@ -77,9 +77,9 @@ public class CacheTest extends TestCase
public void testSetUp() throws Exception
{
CacheManager cacheManager = (CacheManager) ctx.getBean("ehCacheManager");
CacheManager cacheManager = (CacheManager) ctx.getBean("testEHCacheManager");
assertNotNull(cacheManager);
CacheManager cacheManagerCheck = (CacheManager) ctx.getBean("ehCacheManager");
CacheManager cacheManagerCheck = (CacheManager) ctx.getBean("testEHCacheManager");
assertTrue(cacheManager == cacheManagerCheck);
assertNotNull(serviceRegistry);
@@ -344,7 +344,7 @@ public class CacheTest extends TestCase
*/
public void testPerformance() throws Exception
{
for (int i = 0; i < 5; i++)
for (int i = 0; i < 6; i++)
{
int count = (int) Math.pow(10D, (double)i);
@@ -371,6 +371,32 @@ public class CacheTest extends TestCase
}
}
/**
* @see #testPerformance()
*/
public static void main(String ... args)
{
try
{
CacheTest test = new CacheTest();
test.setUp();
System.out.println("Press any key to run test ...");
System.in.read();
test.testPerformance();
System.out.println("Press any key to shutdown ...");
System.in.read();
test.tearDown();
}
catch (Throwable e)
{
e.printStackTrace();
}
finally
{
ApplicationContextHelper.closeApplicationContext();
}
}
/**
* Starts off with a <tt>null</tt> in the backing cache and adds a value to the
* transactional cache. There should be no problem with this.
@@ -412,7 +438,7 @@ public class CacheTest extends TestCase
assertEquals("The start value isn't correct", startValue, transactionalCache.get(startKey));
for (int i = 0; i < 50000; i++)
for (int i = 0; i < 205000; i++)
{
Object value = Integer.valueOf(i);
String key = value.toString();