[jboss-cvs] JBossCache/src/org/jboss/cache ...
Manik Surtani
msurtani at jboss.com
Tue Nov 28 23:42:36 EST 2006
User: msurtani
Date: 06/11/28 23:42:36
Modified: src/org/jboss/cache TreeCache.java
Log:
JBCACHE-813
Revision Changes Path
1.287 +84 -59 JBossCache/src/org/jboss/cache/TreeCache.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: TreeCache.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/TreeCache.java,v
retrieving revision 1.286
retrieving revision 1.287
diff -u -b -r1.286 -r1.287
--- TreeCache.java 26 Nov 2006 20:35:13 -0000 1.286
+++ TreeCache.java 29 Nov 2006 04:42:36 -0000 1.287
@@ -26,10 +26,10 @@
import org.jboss.cache.loader.CacheLoaderManager;
import org.jboss.cache.loader.NodeData;
import org.jboss.cache.lock.IsolationLevel;
-import org.jboss.cache.lock.NodeLock;
import org.jboss.cache.lock.LockStrategyFactory;
import org.jboss.cache.lock.LockUtil;
import org.jboss.cache.lock.LockingException;
+import org.jboss.cache.lock.NodeLock;
import org.jboss.cache.lock.TimeoutException;
import org.jboss.cache.marshall.MethodCall;
import org.jboss.cache.marshall.MethodCallFactory;
@@ -75,9 +75,7 @@
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collection;
import java.util.Collections;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
@@ -96,7 +94,7 @@
* @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
* @author Brian Stansberry
* @author Daniel Huang (dhuang at jboss.org)
- * @version $Id: TreeCache.java,v 1.286 2006/11/26 20:35:13 genman Exp $
+ * @version $Id: TreeCache.java,v 1.287 2006/11/29 04:42:36 msurtani Exp $
* <p/>
* @see <a href="http://labs.jboss.com/portal/jbosscache/docs">JBossCache doc</a>
*/
@@ -112,6 +110,7 @@
* Root DataNode.
*/
protected DataNode root;
+
{
this.rootSpi = new TreeCacheProxyImpl(this);
this.root = NodeFactory.getInstance().createRootDataNode(NodeFactory.NODE_TYPE_TREENODE, this.rootSpi);
@@ -217,8 +216,12 @@
/**
* Uninitialized node key.
*/
- static public final Object UNINITIALIZED = new Object() {
- public String toString() { return "UNINITIALIZED"; }
+ static public final Object UNINITIALIZED = new Object()
+ {
+ public String toString()
+ {
+ return "UNINITIALIZED";
+ }
};
/**
@@ -1901,7 +1904,8 @@
return 0;
}
int count = 1; // for n
- for (Node child: n.getNodeSPI().getChildrenMap().values()) {
+ for (Node child : n.getNodeSPI().getChildrenMap().values())
+ {
count += numNodes(child);
}
return count;
@@ -2011,20 +2015,9 @@
}
// this is a temporary workaround (JBCACHE-813) until AnyCast (JGRP-338) is available.
- if (validMembers.size() == 1)
+ if (useTcpWorkaround())
{
- // use a UNICAST
- try
- {
- Address recipient = (Address) validMembers.get(0);
- Object r = disp.callRemoteMethod(recipient, method_call, mode, timeout);
- rsps = new RspList();
- rsps.addRsp(recipient, r);
- }
- catch (Throwable throwable)
- {
- throw new ReplicationException(throwable);
- }
+ rsps = multipleUnicast(validMembers, method_call, mode, timeout);
}
else
{
@@ -2074,6 +2067,38 @@
return retval;
}
+ boolean useTcpWorkaround()
+ {
+ return channel.getProtocolStack().findProtocol("UDP") == null;
+ }
+
+ /**
+ * This is a workaround for JBCACHE-813
+ */
+ private RspList multipleUnicast(List recipients, MethodCall call, int mode, long timeout) throws Exception
+ {
+ if (recipients == null || recipients.isEmpty()) return null;
+
+ Iterator i = recipients.iterator();
+ RspList rsps = new RspList();
+
+ while (i.hasNext())
+ {
+ Address recipient = (Address) i.next();
+ Object r = null;
+ try
+ {
+ r = disp.callRemoteMethod(recipient, call, mode, timeout);
+ }
+ catch (Throwable throwable)
+ {
+ throw new Exception(throwable);
+ }
+ rsps.addRsp(recipient, r);
+ }
+ return rsps;
+ }
+
/**
* @param members
@@ -2243,7 +2268,7 @@
tx_table.addUndoOperation(tx, undo_op);
}
- ((DataNode)n).put(data, (boolean)erase_contents);
+ ((DataNode) n).put(data, (boolean) erase_contents);
notifier.notifyNodeModified(fqn, false, rawData);
@@ -2696,7 +2721,7 @@
{
if (log.isTraceEnabled())
{
- log.trace("_addChild(\"" + parent_fqn +"\", \"" + child_name + "\", node=" + childNode + ")");
+ log.trace("_addChild(\"" + parent_fqn + "\", \"" + child_name + "\", node=" + childNode + ")");
}
if (parent_fqn == null || child_name == null || childNode == null)
@@ -2898,7 +2923,7 @@
NodeData data = new NodeData(BuddyManager.getActualFqn(node.getFqn()), node.getData());
list.add(data);
Map<Object, Node> children = node.getNodeSPI().getChildrenMap();
- for (Node childNode: children.values())
+ for (Node childNode : children.values())
{
getNodeData(list, childNode);
}
@@ -3187,7 +3212,7 @@
private void moveFqns(Node node, Fqn newBase)
{
- Fqn newFqn = new Fqn(newBase, ((TreeNode)node).getName());
+ Fqn newFqn = new Fqn(newBase, ((TreeNode) node).getName());
node.getNodeSPI().setFqn(newFqn);
}
More information about the jboss-cvs-commits
mailing list