[jboss-cvs] JBossCache/src/org/jboss/cache/loader/jdbm ...
Manik Surtani
manik at jboss.org
Tue Jun 19 13:46:50 EDT 2007
User: msurtani
Date: 07/06/19 13:46:50
Modified: src/org/jboss/cache/loader/jdbm JdbmCacheLoader.java
Log:
Rolling back - additional locking not necessary
Revision Changes Path
1.28 +68 -120 JBossCache/src/org/jboss/cache/loader/jdbm/JdbmCacheLoader.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: JdbmCacheLoader.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/loader/jdbm/JdbmCacheLoader.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- JdbmCacheLoader.java 19 Jun 2007 16:57:43 -0000 1.27
+++ JdbmCacheLoader.java 19 Jun 2007 17:46:50 -0000 1.28
@@ -14,7 +14,6 @@
import org.jboss.cache.Modification;
import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.cache.loader.AbstractCacheLoader;
-import org.jboss.cache.lock.StripedLock;
import java.io.File;
import java.io.IOException;
@@ -57,7 +56,7 @@
* plans to fix this.
*
* @author Elias Ross
- * @version $Id: JdbmCacheLoader.java,v 1.27 2007/06/19 16:57:43 msurtani Exp $
+ * @version $Id: JdbmCacheLoader.java,v 1.28 2007/06/19 17:46:50 msurtani Exp $
*/
@ThreadSafe
public class JdbmCacheLoader extends AbstractCacheLoader
@@ -73,7 +72,6 @@
private RecordManager recman;
private BTree tree;
private Map<Object, List<Modification>> transactions = new ConcurrentHashMap<Object, List<Modification>>();
- private StripedLock lock = new StripedLock();
/*
* Service implementation -- lifecycle methods.
@@ -96,9 +94,7 @@
public void start()
throws Exception
{
- lock.acquireLock(Fqn.ROOT, true);
- try
- {
+
log.trace("Starting JdbmCacheLoader instance.");
checkNotOpen();
checkNonNull(cache, "CacheSPI object is required");
@@ -147,11 +143,6 @@
throw e;
}
}
- finally
- {
- lock.releaseLock(Fqn.ROOT);
- }
- }
/**
* Opens all databases and initializes database related information.
@@ -277,15 +268,11 @@
{
log.trace("getChildrenNames " + name);
}
- lock.acquireLock(name, false);
- try
+
+ synchronized (tree)
{
return getChildrenNames0(name);
}
- finally
- {
- lock.releaseLock(name);
- }
}
private Set<String> getChildrenNames0(Fqn name) throws IOException
@@ -345,9 +332,7 @@
checkOpen();
checkNonNull(name, "name");
- lock.acquireLock(name, false);
- try
- {
+
if (tree.find(name) == null)
{
if (log.isTraceEnabled())
@@ -361,6 +346,8 @@
Tuple t = new Tuple();
Map map = new HashMap();
+ synchronized (tree)
+ {
TupleBrowser browser = tree.browse(keys);
while (browser.getNext(t))
{
@@ -373,6 +360,7 @@
Object v = t.getValue();
map.put(nullUnmask(k), nullUnmask(v));
}
+ }
if (log.isTraceEnabled())
{
@@ -381,27 +369,14 @@
return map;
}
- finally
- {
- lock.releaseLock(name);
- }
- }
/**
* Returns whether the given node exists.
*/
public boolean exists(Fqn name) throws IOException
{
- lock.acquireLock(name, false);
- try
- {
return tree.find(name) != null;
}
- finally
- {
- lock.releaseLock(name);
- }
- }
private void commit() throws Exception
{
@@ -415,7 +390,6 @@
*/
public Object put(Fqn name, Object key, Object value) throws Exception
{
- lock.acquireLock(name, true);
try
{
return put0(name, key, value);
@@ -423,7 +397,6 @@
finally
{
commit();
- lock.releaseLock(name);
}
}
@@ -448,16 +421,8 @@
*/
public void put(Fqn name, Map values) throws Exception
{
- lock.acquireLock(name, true);
- try
- {
put0(name, values);
- }
- finally
- {
commit();
- lock.releaseLock(name);
- }
}
private void put0(Fqn name, Map<?, ?> values) throws Exception
@@ -595,16 +560,8 @@
public void remove(Fqn name)
throws Exception
{
- lock.acquireLock(name, true);
- try
- {
erase0(name);
- }
- finally
- {
commit();
- lock.releaseLock(name);
- }
}
/**
@@ -615,7 +572,7 @@
public Object remove(Fqn name, Object key)
throws Exception
{
- lock.acquireLock(name, true);
+
try
{
return eraseKey0(name, key);
@@ -623,7 +580,6 @@
finally
{
commit();
- lock.releaseLock(name);
}
}
@@ -633,16 +589,8 @@
public void removeData(Fqn name)
throws Exception
{
- lock.acquireLock(name, true);
- try
- {
erase0(name, false);
}
- finally
- {
- lock.releaseLock(name);
- }
- }
/**
* Applies and commits the given modifications in one transaction.
More information about the jboss-cvs-commits
mailing list