[jboss-cvs] JBossCache/src/org/jboss/cache/optimistic ...
Manik Surtani
msurtani at jboss.com
Wed Sep 20 12:28:58 EDT 2006
User: msurtani
Date: 06/09/20 12:28:58
Modified: src/org/jboss/cache/optimistic TransactionWorkspace.java
TransactionWorkspaceImpl.java
WorkspaceNodeImpl.java
Log:
Fixed moving with optlocking
Revision Changes Path
1.11 +47 -43 JBossCache/src/org/jboss/cache/optimistic/TransactionWorkspace.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: TransactionWorkspace.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/optimistic/TransactionWorkspace.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- TransactionWorkspace.java 31 May 2006 14:08:39 -0000 1.10
+++ TransactionWorkspace.java 20 Sep 2006 16:28:58 -0000 1.11
@@ -43,7 +43,6 @@
/**
* Is thread safe so you dont need to deal with synchronising access to this method.
- *
*/
public Object removeNode(Fqn fqn);
@@ -65,4 +64,9 @@
* If set to false, DataVersions will have to come from the caller.
*/
public void setVersioningImplicit(boolean versioningImplicit);
+
+ /**
+ * returns true if the workspace contains a node with specified Fqn
+ */
+ boolean hasNode(Fqn fqn);
}
1.13 +81 -76 JBossCache/src/org/jboss/cache/optimistic/TransactionWorkspaceImpl.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: TransactionWorkspaceImpl.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/optimistic/TransactionWorkspaceImpl.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- TransactionWorkspaceImpl.java 10 Apr 2006 05:31:04 -0000 1.12
+++ TransactionWorkspaceImpl.java 20 Sep 2006 16:28:58 -0000 1.13
@@ -11,8 +11,8 @@
import org.jboss.cache.TreeCache;
import java.util.Map;
-import java.util.TreeMap;
import java.util.SortedMap;
+import java.util.TreeMap;
/**
* Contains a mapping of Fqn to {@link WorkspaceNode}s.
@@ -79,7 +79,7 @@
public SortedMap getNodesAfter(Fqn fqn)
{
SortedMap sm = new TreeMap(fqnComparator);
- sm.putAll( nodes );
+ sm.putAll(nodes);
return sm.tailMap(fqn);
}
@@ -93,6 +93,11 @@
this.versioningImplicit = versioningImplicit;
}
+ public boolean hasNode(Fqn fqn)
+ {
+ return nodes.containsKey(fqn);
+ }
+
/**
* Returns debug information.
*/
1.26 +33 -134 JBossCache/src/org/jboss/cache/optimistic/WorkspaceNodeImpl.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: WorkspaceNodeImpl.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/optimistic/WorkspaceNodeImpl.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- WorkspaceNodeImpl.java 7 Sep 2006 15:42:15 -0000 1.25
+++ WorkspaceNodeImpl.java 20 Sep 2006 16:28:58 -0000 1.26
@@ -67,12 +67,16 @@
public WorkspaceNodeImpl(DataNode node, TransactionWorkspace workspace)
{
if (!(node instanceof OptimisticTreeNode))
+ {
throw new IllegalArgumentException("node " + node + " not OptimisticTreeNode");
+ }
this.node = node;
this.workspace = workspace;
optimisticDataMap = node.getData();
if (optimisticDataMap == null)
+ {
optimisticDataMap = new HashMap();
+ }
if (node.getChildren() == null)
{
optimisticChildNodeMap = new ConcurrentReaderHashMap(0);
@@ -157,7 +161,7 @@
{
optimisticDataMap.clear();
}
- optimisticDataMap.putAll(data);
+ if (data != null) optimisticDataMap.putAll(data);
}
public void removeChild(Object childName)
@@ -190,8 +194,7 @@
public TreeNode createChild(Object child_name, Fqn fqn, TreeNode parent)
{
- log.error("Not implemented here!!");
- return null;
+ throw new UnsupportedOperationException("Unsupported for optimistic nodes");
}
public TreeNode createChild(Object child_name, Fqn fqn, TreeNode parent, TreeCache cache, DataVersion version)
@@ -209,7 +212,9 @@
{
child = NodeFactory.getInstance().createNodeOfType(parent, child_name, fqn, parent, null, cache, version);
if (optimisticChildNodeMap == Collections.EMPTY_MAP)
+ {
optimisticChildNodeMap = new ConcurrentReaderHashMap();
+ }
optimisticChildNodeMap.put(child_name, child);
}
if (log.isTraceEnabled())
@@ -326,245 +331,139 @@
dirty = true;
}
- /**
- * Always returns null; dummy method for TreeNode compatibility.
- *
- * @return null
- */
public Map getData()
{
- return null;
+ return Collections.unmodifiableMap(optimisticDataMap);
}
- /**
- * Always returns null; dummy method for TreeNode compatibility.
- *
- * @return null
- */
public Map getChildren()
{
- return null;
+ return Collections.unmodifiableMap(optimisticChildNodeMap);
}
- /**
- * @see org.jboss.cache.DataNode
- * @deprecated Will be removed in JBossCache 1.3.
- */
public boolean containsKey(Object key)
{
- return false;
+ return optimisticDataMap.containsKey(key);
}
- /**
- * @see org.jboss.cache.DataNode
- * @deprecated Will be removed in JBossCache 1.3.
- */
public Set getDataKeys()
{
- return null;
+ throw new UnsupportedOperationException("Unsupported for optimistic nodes");
}
- /**
- * @see org.jboss.cache.DataNode
- * @deprecated Will be removed in JBossCache 1.3.
- */
public boolean childExists(Object child_name)
{
- return false;
+ throw new UnsupportedOperationException("Unsupported for optimistic nodes");
}
- /**
- * @see org.jboss.cache.DataNode
- * @deprecated Will be removed in JBossCache 1.3.
- */
public IdentityLock getImmutableLock()
{
- return null;
+ throw new UnsupportedOperationException("Unsupported for optimistic nodes");
}
- /**
- * @see org.jboss.cache.DataNode
- * @deprecated Will be removed in JBossCache 1.3.
- */
public IdentityLock getLock()
{
- return null;
+ throw new UnsupportedOperationException("Unsupported for optimistic nodes");
}
- /**
- * @see org.jboss.cache.DataNode
- * @deprecated Will be removed in JBossCache 1.3.
- */
public int numAttributes()
{
- return 0;
+ throw new UnsupportedOperationException("Unsupported for optimistic nodes");
}
- /**
- * @see org.jboss.cache.DataNode
- * @deprecated Will be removed in JBossCache 1.3.
- */
public boolean hasChildren()
{
- return false;
+ throw new UnsupportedOperationException("Unsupported for optimistic nodes");
}
- /**
- * Creates a new child of this node if it doesn't exist. Also notifies the cache
- * that the new child has been created.
- * dded this new getOrCreateChild() method to avoid thread contention
- * on create_lock in PessimisticLockInterceptor.lock()
- *
- * @see org.jboss.cache.DataNode
- * @deprecated Will be removed in JBossCache 1.3.
- */
public TreeNode getOrCreateChild(Object child_name, GlobalTransaction gtx, boolean createIfNotExists)
{
throw new UnsupportedOperationException("Unsupported for optimistic nodes");
}
- /**
- * @see org.jboss.cache.DataNode
- * @deprecated Will be removed in JBossCache 1.3.
- */
public TreeNode createChild(Object child_name, Fqn fqn, TreeNode parent, Object key, Object value)
{
throw new UnsupportedOperationException("Unsupported for optimistic nodes");
}
- /**
- * @see org.jboss.cache.DataNode
- * @deprecated Will be removed in JBossCache 1.3.
- */
public void removeAllChildren()
{
+ throw new UnsupportedOperationException("Unsupported for optimistic nodes");
}
- /**
- * @see org.jboss.cache.DataNode
- * @deprecated Will be removed in JBossCache 1.3.
- */
public void print(StringBuffer sb, int indent)
{
+ throw new UnsupportedOperationException("Unsupported for optimistic nodes");
}
- /**
- * @see org.jboss.cache.DataNode
- * @deprecated Will be removed in JBossCache 1.3.
- */
public void printDetails(StringBuffer sb, int indent)
{
+ throw new UnsupportedOperationException("Unsupported for optimistic nodes");
}
- /**
- * @see org.jboss.cache.DataNode
- * @deprecated Will be removed in JBossCache 1.3.
- */
public void printIndent(StringBuffer sb, int indent)
{
+ throw new UnsupportedOperationException("Unsupported for optimistic nodes");
}
- /**
- * Adds the (already created) child node. Replaces existing node if present.
- *
- * @see org.jboss.cache.DataNode
- * @deprecated Will be removed in JBossCache 1.3.
- */
public void addChild(Object child_name, TreeNode n)
{
+ throw new UnsupportedOperationException("Unsupported for optimistic nodes");
}
- /**
- * @see org.jboss.cache.DataNode
- * @deprecated Will be removed in JBossCache 1.3.
- */
public void printLockInfo(StringBuffer sb, int indent)
{
+ throw new UnsupportedOperationException("Unsupported for optimistic nodes");
}
- /**
- * @see org.jboss.cache.DataNode
- * @deprecated Will be removed in JBossCache 1.3.
- */
public boolean isLocked()
{
- return false;
+ throw new UnsupportedOperationException("Unsupported for optimistic nodes");
}
- /**
- * @see org.jboss.cache.DataNode
- * @deprecated Will be removed in JBossCache 1.3.
- */
public void releaseAll(Object owner)
{
+ throw new UnsupportedOperationException("Unsupported for optimistic nodes");
}
- /**
- * @see org.jboss.cache.DataNode
- * @deprecated Will be removed in JBossCache 1.3.
- */
public void releaseAllForce()
{
+ throw new UnsupportedOperationException("Unsupported for optimistic nodes");
}
- /**
- * @see org.jboss.cache.DataNode
- * @deprecated Will be removed in JBossCache 1.3.
- */
public Set acquireAll(Object caller, long timeout, DataNode.LockType lock_type) throws LockingException, TimeoutException, InterruptedException
{
- return null;
+ throw new UnsupportedOperationException("Unsupported for optimistic nodes");
}
- /**
- * @see org.jboss.cache.DataNode
- * @deprecated Will be removed in JBossCache 1.3.
- */
public void setRecursiveTreeCacheInstance(TreeCache cache)
{
+ throw new UnsupportedOperationException("Unsupported for optimistic nodes");
}
- /**
- * @see org.jboss.cache.DataNode
- * @deprecated Will be removed in JBossCache 1.3.
- */
public boolean getChildrenLoaded()
{
- return false;
+ throw new UnsupportedOperationException("Unsupported for optimistic nodes");
}
- /**
- * @see org.jboss.cache.DataNode
- * @deprecated Will be removed in JBossCache 1.3.
- */
public void setChildrenLoaded(boolean b)
{
+ throw new UnsupportedOperationException("Unsupported for optimistic nodes");
}
- /**
- * Sets Map<Object,TreeNode>
- *
- * @see org.jboss.cache.DataNode
- * @deprecated Will be removed in JBossCache 1.3.
- */
public void setChildren(Map children)
{
+ throw new UnsupportedOperationException("Unsupported for optimistic nodes");
}
- /**
- * @see org.jboss.cache.DataNode
- * @deprecated Will be removed in JBossCache 1.3.
- */
public void release(Object caller)
{
+ throw new UnsupportedOperationException("Unsupported for optimistic nodes");
}
- /**
- * @see org.jboss.cache.DataNode
- * @deprecated Will be removed in JBossCache 1.3.
- */
public void releaseForce()
{
+ throw new UnsupportedOperationException("Unsupported for optimistic nodes");
}
public String toString()
More information about the jboss-cvs-commits
mailing list