[jboss-cvs] JBossCache/src/org/jboss/cache/interceptors ...
Manik Surtani
manik at jboss.org
Mon Jun 18 19:57:27 EDT 2007
User: msurtani
Date: 07/06/18 19:57:27
Modified: src/org/jboss/cache/interceptors
CacheStoreInterceptor.java
CacheLoaderInterceptor.java
Removed: src/org/jboss/cache/interceptors
BaseCacheLoaderInterceptor.java
Log:
Properly remove unnecessary sync
Revision Changes Path
1.50 +32 -90 JBossCache/src/org/jboss/cache/interceptors/CacheStoreInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CacheStoreInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/CacheStoreInterceptor.java,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -b -r1.49 -r1.50
--- CacheStoreInterceptor.java 11 Jun 2007 12:58:17 -0000 1.49
+++ CacheStoreInterceptor.java 18 Jun 2007 23:57:27 -0000 1.50
@@ -6,6 +6,7 @@
import org.jboss.cache.InvocationContext;
import org.jboss.cache.Modification;
import org.jboss.cache.config.CacheLoaderConfig;
+import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.marshall.MethodCall;
import org.jboss.cache.marshall.MethodDeclarations;
import org.jboss.cache.transaction.GlobalTransaction;
@@ -27,9 +28,9 @@
* through the CacheLoader, either after each method call (no TXs), or at TX commit.
*
* @author Bela Ban
- * @version $Id: CacheStoreInterceptor.java,v 1.49 2007/06/11 12:58:17 msurtani Exp $
+ * @version $Id: CacheStoreInterceptor.java,v 1.50 2007/06/18 23:57:27 msurtani Exp $
*/
-public class CacheStoreInterceptor extends BaseCacheLoaderInterceptor implements CacheStoreInterceptorMBean
+public class CacheStoreInterceptor extends Interceptor implements CacheStoreInterceptorMBean
{
protected CacheLoaderConfig loaderConfig = null;
@@ -38,6 +39,7 @@
private HashMap m_txStores = new HashMap();
private Map preparingTxs = new ConcurrentHashMap();
private long m_cacheStores = 0;
+ protected CacheLoader loader;
public void setCache(CacheSPI cache)
{
@@ -45,6 +47,7 @@
this.loaderConfig = cache.getCacheLoaderManager().getCacheLoaderConfig();
tx_mgr = cache.getTransactionManager();
tx_table = cache.getTransactionTable();
+ this.loader = cache.getCacheLoaderManager().getCacheLoader();
}
/**
@@ -94,14 +97,12 @@
if (log.isTraceEnabled()) log.trace("Calling loader.commit() for gtx " + gtx);
// sync call (a write) on the loader
List fqnsModified = getFqnsFromModificationList(tx_table.get(gtx).getCacheLoaderModifications());
- obtainLoaderLocks(fqnsModified);
try
{
loader.commit(gtx);
}
finally
{
- releaseLoaderLocks(fqnsModified);
preparingTxs.remove(gtx);
}
if (configuration.getExposeManagementStatistics() && getStatisticsEnabled())
@@ -157,41 +158,17 @@
{
case MethodDeclarations.removeNodeMethodLocal_id:
fqn = (Fqn) args[1];
- obtainLoaderLock(fqn);
- try
- {
loader.remove(fqn);
- }
- finally
- {
- releaseLoaderLock(fqn);
- }
break;
case MethodDeclarations.removeKeyMethodLocal_id:
fqn = (Fqn) args[1];
key = args[2];
- obtainLoaderLock(fqn);
- try
- {
tmp_retval = loader.remove(fqn, key);
use_tmp_retval = true;
- }
- finally
- {
- releaseLoaderLock(fqn);
- }
break;
case MethodDeclarations.removeDataMethodLocal_id:
fqn = (Fqn) args[1];
- obtainLoaderLock(fqn);
- try
- {
loader.removeData(fqn);
- }
- finally
- {
- releaseLoaderLock(fqn);
- }
break;
}
// }
@@ -210,15 +187,7 @@
Modification mod = convertMethodCallToModification(m);
log.debug(mod);
fqn = mod.getFqn();
- obtainLoaderLock(fqn);
- try
- {
loader.put(Collections.singletonList(mod));
- }
- finally
- {
- releaseLoaderLock(fqn);
- }
if (configuration.getExposeManagementStatistics() && getStatisticsEnabled())
{
m_cacheStores++;
@@ -229,16 +198,8 @@
fqn = (Fqn) args[1];
key = args[2];
value = args[3];
- obtainLoaderLock(fqn);
- try
- {
tmp_retval = loader.put(fqn, key, value);
use_tmp_retval = true;
- }
- finally
- {
- releaseLoaderLock(fqn);
- }
if (configuration.getExposeManagementStatistics() && getStatisticsEnabled())
{
m_cacheStores++;
@@ -260,30 +221,16 @@
private void doMove(Fqn node, Fqn parent) throws Exception
{
Fqn newNodeFqn = new Fqn(parent, node.getLastElement());
- //UnversionedNode n = (UnversionedNode) ((TreeCacheProxyImpl) cache).peek(newNodeFqn);
- //recursiveMove(n);
- // throw new RuntimeException("Implement me!");
recursiveMove(node, newNodeFqn);
- try
- {
- obtainLoaderLock(node);
loader.remove(node);
}
- finally
- {
- releaseLoaderLock(node);
- }
- }
private void recursiveMove(Fqn fqn, Fqn newFqn) throws Exception
{
List fqns = new ArrayList();
fqns.add(fqn);
fqns.add(newFqn);
- obtainLoaderLocks(fqns);
- try
- {
loader.put(newFqn, loader.get(fqn));
//recurse
Set childrenNames = loader.getChildrenNames(fqn);
@@ -295,11 +242,6 @@
}
}
}
- finally
- {
- releaseLoaderLocks(fqns);
- }
- }
private List getFqnsFromModificationList(List<MethodCall> modifications)
{
1.84 +35 -44 JBossCache/src/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CacheLoaderInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/CacheLoaderInterceptor.java,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -b -r1.83 -r1.84
--- CacheLoaderInterceptor.java 18 Jun 2007 22:44:26 -0000 1.83
+++ CacheLoaderInterceptor.java 18 Jun 2007 23:57:27 -0000 1.84
@@ -5,6 +5,7 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
+import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.lock.NodeLock;
import org.jboss.cache.marshall.MethodCall;
import org.jboss.cache.marshall.MethodCallFactory;
@@ -24,14 +25,15 @@
* Loads nodes that don't exist at the time of the call into memory from the CacheLoader
*
* @author Bela Ban
- * @version $Id: CacheLoaderInterceptor.java,v 1.83 2007/06/18 22:44:26 msurtani Exp $
+ * @version $Id: CacheLoaderInterceptor.java,v 1.84 2007/06/18 23:57:27 msurtani Exp $
*/
-public class CacheLoaderInterceptor extends BaseCacheLoaderInterceptor implements CacheLoaderInterceptorMBean
+public class CacheLoaderInterceptor extends Interceptor implements CacheLoaderInterceptorMBean
{
private long m_cacheLoads = 0;
private long m_cacheMisses = 0;
private TransactionTable txTable = null;
protected boolean isActivation = false;
+ protected CacheLoader loader;
/**
* True if CacheStoreInterceptor is in place.
@@ -44,6 +46,7 @@
{
super.setCache(cache);
txTable = cache.getTransactionTable();
+ this.loader = cache.getCacheLoaderManager().getCacheLoader();
}
/**
@@ -157,11 +160,6 @@
private void loadIfNeeded(InvocationContext ctx, Fqn fqn, Object key, boolean initNode, boolean acquireLock, MethodCall m, TransactionEntry entry, boolean recursive, boolean isMove) throws Throwable
{
- obtainLoaderLock(fqn);
-
- try
- {
-
NodeSPI n = cache.peek(fqn, true);
boolean mustLoad = mustLoad(n, key);
@@ -204,13 +202,6 @@
{
loadChildren(fqn, n, recursive, isMove);
}
-
- }
- finally
- {
- releaseLoaderLock(fqn);
- }
-
}
/**
More information about the jboss-cvs-commits
mailing list