[jboss-cvs] JBossCache/src/org/jboss/cache ...
Manik Surtani
msurtani at jboss.com
Mon Aug 14 13:20:35 EDT 2006
User: msurtani
Date: 06/08/14 13:20:35
Modified: src/org/jboss/cache Cache.java InvocationContext.java
Node.java NodeImpl.java NodeSPI.java
TreeCacheProxyImpl.java
Log:
Restored some basic cache functionality (at last!)
Revision Changes Path
1.4 +3 -0 JBossCache/src/org/jboss/cache/Cache.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Cache.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/Cache.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- Cache.java 19 Jul 2006 21:34:45 -0000 1.3
+++ Cache.java 14 Aug 2006 17:20:35 -0000 1.4
@@ -64,6 +64,9 @@
*/
void remove(Fqn fqn, Object key);
+ /** Removes a node based on the (absolute) Fqn passed in.**/
+ void removeNode(Fqn fqn);
+
/**
* Convenience method that allows for direct access to the data in a {@link Node}.
* @param fqn <b><i>absolute</i></b> {@link Fqn} to the {@link Node} to be accessed.
1.6 +10 -4 JBossCache/src/org/jboss/cache/InvocationContext.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: InvocationContext.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/InvocationContext.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- InvocationContext.java 19 Jul 2006 18:47:19 -0000 1.5
+++ InvocationContext.java 14 Aug 2006 17:20:35 -0000 1.6
@@ -99,18 +99,24 @@
* Retrieves the option overrides associated with this invocation
* @return the option overrides associated with this invocation
*/
- public Option getOptionOverrides()
+ public static Option getOptionOverrides()
{
- return optionOverrides;
+ Option o = getCurrent().optionOverrides;
+ if (o == null)
+ {
+ o = new Option();
+ setOptionOverrides(o);
+ }
+ return o;
}
/**
* Sets the option overrides associated with this invocation
* @param optionOverrides
*/
- public void setOptionOverrides(Option optionOverrides)
+ public static void setOptionOverrides(Option optionOverrides)
{
- this.optionOverrides = optionOverrides;
+ getCurrent().optionOverrides = optionOverrides;
}
/**
1.44 +0 -10 JBossCache/src/org/jboss/cache/Node.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Node.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/Node.java,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -b -r1.43 -r1.44
--- Node.java 10 Aug 2006 16:28:21 -0000 1.43
+++ Node.java 14 Aug 2006 17:20:35 -0000 1.44
@@ -6,8 +6,6 @@
*/
package org.jboss.cache;
-import org.jboss.cache.lock.IdentityLock;
-
import java.util.Collection;
import java.util.Map;
import java.util.Set;
@@ -188,12 +186,4 @@
* @return Returns true if the child node denoted by the {@link Fqn} passed in exists.
*/
boolean hasChild(Fqn f);
-
- // TODO: Think about what we need to do here regarding locking on Nodes
- boolean acquire(Object owner, long lock_timeout, int lockTypeWrite);
-
- IdentityLock getLock();
-
- Set acquireAll(Object owner, long lock_timeout, int lock_type);
-
}
1.2 +2 -2 JBossCache/src/org/jboss/cache/NodeImpl.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: NodeImpl.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/NodeImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- NodeImpl.java 21 Jun 2006 11:10:58 -0000 1.1
+++ NodeImpl.java 14 Aug 2006 17:20:35 -0000 1.2
@@ -263,7 +263,7 @@
// construct the new child outside the synchronized block to avoid
// spending any more time than necessary in the synchronized section
Fqn child_fqn = new Fqn(this.fqn, child_name);
- DataNode newChild = (DataNode)NodeFactory.getInstance().createNodeOfType(this, child_name, child_fqn, this, null, cache);
+ DataNode newChild = (DataNode)NodeFactory.getInstance().createNode(child_name, child_fqn, this, null, cache);
if (newChild == null)
throw new IllegalStateException();
synchronized(this) {
@@ -368,7 +368,7 @@
public Object clone() throws CloneNotSupportedException {
DataNode parent = (DataNode)getParent();
- DataNode n = (DataNode)NodeFactory.getInstance().createNodeOfType(parent, getName(), fqn, parent != null ? (DataNode) parent.clone() : null, data, cache);
+ DataNode n = (DataNode)NodeFactory.getInstance().createNode(getName(), fqn, parent != null ? (DataNode) parent.clone() : null, data, cache);
n.setChildren(children == null? null : (HashMap)((HashMap)children).clone());
return n;
}
1.2 +0 -27 JBossCache/src/org/jboss/cache/NodeSPI.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: NodeSPI.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/NodeSPI.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- NodeSPI.java 21 Jun 2006 11:17:25 -0000 1.1
+++ NodeSPI.java 14 Aug 2006 17:20:35 -0000 1.2
@@ -6,8 +6,6 @@
*/
package org.jboss.cache;
-import org.jboss.cache.lock.IdentityLock;
-
/**
* A more detailed interface to {@link Node}, which is used when writing plugins for or extending JBoss Cache.
*
@@ -17,31 +15,6 @@
*/
public interface NodeSPI extends Node
{
-
- /**
- *
- * @return the lock associated with this {@link Node}
- */
- IdentityLock getLock();
-
- /**
- *
- * @return true if the {@link Node} is locked
- */
- boolean isLocked();
-
- /**
- *
- * @return true if the {@link Node} is locked for reading
- */
- boolean isReadLocked();
-
- /**
- *
- * @return true if the {@link Node} is ocked for writing
- */
- boolean isWriteLocked();
-
// TODO:
// everything that is not already represented by Node
// that is used by either an interceptor, or eviction policy
1.8 +60 -9 JBossCache/src/org/jboss/cache/TreeCacheProxyImpl.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: TreeCacheProxyImpl.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/TreeCacheProxyImpl.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- TreeCacheProxyImpl.java 10 Aug 2006 16:28:21 -0000 1.7
+++ TreeCacheProxyImpl.java 14 Aug 2006 17:20:35 -0000 1.8
@@ -13,8 +13,11 @@
import org.jboss.cache.lock.IdentityLock;
import org.jboss.cache.eviction.RegionManager;
import org.jboss.cache.statetransfer.StateTransferManager;
+import org.jboss.cache.factories.NodeFactory;
import org.jgroups.Address;
import org.jgroups.blocks.MethodCall;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import javax.management.ObjectName;
import javax.transaction.TransactionManager;
@@ -37,6 +40,7 @@
{
TreeCache treeCache;
NodeImpl currentNode;
+ Log log = LogFactory.getLog(TreeCacheProxyImpl.class);
public TreeCacheProxyImpl(TreeCache treeCache, NodeImpl currentNode)
{
@@ -275,9 +279,37 @@
public Node addChild(Fqn f)
{
+ if (InvocationContext.getOptionOverrides().isBypassInterceptorChain())
+ {
+ TreeCacheProxyImpl retval = null;
+
+ if (f.size() == 1)
+ {
+ NodeImpl newNode = (NodeImpl) NodeFactory.getInstance().createNode(f.getLast(), currentNode, Collections.EMPTY_MAP, treeCache);
+ this.currentNode.addChild(f.getLast(), newNode);
+ retval = new TreeCacheProxyImpl(treeCache, newNode);
+ }
+ else
+ {
+ // recursively create children
+ NodeImpl currentParent = currentNode;
+ for (Object o : f.peekElements())
+ {
+ NodeImpl newNode = (NodeImpl) NodeFactory.getInstance().createNode(o, currentParent, Collections.EMPTY_MAP, treeCache);
+ currentParent.addChild(o, newNode);
+ currentParent = newNode;
+ }
+ retval = new TreeCacheProxyImpl(treeCache, currentParent);
+ }
+ InvocationContext.getOptionOverrides().setBypassInterceptorChain(false);
+ return retval;
+ }
+ else
+ {
treeCache.put(new Fqn(currentNode.getFqn(), f), Collections.EMPTY_MAP);
return getChild(f);
}
+ }
public void removeChild(Fqn f)
{
@@ -286,7 +318,17 @@
public Node getChild(Fqn f)
{
- return new TreeCacheProxyImpl(treeCache, treeCache.get(new Fqn(currentNode.getFqn(), f)));
+ NodeImpl child = null;
+ if (InvocationContext.getOptionOverrides().isBypassInterceptorChain())
+ {
+ if (currentNode.getChildren() != null) child = (NodeImpl) currentNode.getChildren().get(f.getLast());
+ InvocationContext.getOptionOverrides().setBypassInterceptorChain(false);
+ }
+ else
+ {
+ child = treeCache.get(new Fqn(currentNode.getFqn(), f));
+ }
+ return child == null ? null : new TreeCacheProxyImpl(treeCache, child);
}
public void put(Object k, Object v)
@@ -314,8 +356,17 @@
return treeCache.get(currentNode.getFqn(), k);
}
+ public void removeNode(Fqn f)
+ {
+ treeCache.remove(f);
+ }
+
public Object remove(Object k)
{
+ if (k instanceof Fqn)
+ {
+ log.warn("Did you mean to call removeNode() instead? remove() just removes data in the node under the key passed in.");
+ }
return treeCache.remove(currentNode.getFqn(), k);
}
@@ -334,7 +385,7 @@
return treeCache.exists(new Fqn(currentNode.getFqn(), f));
}
- private void move(NodeImpl node, Fqn oldRoot, Fqn newRoot)
+ private void move(TreeNode node, Fqn oldRoot, Fqn newRoot)
{
// recursive
Iterator i = node.getChildren().values().iterator();
@@ -373,19 +424,19 @@
// -----------
// TODO: Think about what we need to do here regarding locking on Nodes
- public boolean acquire(Object owner, long lock_timeout, int lockTypeWrite)
+ public boolean acquire(Object owner, long lock_timeout, int lockType) throws InterruptedException
{
- throw new RuntimeException("TODO: Need to figure out how to deal with these.");
+ return currentNode.acquire(owner, lock_timeout, lockType);
}
public IdentityLock getLock()
{
- throw new RuntimeException("TODO: Need to figure out how to deal with these.");
+ return currentNode.getLock();
}
- public Set acquireAll(Object owner, long lock_timeout, int lock_type)
+ public Set acquireAll(Object owner, long lock_timeout, int lockType) throws InterruptedException
{
- throw new RuntimeException("TODO: Need to figure out how to deal with these.");
+ return currentNode.acquireAll(owner, lock_timeout, lockType);
}
// TODO: Figure out how we deal with these:
More information about the jboss-cvs-commits
mailing list