JBoss Cache SVN: r5400 - in core/trunk/src: main/java/org/jboss/cache/interceptors and 3 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-03-07 12:05:23 -0500 (Fri, 07 Mar 2008)
New Revision: 5400
Modified:
core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OrderedSynchronizationHandler.java
core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
core/trunk/src/main/java/org/jboss/cache/transaction/OptimisticTransactionEntry.java
core/trunk/src/main/java/org/jboss/cache/transaction/TransactionEntry.java
core/trunk/src/test/java/org/jboss/cache/loader/TcpCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/AbortionTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/InvocationContextCleanupTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/NotifyingTransactionManager.java
Log:
JBCACHE-1304 - OrderedSynchronizationHandler thread safety and scoping issues
Modified: core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2008-03-07 15:48:54 UTC (rev 5399)
+++ core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2008-03-07 17:05:23 UTC (rev 5400)
@@ -2115,8 +2115,16 @@
Address addr = rpcManager.getLocalAddress();
gtx = GlobalTransaction.create(addr);
transactionTable.put(tx, gtx);
- TransactionEntry ent = configuration.isNodeLockingOptimistic() ? new OptimisticTransactionEntry() : new TransactionEntry();
- ent.setTransaction(tx);
+ TransactionEntry ent = null;
+ try
+ {
+ ent = configuration.isNodeLockingOptimistic() ? new OptimisticTransactionEntry(tx) : new TransactionEntry(tx);
+ }
+ catch (Exception e)
+ {
+ throw new CacheException("Unable to create a transaction entry!", e);
+ }
+
transactionTable.put(gtx, ent);
if (trace)
{
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OrderedSynchronizationHandler.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OrderedSynchronizationHandler.java 2008-03-07 15:48:54 UTC (rev 5399)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OrderedSynchronizationHandler.java 2008-03-07 17:05:23 UTC (rev 5400)
@@ -7,9 +7,7 @@
import javax.transaction.Synchronization;
import javax.transaction.SystemException;
import javax.transaction.Transaction;
-import java.util.HashMap;
import java.util.LinkedList;
-import java.util.Map;
/**
* Maintains a list of Synchronization handlers. Reason is that we have to
@@ -26,36 +24,15 @@
private Transaction tx = null;
private LinkedList<Synchronization> handlers = new LinkedList<Synchronization>();
- /**
- * Map<Transaction,OrderedSynchronizationHandler>
- */
- static Map instances = new HashMap();
-
static Log log = LogFactory.getLog(OrderedSynchronizationHandler.class);
- private OrderedSynchronizationHandler(Transaction tx)
+ public OrderedSynchronizationHandler(Transaction tx) throws SystemException, RollbackException
{
this.tx = tx;
+ tx.registerSynchronization(this);
}
- /**
- * Creates a new instance of OrderedSynchronizationHandler, or fetches an existing instance. Key is the local
- * transaction (tx). This instance registers with the TransactionManager automatically
- *
- * @param tx
- */
- public static OrderedSynchronizationHandler getInstance(Transaction tx) throws SystemException, RollbackException
- {
- OrderedSynchronizationHandler retval = (OrderedSynchronizationHandler) instances.get(tx);
- if (retval != null) return retval;
- retval = new OrderedSynchronizationHandler(tx);
- tx.registerSynchronization(retval);
- instances.put(tx, retval);
- return retval;
- }
-
-
public void registerAtHead(Synchronization handler)
{
register(handler, true);
@@ -101,9 +78,6 @@
}
}
- // finally unregister us from the hashmap
- instances.remove(tx);
-
// throw the exception so the TM can deal with it.
if (exceptionInAfterCompletion != null) throw exceptionInAfterCompletion;
}
@@ -114,13 +88,13 @@
sb.append("tx=" + getTxAsString() + ", handlers=" + handlers);
return sb.toString();
}
-
+
private String getTxAsString()
{
// JBCACHE-1114 -- don't call toString() on tx or it can lead to stack overflow
if (tx == null)
return null;
-
+
return tx.getClass().getName() + "@" + System.identityHashCode(tx);
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2008-03-07 15:48:54 UTC (rev 5399)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2008-03-07 17:05:23 UTC (rev 5400)
@@ -383,20 +383,24 @@
// entry for TX in txTable, the modifications
// below will need this entry to add their modifications
// under the GlobalTx key
+ TransactionEntry entry;
if (txTable.get(gtx) == null)
{
// create a new transaction entry
- TransactionEntry entry = configuration.isNodeLockingOptimistic() ? new OptimisticTransactionEntry() : new TransactionEntry();
- entry.setTransaction(ltx);
+ entry = configuration.isNodeLockingOptimistic() ? new OptimisticTransactionEntry(ltx) : new TransactionEntry(ltx);
log.debug("creating new tx entry");
txTable.put(gtx, entry);
if (trace) log.trace("TxTable contents: " + txTable);
}
+ else
+ {
+ entry = txTable.get(gtx);
+ }
setTransactionalContext(ltx, gtx, ctx);
// register a sync handler for this tx.
- registerHandler(ltx, new RemoteSynchronizationHandler(gtx, ltx), ctx);
+ registerHandler(ltx, new RemoteSynchronizationHandler(gtx, ltx), ctx, entry);
if (configuration.isNodeLockingOptimistic())
{
@@ -1054,7 +1058,7 @@
}
// see the comment in the LocalSyncHandler for the last isOriginLocal param.
LocalSynchronizationHandler myHandler = new LocalSynchronizationHandler(gtx, tx, !ctx.isOriginLocal());
- registerHandler(tx, myHandler, ctx);
+ registerHandler(tx, myHandler, ctx, txTable.get(gtx));
}
}
else if ((gtx = (GlobalTransaction) rollbackTransactions.get(tx)) != null)
@@ -1076,9 +1080,9 @@
* @param handler
* @throws Exception
*/
- private void registerHandler(Transaction tx, Synchronization handler, InvocationContext ctx) throws Exception
+ private void registerHandler(Transaction tx, Synchronization handler, InvocationContext ctx, TransactionEntry entry) throws Exception
{
- OrderedSynchronizationHandler orderedHandler = OrderedSynchronizationHandler.getInstance(tx);
+ OrderedSynchronizationHandler orderedHandler = entry.getOrderedSynchronizationHandler(); //OrderedSynchronizationHandler.getInstance(tx);
if (trace) log.trace("registering for TX completion: SynchronizationHandler(" + handler + ")");
Modified: core/trunk/src/main/java/org/jboss/cache/transaction/OptimisticTransactionEntry.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/OptimisticTransactionEntry.java 2008-03-07 15:48:54 UTC (rev 5399)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/OptimisticTransactionEntry.java 2008-03-07 17:05:23 UTC (rev 5400)
@@ -9,6 +9,10 @@
import org.jboss.cache.optimistic.TransactionWorkspace;
import org.jboss.cache.optimistic.TransactionWorkspaceImpl;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+
/**
* Subclasses the {@link TransactionEntry} class to add a {@link TransactionWorkspace}. Used with optimistic locking
* where each call is assigned a trasnaction and a transaction workspace.
@@ -21,6 +25,11 @@
{
private TransactionWorkspace transactionWorkSpace = new TransactionWorkspaceImpl();
+ public OptimisticTransactionEntry(Transaction tx) throws SystemException, RollbackException
+ {
+ super(tx);
+ }
+
public String toString()
{
StringBuffer sb = new StringBuffer(super.toString());
Modified: core/trunk/src/main/java/org/jboss/cache/transaction/TransactionEntry.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/TransactionEntry.java 2008-03-07 15:48:54 UTC (rev 5399)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/TransactionEntry.java 2008-03-07 17:05:23 UTC (rev 5400)
@@ -15,11 +15,14 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
import org.jboss.cache.config.Option;
+import org.jboss.cache.interceptors.OrderedSynchronizationHandler;
import org.jboss.cache.invocation.CacheInvocationDelegate;
import org.jboss.cache.lock.IdentityLock;
import org.jboss.cache.lock.NodeLock;
import org.jboss.cache.marshall.MethodCall;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
import javax.transaction.Transaction;
import java.util.ArrayList;
import java.util.Collection;
@@ -57,6 +60,7 @@
*/
private Transaction ltx = null;
private Option option;
+ private OrderedSynchronizationHandler orderedSynchronizationHandler;
private boolean forceAsyncReplication = false;
private boolean forceSyncReplication = false;
@@ -97,6 +101,12 @@
*/
private List<Fqn> removedNodes = new LinkedList<Fqn>();
+ public TransactionEntry(Transaction tx) throws SystemException, RollbackException
+ {
+ ltx = tx;
+ orderedSynchronizationHandler = new OrderedSynchronizationHandler(tx);
+ }
+
/**
* Adds a modification to the modification list.
*/
@@ -412,4 +422,14 @@
{
return this.option;
}
+
+ public OrderedSynchronizationHandler getOrderedSynchronizationHandler()
+ {
+ return orderedSynchronizationHandler;
+ }
+
+ public void setOrderedSynchronizationHandler(OrderedSynchronizationHandler orderedSynchronizationHandler)
+ {
+ this.orderedSynchronizationHandler = orderedSynchronizationHandler;
+ }
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/TcpCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/TcpCacheLoaderTest.java 2008-03-07 15:48:54 UTC (rev 5399)
+++ core/trunk/src/test/java/org/jboss/cache/loader/TcpCacheLoaderTest.java 2008-03-07 17:05:23 UTC (rev 5400)
@@ -1,8 +1,8 @@
package org.jboss.cache.loader;
import org.jboss.cache.CacheException;
+import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
-import org.jboss.cache.CacheSPI;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.interceptors.OrderedSynchronizationHandler;
@@ -11,6 +11,7 @@
import org.jboss.cache.notifications.annotation.CacheListener;
import org.jboss.cache.notifications.annotation.NodeCreated;
import org.jboss.cache.notifications.event.Event;
+import org.jboss.cache.transaction.GlobalTransaction;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -184,7 +185,15 @@
{
int oldStartCount = START_COUNT;
cache.getTransactionManager().begin();
- OrderedSynchronizationHandler.getInstance(cache.getTransactionManager().getTransaction()).registerAtTail(
+
+ cache.put(FQN, "key", "value");
+ cache.put(FQN, "key2", "value2");
+
+ GlobalTransaction gtx = cache.getTransactionTable().get(cache.getTransactionManager().getTransaction());
+ OrderedSynchronizationHandler osh = cache.getTransactionTable().get(gtx).getOrderedSynchronizationHandler();
+
+// OrderedSynchronizationHandler.getInstance(cache.getTransactionManager().getTransaction()).registerAtTail(
+ osh.registerAtTail(
new Synchronization()
{
@@ -201,8 +210,6 @@
}
);
- cache.put(FQN, "key", "value");
- cache.put(FQN, "key2", "value2");
cache.getTransactionManager().commit();
Map m = new HashMap();
Modified: core/trunk/src/test/java/org/jboss/cache/transaction/AbortionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/AbortionTest.java 2008-03-07 15:48:54 UTC (rev 5399)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/AbortionTest.java 2008-03-07 17:05:23 UTC (rev 5400)
@@ -34,25 +34,16 @@
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- System.out.println("********* START: SET UP *************");
cache1 = initCache(false);
TestingUtil.sleepThread(1500); // to ensure cache1 is the coordinator
cache2 = initCache(false);
cache3 = initCache(true);
- System.out.println("********* END: SET UP *************");
}
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- System.out.println("********* START: TEAR DOWN *************");
- destroyCache(cache3);
- destroyCache(cache2);
- destroyCache(cache1);
- cache1 = null;
- cache2 = null;
- cache3 = null;
- System.out.println("********* END: TEAR DOWN *************");
+ TestingUtil.killCaches(cache3, cache2, cache1);
}
private CacheSPI initCache(boolean notifying)
@@ -121,6 +112,7 @@
TransactionManager mgr2 = cache2.getTransactionManager();
assertTrue(cache3.getTransactionManager() instanceof NotifyingTransactionManager);
NotifyingTransactionManager mgr3 = (NotifyingTransactionManager) cache3.getTransactionManager();
+ mgr3.setCache(cache3);
assertSame(mgr1, mgr2);
assertNotSame(mgr1, mgr3);
@@ -160,8 +152,10 @@
this.abortBeforeCompletion = abortBeforeCompletion;
}
- public void notify(Transaction tx) throws SystemException, RollbackException
+ public void notify(Transaction tx, TransactionEntry entry) throws SystemException, RollbackException
{
+ OrderedSynchronizationHandler osh = entry.getOrderedSynchronizationHandler();
+
final Transaction finalTx = tx;
System.out.println("Notify called.");
// add an aborting sync handler.
@@ -197,7 +191,6 @@
}
};
- OrderedSynchronizationHandler osh = OrderedSynchronizationHandler.getInstance(tx);
osh.registerAtHead(abort);
System.out.println("Added sync handler.");
}
Modified: core/trunk/src/test/java/org/jboss/cache/transaction/InvocationContextCleanupTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/InvocationContextCleanupTest.java 2008-03-07 15:48:54 UTC (rev 5399)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/InvocationContextCleanupTest.java 2008-03-07 17:05:23 UTC (rev 5400)
@@ -81,10 +81,13 @@
mgr.begin();
- OrderedSynchronizationHandler orderedHandler = OrderedSynchronizationHandler.getInstance(mgr.getTransaction());
+ cache0.put("/test", "x", "y");
+
+ GlobalTransaction gtx = cache0.getTransactionTable().get(mgr.getTransaction());
+ OrderedSynchronizationHandler orderedHandler = cache0.getTransactionTable().get(gtx).getOrderedSynchronizationHandler();
+// OrderedSynchronizationHandler orderedHandler = OrderedSynchronizationHandler.getInstance(mgr.getTransaction());
orderedHandler.registerAtTail(new DummySynchronization(cache0, mgr));
- cache0.put("/test", "x", "y");
try
{
mgr.commit();
Modified: core/trunk/src/test/java/org/jboss/cache/transaction/NotifyingTransactionManager.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/NotifyingTransactionManager.java 2008-03-07 15:48:54 UTC (rev 5399)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/NotifyingTransactionManager.java 2008-03-07 17:05:23 UTC (rev 5400)
@@ -7,7 +7,10 @@
package org.jboss.cache.transaction;
-import javax.transaction.NotSupportedException;
+import org.jboss.cache.CacheSPI;
+
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
import javax.transaction.RollbackException;
import javax.transaction.SystemException;
import javax.transaction.Transaction;
@@ -24,18 +27,35 @@
private static final long serialVersionUID = -2994163352889758708L;
private Notification notification;
+ private CacheSPI cache;
- public void begin() throws SystemException, NotSupportedException
+ @Override
+ public void commit() throws HeuristicMixedException, SystemException, HeuristicRollbackException, RollbackException
{
- super.begin();
+ notifyListeners();
+ super.commit();
+ }
+
+ @Override
+ public void rollback() throws SystemException
+ {
+ notifyListeners();
+ super.rollback();
+ }
+
+ private void notifyListeners()
+ {
try
{
- System.out.println("Calling notification.notify()");
- notification.notify(getTransaction());
+ log.debug("Calling notification.notify()");
+ TransactionTable txTable = cache.getTransactionTable();
+ Transaction tx = getTransaction();
+ GlobalTransaction gtx = txTable.get(tx);
+ notification.notify(tx, txTable.get(gtx));
}
- catch (RollbackException e)
+ catch (Exception e)
{
- e.printStackTrace();
+ log.debug(e);
}
}
@@ -46,15 +66,23 @@
public interface Notification
{
- public void notify(Transaction tx) throws SystemException, RollbackException;
+ public void notify(Transaction tx, TransactionEntry entry) throws SystemException, RollbackException;
}
-
+ public CacheSPI getCache()
+ {
+ return cache;
+ }
+
+ public void setCache(CacheSPI cache)
+ {
+ this.cache = cache;
+ }
+
public Notification getNotification()
{
return notification;
}
-
public void setNotification(Notification notification)
{
16 years, 1 month
JBoss Cache SVN: r5399 - in core/trunk/src/main/docbook: css and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-03-07 10:48:54 -0500 (Fri, 07 Mar 2008)
New Revision: 5399
Added:
core/trunk/src/main/docbook/css/
core/trunk/src/main/docbook/css/dummy.css
Log:
Added placeholder css file
Added: core/trunk/src/main/docbook/css/dummy.css
===================================================================
--- core/trunk/src/main/docbook/css/dummy.css (rev 0)
+++ core/trunk/src/main/docbook/css/dummy.css 2008-03-07 15:48:54 UTC (rev 5399)
@@ -0,0 +1 @@
+/* This is a placeholder */
\ No newline at end of file
16 years, 1 month
JBoss Cache SVN: r5398 - pojo/trunk.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-03-07 10:20:13 -0500 (Fri, 07 Mar 2008)
New Revision: 5398
Modified:
pojo/trunk/pom.xml
Log:
Updated transformations to use standard JBoss.org look and feel
Modified: pojo/trunk/pom.xml
===================================================================
--- pojo/trunk/pom.xml 2008-03-07 15:19:09 UTC (rev 5397)
+++ pojo/trunk/pom.xml 2008-03-07 15:20:13 UTC (rev 5398)
@@ -147,12 +147,18 @@
<version>2.0.0</version>
<extensions>true</extensions>
<dependencies>
- <dependency>
- <groupId>org.jboss.cache</groupId>
- <artifactId>jbosscache-doc-xslt-support</artifactId>
- <version>1.0</version>
- </dependency>
- </dependencies>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jbossorg-docbook-xslt</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jbossorg-jdocbook-style</artifactId>
+ <version>1.0.0</version>
+ <type>jdocbook-style</type>
+ </dependency>
+ </dependencies>
<executions>
<!-- The User Guide-->
@@ -176,20 +182,20 @@
<formats>
<format>
<formatName>pdf</formatName>
- <stylesheetResource>classpath:/standard/fopdf.xsl</stylesheetResource>
+ <stylesheetResource>classpath:/xslt/org/jboss/main-pdf.xsl</stylesheetResource>
<finalName>userguide_en.pdf</finalName>
</format>
- <format>
- <formatName>html</formatName>
- <stylesheetResource>classpath:/standard/html_chunk.xsl</stylesheetResource>
- <finalName>index.html</finalName>
- </format>
- <format>
- <formatName>html_single</formatName>
- <stylesheetResource>classpath:/standard/html.xsl</stylesheetResource>
- <finalName>index.html</finalName>
- </format>
- </formats>
+ <format>
+ <formatName>html</formatName>
+ <stylesheetResource>classpath:/xslt/org/jboss/main-html.xsl</stylesheetResource>
+ <finalName>index.html</finalName>
+ </format>
+ <format>
+ <formatName>html_single</formatName>
+ <stylesheetResource>classpath:/xslt/org/jboss/nochunk-html.xsl</stylesheetResource>
+ <finalName>index.html</finalName>
+ </format>
+ </formats>
<options>
<xincludeSupported>false</xincludeSupported>
</options>
@@ -217,19 +223,19 @@
<formats>
<format>
<formatName>pdf</formatName>
- <stylesheetResource>classpath:/standard/fopdf.xsl</stylesheetResource>
+ <stylesheetResource>classpath:/xslt/org/jboss/main-pdf.xsl</stylesheetResource>
<finalName>tutorial_en.pdf</finalName>
</format>
- <format>
- <formatName>html</formatName>
- <stylesheetResource>classpath:/standard/html_chunk.xsl</stylesheetResource>
- <finalName>index.html</finalName>
- </format>
- <format>
- <formatName>html_single</formatName>
- <stylesheetResource>classpath:/standard/html.xsl</stylesheetResource>
- <finalName>index.html</finalName>
- </format>
+ <format>
+ <formatName>html</formatName>
+ <stylesheetResource>classpath:/xslt/org/jboss/main-html.xsl</stylesheetResource>
+ <finalName>index.html</finalName>
+ </format>
+ <format>
+ <formatName>html_single</formatName>
+ <stylesheetResource>classpath:/xslt/org/jboss/nochunk-html.xsl</stylesheetResource>
+ <finalName>index.html</finalName>
+ </format>
</formats>
<options>
<xincludeSupported>false</xincludeSupported>
@@ -258,19 +264,19 @@
<formats>
<format>
<formatName>pdf</formatName>
- <stylesheetResource>classpath:/standard/fopdf.xsl</stylesheetResource>
+ <stylesheetResource>classpath:/xslt/org/jboss/main-pdf.xsl</stylesheetResource>
<finalName>faq_en.pdf</finalName>
</format>
- <format>
- <formatName>html</formatName>
- <stylesheetResource>classpath:/standard/html_chunk.xsl</stylesheetResource>
- <finalName>index.html</finalName>
- </format>
- <format>
- <formatName>html_single</formatName>
- <stylesheetResource>classpath:/standard/html.xsl</stylesheetResource>
- <finalName>index.html</finalName>
- </format>
+ <format>
+ <formatName>html</formatName>
+ <stylesheetResource>classpath:/xslt/org/jboss/main-html.xsl</stylesheetResource>
+ <finalName>index.html</finalName>
+ </format>
+ <format>
+ <formatName>html_single</formatName>
+ <stylesheetResource>classpath:/xslt/org/jboss/nochunk-html.xsl</stylesheetResource>
+ <finalName>index.html</finalName>
+ </format>
</formats>
<options>
<xincludeSupported>false</xincludeSupported>
16 years, 1 month
JBoss Cache SVN: r5397 - in core/trunk: src/main/docbook and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-03-07 10:19:09 -0500 (Fri, 07 Mar 2008)
New Revision: 5397
Removed:
core/trunk/src/main/docbook/css/
Modified:
core/trunk/pom.xml
core/trunk/src/main/docbook/userguide/en/master.xml
Log:
Updated documentation
Updated html transformations to use standard JBoss.org look and feel
Removed custom CSS stylesheets
Modified: core/trunk/pom.xml
===================================================================
--- core/trunk/pom.xml 2008-03-07 12:30:19 UTC (rev 5396)
+++ core/trunk/pom.xml 2008-03-07 15:19:09 UTC (rev 5397)
@@ -162,10 +162,16 @@
<extensions>true</extensions>
<dependencies>
<dependency>
- <groupId>org.jboss.cache</groupId>
- <artifactId>jbosscache-doc-xslt-support</artifactId>
- <version>1.0</version>
+ <groupId>org.jboss</groupId>
+ <artifactId>jbossorg-docbook-xslt</artifactId>
+ <version>1.0.0</version>
</dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jbossorg-jdocbook-style</artifactId>
+ <version>1.0.0</version>
+ <type>jdocbook-style</type>
+ </dependency>
</dependencies>
<executions>
@@ -190,17 +196,17 @@
<formats>
<format>
<formatName>pdf</formatName>
- <stylesheetResource>classpath:/standard/fopdf.xsl</stylesheetResource>
+ <stylesheetResource>classpath:/xslt/org/jboss/main-pdf.xsl</stylesheetResource>
<finalName>userguide_en.pdf</finalName>
</format>
<format>
<formatName>html</formatName>
- <stylesheetResource>classpath:/standard/html_chunk.xsl</stylesheetResource>
+ <stylesheetResource>classpath:/xslt/org/jboss/main-html.xsl</stylesheetResource>
<finalName>index.html</finalName>
</format>
<format>
<formatName>html_single</formatName>
- <stylesheetResource>classpath:/standard/html.xsl</stylesheetResource>
+ <stylesheetResource>classpath:/xslt/org/jboss/nochunk-html.xsl</stylesheetResource>
<finalName>index.html</finalName>
</format>
</formats>
@@ -231,17 +237,17 @@
<formats>
<format>
<formatName>pdf</formatName>
- <stylesheetResource>classpath:/standard/fopdf.xsl</stylesheetResource>
+ <stylesheetResource>classpath:/xslt/org/jboss/main-pdf.xsl</stylesheetResource>
<finalName>tutorial_en.pdf</finalName>
</format>
<format>
<formatName>html</formatName>
- <stylesheetResource>classpath:/standard/html_chunk.xsl</stylesheetResource>
+ <stylesheetResource>classpath:/xslt/org/jboss/main-html.xsl</stylesheetResource>
<finalName>index.html</finalName>
</format>
<format>
<formatName>html_single</formatName>
- <stylesheetResource>classpath:/standard/html.xsl</stylesheetResource>
+ <stylesheetResource>classpath:/xslt/org/jboss/nochunk-html.xsl</stylesheetResource>
<finalName>index.html</finalName>
</format>
</formats>
@@ -272,17 +278,17 @@
<formats>
<format>
<formatName>pdf</formatName>
- <stylesheetResource>classpath:/standard/fopdf.xsl</stylesheetResource>
+ <stylesheetResource>classpath:/xslt/org/jboss/main-pdf.xsl</stylesheetResource>
<finalName>faq_en.pdf</finalName>
</format>
<format>
<formatName>html</formatName>
- <stylesheetResource>classpath:/standard/html_chunk.xsl</stylesheetResource>
+ <stylesheetResource>classpath:/xslt/org/jboss/main-html.xsl</stylesheetResource>
<finalName>index.html</finalName>
</format>
<format>
<formatName>html_single</formatName>
- <stylesheetResource>classpath:/standard/html.xsl</stylesheetResource>
+ <stylesheetResource>classpath:/xslt/org/jboss/nochunk-html.xsl</stylesheetResource>
<finalName>index.html</finalName>
</format>
</formats>
Modified: core/trunk/src/main/docbook/userguide/en/master.xml
===================================================================
--- core/trunk/src/main/docbook/userguide/en/master.xml 2008-03-07 12:30:19 UTC (rev 5396)
+++ core/trunk/src/main/docbook/userguide/en/master.xml 2008-03-07 15:19:09 UTC (rev 5397)
@@ -118,7 +118,7 @@
</part>
<part label="III">
- <title>JBoss Cache References</title>
+ <title>JBoss Cache Configuration References</title>
<partintro>
<para>
This section contains technical references for easy looking up.
16 years, 1 month
JBoss Cache SVN: r5396 - in core/trunk/src/main/java/org/jboss/cache: factories and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-03-07 07:30:19 -0500 (Fri, 07 Mar 2008)
New Revision: 5396
Modified:
core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java
core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java
Log:
JBCACHE-1300 - Standardize mechanism for setting defaultClassLoader
Modified: core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java 2008-03-07 09:21:32 UTC (rev 5395)
+++ core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java 2008-03-07 12:30:19 UTC (rev 5396)
@@ -33,6 +33,8 @@
*/
public class DefaultCacheFactory<K, V> extends ComponentFactory implements CacheFactory<K, V>
{
+ private ClassLoader defaultClassLoader;
+
/**
* Note - this method used to return a singleton instance, and since 2.1.0 returns a new instance. The method is
* deprecated and you should use the no-arg constructor to create a new instance of this factory.
@@ -131,7 +133,7 @@
{
// injection bootstrap stuff
componentRegistry = cache.getComponentRegistry();
-
+ componentRegistry.registerDefaultClassLoader(defaultClassLoader);
this.configuration = configuration;
// make sure we set the CacheImpl and CacheSPI instance in the component registry.
@@ -139,6 +141,16 @@
componentRegistry.registerComponent(CacheSPI.class.getName(), spi, CacheSPI.class);
}
+ /**
+ * Allows users to specify a default class loader to use for both the construction and running of the cache.
+ *
+ * @param loader class loader to use as a default.
+ */
+ public void setDefaultClassLoader(ClassLoader loader)
+ {
+ this.defaultClassLoader = loader;
+ }
+
public Cache<K, V> createCache(InputStream is) throws ConfigurationException
{
XmlConfigurationParser parser = new XmlConfigurationParser();
Modified: core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java 2008-03-07 09:21:32 UTC (rev 5395)
+++ core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java 2008-03-07 12:30:19 UTC (rev 5396)
@@ -91,11 +91,24 @@
public ComponentRegistry(Configuration configuration)
{
// bootstrap.
- registerComponent("deployerClassLoader", getClass().getClassLoader(), ClassLoader.class);
+ registerDefaultClassLoader(null);
registerComponent(this, ComponentRegistry.class);
registerComponent(configuration, Configuration.class);
}
+ /**
+ * Registers the default class loader. This method *must* be called before any other components are registered,
+ * typically called by bootstrap code. Defensively, it is called in the constructor of ComponentRegistry with a null
+ * parameter.
+ *
+ * @param loader a class loader to use by default. If this is null, the class loader used to load this instance of ComponentRegistry is used.
+ */
+ public void registerDefaultClassLoader(ClassLoader loader)
+ {
+ registerComponent("deployerClassLoader", loader == null ? getClass().getClassLoader() : loader, ClassLoader.class);
+ }
+
+
public State getOverallState()
{
return overallState;
16 years, 1 month
JBoss Cache SVN: r5395 - core/trunk.
by jbosscache-commits@lists.jboss.org
Author: galder.zamarreno(a)jboss.com
Date: 2008-03-07 04:21:32 -0500 (Fri, 07 Mar 2008)
New Revision: 5395
Modified:
core/trunk/pom.xml
Log:
[JBossAS-profile] switched profile JBC version to 2.1.0-SNAPSHOT and updated JGroups version there.
Modified: core/trunk/pom.xml
===================================================================
--- core/trunk/pom.xml 2008-03-07 02:43:26 UTC (rev 5394)
+++ core/trunk/pom.xml 2008-03-07 09:21:32 UTC (rev 5395)
@@ -315,13 +315,13 @@
<activeByDefault>false</activeByDefault>
</activation>
<properties>
- <jbosscache-core-version>2.1.0.CR3-JBossAS</jbosscache-core-version>
+ <jbosscache-core-version>2.1.0-SNAPSHOT-JBossAS</jbosscache-core-version>
</properties>
<dependencies>
<dependency>
<groupId>jgroups</groupId>
<artifactId>jgroups</artifactId>
- <version>2.6.1</version>
+ <version>2.6.2</version>
</dependency>
<dependency>
<groupId>org.jboss.javaee</groupId>
16 years, 1 month
JBoss Cache SVN: r5394 - in core/trunk/src: test/java/org/jboss/cache/api and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-03-06 21:43:26 -0500 (Thu, 06 Mar 2008)
New Revision: 5394
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
core/trunk/src/test/java/org/jboss/cache/api/DeletedChildResurrectionTest.java
Log:
JBCACHE-1296 - if we'll rollback the tx, data should be added to the node again
+ enhanced the test
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java 2008-03-07 00:56:47 UTC (rev 5393)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java 2008-03-07 02:43:26 UTC (rev 5394)
@@ -18,17 +18,15 @@
import org.jboss.cache.lock.NodeLock;
import org.jboss.cache.lock.TimeoutException;
import org.jboss.cache.marshall.MethodDeclarations;
+import org.jboss.cache.marshall.MethodCallFactory;
+import org.jboss.cache.marshall.MethodCall;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionEntry;
import org.jboss.cache.transaction.TransactionTable;
import org.jgroups.Address;
import javax.transaction.Transaction;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
/*
* todo refactorings ideas
@@ -624,10 +622,18 @@
*/
private void manageReverseRemove(GlobalTransaction gtx, NodeSPI childNode, boolean reverseRemoveCheck, List createdNodes)
{
- boolean needToReverseRemove = reverseRemoveCheck && childNode.isDeleted() && tx_table.isNodeRemovedInTx(gtx, childNode.getFqn());
- if (gtx != null && needToReverseRemove)
+ if (gtx != null) //if no tx then reverse remove does not make sense
{
+ Fqn fqn = childNode.getFqn();
+ boolean needToReverseRemove = reverseRemoveCheck && childNode.isDeleted() && tx_table.isNodeRemovedInTx(gtx, fqn);
+ if (!needToReverseRemove) return;
childNode.markAsDeleted(false);
+ //if we'll rollback the tx data should be added to the node again
+ Map oldData = new HashMap(childNode.getDataDirect());
+ MethodCall undoOp = MethodCallFactory.create(MethodDeclarations.putDataMethodLocal_id,
+ gtx, fqn, oldData , false);
+ tx_table.get(gtx).addUndoOperation(undoOp);
+ //we're prepared for rollback, now reset the node
childNode.clearDataDirect();
if (createdNodes != null)
{
Modified: core/trunk/src/test/java/org/jboss/cache/api/DeletedChildResurrectionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/DeletedChildResurrectionTest.java 2008-03-07 00:56:47 UTC (rev 5393)
+++ core/trunk/src/test/java/org/jboss/cache/api/DeletedChildResurrectionTest.java 2008-03-07 02:43:26 UTC (rev 5394)
@@ -106,11 +106,13 @@
TransactionManager txManager = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
root.addChild(A_B).put(KEY, VALUE);
+ cache.put(A, "key","value");
txManager.begin();
root.removeChild(A);
root.addChild(A);
txManager.commit();
assert !root.hasChild(A_B);
+ assert null == cache.get(A, "key");
// do a peek to ensure the node really has been removed and not just marked for removal
assert spi.peek(A_B, true, true) == null;
assert root.hasChild(A);
16 years, 1 month
JBoss Cache SVN: r5393 - in core/trunk/src: test/java/org/jboss/cache/invalidation and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-03-06 19:56:47 -0500 (Thu, 06 Mar 2008)
New Revision: 5393
Modified:
core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
core/trunk/src/test/java/org/jboss/cache/invalidation/InvalidationInterceptorTest.java
Log:
JBCACHE-1298 - removal of nonexistent nodes using invalidation and creation of invalid tombstones
Modified: core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2008-03-06 21:51:14 UTC (rev 5392)
+++ core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2008-03-07 00:56:47 UTC (rev 5393)
@@ -11,6 +11,7 @@
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.buddyreplication.GravitateResult;
import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Option;
import org.jboss.cache.factories.ComponentRegistry;
import org.jboss.cache.factories.InterceptorChainFactory;
import org.jboss.cache.factories.annotations.ComponentName;
@@ -1595,12 +1596,20 @@
NodeSPI nodeSPI = peek(fqn, false, true);
if (nodeSPI == null)
{
- log.trace("Node doesn't exist; creating a tombstone");
+ if (versionToInvalidate == null)
+ {
+ if (trace)
+ log.trace("Would have created a tombstone since the node doesn't exist, but the version to invalidate is null and hence cannot create a tombstone!");
+ return;
+ }
+ if (trace) log.trace("Node doesn't exist; creating a tombstone with data version " + versionToInvalidate);
// create the node we need.
Map m = Collections.emptyMap();
InvocationContext ic = spi.getInvocationContext();
- boolean origCacheModeLocal = ic.getOptionOverrides().isCacheModeLocal();
- ic.getOptionOverrides().setCacheModeLocal(true);
+ Option o = ic.getOptionOverrides();
+ boolean origCacheModeLocal = o.isCacheModeLocal();
+ o.setCacheModeLocal(true);
+ o.setDataVersion(versionToInvalidate);
// if we are in a tx this call should happen outside of any tx
try
{
Modified: core/trunk/src/test/java/org/jboss/cache/invalidation/InvalidationInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/invalidation/InvalidationInterceptorTest.java 2008-03-06 21:51:14 UTC (rev 5392)
+++ core/trunk/src/test/java/org/jboss/cache/invalidation/InvalidationInterceptorTest.java 2008-03-07 00:56:47 UTC (rev 5393)
@@ -20,7 +20,6 @@
import org.jboss.cache.optimistic.DefaultDataVersion;
import org.jboss.cache.xml.XmlHelper;
import static org.testng.AssertJUnit.*;
-
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
import org.w3c.dom.Element;
@@ -463,7 +462,7 @@
/**
* Test for JBCACHE-1251.
- *
+ *
* @throws Exception
*/
public void testPessimisticNodeResurrection2() throws Exception
@@ -475,7 +474,7 @@
* OPTIMISTIC locking verion of test for JBCACHE-1251. JBCACHE-1251
* did not effect optimistic, but we add the test to guard against
* regressions.
- *
+ *
* @throws Exception
*/
public void testOptimisticNodeResurrection2() throws Exception
@@ -485,17 +484,17 @@
/**
* Here we model a scenario where a parent node represents
- * a structural node, and then child nodes represent different
+ * a structural node, and then child nodes represent different
* data elements.
- *
- * Such data structures are set up on both caches, and then the parent node
- * is removed (globally) and re-added (locally) on one cache. This
- * represents an attempt to clear the region -- removing a node and
+ * <p/>
+ * Such data structures are set up on both caches, and then the parent node
+ * is removed (globally) and re-added (locally) on one cache. This
+ * represents an attempt to clear the region -- removing a node and
* re-adding is one of the only ways to do this.
- *
+ * <p/>
* On the second cache, the fact that the structural node is missing is
* detected, and an attempt is made to re-add it locally.
- *
+ *
* @param optimistic should the cache be configured for optimistic locking
* @throws Exception
*/
@@ -515,20 +514,20 @@
cache2.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
root1.addChild(fqn);
assertEquals(true, root1.hasChild(fqn));
-
+
Fqn<String> child = new Fqn(fqn, "child");
cache1.putForExternalRead(child, "key", "value");
cache2.putForExternalRead(child, "key", "value");
assertEquals("value", cache1.get(child, "key"));
- assertEquals("value", cache2.get(child, "key"));
-
+ assertEquals("value", cache2.get(child, "key"));
+
assertEquals(true, cache1.removeNode(fqn));
assertFalse(root1.hasChild(fqn));
cache1.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
root1.addChild(fqn);
assertEquals(true, root1.hasChild(fqn));
-
+
Node remoteNode = root2.getChild(fqn);
checkRemoteNodeIsRemoved(remoteNode);
cache2.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
@@ -756,22 +755,22 @@
n = caches.get(0).getNode(fqn);
assertHasBeenInvalidated(n, "Should have been invalidated");
}
-
+
public void testDeleteNonExistentPessimistic() throws Exception
{
deleteNonExistentTest(false);
}
-
+
/**
* Test for JBCACHE-1297
- *
+ *
* @throws Exception
*/
public void testDeleteNonExistentOptimistic() throws Exception
{
deleteNonExistentTest(true);
}
-
+
private void deleteNonExistentTest(boolean optimistic) throws Exception
{
List<CacheSPI<Object, Object>> caches = new ArrayList<CacheSPI<Object, Object>>();
@@ -791,10 +790,10 @@
assertNull("Should be null", cache2.getNode(fqn));
cache1.putForExternalRead(fqn, "key", "value");
-
- assertEquals("value",cache1.getNode(fqn).get("key"));
+
+ assertEquals("value", cache1.getNode(fqn).get("key"));
assertNull("Should be null", cache2.getNode(fqn));
-
+
// OK, here's the real test
TransactionManager tm = cache2.getTransactionManager();
tm.begin();
@@ -810,34 +809,28 @@
log.error(msg, e);
fail(msg + " -- " + e);
}
-
- assertHasBeenInvalidated(cache1.getNode(fqn), "Should have been invalidated");
- assertNull("Should be null", cache2.getNode(fqn));
+
+ assertHasBeenInvalidated(cache1.getNode(fqn), "Should have been invalidated");
+ assertNull("Should be null", cache2.getNode(fqn));
}
-
+
/**
* Test for JBCACHE-1298.
- *
+ *
* @throws Exception
*/
public void testAddOfDeletedNonExistent() throws Exception
{
- List<CacheSPI<Object, Object>> caches = new ArrayList<CacheSPI<Object, Object>>();
- caches.add(createUnstartedCache(true));
- caches.add(createUnstartedCache(true));
- cache1 = caches.get(0);
- cache2 = caches.get(1);
+ cache1 = createCache(true);
+ cache2 = createCache(true);
- cache1.start();
- cache2.start();
+ TestingUtil.blockUntilViewsReceived(5000, cache1, cache2);
- TestingUtil.blockUntilViewsReceived(caches.toArray(new CacheSPI[0]), 5000);
-
Fqn fqn = Fqn.fromString("/a/b");
assertNull("Should be null", cache1.getNode(fqn));
assertNull("Should be null", cache2.getNode(fqn));
-
+
// OK, here's the real test
TransactionManager tm = cache2.getTransactionManager();
tm.begin();
@@ -853,17 +846,17 @@
log.error(msg, e);
fail(msg + " -- " + e);
}
-
+
// Actually, it shouldn't have been invalidated, should be null
// But, this assertion will pass if it is null, and we want
- assertHasBeenInvalidated(cache1.getNode(fqn), "Should have been invalidated");
- assertNull("Should be null", cache2.getNode(fqn));
+ assertHasBeenInvalidated(cache1.getNode(fqn), "Should have been invalidated");
+ assertNull("Should be null", cache2.getNode(fqn));
cache1.getInvocationContext().getOptionOverrides().setDataVersion(new DefaultDataVersion());
cache1.put(fqn, "key", "value");
-
+
assertEquals("value", cache1.getNode(fqn).get("key"));
- assertHasBeenInvalidated(cache2.getNode(fqn), "Should have been invalidated");
+ assertHasBeenInvalidated(cache2.getNode(fqn), "Should have been invalidated");
}
protected CacheSPI<Object, Object> createUnstartedCache(boolean optimistic) throws Exception
16 years, 1 month
JBoss Cache SVN: r5392 - core/trunk/src/test/java/org/jboss/cache/notifications.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-03-06 16:51:14 -0500 (Thu, 06 Mar 2008)
New Revision: 5392
Modified:
core/trunk/src/test/java/org/jboss/cache/notifications/RemoteCacheListenerTest.java
Log:
fixed testStateTransfer in the case of optimistic lock:
- in case of optimistic locking an transaction registered event was expected. This is incorrect as locking in case of state transfer is always pessimistic . The assesment was introduced as a workaround in 2.1.0CR3, when a non-direct cache call was performed in DefaultStateTransferIntegrator.retainInternalNodes.
Modified: core/trunk/src/test/java/org/jboss/cache/notifications/RemoteCacheListenerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/notifications/RemoteCacheListenerTest.java 2008-03-06 02:01:44 UTC (rev 5391)
+++ core/trunk/src/test/java/org/jboss/cache/notifications/RemoteCacheListenerTest.java 2008-03-06 21:51:14 UTC (rev 5392)
@@ -659,11 +659,6 @@
List<Event> expected = new ArrayList<Event>();
// public EventImpl(boolean pre, Cache cache, ModificationType modificationType, Map data, Fqn fqn,
// Transaction transaction, boolean originLocal, Fqn targetFqn, boolean successful, View newView, Type type)
- if (optLocking)
- expected.add(new EventImpl(false, cache2, null, null, null, null, true, null, false, null, TRANSACTION_REGISTERED));
- if (optLocking)
- expected.add(new EventImpl(false, cache2, null, null, null, null, true, null, true, null, TRANSACTION_COMPLETED));
-
expected.add(new EventImpl(true, cache2, null, null, Fqn.ROOT, null, false, null, false, null, NODE_CREATED));
expected.add(new EventImpl(false, cache2, null, null, Fqn.ROOT, null, false, null, false, null, NODE_CREATED));
16 years, 1 month
JBoss Cache SVN: r5391 - core/trunk/src/test-perf/java/org/jboss/cache.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-03-05 21:01:44 -0500 (Wed, 05 Mar 2008)
New Revision: 5391
Modified:
core/trunk/src/test-perf/java/org/jboss/cache/LockMapPerformanceTest.java
Log:
added some additional benchmarks
Modified: core/trunk/src/test-perf/java/org/jboss/cache/LockMapPerformanceTest.java
===================================================================
--- core/trunk/src/test-perf/java/org/jboss/cache/LockMapPerformanceTest.java 2008-03-06 00:45:19 UTC (rev 5390)
+++ core/trunk/src/test-perf/java/org/jboss/cache/LockMapPerformanceTest.java 2008-03-06 02:01:44 UTC (rev 5391)
@@ -208,5 +208,44 @@
throw new RuntimeException("Did not expect " + val);
}
}
+
+ public void testIterationOverDirectAccess()
+ {
+ int size = 10000000;
+ List lm = new LinkedList();
+ Object oo = new Object();
+ for (int i = 0; i < size; i ++)
+ {
+ lm.add(oo);
+ }
+ long iteratingTimeStart = System.currentTimeMillis();
+ for (Object o : lm)
+ {
+ nothing(o);
+ }
+ System.out.println("Time needed for iterating: " + (System.currentTimeMillis() - iteratingTimeStart));
+ long seqAccessStart = System.currentTimeMillis();
+ for (int i =0; i < size; i++)
+ {
+ nothing(lm);
+ }
+ System.out.println("Time needed for seq access: " + (System.currentTimeMillis() - seqAccessStart));
+ }
+
+
+ void nothing(Object obj) {}
+
+ public void testCreationDurration()
+ {
+ int size = 100000;
+ Object[] pool = new Object[size];
+ long start = System.currentTimeMillis();
+ for (int i = 0; i < size; i++)
+ {
+ pool[i] = new ConcurrentHashSet();
+ }
+ System.out.println("Total durration: " + (System.currentTimeMillis() - start));
+ System.out.println(pool[0]);
+ }
}
16 years, 1 month