[jboss-cvs] JBossCache/src/org/jboss/cache ...
Manik Surtani
msurtani at jboss.com
Tue Aug 29 08:20:34 EDT 2006
User: msurtani
Date: 06/08/29 08:20:34
Modified: src/org/jboss/cache TreeCache.java
Log:
Fixed NPEs when running notifications
Revision Changes Path
1.230 +614 -416 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.229
retrieving revision 1.230
diff -u -b -r1.229 -r1.230
--- TreeCache.java 25 Aug 2006 14:10:09 -0000 1.229
+++ TreeCache.java 29 Aug 2006 12:20:34 -0000 1.230
@@ -20,29 +20,18 @@
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.CacheLoaderManager;
import org.jboss.cache.loader.NodeData;
-import org.jboss.cache.lock.IdentityLock;
-import org.jboss.cache.lock.IsolationLevel;
-import org.jboss.cache.lock.LockStrategyFactory;
-import org.jboss.cache.lock.LockUtil;
-import org.jboss.cache.lock.LockingException;
+import org.jboss.cache.lock.*;
import org.jboss.cache.lock.TimeoutException;
-import org.jboss.cache.marshall.MethodCallFactory;
-import org.jboss.cache.marshall.MethodDeclarations;
+import org.jboss.cache.marshall.*;
import org.jboss.cache.marshall.Region;
-import org.jboss.cache.marshall.RegionManager;
-import org.jboss.cache.marshall.RegionNameConflictException;
-import org.jboss.cache.marshall.RegionNotFoundException;
-import org.jboss.cache.marshall.TreeCacheMarshaller;
-import org.jboss.cache.marshall.VersionAwareMarshaller;
+import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.statetransfer.StateTransferManager;
import org.jboss.cache.util.MBeanConfigurator;
-import org.jboss.cache.notifications.Notifier;
import org.jboss.invocation.MarshalledValueOutputStream;
import org.jboss.system.ServiceMBeanSupport;
import org.jgroups.*;
import org.jgroups.blocks.GroupRequest;
-import org.jboss.cache.marshall.MethodCall;
import org.jgroups.blocks.RpcDispatcher;
import org.jgroups.stack.IpAddress;
import org.jgroups.util.Rsp;
@@ -57,11 +46,7 @@
import javax.transaction.SystemException;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.NotSerializableException;
-import java.io.OutputStream;
+import java.io.*;
import java.lang.reflect.Method;
import java.util.*;
@@ -75,7 +60,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.229 2006/08/25 14:10:09 msurtani Exp $
+ * @version $Id: TreeCache.java,v 1.230 2006/08/29 12:20:34 msurtani Exp $
* <p/>
* @see <a href="http://labs.jboss.com/portal/jbosscache/docs">JBossCache doc</a>
*/
@@ -96,7 +81,7 @@
/**
* A registry of regions that have been defined.
*/
- Map<Fqn,org.jboss.cache.Region> regionsRegistry = null;
+ Map<Fqn, org.jboss.cache.Region> regionsRegistry = null;
final static Object NULL = new Object();
@@ -227,7 +212,9 @@
*/
protected BuddyManager buddyManager;
- /** State transfer manager. Do not access this field directly -- use the getter */
+ /**
+ * State transfer manager. Do not access this field directly -- use the getter
+ */
private StateTransferManager stateTransferManager;
private Notifier notifier;
private CacheSPI rootSpi;
@@ -383,10 +370,14 @@
{
String retval = InterceptorChainFactory.printInterceptorChain(interceptor_chain);
if (retval == null || retval.length() == 0)
+ {
return "<empty>";
+ }
else
+ {
return retval;
}
+ }
/**
* Used for testing only - sets the interceptor chain.
@@ -525,13 +516,19 @@
public void fetchState(long timeout) throws ChannelClosedException, ChannelNotConnectedException
{
if (channel == null)
+ {
throw new ChannelNotConnectedException();
+ }
boolean rc = channel.getState(null, timeout);
if (rc)
+ {
log.debug("fetchState(): state was retrieved successfully");
+ }
else
+ {
log.debug("fetchState(): state could not be retrieved (first member)");
}
+ }
/* --------------------------- MBeanSupport ------------------------- */
@@ -568,10 +565,14 @@
try
{
if (tm_lookup != null)
+ {
tm = tm_lookup.getTransactionManager();
+ }
else
+ {
log.warn("No transaction manager lookup class has been defined. Transactions cannot be used");
}
+ }
catch (Exception e)
{
log.debug("failed looking up TransactionManager, will not use transactions", e);
@@ -593,8 +594,10 @@
{
MBeanServer mbserver = getMBeanServer();
if (mbserver != null)
+ {
MBeanConfigurator.registerInterceptors(mbserver, this, isStandalone);
}
+ }
switch (configuration.getCacheMode())
{
@@ -617,9 +620,12 @@
}
if (channel != null)
{ // mux channel
- if (log.isDebugEnabled()) log.debug("Created Multiplexer Channel for cache cluster " + configuration.getClusterName() +
+ if (log.isDebugEnabled())
+ {
+ log.debug("Created Multiplexer Channel for cache cluster " + configuration.getClusterName() +
" using stack " + configuration.getMultiplexerStack());
}
+ }
else
{
if (configuration.getClusterConfig() == null)
@@ -630,8 +636,10 @@
channel = new JChannel(configuration.getClusterConfig());
channel.setOpt(Channel.GET_STATE_EVENTS, Boolean.TRUE);
if (log.isTraceEnabled())
+ {
log.trace("cache properties: " + configuration.getClusterConfig());
}
+ }
channel.setOpt(Channel.AUTO_RECONNECT, Boolean.TRUE);
channel.setOpt(Channel.AUTO_GETSTATE, Boolean.TRUE);
@@ -675,7 +683,9 @@
// Get around the problem of standalone user forgets to call createService.
if (!useCreateService)
+ {
_createService();
+ }
// cache loaders should be initialised *before* any state transfers take place to prevent
// exceptions involving cache loaders not being started. - Manik
@@ -695,7 +705,9 @@
channel.connect(configuration.getClusterName());
if (log.isInfoEnabled())
+ {
log.info("TreeCache local address is " + channel.getLocalAddress());
+ }
if (shouldFetchStateOnStartup())
{
fetchStateOnStartup();
@@ -740,7 +752,8 @@
{
try
{
- MBeanConfigurator.unregisterInterceptors(mbserver, this, isStandalone); }
+ MBeanConfigurator.unregisterInterceptors(mbserver, this, isStandalone);
+ }
catch (Exception e)
{
log.error("failed unregistering cache interceptor mbeans ", e);
@@ -768,10 +781,14 @@
disp = null;
}
if (members != null && members.size() > 0)
+ {
members.clear();
+ }
if (repl_queue != null)
+ {
repl_queue.stop();
+ }
if (cacheLoaderManager != null)
{
@@ -790,10 +807,11 @@
/* ----------------------- End of MBeanSupport ----------------------- */
-
/* ----------------------- Start of buddy replication specific methods ------------*/
+
/**
* Sets the buddy replication configuration element
+ *
* @param config
*/
private void setBuddyReplicationConfig(Element config)
@@ -802,14 +820,19 @@
{
buddyManager = new BuddyManager(config);
if (!buddyManager.isEnabled())
+ {
buddyManager = null;
+ }
else
+ {
internalFqns.add(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN);
}
}
+ }
/**
* Retrieves the Buddy Manager configured.
+ *
* @return null if buddy replication is not enabled.
*/
public BuddyManager getBuddyManager()
@@ -870,10 +893,14 @@
protected boolean determineCoordinator()
{
if (channel == null)
+ {
return false;
+ }
Object local_addr = getLocalAddress();
if (local_addr == null)
+ {
return false;
+ }
View view = channel.getView();
if (view == null) return false;
ViewId vid = view.getVid();
@@ -914,7 +941,9 @@
throws RegionNameConflictException
{
if (!configuration.isUseRegionBasedMarshalling())
+ {
throw new IllegalStateException("useRegionBasedMarshalling is false; cannot use this method");
+ }
// Use the getter method here, as it will create the marshaller
// if this method is called before we do it in _createService()
@@ -931,7 +960,9 @@
public void unregisterClassLoader(String fqn) throws RegionNotFoundException
{
if (!configuration.isUseRegionBasedMarshalling())
+ {
throw new IllegalStateException("useRegionBasedMarshalling is false; cannot use this method");
+ }
// Use the getter method here, as it will create the marshaller
// if this method is called before we do it in _createService()
@@ -959,7 +990,9 @@
throws RegionNotEmptyException, RegionNameConflictException, CacheException
{
if (!configuration.isUseRegionBasedMarshalling())
+ {
throw new IllegalStateException("TreeCache.activateRegion(). useRegionBasedMarshalling flag is not set!");
+ }
Fqn fqn = Fqn.fromString(subtreeFqn);
@@ -972,7 +1005,9 @@
}
if (log.isDebugEnabled())
+ {
log.debug("activating " + fqn);
+ }
try
{
@@ -987,7 +1022,9 @@
// whose corresponding commit will thus fail after activation
Region region = regionManager_.getRegion(fqn);
if (region == null)
+ {
region = regionManager_.createRegion(fqn, null, true);
+ }
region.startQueuing();
@@ -1016,7 +1053,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);
@@ -1056,15 +1093,23 @@
// Throw the exception on, wrapping if necessary
if (t instanceof RegionNameConflictException)
+ {
throw (RegionNameConflictException) t;
+ }
else if (t instanceof RegionNotEmptyException)
+ {
throw (RegionNotEmptyException) t;
+ }
else if (t instanceof CacheException)
+ {
throw (CacheException) t;
+ }
else
+ {
throw new CacheException(t.getClass().getName() + " " +
t.getLocalizedMessage(), t);
}
+ }
finally
{
activationChangeNodes.remove(fqn);
@@ -1090,7 +1135,9 @@
if (node != null)
{
if (node.hasChildren())
+ {
empty = false;
+ }
else
{
Set keys = node.getDataKeys();
@@ -1142,7 +1189,9 @@
finally
{
if (log.isDebugEnabled())
+ {
log.debug("forcing release of locks in " + parent.getFqn());
+ }
try
{
parent.releaseForce();
@@ -1177,7 +1226,9 @@
public void inactivateRegion(String subtreeFqn) throws RegionNameConflictException, CacheException
{
if (!configuration.isUseRegionBasedMarshalling())
+ {
throw new IllegalStateException("TreeCache.inactivate(). useRegionBasedMarshalling flag is not set!");
+ }
Fqn fqn = Fqn.fromString(subtreeFqn);
DataNode parent = null;
@@ -1191,7 +1242,9 @@
boolean inactive = marshaller_.isInactive(subtreeFqn);
if (!inactive)
+ {
marshaller_.inactivate(subtreeFqn);
+ }
// Create a list with the Fqn in the main tree and any buddy backup trees
ArrayList list = new ArrayList();
@@ -1201,7 +1254,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));
@@ -1210,7 +1263,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);
@@ -1299,10 +1352,14 @@
{
if (!exists(subtree))
+ {
return; // node does not exist. Maybe it has been recursively removed.
+ }
if (log.isTraceEnabled())
+ {
log.trace("_evictSubtree(" + subtree + ")");
+ }
// Recursively remove any children
Set children = getChildrenNames(subtree);
@@ -1339,7 +1396,9 @@
MethodCall jbcCall = (MethodCall) call;
Region region = regionManager_.getRegion(subtree);
if (region == null)
+ {
throw new IllegalStateException("No region found for " + subtree);
+ }
List queue = region.getMethodCallQueue();
synchronized (queue)
@@ -1349,8 +1408,10 @@
{
case (Region.STATUS_ACTIVE):
if (log.isTraceEnabled())
+ {
log.trace("_enqueueMethodCall(): Invoking " + call.getName() +
" on subtree " + subtree);
+ }
call.invoke(this);
break;
@@ -1362,11 +1423,15 @@
{
MethodCall mc = (MethodCall) call.getArgs()[0];
if (mc.getMethodId() == MethodDeclarations.getPartialStateMethod_id)
+ {
return;
}
+ }
if (log.isTraceEnabled())
+ {
log.trace("_enqueueMethodCall(): Enqueuing " + call.getName() +
" " + call.getArgs() + " on subtree " + subtree);
+ }
queue.add(jbcCall);
break;
@@ -1404,13 +1469,17 @@
// TODO maybe just skip the commit/rollback?
// forgive = (gtxMap.remove(args[0]) == null);
if (gtxMap.remove(args[0]) == null)
+ {
continue;
+ }
break;
}
}
if (log.isTraceEnabled())
+ {
log.trace("processing queued method call " + call.getName());
+ }
try
{
@@ -1420,8 +1489,10 @@
{
if (!forgive)
+ {
throw e;
}
+ }
finally
{
// Clear any invocation context from this thread
@@ -1456,7 +1527,7 @@
public void _getState(OutputStream os, Fqn fqn, long timeout, boolean force, boolean suppressErrors) throws Throwable
{
- getStateTransferManager().getState(os,fqn, timeout, force, suppressErrors);
+ getStateTransferManager().getState(os, fqn, timeout, force, suppressErrors);
}
private void removeLocksForDeadMembers(DataNode node,
@@ -1488,9 +1559,11 @@
boolean broken = LockUtil.breakTransactionLock(lock, deadOwner, localTx, this);
if (broken && log.isTraceEnabled())
+ {
log.trace("Broke lock for node " + node.getFqn() +
" held by " + deadOwner);
}
+ }
// Recursively unlock children
if (node.hasChildren())
@@ -1543,7 +1616,9 @@
while (!isStateSet)
{
if (setStateException != null)
+ {
throw setStateException;
+ }
try
{
@@ -1555,7 +1630,10 @@
}
}
stop = System.currentTimeMillis();
- if (log.isDebugEnabled()) log.debug("state was retrieved successfully (in " + (stop - start) + " milliseconds)");
+ if (log.isDebugEnabled())
+ {
+ log.debug("state was retrieved successfully (in " + (stop - start) + " milliseconds)");
+ }
}
else
{
@@ -1813,11 +1891,15 @@
{
DataNode n = findNode(fqn);
if (n == null)
+ {
return null;
+ }
Set keys = n.getDataKeys();
// See http://jira.jboss.com/jira/browse/JBCACHE-551
if (keys == null)
+ {
return new HashSet(0);
+ }
return new HashSet(keys);
}
@@ -1849,8 +1931,10 @@
public Object _get(Fqn fqn, Object key, boolean sendNodeEvent) throws CacheException
{
if (log.isTraceEnabled())
+ {
log.trace(new StringBuffer("_get(").append("\"").append(fqn).append("\", ").append(key).append(", \"").
append(sendNodeEvent).append("\")"));
+ }
if (sendNodeEvent) notifier.notifyNodeVisited(fqn, true);
DataNode n = findNode(fqn);
if (n == null) return null;
@@ -1869,9 +1953,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
{
@@ -1881,6 +1965,7 @@
/**
* added so one can get nodes internally without triggering stuff
+ *
* @deprecated This will go away.
*/
public DataNode peek(Fqn fqn)
@@ -1933,8 +2018,10 @@
Object obj = fqn.get(i);
n = n.getChild(obj);
if (n == null)
+ {
return null;
}
+ }
return (DataNode) n;
}
@@ -1961,10 +2048,14 @@
{
DataNode n = findInternal(fqn);
if (n == null)
+ {
return false;
+ }
else
+ {
return n.containsKey(key);
}
+ }
/**
@@ -2187,8 +2278,13 @@
retval = e;
}
if (retval != null)
+ {
return retval.toString();
- else return "";
+ }
+ else
+ {
+ return "";
+ }
}
@@ -2232,8 +2328,10 @@
return new HashSet(m.keySet());
}
else
+ {
return null;
}
+ }
public boolean hasChild(Fqn fqn)
@@ -2247,8 +2345,10 @@
obj = fqn.get(i);
n = n.getChild(obj);
if (n == null)
+ {
return false;
}
+ }
return n.hasChildren();
}
@@ -2288,8 +2388,10 @@
}
}
else
+ {
sb.append(Fqn.SEPARATOR);
}
+ }
return sb.toString();
}
@@ -2316,7 +2418,9 @@
}
}
else
+ {
sb.append(Fqn.SEPARATOR);
+ }
return sb.toString();
}
@@ -2340,7 +2444,9 @@
}
}
else
+ {
sb.append(Fqn.SEPARATOR);
+ }
return sb.toString();
}
@@ -2357,7 +2463,9 @@
int num = 0;
Map children;
if (n.isLocked())
+ {
num++;
+ }
if ((children = n.getChildren()) != null)
{
for (Iterator it = children.values().iterator(); it.hasNext();)
@@ -2382,7 +2490,9 @@
private int numNodes(DataNode n)
{
if (n == null)
+ {
return 0;
+ }
int count = 1; // for n
if (n.hasChildren())
{
@@ -2427,7 +2537,9 @@
private int numAttributes(DataNode n)
{
if (n == null)
+ {
return 0;
+ }
int count = n.numAttributes();
if (n.hasChildren())
{
@@ -2487,24 +2599,32 @@
Vector validMembers;
if (disp == null)
+ {
return null;
+ }
validMembers = mbrs != null ? new Vector(mbrs) : new Vector(this.members);
if (exclude_self && validMembers.size() > 0)
{
Object local_addr = getLocalAddress();
if (local_addr != null)
+ {
validMembers.remove(local_addr);
}
+ }
if (validMembers.size() == 0)
{
if (log.isTraceEnabled())
+ {
log.trace("destination list is empty, discarding call");
+ }
return null;
}
if (log.isTraceEnabled())
+ {
log.trace("callRemoteMethods(): valid members are " + validMembers + " methods: " + method_call.getArgs()[0]);
+ }
// checkForNonSerializableArgs(method_call);
@@ -2519,10 +2639,14 @@
}
if (mode == GroupRequest.GET_NONE)
+ {
return new ArrayList(); // async case
+ }
if (log.isTraceEnabled())
+ {
log.trace("(" + getLocalAddress() + "): responses for method " + method_call.getName() + ":\n" + rsps);
+ }
retval = new ArrayList(rsps.size());
for (int i = 0; i < rsps.size(); i++)
@@ -2542,8 +2666,10 @@
retval.add(new ReplicationException("rsp=" + rsp, ex));
}
else
+ {
retval.add(rsp.getValue());
}
+ }
return retval;
}
@@ -2675,11 +2801,13 @@
{
String errStr = "node " + fqn + " not found (gtx=" + tx + ", caller=" + Thread.currentThread() + ")";
if (log.isTraceEnabled())
+ {
log.trace(errStr);
+ }
throw new NodeNotExistsException(errStr);
}
Map oldData = n.getData();
- notifier.notifyNodeModified(fqn, true, oldData == null ? null : Collections.unmodifiableMap(n.getData()));
+ notifier.notifyNodeModified(fqn, true, oldData == null ? Collections.emptyMap() : Collections.unmodifiableMap(n.getData()));
// TODO: move creation of undo-operations to separate Interceptor
// create a compensating method call (reverting the effect of
@@ -2710,7 +2838,7 @@
tx_table.addUndoOperation(tx, undo_op);
}
- notifier.notifyNodeModified(fqn, false, Collections.unmodifiableMap(n.getData()));
+ notifier.notifyNodeModified(fqn, false, n.getData() == null ? Collections.emptyMap() : Collections.unmodifiableMap(n.getData()));
}
/**
@@ -2748,11 +2876,13 @@
{
String errStr = "node " + fqn + " not found (gtx=" + tx + ", caller=" + Thread.currentThread() + ")";
if (log.isTraceEnabled())
+ {
log.trace(errStr);
+ }
throw new NodeNotExistsException(errStr);
}
- notifier.notifyNodeModified(fqn, true, Collections.unmodifiableMap(n.getData()));
+ notifier.notifyNodeModified(fqn, true, n.getData() == null ? Collections.emptyMap() : Collections.unmodifiableMap(n.getData()));
old_value = n.put(key, value);
// create a compensating method call (reverting the effect of
@@ -2774,7 +2904,7 @@
tx_table.addUndoOperation(tx, undo_op);
}
- notifier.notifyNodeModified(fqn, false, Collections.unmodifiableMap(n.getData()));
+ notifier.notifyNodeModified(fqn, false, n.getData() == null ? Collections.emptyMap() : Collections.unmodifiableMap(n.getData()));
return old_value;
}
@@ -2836,7 +2966,9 @@
MethodCall undo_op = null;
if (log.isTraceEnabled())
+ {
log.trace(new StringBuffer("_remove(").append(tx).append(", \"").append(fqn).append("\")"));
+ }
if (fqn.size() == 0)
{
@@ -2867,21 +2999,29 @@
if (n == null)
{
if (log.isTraceEnabled())
+ {
log.trace("node " + fqn + " not found");
+ }
return;
}
if (eviction)
+ {
notifier.notifyNodeEvicted(fqn, true);
+ }
else
+ {
notifier.notifyNodeRemoved(fqn, true, n.getData() == null ? Collections.emptyMap() : Collections.unmodifiableMap(n.getData()));
+ }
parent_node = n.getParent();
// remove subtree from parent
parent_node.removeChild(n.getName());
if (eviction)
+ {
parent_node.setChildrenLoaded(false);
+ }
// release all locks for the entire subtree
n.releaseAll(tx != null ? tx : (Object) Thread.currentThread());
@@ -2897,10 +3037,14 @@
}
if (eviction)
+ {
notifier.notifyNodeEvicted(fqn, false);
+ }
else
+ {
notifier.notifyNodeRemoved(fqn, false, null);
}
+ }
/**
* Internal method to remove a key.
@@ -2930,7 +3074,9 @@
Object old_value = null;
if (log.isTraceEnabled())
+ {
log.trace(new StringBuffer("_remove(").append(tx).append(", \"").append(fqn).append("\", ").append(key).append(")"));
+ }
// Find the node. This will lock it (if <tt>locking</tt> is true) and
// add the temporarily created parent nodes to the TX's node list if tx != null)
@@ -2941,7 +3087,7 @@
return null;
}
- notifier.notifyNodeModified(fqn, true, Collections.unmodifiableMap(n.getData()));
+ notifier.notifyNodeModified(fqn, true, n.getData() == null ? Collections.emptyMap() : Collections.unmodifiableMap(n.getData()));
old_value = n.remove(key);
@@ -2956,7 +3102,7 @@
tx_table.addUndoOperation(tx, undo_op);
}
- notifier.notifyNodeModified(fqn, false, Collections.unmodifiableMap(n.getData()));
+ notifier.notifyNodeModified(fqn, false, n.getData() == null ? Collections.emptyMap() : Collections.unmodifiableMap(n.getData()));
return old_value;
}
@@ -3007,7 +3153,9 @@
Map old_data = null;
if (log.isTraceEnabled())
+ {
log.trace(new StringBuffer("_removeData(").append(tx).append(", \"").append(fqn).append("\")"));
+ }
// Find the node. This will lock it (if <tt>locking</tt> is true) and
// add the temporarily created parent nodes to the TX's node list if tx != null)
@@ -3026,13 +3174,19 @@
}
if (eviction)
+ {
notifier.notifyNodeEvicted(fqn, true);
+ }
else
- notifier.notifyNodeModified(fqn, true, Collections.unmodifiableMap(n.getData()));
+ {
+ notifier.notifyNodeModified(fqn, true, n.getData() == null ? Collections.emptyMap() : Collections.unmodifiableMap(n.getData()));
+ }
n.clear();
if (eviction)
+ {
n.put(UNINITIALIZED, null); // required by cache loader to subsequently load the element again
+ }
if (sendNodeEvent)
{
@@ -3046,7 +3200,7 @@
}
else
{
- notifier.notifyNodeModified(fqn, false, Collections.unmodifiableMap(n.getData()));
+ notifier.notifyNodeModified(fqn, false, n.getData() == null ? Collections.emptyMap() : Collections.unmodifiableMap(n.getData()));
}
}
@@ -3072,7 +3226,9 @@
boolean sendNodeEvent = false;
boolean eviction = true;
if (log.isTraceEnabled())
+ {
log.trace("_evict(" + fqn + ")");
+ }
if (hasChild(fqn))
{
_removeData(null, fqn, create_undo_ops, sendNodeEvent, eviction);
@@ -3098,7 +3254,9 @@
boolean sendNodeEvent = false;
boolean eviction = true;
if (log.isTraceEnabled())
+ {
log.trace("_evict(" + fqn + ", " + version + ")");
+ }
if (hasChild(fqn))
{
_removeData(null, fqn, create_undo_ops, sendNodeEvent, eviction, version);
@@ -3131,8 +3289,10 @@
throws CacheException
{
if (log.isTraceEnabled())
+ {
log.trace(new StringBuffer("_addChild(").append("\"").append(parent_fqn).
append("\", \"").append(child_name).append("\")"));
+ }
if (parent_fqn == null || child_name == null || childNode == null)
{
@@ -3168,7 +3328,7 @@
}
catch (Exception ex)
{
- 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
@@ -3232,11 +3392,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.
@@ -3548,10 +3708,10 @@
}
/*
- * vladimir 24/08/06 Will change to ExtendedMessageListener
- * after JGroups 2.4 CR2 is released
- *
- * -------------------- MessageListener ----------------------*/
+* vladimir 24/08/06 Will change to ExtendedMessageListener
+* after JGroups 2.4 CR2 is released
+*
+* -------------------- MessageListener ----------------------*/
class MessageListenerAdaptor implements MessageListener
{
@@ -3570,8 +3730,10 @@
public void receive(Message msg)
{
if (trace)
+ {
my_log.trace("Received message " + msg);
}
+ }
/**
* Returns a copy of the current cache (tree). It actually returns a 2
@@ -3610,9 +3772,13 @@
{
if (new_state == null)
+ {
my_log.debug("transferred state is null (may be first member in cluster)");
+ }
else
+ {
getStateTransferManager().setState(new_state, Fqn.ROOT, null);
+ }
isStateSet = true;
}
@@ -3620,10 +3786,14 @@
{
my_log.error("failed setting state", t);
if (t instanceof Exception)
+ {
setStateException = (Exception) t;
+ }
else
+ {
setStateException = new Exception(t);
}
+ }
finally
{
synchronized (stateLock)
@@ -3644,7 +3814,7 @@
{
try
{
- _getState(ostream,Fqn.ROOT, configuration.getInitialStateRetrievalTimeout(), true, true);
+ _getState(ostream, Fqn.ROOT, configuration.getInitialStateRetrievalTimeout(), true, true);
}
catch (Throwable t)
{
@@ -3668,9 +3838,13 @@
{
if (istream == null)
+ {
my_log.debug("stream is null (may be first member in cluster)");
+ }
else
+ {
getStateTransferManager().setState(istream, Fqn.ROOT, null);
+ }
isStateSet = true;
}
@@ -3678,10 +3852,14 @@
{
my_log.error("failed setting state", t);
if (t instanceof Exception)
+ {
setStateException = (Exception) t;
+ }
else
+ {
setStateException = new Exception(t);
}
+ }
finally
{
synchronized (stateLock)
@@ -3882,8 +4060,10 @@
ent.setTransaction(tx);
tx_table.put(gtx, ent);
if (log.isTraceEnabled())
+ {
log.trace("created new GTX: " + gtx + ", local TX=" + tx);
}
+ }
return gtx;
}
@@ -3902,7 +4082,9 @@
catch (Throwable t)
{
if (t instanceof CacheException)
+ {
throw (CacheException) t;
+ }
throw new RuntimeException(t);
}
}
@@ -3915,7 +4097,9 @@
{
Object owner = getCurrentTransaction();
if (owner == null)
+ {
owner = Thread.currentThread();
+ }
return owner;
}
@@ -3934,7 +4118,9 @@
{
ClassLoader cl = getClass().getClassLoader();
if (cl == null)
+ {
cl = ClassLoader.getSystemClassLoader();
+ }
return cl.loadClass(classname);
}
@@ -4002,7 +4188,9 @@
// we need to check the version of the data node...
DataVersion nodeVersion = ((OptimisticTreeNode) toReturn).getVersion();
if (log.isDebugEnabled())
+ {
log.debug("looking for optimistic node [" + fqn + "] with version [" + version + "]. My version is [" + nodeVersion + "]");
+ }
if (nodeVersion.newerThan(version))
{
// we have a versioning problem; throw an exception!
@@ -4019,7 +4207,9 @@
public RegionManager getRegionManager()
{
if (regionManager_ == null)
+ {
regionManager_ = new RegionManager();
+ }
return regionManager_;
}
@@ -4124,7 +4314,9 @@
private JChannel getMultiplexerChannel(String serviceName, String stackName)
{
if (serviceName == null || serviceName.length() == 0)
+ {
return null;
+ }
MBeanServer mbserver = getMBeanServer();
if (mbserver == null)
@@ -4168,7 +4360,7 @@
// create the multiplexer channel and return as a JChannel instance
Object[] params = {stackName, configuration.getClusterName()};
- 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)
{
@@ -4182,22 +4374,28 @@
{
// return local server from ServiceMBeanSupport if available
if (server != null)
+ {
return server;
+ }
ArrayList servers = MBeanServerFactory.findMBeanServer(null);
if (servers == null || servers.size() == 0)
+ {
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