[jboss-cvs] JBossCache/src/org/jboss/cache ...
Manik Surtani
msurtani at jboss.com
Tue Oct 31 09:55:37 EST 2006
User: msurtani
Date: 06/10/31 09:55:37
Modified: src/org/jboss/cache Tag: Branch_JBossCache_1_4_0
TreeCache.java
Log:
JBCACHE-813
Revision Changes Path
No revision
No revision
1.195.2.14 +408 -372 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.195.2.13
retrieving revision 1.195.2.14
diff -u -b -r1.195.2.13 -r1.195.2.14
--- TreeCache.java 11 Oct 2006 14:14:58 -0000 1.195.2.13
+++ TreeCache.java 31 Oct 2006 14:55:37 -0000 1.195.2.14
@@ -27,6 +27,7 @@
import org.jboss.cache.lock.LockStrategyFactory;
import org.jboss.cache.lock.LockingException;
import org.jboss.cache.lock.TimeoutException;
+import org.jboss.cache.marshall.JBCMethodCall;
import org.jboss.cache.marshall.MethodCallFactory;
import org.jboss.cache.marshall.MethodDeclarations;
import org.jboss.cache.marshall.Region;
@@ -35,7 +36,6 @@
import org.jboss.cache.marshall.RegionNotFoundException;
import org.jboss.cache.marshall.TreeCacheMarshaller;
import org.jboss.cache.marshall.VersionAwareMarshaller;
-import org.jboss.cache.marshall.JBCMethodCall;
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.statetransfer.StateTransferFactory;
import org.jboss.cache.statetransfer.StateTransferGenerator;
@@ -43,7 +43,16 @@
import org.jboss.cache.util.MBeanConfigurator;
import org.jboss.invocation.MarshalledValueOutputStream;
import org.jboss.system.ServiceMBeanSupport;
-import org.jgroups.*;
+import org.jgroups.Address;
+import org.jgroups.Channel;
+import org.jgroups.ChannelClosedException;
+import org.jgroups.ChannelNotConnectedException;
+import org.jgroups.JChannel;
+import org.jgroups.MembershipListener;
+import org.jgroups.Message;
+import org.jgroups.MessageListener;
+import org.jgroups.View;
+import org.jgroups.ViewId;
import org.jgroups.blocks.GroupRequest;
import org.jgroups.blocks.MethodCall;
import org.jgroups.blocks.RpcDispatcher;
@@ -63,12 +72,22 @@
import javax.transaction.SystemException;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
-
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.NotSerializableException;
import java.lang.reflect.Method;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.Vector;
/**
* A tree-like structure that is replicated across several members. Updates are
@@ -80,7 +99,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.195.2.13 2006/10/11 14:14:58 msurtani Exp $
+ * @version $Id: TreeCache.java,v 1.195.2.14 2006/10/31 14:55:37 msurtani Exp $
* <p/>
* @see <a href="http://labs.jboss.com/portal/jbosscache/docs">JBossCache doc</a>
*/
@@ -1478,7 +1497,8 @@
{
try
{
- MBeanConfigurator.unregisterInterceptors(mbserver, this, isStandalone); }
+ MBeanConfigurator.unregisterInterceptors(mbserver, this, isStandalone);
+ }
catch (Exception e)
{
log.error("failed unregistering cache interceptor mbeans ", e);
@@ -1529,10 +1549,11 @@
/* ----------------------- End of MBeanSupport ----------------------- */
-
/* ----------------------- Start of buddy replication specific methods ------------*/
+
/**
* Sets the buddy replication configuration element
+ *
* @param config
*/
public void setBuddyReplicationConfig(Element config)
@@ -1550,6 +1571,7 @@
/**
* Retrieves the buddy replication cofiguration element
+ *
* @return config
*/
public Element getBuddyReplicationConfig()
@@ -1559,6 +1581,7 @@
/**
* Retrieves the Buddy Manager configured.
+ *
* @return null if buddy replication is not enabled.
*/
public BuddyManager getBuddyManager()
@@ -1638,7 +1661,7 @@
* Sets whether marshalling uses scoped class loaders on a per region basis.
* <p/>
* This property must be set to <code>true</code> before any call to
- * {@link #registerClassLoader(String, ClassLoader)} or
+ * {@link #registerClassLoader(String,ClassLoader)} or
* {@link #activateRegion(String)}
*
* @param isTrue
@@ -1844,7 +1867,7 @@
for (Iterator it = buddies.iterator(); it.hasNext();)
{
Address buddy = (Address) it.next();
- Object[] sources = { buddy };
+ Object[] sources = {buddy};
Fqn base = new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, BuddyManager.getGroupNameFromAddress(buddy));
Fqn buddyRoot = new Fqn(base, fqn);
subtreeRoot = findNode(buddyRoot);
@@ -1884,11 +1907,11 @@
// Throw the exception on, wrapping if necessary
if (t instanceof RegionNameConflictException)
- throw (RegionNameConflictException) t;
+ throw(RegionNameConflictException) t;
else if (t instanceof RegionNotEmptyException)
- throw (RegionNotEmptyException) t;
+ throw(RegionNotEmptyException) t;
else if (t instanceof CacheException)
- throw (CacheException) t;
+ throw(CacheException) t;
else
throw new CacheException(t.getClass().getName() + " " +
t.getLocalizedMessage(), t);
@@ -2198,7 +2221,7 @@
Set buddies = getChildrenNames(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN);
if (buddies != null)
{
- for (Iterator it = buddies.iterator(); it.hasNext(); )
+ for (Iterator it = buddies.iterator(); it.hasNext();)
{
Fqn base = new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, it.next());
list.add(new Fqn(base, fqn));
@@ -2207,7 +2230,7 @@
}
// Remove the subtree from the main tree and any buddy backup trees
- for (Iterator it = list.iterator(); it.hasNext(); )
+ for (Iterator it = list.iterator(); it.hasNext();)
{
Fqn subtree = (Fqn) it.next();
subtreeRoot = findNode(subtree);
@@ -2347,14 +2370,14 @@
// Confirm we're not active yet; if we are just invoke the method
switch (region.getStatus())
{
- case (Region.STATUS_ACTIVE):
+ case(Region.STATUS_ACTIVE):
if (log.isTraceEnabled())
log.trace("_enqueueMethodCall(): Invoking " + call.getName() +
" on subtree " + subtree);
call.invoke(this);
break;
- case (Region.STATUS_QUEUEING):
+ case(Region.STATUS_QUEUEING):
// Don't bother queueing a getState call
@@ -2545,7 +2568,7 @@
/**
* Returns any state stored in the cache that needs to be propagated
* along with the normal transient state in a subtree when
- * {@link #_getState(Fqn, long, boolean, boolean)} is called for an Fqn. Typically this would be state
+ * {@link #_getState(Fqn,long,boolean,boolean)} is called for an Fqn. Typically this would be state
* stored outside of the subtree that is somehow associated with the subtree.
* <p/>
* This method is designed for overriding by
@@ -2707,6 +2730,7 @@
/**
* Calls {@link #getReplicationVersionShort}.
+ *
* @deprecated
*/
public short getStateTransferVersion()
@@ -2718,6 +2742,7 @@
/**
* Calls {@link #setReplicationVersion} with the version string
* from {@link Version#getVersionString}.
+ *
* @deprecated
*/
public void setStateTransferVersion(short version)
@@ -3264,7 +3289,7 @@
}
/**
- * The same as calling {@link #get(Fqn, Object, boolean)} except apply options for this
+ * The same as calling {@link #get(Fqn,Object,boolean)} except apply options for this
* specific method invocation.
*/
public Object get(Fqn fqn, Object key, boolean sendNodeEvent, Option option) throws CacheException
@@ -3298,7 +3323,7 @@
}
/**
- * The same as calling {@link #remove(Fqn, Object)} except apply options for this
+ * The same as calling {@link #remove(Fqn,Object)} except apply options for this
* specific method invocation.
*/
public Object remove(Fqn fqn, Object key, Option option) throws CacheException
@@ -3333,7 +3358,7 @@
}
/**
- * The same as calling {@link #put(Fqn, Map)} except apply options for this
+ * The same as calling {@link #put(Fqn,Map)} except apply options for this
* specific method invocation.
*/
public void put(Fqn fqn, Map data, Option option) throws CacheException
@@ -3350,7 +3375,7 @@
}
/**
- * The same as calling {@link #put(Fqn, Object, Object)} except apply options for this
+ * The same as calling {@link #put(Fqn,Object,Object)} except apply options for this
* specific method invocation.
*/
public void put(Fqn fqn, Object key, Object value, Option option) throws CacheException
@@ -3485,9 +3510,9 @@
* Like <code>get()</code> method but without triggering a node visit event. This is used
* to prevent refresh of the cache data in the eviction policy.
*
- * @deprecated This will go away.
* @param fqn
* @param key
+ * @deprecated This will go away.
*/
public Object peek(Fqn fqn, Object key) throws CacheException
{
@@ -3497,6 +3522,7 @@
/**
* added so one can get nodes internally without triggering stuff
+ *
* @deprecated This will go away.
*/
public DataNode peek(Fqn fqn)
@@ -4167,9 +4193,19 @@
if (log.isTraceEnabled())
log.trace("callRemoteMethods(): valid members are " + validMembers + " method: " + method_call);
- // checkForNonSerializableArgs(method_call);
-
+ // this is a temporary workaround (JBCACHE-813) until AnyCast (JGRP-338) is available.
+ if (validMembers.size() == 1)
+ {
+ // use a UNICAST
+ Address recipient = (Address) validMembers.get(0);
+ Object r = disp.callRemoteMethod(recipient, method_call, mode, timeout);
+ rsps = new RspList();
+ rsps.addRsp(recipient, r);
+ }
+ else
+ {
rsps = disp.callRemoteMethods(validMembers, method_call, mode, timeout);
+ }
// a null response is 99% likely to be due to a marshalling problem - we throw a NSE, this needs to be changed when
// JGroups supports http://jira.jboss.com/jira/browse/JGRP-193
@@ -4864,7 +4900,7 @@
return null;
}
- log.warn("replication failure with method_call " +method_call + " exception: " +ex);
+ log.warn("replication failure with method_call " + method_call + " exception: " + ex);
throw ex;
}
finally
@@ -4928,11 +4964,11 @@
/**
* Used with buddy replication's data gravitation interceptor
+ *
* @param fqn the fqn to gravitate
* @param searchSubtrees should _BUDDY_BACKUP_ subtrees be searched
* @param marshal should the list of NodeData being gravitated be marshalled into
* a byte[] or returned as a List
- *
* @return <code>List</code> with 1 or 3 elements. First element is a
* <code>Boolean</code> indicating whether data was found. If
* <code>Boolean.FALSE</code>, the list will only have one element.
@@ -5082,7 +5118,7 @@
return callResults != null || exists(fqn);
case MethodDeclarations.existsMethod_id:
return ((Boolean) callResults).booleanValue();
- default :
+ default:
return false;
}
}
@@ -5098,7 +5134,7 @@
return new HashMap(0);
case MethodDeclarations.getChildrenNamesMethodLocal_id:
return new HashSet(0);
- default :
+ default:
return null;
}
}
@@ -5495,7 +5531,7 @@
catch (Throwable t)
{
if (t instanceof CacheException)
- throw (CacheException) t;
+ throw(CacheException) t;
throw new RuntimeException(t);
}
}
@@ -6260,7 +6296,7 @@
// create the multiplexer channel and return as a JChannel instance
Object[] params = {stackName, cluster_name};
- return (JChannel)mbserver.invoke(muxName, CREATE_MUX_CHANNEL, params, MUX_TYPES);
+ return (JChannel) mbserver.invoke(muxName, CREATE_MUX_CHANNEL, params, MUX_TYPES);
}
catch (Exception e)
{
@@ -6281,15 +6317,15 @@
return null;
// return 'jboss' server if available
- for (int i=0; i<servers.size(); i++)
+ for (int i = 0; i < servers.size(); i++)
{
- MBeanServer server = (MBeanServer)servers.get(i);
+ MBeanServer server = (MBeanServer) servers.get(i);
if (server.getDefaultDomain().equalsIgnoreCase(JBOSS_SERVER_DOMAIN))
return server;
}
// return first available server
- return (MBeanServer)servers.get(0);
+ return (MBeanServer) servers.get(0);
}
More information about the jboss-cvs-commits
mailing list