[jbosscache-commits] JBoss Cache SVN: r6355 - in core/trunk/src: main/java/org/jboss/cache/interceptors and 4 other directories.
jbosscache-commits at lists.jboss.org
jbosscache-commits at lists.jboss.org
Tue Jul 22 04:50:08 EDT 2008
Author: manik.surtani at jboss.com
Date: 2008-07-22 04:50:07 -0400 (Tue, 22 Jul 2008)
New Revision: 6355
Modified:
core/trunk/src/main/java/org/jboss/cache/AbstractNode.java
core/trunk/src/main/java/org/jboss/cache/InternalNode.java
core/trunk/src/main/java/org/jboss/cache/PessimisticUnversionedNode.java
core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java
core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java
core/trunk/src/main/java/org/jboss/cache/mvcc/NodeReference.java
core/trunk/src/main/java/org/jboss/cache/optimistic/WorkspaceNode.java
core/trunk/src/main/java/org/jboss/cache/optimistic/WorkspaceNodeImpl.java
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveNodeTest.java
Log:
fixed stuff
Modified: core/trunk/src/main/java/org/jboss/cache/AbstractNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/AbstractNode.java 2008-07-22 00:54:02 UTC (rev 6354)
+++ core/trunk/src/main/java/org/jboss/cache/AbstractNode.java 2008-07-22 08:50:07 UTC (rev 6355)
@@ -3,7 +3,7 @@
*/
package org.jboss.cache;
-import static org.jboss.cache.AbstractNode.NodeFlags.DELETED;
+import static org.jboss.cache.AbstractNode.NodeFlags.REMOVED;
import static org.jboss.cache.AbstractNode.NodeFlags.RESIDENT;
import java.util.concurrent.ConcurrentMap;
@@ -27,7 +27,7 @@
* These flags were originally stored as booleans on the UnversionedNode class. They have been replaced with an enum
* and an EnumSet, which is much more space-efficient for very little cost in lookups.
*/
- protected static enum NodeFlags
+ public static enum NodeFlags
{
/**
* All children are loaded from the cache loader if this flag is present.
@@ -46,9 +46,9 @@
*/
VALID(0x8),
/**
- * Node has been deleted.
+ * Node has been removed.
*/
- DELETED(0x10),
+ REMOVED(0x10),
/**
* NOde is resident and excluded from evictions
*/
@@ -128,19 +128,19 @@
flags &= ~flag.mask;
}
- public boolean isDeleted()
+ public boolean isRemoved()
{
- return isFlagSet(DELETED);
+ return isFlagSet(REMOVED);
}
- public void markAsDeleted(boolean marker)
+ public void setRemoved(boolean marker)
{
- markAsDeleted(marker, false);
+ markAsRemoved(marker, false);
}
- public void markAsDeleted(boolean marker, boolean recursive)
+ public void markAsRemoved(boolean marker, boolean recursive)
{
- setFlag(DELETED, marker);
+ setFlag(REMOVED, marker);
if (recursive && children != null)
{
Modified: core/trunk/src/main/java/org/jboss/cache/InternalNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/InternalNode.java 2008-07-22 00:54:02 UTC (rev 6354)
+++ core/trunk/src/main/java/org/jboss/cache/InternalNode.java 2008-07-22 08:50:07 UTC (rev 6355)
@@ -12,74 +12,98 @@
* to {@link Node} and it's {@link NodeSPI} sub-interface, which are typically implemented by delegates which then delegate calls
* to internal nodes, potentially after passing the call up an interceptor chain.
* <p/>
+ * All calls on an InternalNode are executed directly on the data structure. Usually, XXXDirect() calls on {@link NodeSPI}
+ * delegate to calls on an InternalNode, for example, {@link NodeSPI#putDirect(Object, Object)} delegating to {@link #put(Object, Object)}.
+ * <p/>
*
* @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
* @since 3.0
*/
public interface InternalNode<K, V>
{
- NodeSPI<K, V> getParent();
+ // --------------- basic access to he internal state of the node. -------------------------
+ V get(K key);
- CacheSPI<K, V> getCache();
+ Map<K, V> getData();
- boolean isChildrenLoaded();
+ V put(K key, V value);
- void setChildrenLoaded(boolean flag);
+ void putAll(Map<K, V> data);
- V getDirect(K key);
+ V remove(K key);
- Map<K, V> getDataDirect();
+ void clear();
- V putDirect(K key, V value);
+ Set<K> getKeys();
- NodeSPI<K, V> getOrCreateChild(Object childName, GlobalTransaction gtx, boolean notify);
+ void setInternalState(Map<K, V> state);
- V removeDirect(K key);
+ Map getInternalState(boolean onlyInternalState);
- void addChildDirect(NodeSPI<K, V> child);
+ void releaseObjectReferences(boolean recursive);
- NodeSPI<K, V> addChildDirect(Fqn f);
+ // --------------- node naming and tree structure ---------------------
+ /**
+ * @return the node's Fqn
+ */
+ Fqn getFqn();
- NodeSPI<K, V> addChildDirect(Fqn f, boolean notify);
+ /**
+ * Sets the node's Fqn
+ *
+ * @param fqn Fqn to set to
+ */
+ void setFqn(Fqn fqn);
- NodeSPI<K, V> addChildDirect(Object o, boolean notify);
+ boolean hasChildren();
- void clearDataDirect();
+ NodeSPI<K, V> getChild(Fqn fqn);
- NodeSPI<K, V> getChildDirect(Fqn fqn);
+ NodeSPI<K, V> getChild(Object childName);
- Set<Object> getChildrenNamesDirect();
+ Set<NodeSPI<K, V>> getChildren();
- Set<K> getKeysDirect();
+ Set<NodeSPI<K, V>> getChildren(boolean includeMarkedForRemoval);
- boolean removeChildDirect(Object childName);
+ NodeSPI<K, V> getOrCreateChild(Object childName, GlobalTransaction gtx, boolean notify);
- boolean removeChildDirect(Fqn f);
+ Set<Object> getChildrenNames();
- Map<Object, Node<K, V>> getChildrenMapDirect();
+ Map<Object, Node<K, V>> getChildrenMap();
- void setChildrenMapDirect(Map<Object, Node<K, V>> children);
+ void setChildrenMap(Map<Object, Node<K, V>> children);
- void putAllDirect(Map<K, V> data);
+ void addChild(NodeSPI<K, V> child);
- void removeChildrenDirect();
+ void addChild(Object nodeName, Node<K, V> nodeToAdd);
- void setVersion(DataVersion version);
+ NodeSPI<K, V> addChild(Fqn f);
- DataVersion getVersion();
+ NodeSPI<K, V> addChild(Fqn f, boolean notify);
- Fqn getFqn();
+ NodeSPI<K, V> addChild(Object o, boolean notify);
- void setFqn(Fqn fqn);
+ void removeChildren();
- NodeSPI<K, V> getChildDirect(Object childName);
+ boolean removeChild(Object childName);
- Set<NodeSPI<K, V>> getChildrenDirect();
+ boolean removeChild(Fqn f);
- boolean hasChildrenDirect();
- Set<NodeSPI<K, V>> getChildrenDirect(boolean includeMarkedForRemoval);
+ /**
+ * Creates a new instance of the same type and copies internal state. Note that a shallow copy is made for all fields
+ * except the data map, where a new map is created.
+ *
+ * @return a copy.
+ */
+ InternalNode<K, V> copy();
+
+ // ------------- Getters and setters for various flags -------------
+ boolean isChildrenLoaded();
+
+ void setChildrenLoaded(boolean flag);
+
boolean isDataLoaded();
void setDataLoaded(boolean dataLoaded);
@@ -92,33 +116,27 @@
void setLockForChildInsertRemove(boolean lockForChildInsertRemove);
- void setInternalState(Map<K, V> state);
+ boolean isRemoved();
- Map getInternalState(boolean onlyInternalState);
+ void setRemoved(boolean marker);
- void releaseObjectReferences(boolean recursive);
+ void markAsRemoved(boolean marker, boolean recursive);
- boolean isDeleted();
+ void setResident(boolean resident);
- void markAsDeleted(boolean marker);
+ boolean isResident();
- void markAsDeleted(boolean marker, boolean recursive);
+ // ------------- Utility stuff, mainly for backward compatibility -----------------
- void setResident(boolean resident);
+ void printDetails(StringBuilder sb, int indent);
- boolean isResident();
+ NodeSPI<K, V> getParent();
- /**
- * Creates a new instance of the same type and copies internal state. Note that a shallow copy is made for all fields
- * except the data map, where a new map is created.
- *
- * @return a copy.
- */
- InternalNode<K, V> copy();
+ CacheSPI<K, V> getCache();
- NodeLock getLock();
+ void setVersion(DataVersion version);
- void addChild(Object nodeName, Node<K, V> nodeToAdd);
+ DataVersion getVersion();
- void printDetails(StringBuilder sb, int indent);
+ NodeLock getLock();
}
Modified: core/trunk/src/main/java/org/jboss/cache/PessimisticUnversionedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/PessimisticUnversionedNode.java 2008-07-22 00:54:02 UTC (rev 6354)
+++ core/trunk/src/main/java/org/jboss/cache/PessimisticUnversionedNode.java 2008-07-22 08:50:07 UTC (rev 6355)
@@ -83,7 +83,7 @@
// ------ legacy addChild methods that used a lot of implicit locks.
@Override
- public void addChildDirect(NodeSPI<K, V> child)
+ public void addChild(NodeSPI<K, V> child)
{
if (child.getFqn().getParent().equals(getFqn()))
{
Modified: core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2008-07-22 00:54:02 UTC (rev 6354)
+++ core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2008-07-22 08:50:07 UTC (rev 6355)
@@ -179,7 +179,7 @@
setFlag(CHILDREN_LOADED, childrenLoaded);
}
- public V getDirect(K key)
+ public V get(K key)
{
return data == null ? null : data.get(key);
}
@@ -190,13 +190,13 @@
throw new UnsupportedOperationException("Not supported in this implementation!");
}
- public Map<K, V> getDataDirect()
+ public Map<K, V> getData()
{
if (data == null) return Collections.emptyMap();
return data;
}
- public V putDirect(K key, V value)
+ public V put(K key, V value)
{
if (data == null) initDataMap();
return data.put(key, value);
@@ -248,7 +248,7 @@
return child;
}
- public V removeDirect(K key)
+ public V remove(K key)
{
if (data == null) return null;
return data.remove(key);
@@ -269,7 +269,7 @@
sb.append(getClass().getSimpleName());
if (!isValid()) sb.append(" (invalid) ");
- if (isDeleted())
+ if (isRemoved())
{
sb.append(" (deleted) [ ").append(fqn);
}
@@ -322,12 +322,12 @@
{
if (trace)
{
- sb.append(" children=").append(getChildrenNamesDirect());
+ sb.append(" children=").append(getChildrenNames());
}
else
{
sb.append(" children=[");
- Set names = getChildrenNamesDirect();
+ Set names = getChildrenNames();
int i = 0;
for (Object o : names)
{
@@ -357,7 +357,7 @@
return sb.toString();
}
- public void addChildDirect(NodeSPI<K, V> child)
+ public void addChild(NodeSPI<K, V> child)
{
Fqn childFqn = child.getFqn();
Fqn parentFqn = childFqn.getParent();
@@ -371,12 +371,12 @@
}
}
- public NodeSPI<K, V> addChildDirect(Fqn f)
+ public NodeSPI<K, V> addChild(Fqn f)
{
- return addChildDirect(f, true);
+ return addChild(f, true);
}
- public NodeSPI<K, V> addChildDirect(Fqn f, boolean notify)
+ public NodeSPI<K, V> addChild(Fqn f, boolean notify)
{
if (f.size() == 1)
{
@@ -390,22 +390,22 @@
}
- public NodeSPI<K, V> addChildDirect(Object childName, boolean notify)
+ public NodeSPI<K, V> addChild(Object childName, boolean notify)
{
GlobalTransaction gtx = cache.getInvocationContext().getGlobalTransaction();
return getOrCreateChild(childName, gtx, true, notify);
}
- public void clearDataDirect()
+ public void clear()
{
if (data != null) data.clear();
}
- public NodeSPI<K, V> getChildDirect(Fqn fqn)
+ public NodeSPI<K, V> getChild(Fqn fqn)
{
if (fqn.size() == 1)
{
- return getChildDirect(fqn.getLastElement());
+ return getChild(fqn.getLastElement());
}
else
{
@@ -420,12 +420,12 @@
}
}
- public Set<Object> getChildrenNamesDirect()
+ public Set<Object> getChildrenNames()
{
return children == null ? Collections.emptySet() : new HashSet<Object>(children.keySet());
}
- public Set<K> getKeysDirect()
+ public Set<K> getKeys()
{
if (data == null)
{
@@ -434,30 +434,30 @@
return Collections.unmodifiableSet(new HashSet<K>(data.keySet()));
}
- public boolean removeChildDirect(Object childName)
+ public boolean removeChild(Object childName)
{
return children != null && children.remove(childName) != null;
}
- public boolean removeChildDirect(Fqn f)
+ public boolean removeChild(Fqn f)
{
if (f.size() == 1)
{
- return removeChildDirect(f.getLastElement());
+ return removeChild(f.getLastElement());
}
else
{
- NodeSPI<K, V> child = getChildDirect(f);
+ NodeSPI<K, V> child = getChild(f);
return child != null && child.getParentDirect().removeChildDirect(f.getLastElement());
}
}
- public Map<Object, Node<K, V>> getChildrenMapDirect()
+ public Map<Object, Node<K, V>> getChildrenMap()
{
return children;
}
- public void setChildrenMapDirect(Map<Object, Node<K, V>> children)
+ public void setChildrenMap(Map<Object, Node<K, V>> children)
{
if (children == null)
this.children = null;
@@ -468,7 +468,7 @@
}
}
- public void putAllDirect(Map<K, V> data)
+ public void putAll(Map<K, V> data)
{
if (data != null)
{
@@ -477,7 +477,7 @@
}
}
- public void removeChildrenDirect()
+ public void removeChildren()
{
if (children != null)
{
@@ -548,13 +548,13 @@
}
}
- public NodeSPI<K, V> getChildDirect(Object childName)
+ public NodeSPI<K, V> getChild(Object childName)
{
if (childName == null) return null;
return (NodeSPI<K, V>) (children == null ? null : children.get(childName));
}
- public Set<NodeSPI<K, V>> getChildrenDirect()
+ public Set<NodeSPI<K, V>> getChildren()
{
// strip out deleted child nodes...
if (children == null || children.size() == 0) return Collections.emptySet();
@@ -569,13 +569,13 @@
return exclDeleted;
}
- public boolean hasChildrenDirect()
+ public boolean hasChildren()
{
return children != null && children.size() != 0;
}
@SuppressWarnings("unchecked")
- public Set<NodeSPI<K, V>> getChildrenDirect(boolean includeMarkedForRemoval)
+ public Set<NodeSPI<K, V>> getChildren(boolean includeMarkedForRemoval)
{
if (includeMarkedForRemoval)
{
@@ -590,7 +590,7 @@
}
else
{
- return getChildrenDirect();
+ return getChildren();
}
}
@@ -692,7 +692,7 @@
else
{
// don't bother doing anything here
- putAllDirect(state);
+ putAll(state);
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java 2008-07-22 00:54:02 UTC (rev 6354)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java 2008-07-22 08:50:07 UTC (rev 6355)
@@ -169,9 +169,9 @@
{
// exists in workspace and has just been created.
currentNode = peekInWorkspace.getNode();
- if (peekInWorkspace.isDeleted())
+ if (peekInWorkspace.isRemoved())
{
- peekInWorkspace.markAsDeleted(false);
+ peekInWorkspace.setRemoved(false);
// add in parent again
workspaceNode.addChild(peekInWorkspace);
}
@@ -185,7 +185,7 @@
// we put the parent node into the workspace as we are changing it's children.
// at this point "workspaceNode" refers to the parent of the current node. It should never be null if
// you got this far!
- if (workspaceNode.isDeleted())
+ if (workspaceNode.isRemoved())
{
//add a new one or overwrite an existing one that has been deleted
if (trace)
@@ -246,7 +246,7 @@
log.trace("setting versioning of " + workspaceNode.getFqn() + " to be " + (workspaceNode.isVersioningImplicit() ? "implicit" : "explicit"));
workspace.addNode(workspaceNode);
}
- else if (workspaceNode.isDeleted())
+ else if (workspaceNode.isRemoved())
{
if (trace) log.trace("Found node but it is deleted in this workspace. Needs resurrecting.");
undeleteWorkspaceNode(workspaceNode, workspace);
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java 2008-07-22 00:54:02 UTC (rev 6354)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java 2008-07-22 08:50:07 UTC (rev 6355)
@@ -101,7 +101,7 @@
@SuppressWarnings("unchecked")
protected void undeleteWorkspaceNode(WorkspaceNode nodeToUndelete, WorkspaceNode parent)
{
- nodeToUndelete.markAsDeleted(false);
+ nodeToUndelete.setRemoved(false);
nodeToUndelete.clearData();
// add in parent again
parent.addChild(nodeToUndelete);
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java 2008-07-22 00:54:02 UTC (rev 6354)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java 2008-07-22 08:50:07 UTC (rev 6355)
@@ -294,7 +294,7 @@
if (trace) log.trace("Unable to find node " + command.getFqn() + " in workspace.");
result = null;
}
- else if (workspaceNode.isDeleted())
+ else if (workspaceNode.isRemoved())
{
if (trace) log.trace("Attempted to retrieve node " + command.getFqn() + " but it has been deleted!");
result = null;
@@ -484,7 +484,7 @@
if (toDelete.getFqn().isChildOrEquals(nodeFqn))
{
if (trace) log.trace("marking node " + toDelete.getFqn() + " as deleted");
- toDelete.markAsDeleted(true);
+ toDelete.setRemoved(true);
}
else
{
@@ -571,7 +571,7 @@
}
// Check that the workspace node has been marked as deleted.
- if (workspaceNode.isDeleted())
+ if (workspaceNode.isRemoved())
{
if (trace) log.trace("Node " + fqn + " has been deleted in the workspace.");
if (undeleteIfNecessary)
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java 2008-07-22 00:54:02 UTC (rev 6354)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java 2008-07-22 08:50:07 UTC (rev 6355)
@@ -88,7 +88,7 @@
// if this is a newly created node then we expect the underlying node to be null.
// also, if the node has been deleted in the WS and the underlying node is null, this *may* be ok ... will test again later when comparing versions
// if not, we have a problem...
- if (underlyingNode == null && !workspaceNode.isCreated() && !workspaceNode.isDeleted())
+ if (underlyingNode == null && !workspaceNode.isCreated() && !workspaceNode.isRemoved())
{
throw new DataVersioningException("Underlying node for " + fqn + " is null, and this node wasn't newly created in this transaction! We have a concurrent deletion event.");
}
@@ -102,7 +102,7 @@
if (underlyingNode != null && !underlyingNode.isValid())
{
// we havea tombstone
- if (!workspaceNode.isCreated() && !workspaceNode.isDeleted())
+ if (!workspaceNode.isCreated() && !workspaceNode.isRemoved())
throw new DataVersioningException("Underlying node doesn't exist but a tombstone does; workspace node should be marked as created!");
if (underlyingNode.getVersion().newerThan(workspaceNode.getVersion()))
{
@@ -111,13 +111,13 @@
}
}
- if (!workspaceNode.isCreated() && (workspaceNode.isDeleted() || workspaceNode.isModified()))
+ if (!workspaceNode.isCreated() && (workspaceNode.isRemoved() || workspaceNode.isModified()))
{
// if the real node is null, throw a DVE
if (underlyingNode == null)
{
// but not if the WSN has also been deleted
- if (!workspaceNode.isDeleted())
+ if (!workspaceNode.isRemoved())
throw new DataVersioningException("Unable to compare versions since the underlying node has been deleted by a concurrent transaction!");
else if (trace)
log.trace("The data node [" + fqn + "] is null, but this is ok since the workspace node is marked as deleted as well");
@@ -151,7 +151,7 @@
{
NodeSPI underlyingNode = workspaceNode.getNode();
// short circuit if this node is deleted?
- if (workspaceNode.isDeleted())
+ if (workspaceNode.isRemoved())
{
if (trace) log.trace("Workspace node " + workspaceNode.getFqn() + " deleted; removing");
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java 2008-07-22 00:54:02 UTC (rev 6354)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java 2008-07-22 08:50:07 UTC (rev 6355)
@@ -71,12 +71,12 @@
public Map<Object, Node<K, V>> getChildrenMapDirect()
{
- return node.getChildrenMapDirect();
+ return node.getChildrenMap();
}
public void setChildrenMapDirect(Map<Object, Node<K, V>> children)
{
- node.setChildrenMapDirect(children);
+ node.setChildrenMap(children);
}
public NodeSPI<K, V> getOrCreateChild(Object name, GlobalTransaction tx)
@@ -97,17 +97,17 @@
public boolean isDeleted()
{
- return node.isDeleted();
+ return node.isRemoved();
}
public void markAsDeleted(boolean marker)
{
- node.markAsDeleted(marker);
+ node.setRemoved(marker);
}
public void markAsDeleted(boolean marker, boolean recursive)
{
- node.markAsDeleted(marker, recursive);
+ node.markAsRemoved(marker, recursive);
}
public void addChild(Object nodeName, Node<K, V> nodeToAdd)
@@ -137,97 +137,97 @@
public Set<NodeSPI<K, V>> getChildrenDirect()
{
- return node.getChildrenDirect();
+ return node.getChildren();
}
public void removeChildrenDirect()
{
- node.removeChildrenDirect();
+ node.removeChildren();
}
public Set<NodeSPI<K, V>> getChildrenDirect(boolean includeMarkedAsDeleted)
{
- return node.getChildrenDirect(includeMarkedAsDeleted);
+ return node.getChildren(includeMarkedAsDeleted);
}
public NodeSPI<K, V> getChildDirect(Object childName)
{
- return node.getChildDirect(childName);
+ return node.getChild(childName);
}
public NodeSPI<K, V> addChildDirect(Fqn childName)
{
- return node.addChildDirect(childName);
+ return node.addChild(childName);
}
public NodeSPI<K, V> addChildDirect(Fqn f, boolean notify)
{
- return node.addChildDirect(f, notify);
+ return node.addChild(f, notify);
}
public NodeSPI<K, V> addChildDirect(Object childName, boolean notify)
{
- return node.addChildDirect(childName, notify);
+ return node.addChild(childName, notify);
}
public void addChildDirect(NodeSPI<K, V> child)
{
- node.addChildDirect(child);
+ node.addChild(child);
}
public NodeSPI<K, V> getChildDirect(Fqn childName)
{
- return node.getChildDirect(childName);
+ return node.getChild(childName);
}
public boolean removeChildDirect(Fqn fqn)
{
- return node.removeChildDirect(fqn);
+ return node.removeChild(fqn);
}
public boolean removeChildDirect(Object childName)
{
- return node.removeChildDirect(childName);
+ return node.removeChild(childName);
}
public V removeDirect(K key)
{
- return node.removeDirect(key);
+ return node.remove(key);
}
public V putDirect(K key, V value)
{
- return node.putDirect(key, value);
+ return node.put(key, value);
}
public void putAllDirect(Map<K, V> data)
{
- node.putAllDirect(data);
+ node.putAll(data);
}
public Map<K, V> getDataDirect()
{
- return node.getDataDirect();
+ return node.getData();
}
public V getDirect(K key)
{
- return node.getDirect(key);
+ return node.get(key);
}
public void clearDataDirect()
{
- node.clearDataDirect();
+ node.clear();
}
public Set<K> getKeysDirect()
{
- return node.getKeysDirect();
+ return node.getKeys();
}
public Set<Object> getChildrenNamesDirect()
{
- return node.getChildrenNamesDirect();
+ return node.getChildrenNames();
}
public CacheSPI<K, V> getCache()
@@ -470,7 +470,7 @@
public boolean hasChildrenDirect()
{
- return node.hasChildrenDirect();
+ return node.hasChildren();
}
public Map getInternalState(boolean onlyInternalState)
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/NodeReference.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/NodeReference.java 2008-07-22 00:54:02 UTC (rev 6354)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/NodeReference.java 2008-07-22 08:50:07 UTC (rev 6355)
@@ -75,19 +75,19 @@
delegate.setChildrenLoaded(flag);
}
- public V getDirect(K key)
+ public V get(K key)
{
- return delegate.getDirect(key);
+ return delegate.get(key);
}
- public Map<K, V> getDataDirect()
+ public Map<K, V> getData()
{
- return delegate.getDataDirect();
+ return delegate.getData();
}
- public V putDirect(K key, V value)
+ public V put(K key, V value)
{
- return delegate.putDirect(key, value);
+ return delegate.put(key, value);
}
public NodeSPI<K, V> getOrCreateChild(Object child_name, GlobalTransaction gtx, boolean notify)
@@ -95,79 +95,79 @@
return delegate.getOrCreateChild(child_name, gtx, notify);
}
- public V removeDirect(K key)
+ public V remove(K key)
{
- return delegate.removeDirect(key);
+ return delegate.remove(key);
}
- public void addChildDirect(NodeSPI child)
+ public void addChild(NodeSPI child)
{
- delegate.addChildDirect(child);
+ delegate.addChild(child);
}
- public NodeSPI<K, V> addChildDirect(Fqn f)
+ public NodeSPI<K, V> addChild(Fqn f)
{
- return delegate.addChildDirect(f);
+ return delegate.addChild(f);
}
- public NodeSPI<K, V> addChildDirect(Fqn f, boolean notify)
+ public NodeSPI<K, V> addChild(Fqn f, boolean notify)
{
- return delegate.addChildDirect(f, notify);
+ return delegate.addChild(f, notify);
}
- public NodeSPI<K, V> addChildDirect(Object o, boolean notify)
+ public NodeSPI<K, V> addChild(Object o, boolean notify)
{
- return delegate.addChildDirect(o, notify);
+ return delegate.addChild(o, notify);
}
- public void clearDataDirect()
+ public void clear()
{
- delegate.clearDataDirect();
+ delegate.clear();
}
- public NodeSPI<K, V> getChildDirect(Fqn fqn)
+ public NodeSPI<K, V> getChild(Fqn fqn)
{
- return delegate.getChildDirect(fqn);
+ return delegate.getChild(fqn);
}
- public Set<Object> getChildrenNamesDirect()
+ public Set<Object> getChildrenNames()
{
- return delegate.getChildrenNamesDirect();
+ return delegate.getChildrenNames();
}
- public Set<K> getKeysDirect()
+ public Set<K> getKeys()
{
- return delegate.getKeysDirect();
+ return delegate.getKeys();
}
- public boolean removeChildDirect(Object childName)
+ public boolean removeChild(Object childName)
{
- return delegate.removeChildDirect(childName);
+ return delegate.removeChild(childName);
}
- public boolean removeChildDirect(Fqn f)
+ public boolean removeChild(Fqn f)
{
- return delegate.removeChildDirect(f);
+ return delegate.removeChild(f);
}
- public Map<Object, Node<K, V>> getChildrenMapDirect()
+ public Map<Object, Node<K, V>> getChildrenMap()
{
- return delegate.getChildrenMapDirect();
+ return delegate.getChildrenMap();
}
- public void setChildrenMapDirect(Map<Object, Node<K, V>> children)
+ public void setChildrenMap(Map<Object, Node<K, V>> children)
{
- delegate.setChildrenMapDirect(children);
+ delegate.setChildrenMap(children);
}
- public void putAllDirect(Map<K, V> data)
+ public void putAll(Map<K, V> data)
{
- delegate.putAllDirect(data);
+ delegate.putAll(data);
}
- public void removeChildrenDirect()
+ public void removeChildren()
{
- delegate.removeChildrenDirect();
+ delegate.removeChildren();
}
public void setVersion(DataVersion version)
@@ -190,24 +190,24 @@
delegate.setFqn(fqn);
}
- public NodeSPI<K, V> getChildDirect(Object childName)
+ public NodeSPI<K, V> getChild(Object childName)
{
- return delegate.getChildDirect(childName);
+ return delegate.getChild(childName);
}
- public Set<NodeSPI<K, V>> getChildrenDirect()
+ public Set<NodeSPI<K, V>> getChildren()
{
- return delegate.getChildrenDirect();
+ return delegate.getChildren();
}
- public boolean hasChildrenDirect()
+ public boolean hasChildren()
{
- return delegate.hasChildrenDirect();
+ return delegate.hasChildren();
}
- public Set<NodeSPI<K, V>> getChildrenDirect(boolean includeMarkedForRemoval)
+ public Set<NodeSPI<K, V>> getChildren(boolean includeMarkedForRemoval)
{
- return delegate.getChildrenDirect(includeMarkedForRemoval);
+ return delegate.getChildren(includeMarkedForRemoval);
}
public boolean isDataLoaded()
@@ -255,19 +255,19 @@
delegate.releaseObjectReferences(recursive);
}
- public boolean isDeleted()
+ public boolean isRemoved()
{
- return delegate.isDeleted();
+ return delegate.isRemoved();
}
- public void markAsDeleted(boolean marker)
+ public void setRemoved(boolean marker)
{
- delegate.markAsDeleted(marker);
+ delegate.setRemoved(marker);
}
- public void markAsDeleted(boolean marker, boolean recursive)
+ public void markAsRemoved(boolean marker, boolean recursive)
{
- delegate.markAsDeleted(marker, recursive);
+ delegate.markAsRemoved(marker, recursive);
}
public void setResident(boolean resident)
Modified: core/trunk/src/main/java/org/jboss/cache/optimistic/WorkspaceNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/optimistic/WorkspaceNode.java 2008-07-22 00:54:02 UTC (rev 6354)
+++ core/trunk/src/main/java/org/jboss/cache/optimistic/WorkspaceNode.java 2008-07-22 08:50:07 UTC (rev 6355)
@@ -124,26 +124,6 @@
void setVersioningImplicit(boolean b);
/**
- * @return true if the instance has been deleted in the current transaction.
- */
- boolean isDeleted();
-
- /**
- * Marks the node as being deleted (or not) in the current transaction. This is not recursive, child nodes are not affected.
- *
- * @param marker true if the node has been deleted, false if not.
- */
- void markAsDeleted(boolean marker);
-
- /**
- * Same as {@link #markAsDeleted(boolean)} except that the option to recurse into children is provided.
- *
- * @param marker true if the node has been deleted, false if not.
- * @param recursive if true, child nodes (and their children) are marked as well.
- */
- void markAsDeleted(boolean marker, boolean recursive);
-
- /**
* Overrides {@link Node#getChild(Object)} to return a {@link org.jboss.cache.NodeSPI} rather than a {@link org.jboss.cache.Node}
*
* @param o node name
@@ -187,4 +167,10 @@
* @param resurrected
*/
void markAsResurrected(boolean resurrected);
+
+ boolean isRemoved();
+
+ void setRemoved(boolean marker);
+
+ void markAsRemoved(boolean marker, boolean recursive);
}
Modified: core/trunk/src/main/java/org/jboss/cache/optimistic/WorkspaceNodeImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/optimistic/WorkspaceNodeImpl.java 2008-07-22 00:54:02 UTC (rev 6354)
+++ core/trunk/src/main/java/org/jboss/cache/optimistic/WorkspaceNodeImpl.java 2008-07-22 08:50:07 UTC (rev 6355)
@@ -110,9 +110,9 @@
}
@Override
- public void markAsDeleted(boolean marker, boolean recursive)
+ public void markAsRemoved(boolean marker, boolean recursive)
{
- super.markAsDeleted(marker, recursive);
+ super.markAsRemoved(marker, recursive);
if (marker)
{
if (childrenAdded != null) childrenAdded.clear();
@@ -135,7 +135,7 @@
*/
public boolean isDirty()
{
- return isModified() || isCreated() || isDeleted();
+ return isModified() || isCreated() || isRemoved();
}
public Fqn getFqn()
@@ -333,7 +333,7 @@
public String toString()
{
StringBuilder sb = new StringBuilder();
- if (isDeleted()) sb.append("del ");
+ if (isRemoved()) sb.append("del ");
if (isModified()) sb.append("modified ");
if (isCreated()) sb.append("new ");
return getClass().getSimpleName() + " [ fqn=" + getFqn() + " " + sb + "ver=" + version + " " + (isVersioningImplicit() ? "implicit" : "explicit") + "]";
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveNodeTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveNodeTest.java 2008-07-22 00:54:02 UTC (rev 6354)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveNodeTest.java 2008-07-22 08:50:07 UTC (rev 6355)
@@ -123,9 +123,9 @@
assertEquals(3, workspace.getNodes().size());
assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));
- assertEquals(true, workspace.getNode(Fqn.fromString("/one/two")).isDeleted());
+ assertEquals(true, workspace.getNode(Fqn.fromString("/one/two")).isRemoved());
assertNotNull(workspace.getNode(Fqn.fromString("/one")));
- assertEquals(false, workspace.getNode(Fqn.fromString("/one")).isDeleted());
+ assertEquals(false, workspace.getNode(Fqn.fromString("/one")).isRemoved());
List<Set<Fqn>> mergedChildren = workspace.getNode(Fqn.fromString("/one")).getMergedChildren();
assertEquals(1, mergedChildren.get(1).size());
System.out.println(entry.getModifications());
@@ -162,9 +162,9 @@
assertEquals(3, workspace.getNodes().size());
assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));
- assertEquals(true, workspace.getNode(Fqn.fromString("/one/two")).isDeleted());
+ assertEquals(true, workspace.getNode(Fqn.fromString("/one/two")).isRemoved());
assertNotNull(workspace.getNode(Fqn.fromString("/one")));
- assertEquals(true, workspace.getNode(Fqn.fromString("/one")).isDeleted());
+ assertEquals(true, workspace.getNode(Fqn.fromString("/one")).isRemoved());
assertEquals(0, workspace.getNode(Fqn.fromString("/one")).getMergedChildren().get(0).size());
assertTrue(!cache.exists("/one/two"));
assert 2 == dummy.getAllCalled().size();
@@ -202,18 +202,18 @@
cache.removeNode("/one");
assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));
- assertEquals(true, workspace.getNode(Fqn.fromString("/one/two")).isDeleted());
+ assertEquals(true, workspace.getNode(Fqn.fromString("/one/two")).isRemoved());
assertNotNull(workspace.getNode(Fqn.fromString("/one")));
- assertEquals(true, workspace.getNode(Fqn.fromString("/one")).isDeleted());
+ assertEquals(true, workspace.getNode(Fqn.fromString("/one")).isRemoved());
//now put /one/two back in
cache.removeNode("/one");
assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));
- assertEquals(true, workspace.getNode(Fqn.fromString("/one/two")).isDeleted());
+ assertEquals(true, workspace.getNode(Fqn.fromString("/one/two")).isRemoved());
assertNotNull(workspace.getNode(Fqn.fromString("/one")));
- assertEquals(true, workspace.getNode(Fqn.fromString("/one")).isDeleted());
+ assertEquals(true, workspace.getNode(Fqn.fromString("/one")).isRemoved());
assertEquals(null, dummy.getCalledCommand());
@@ -258,9 +258,9 @@
cache.removeNode("/one");
assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));
- assertEquals(true, workspace.getNode(Fqn.fromString("/one/two")).isDeleted());
+ assertEquals(true, workspace.getNode(Fqn.fromString("/one/two")).isRemoved());
assertNotNull(workspace.getNode(Fqn.fromString("/one")));
- assertEquals(true, workspace.getNode(Fqn.fromString("/one")).isDeleted());
+ assertEquals(true, workspace.getNode(Fqn.fromString("/one")).isRemoved());
//now put /one/two back in
cache.put("/one/two", temp);
@@ -269,9 +269,9 @@
WorkspaceNode twoAfter = workspace.getNode(Fqn.fromString("/one/two"));
assertSame(one, oneAfter);
- assertEquals(false, oneAfter.isDeleted());
+ assertEquals(false, oneAfter.isRemoved());
assertSame(two, twoAfter);
- assertEquals(false, twoAfter.isDeleted());
+ assertEquals(false, twoAfter.isRemoved());
assertEquals(null, dummy.getCalledCommand());
@@ -318,9 +318,9 @@
cache.removeNode("/one");
assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));
- assertEquals(true, workspace.getNode(Fqn.fromString("/one/two")).isDeleted());
+ assertEquals(true, workspace.getNode(Fqn.fromString("/one/two")).isRemoved());
assertNotNull(workspace.getNode(Fqn.fromString("/one")));
- assertEquals(true, workspace.getNode(Fqn.fromString("/one")).isDeleted());
+ assertEquals(true, workspace.getNode(Fqn.fromString("/one")).isRemoved());
//now put /one back in
cache.put(Fqn.fromString("/one"), "key1", "value2");
@@ -329,9 +329,9 @@
WorkspaceNode twoAfter = workspace.getNode(Fqn.fromString("/one/two"));
assertSame(one, oneAfter);
- assertEquals(false, oneAfter.isDeleted());
+ assertEquals(false, oneAfter.isRemoved());
assertEquals(two, twoAfter);
- assertEquals(true, twoAfter.isDeleted());
+ assertEquals(true, twoAfter.isRemoved());
assertEquals(null, dummy.getCalledCommand());
@@ -379,9 +379,9 @@
cache.removeNode("/one/two");
assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));
- assertEquals(true, workspace.getNode(Fqn.fromString("/one/two")).isDeleted());
+ assertEquals(true, workspace.getNode(Fqn.fromString("/one/two")).isRemoved());
assertNotNull(workspace.getNode(Fqn.fromString("/one")));
- assertEquals(false, workspace.getNode(Fqn.fromString("/one")).isDeleted());
+ assertEquals(false, workspace.getNode(Fqn.fromString("/one")).isRemoved());
assertEquals(null, dummy.getCalledCommand());
More information about the jbosscache-commits
mailing list