[jboss-cvs] JBossCache/src/org/jboss/cache/interceptors ...
Manik Surtani
msurtani at jboss.com
Thu Aug 17 13:34:59 EDT 2006
User: msurtani
Date: 06/08/17 13:34:59
Modified: src/org/jboss/cache/interceptors
ActivationInterceptor.java
CacheLoaderInterceptor.java
CreateIfNotExistsInterceptor.java
DataGravitatorInterceptor.java
OptimisticCreateIfNotExistsInterceptor.java
OptimisticNodeInterceptor.java
OptimisticValidatorInterceptor.java
PassivationInterceptor.java
Log:
Habanero stabilisation efforts - cache loading
Revision Changes Path
1.30 +12 -6 JBossCache/src/org/jboss/cache/interceptors/ActivationInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ActivationInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/ActivationInterceptor.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- ActivationInterceptor.java 19 Jul 2006 21:34:43 -0000 1.29
+++ ActivationInterceptor.java 17 Aug 2006 17:34:59 -0000 1.30
@@ -1,10 +1,16 @@
package org.jboss.cache.interceptors;
import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap;
-import org.jboss.cache.*;
-import org.jboss.cache.loader.CacheLoader;
-import org.jboss.cache.marshall.MethodDeclarations;
+import org.jboss.cache.DataNode;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.GlobalTransaction;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.Modification;
+import org.jboss.cache.TransactionEntry;
+import org.jboss.cache.TransactionTable;
+import org.jboss.cache.TreeCache;
import org.jboss.cache.marshall.JBCMethodCall;
+import org.jboss.cache.marshall.MethodDeclarations;
import org.jgroups.blocks.MethodCall;
import javax.transaction.TransactionManager;
@@ -22,7 +28,7 @@
* their attributes have been initialized and their children have been loaded in memory.
*
* @author <a href="mailto:{hmesha at novell.com}">{Hany Mesha}</a>
- * @version $Id: ActivationInterceptor.java,v 1.29 2006/07/19 21:34:43 msurtani Exp $
+ * @version $Id: ActivationInterceptor.java,v 1.30 2006/08/17 17:34:59 msurtani Exp $
*/
public class ActivationInterceptor extends CacheLoaderInterceptor implements ActivationInterceptorMBean {
@@ -157,8 +163,8 @@
}
private void remove(Fqn fqn) throws Exception {
+ cache.getNotifier().notifyNodeActivated(fqn, true);
loader.remove(fqn);
- cache.notifyNodeActivate(fqn, false);
if (configuration.isUseInterceptorMbeans() && getStatisticsEnabled())
m_activations++;
}
@@ -284,7 +290,7 @@
private void addRemoveMod(List l, Fqn fqn) {
Modification mod = new Modification(Modification.REMOVE_NODE, fqn);
l.add(mod);
- cache.notifyNodeActivate(fqn, false);
+ cache.getNotifier().notifyNodeActivated(fqn, false);
}
}
1.44 +34 -22 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.43
retrieving revision 1.44
diff -u -b -r1.43 -r1.44
--- CacheLoaderInterceptor.java 14 Aug 2006 17:52:34 -0000 1.43
+++ CacheLoaderInterceptor.java 17 Aug 2006 17:34:59 -0000 1.44
@@ -1,6 +1,7 @@
package org.jboss.cache.interceptors;
import org.jboss.cache.*;
+import org.jboss.cache.config.Option;
import org.jboss.cache.loader.AsyncCacheLoader;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.ChainingCacheLoader;
@@ -17,11 +18,12 @@
import java.util.Map;
import java.util.Set;
import java.util.Collection;
+import java.util.Collections;
/**
* 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.43 2006/08/14 17:52:34 msurtani Exp $
+ * @version $Id: CacheLoaderInterceptor.java,v 1.44 2006/08/17 17:34:59 msurtani Exp $
*/
public class CacheLoaderInterceptor extends BaseCacheLoaderInterceptor implements CacheLoaderInterceptorMBean
{
@@ -154,10 +156,13 @@
try
{
- DataNode n = cache.peek(fqn);
+ TreeCacheProxyImpl cacheImpl = (TreeCacheProxyImpl) cache;
+ Node n = cacheImpl.peekNode(fqn);
+
+ boolean mustLoad = mustLoad(n, key);
if (log.isTraceEnabled())
- log.trace("load element " + fqn + " mustLoad=" + mustLoad(n, key));
- if (mustLoad(n, key))
+ log.trace("load element " + fqn + " mustLoad=" + mustLoad);
+ if (mustLoad)
{
if (initNode)
n = createTempNode(fqn, entry);
@@ -199,11 +204,12 @@
/**
* Load the children.
- * @param n may be null if the node was not found.
+ * @param node may be null if the node was not found.
*/
- private void loadChildren(Fqn fqn, DataNode n) throws Throwable
+ private void loadChildren(Fqn fqn, Node node) throws Throwable
{
+ TreeCacheProxyImpl n = (TreeCacheProxyImpl) node;
if (n != null && n.getChildrenLoaded())
return;
Set children_names = loader.getChildrenNames(fqn);
@@ -223,8 +229,7 @@
}
// Create if node had not been created already
- if (n == null)
- n = createNodes(fqn, null); // dont care about local transactions
+ if (n == null) n = (TreeCacheProxyImpl) createNodes(fqn, null); // dont care about local transactions
// Create one DataNode per child, mark as UNINITIALIZED
for (Iterator i = children_names.iterator(); i.hasNext(); )
@@ -232,16 +237,16 @@
String child_name = (String)i.next();
Fqn child_fqn = new Fqn(fqn, child_name);
// create child if it didn't exist
- n.createChild(child_name, child_fqn, n, TreeCache.UNINITIALIZED, null);
+ n.addChild(child_fqn);
+ findChild(n.getChildren(), child_name).put(TreeCache.UNINITIALIZED, null);
}
lock(fqn, DataNode.LockType.READ, true); // recursive=true: lock entire subtree
n.setChildrenLoaded(true);
}
- private boolean mustLoad(DataNode n, Object key)
+ private boolean mustLoad(Node n, Object key)
{
- return n == null ||
- (n.containsKey(TreeCache.UNINITIALIZED) && (key == null || !n.containsKey(key)));
+ return n == null || (n.getKeys().contains(TreeCache.UNINITIALIZED) && (key == null || !n.getKeys().contains(key)));
}
public long getCacheLoaderLoads() {
@@ -319,7 +324,7 @@
* If it doesn't exist on disk but in memory, clears the
* uninitialized flag, otherwise returns null.
*/
- private DataNode loadNode(Fqn fqn, DataNode n, TransactionEntry entry) throws Exception
+ private Node loadNode(Fqn fqn, Node n, TransactionEntry entry) throws Exception
{
if (log.isTraceEnabled()) log.trace("loadNode " + fqn);
Map nodeData = loadData(fqn);
@@ -328,7 +333,7 @@
n = createNodes(fqn, entry);
n.put(nodeData, true);
}
- else if (n != null && n.containsKey(TreeCache.UNINITIALIZED))
+ else if (n != null && n.getKeys().contains(TreeCache.UNINITIALIZED))
{
n.remove(TreeCache.UNINITIALIZED);
}
@@ -338,9 +343,10 @@
/**
* Creates a new memory node in preparation for storage.
*/
- private DataNode createTempNode(Fqn fqn, TransactionEntry entry) throws Exception
+ private Node createTempNode(Fqn fqn, TransactionEntry entry) throws Exception
{
- DataNode n = createNodes(fqn, entry);
+ Node n = createNodes(fqn, entry);
+ InvocationContext.getOptionOverrides().setBypassInterceptorChain(true);
n.put(TreeCache.UNINITIALIZED, null);
if (log.isTraceEnabled())
log.trace("createTempNode n " + n);
@@ -348,7 +354,7 @@
}
- private DataNode createNodes(Fqn fqn, TransactionEntry entry) throws Exception
+ private Node createNodes(Fqn fqn, TransactionEntry entry) throws Exception
{
Fqn tmp_fqn = Fqn.ROOT;
@@ -367,6 +373,9 @@
if (child_node == null)
{
+ Option o = InvocationContext.getOptionOverrides();
+ o.setBypassInterceptorChain(true);
+ InvocationContext.setOptionOverrides(o);
if (last)
{
child_node = n.addChild(new Fqn(child_name));
@@ -388,7 +397,7 @@
n = child_node;
}
- return (DataNode) n;
+ return n;
}
private Node findChild(Collection<Node> children, Object child_name)
@@ -415,7 +424,7 @@
Fqn fqn = (Fqn) i.previous();
try
{
- cache._evict(fqn);
+ cache.evict(fqn, false);
}
catch (CacheException e)
{
@@ -426,7 +435,9 @@
}
- private Map loadData(Fqn fqn) throws Exception {
+ private Map loadData(Fqn fqn) throws Exception
+ {
+
Map nodeData = loader.get(fqn);
boolean nodeExists = (nodeData != null);
if (log.isTraceEnabled()) log.trace("nodeExists " + nodeExists);
@@ -446,7 +457,8 @@
if (nodeExists)
{
- cache.notifyNodeLoaded(fqn);
+ cache.getNotifier().notifyNodeLoaded(fqn, true, Collections.emptyMap());
+ cache.getNotifier().notifyNodeLoaded(fqn, false, nodeData);
}
return nodeData;
1.14 +3 -2 JBossCache/src/org/jboss/cache/interceptors/CreateIfNotExistsInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CreateIfNotExistsInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/CreateIfNotExistsInterceptor.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- CreateIfNotExistsInterceptor.java 19 Jul 2006 21:34:43 -0000 1.13
+++ CreateIfNotExistsInterceptor.java 17 Aug 2006 17:34:59 -0000 1.14
@@ -16,7 +16,7 @@
* Handles putXXX() methods: if the given node doesn't exist, it will be created
* (depending on the create_if_not_exists argument)
* @author Bela Ban
- * @version $Id: CreateIfNotExistsInterceptor.java,v 1.13 2006/07/19 21:34:43 msurtani Exp $
+ * @version $Id: CreateIfNotExistsInterceptor.java,v 1.14 2006/08/17 17:34:59 msurtani Exp $
* @deprecated This code is not used anymore and will be removed in a future release
*/
public class CreateIfNotExistsInterceptor extends Interceptor {
@@ -346,7 +346,8 @@
// (needed for abort/rollback of transaction)
// cache.addNode(tx, (Fqn)tmp_fqn.clone());
}
- cache.notifyNodeCreated(tmp_fqn);
+ cache.getNotifier().notifyNodeCreated(tmp_fqn, true);
+ cache.getNotifier().notifyNodeCreated(tmp_fqn, false);
}
n=child_node;
}
1.20 +2 -1 JBossCache/src/org/jboss/cache/interceptors/DataGravitatorInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: DataGravitatorInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/DataGravitatorInterceptor.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- DataGravitatorInterceptor.java 20 Jul 2006 10:54:00 -0000 1.19
+++ DataGravitatorInterceptor.java 17 Aug 2006 17:34:59 -0000 1.20
@@ -17,6 +17,7 @@
import org.jboss.cache.InvocationContext;
import org.jboss.cache.Node;
import org.jboss.cache.TransactionEntry;
+import org.jboss.cache.TreeCacheProxyImpl;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Option;
@@ -462,7 +463,7 @@
private Iterator getBackupRootIterator()
{
- DataNode backupRoot = cache.peek(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN);
+ DataNode backupRoot = ((TreeCacheProxyImpl) cache).peek(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN);
return backupRoot == null ? Collections.EMPTY_SET.iterator() : backupRoot.getChildren().values().iterator();
}
1.23 +2 -1 JBossCache/src/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: OptimisticCreateIfNotExistsInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- OptimisticCreateIfNotExistsInterceptor.java 19 Jul 2006 21:34:43 -0000 1.22
+++ OptimisticCreateIfNotExistsInterceptor.java 17 Aug 2006 17:34:59 -0000 1.23
@@ -215,7 +215,8 @@
for (Iterator it = nodesCreated.iterator(); it.hasNext();)
{
Object temp = it.next();
- cache.notifyNodeCreated((Fqn) temp);
+ cache.getNotifier().notifyNodeCreated((Fqn) temp, true);
+ cache.getNotifier().notifyNodeCreated((Fqn) temp, false);
if (log.isDebugEnabled()) log.debug("Notifying cache of node created in workspace " + temp);
}
}
1.23 +1 -1 JBossCache/src/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: OptimisticNodeInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- OptimisticNodeInterceptor.java 19 Jul 2006 21:34:43 -0000 1.22
+++ OptimisticNodeInterceptor.java 17 Aug 2006 17:34:59 -0000 1.23
@@ -305,7 +305,7 @@
// if we do not have the node then we need to add it to the workspace
if (workspaceNode == null)
{
- DataNode node = cache.peek(fqn);
+ DataNode node = ((TreeCacheProxyImpl) cache).peek(fqn);
if (node == null)
return null; // seems to happen quite a bit
workspaceNode = NodeFactory.getInstance().createWorkspaceNode( node, workspace );
1.28 +9 -1 JBossCache/src/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: OptimisticValidatorInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- OptimisticValidatorInterceptor.java 9 Aug 2006 14:50:00 -0000 1.27
+++ OptimisticValidatorInterceptor.java 17 Aug 2006 17:34:59 -0000 1.28
@@ -7,6 +7,7 @@
package org.jboss.cache.interceptors;
import org.jboss.cache.*;
+import org.jboss.cache.config.Option;
import org.jboss.cache.marshall.MethodDeclarations;
import org.jboss.cache.marshall.JBCMethodCall;
import org.jboss.cache.optimistic.TransactionWorkspace;
@@ -107,7 +108,14 @@
workspaceNode = (WorkspaceNode) it.next();
Fqn fqn = workspaceNode.getFqn();
if (trace) log.trace("validating version for node " + fqn);
- OptimisticTreeNode realNode = (OptimisticTreeNode) cache._get(fqn);
+ Option o = InvocationContext.getOptionOverrides();
+ o.setBypassInterceptorChain(true);
+ InvocationContext.setOptionOverrides(o);
+ OptimisticTreeNode realNode = (OptimisticTreeNode) cache.get(fqn);
+ o = InvocationContext.getOptionOverrides();
+ o.setBypassInterceptorChain(false);
+ InvocationContext.setOptionOverrides(o);
+
// if this is a newly created node then we expect the underlying node to be null.
// if not, we have a problem...
1.24 +8 -9 JBossCache/src/org/jboss/cache/interceptors/PassivationInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: PassivationInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/PassivationInterceptor.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- PassivationInterceptor.java 19 Jul 2006 21:34:43 -0000 1.23
+++ PassivationInterceptor.java 17 Aug 2006 17:34:59 -0000 1.24
@@ -1,17 +1,15 @@
package org.jboss.cache.interceptors;
+import EDU.oswego.cs.dl.util.concurrent.SynchronizedLong;
+import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
-import org.jboss.cache.TreeNode;
-import org.jboss.cache.TreeCache;
import org.jboss.cache.Node;
-import org.jboss.cache.CacheSPI;
+import org.jboss.cache.TreeCache;
import org.jboss.cache.loader.CacheLoader;
-import org.jboss.cache.marshall.MethodDeclarations;
import org.jboss.cache.marshall.JBCMethodCall;
+import org.jboss.cache.marshall.MethodDeclarations;
import org.jgroups.blocks.MethodCall;
-import EDU.oswego.cs.dl.util.concurrent.SynchronizedLong;
-import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
@@ -20,7 +18,7 @@
* CacheLoader, either before each method call (no TXs), or at TX commit.
*
* @author <a href="mailto:{hmesha at novell.com}">{Hany Mesha}</a>
- * @version $Id: PassivationInterceptor.java,v 1.23 2006/07/19 21:34:43 msurtani Exp $
+ * @version $Id: PassivationInterceptor.java,v 1.24 2006/08/17 17:34:59 msurtani Exp $
*/
public class PassivationInterceptor extends Interceptor implements PassivationInterceptorMBean {
@@ -37,7 +35,7 @@
* be passivated and stores the evicted node and its attributes back to the
* store using the CacheLoader.
*
- * @param m
+ * @param call
* @return
* @throws Throwable
*/
@@ -61,7 +59,8 @@
if (attributes != null)
attributes.remove(TreeCache.UNINITIALIZED);
// notify listeners to the cache instance that this node is about to be passivated
- cache.notifyNodePassivate(fqn, true);
+ cache.getNotifier().notifyNodePassivated(fqn, true);
+ cache.getNotifier().notifyNodePassivated(fqn, false);
loader.put(fqn, attributes);
}
if (getStatisticsEnabled() && configuration.isUseInterceptorMbeans())
More information about the jboss-cvs-commits
mailing list