[jboss-cvs] JBossCache/src/org/jboss/cache/loader/bdbje ...
Manik Surtani
manik at jboss.org
Tue Jun 19 11:41:34 EDT 2007
User: msurtani
Date: 07/06/19 11:41:34
Modified: src/org/jboss/cache/loader/bdbje BdbjeCacheLoader.java
Log:
thread safety across JE transactions
Revision Changes Path
1.28 +24 -3 JBossCache/src/org/jboss/cache/loader/bdbje/BdbjeCacheLoader.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: BdbjeCacheLoader.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/loader/bdbje/BdbjeCacheLoader.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- BdbjeCacheLoader.java 19 Jun 2007 14:54:02 -0000 1.27
+++ BdbjeCacheLoader.java 19 Jun 2007 15:41:34 -0000 1.28
@@ -32,6 +32,7 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -51,7 +52,7 @@
*
* @author Mark Hayes May 16, 2004
* @author Bela Ban
- * @version $Id: BdbjeCacheLoader.java,v 1.27 2007/06/19 14:54:02 msurtani Exp $
+ * @version $Id: BdbjeCacheLoader.java,v 1.28 2007/06/19 15:41:34 msurtani Exp $
*/
@ThreadSafe
public class BdbjeCacheLoader extends AbstractCacheLoader
@@ -927,9 +928,29 @@
{
if (!transactional) throw new IllegalStateException();
+ List<Fqn> fqns = getFqns(mods);
+ lock.acquireAllLocks(fqns, true);
+ try
+ {
Transaction txn = performTransaction(mods);
txn.commit();
}
+ finally
+ {
+ lock.releaseAllLocks(fqns);
+ }
+ }
+
+ private List<Fqn> getFqns(List<Modification> mods)
+ {
+ List<Fqn> fqns = new LinkedList<Fqn>();
+ for (Modification m : mods)
+ {
+ fqns.add(m.getFqn());
+ if (m.getType() == Modification.ModificationType.MOVE) fqns.add(m.getFqn2());
+ }
+ return fqns;
+ }
/**
* Performs the given operation, starting a transaction and performing
More information about the jboss-cvs-commits
mailing list