Author: manik.surtani(a)jboss.com
Date: 2009-02-27 05:26:02 -0500 (Fri, 27 Feb 2009)
New Revision: 7801
Modified:
core/trunk/src/test/java/org/jboss/cache/statetransfer/NonBlockingStateTransferTest.java
Log:
Writer thread clears data periodically to prevent OOMs
Modified:
core/trunk/src/test/java/org/jboss/cache/statetransfer/NonBlockingStateTransferTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/statetransfer/NonBlockingStateTransferTest.java 2009-02-27
10:06:26 UTC (rev 7800)
+++
core/trunk/src/test/java/org/jboss/cache/statetransfer/NonBlockingStateTransferTest.java 2009-02-27
10:26:02 UTC (rev 7801)
@@ -102,11 +102,19 @@
{
try
{
- if (tx)
-
cache.getConfiguration().getRuntimeConfig().getTransactionManager().begin();
- cache.put("/test" + c, "test", c++);
- if (tx)
-
cache.getConfiguration().getRuntimeConfig().getTransactionManager().commit();
+ if (c % 1000 == 0)
+ {
+ startTxIfNeeded();
+ for (int i=0; i<1000; i++) cache.removeNode("/test" + i);
+ commitTxIfNeeded();
+ c = 0;
+ }
+ else
+ {
+ startTxIfNeeded();
+ cache.put("/test" + c, "test", c++);
+ commitTxIfNeeded();
+ }
}
catch (Exception e)
{
@@ -117,6 +125,16 @@
result = c;
}
+ private void startTxIfNeeded() throws Exception
+ {
+ if (tx)
cache.getConfiguration().getRuntimeConfig().getTransactionManager().begin();
+ }
+
+ private void commitTxIfNeeded() throws Exception
+ {
+ if (tx)
cache.getConfiguration().getRuntimeConfig().getTransactionManager().commit();
+ }
+
public void stop()
{
stop = true;