[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/loader ...
Manik Surtani
manik at jboss.org
Mon Jul 16 20:00:19 EDT 2007
User: msurtani
Date: 07/07/16 20:00:19
Modified: tests/functional/org/jboss/cache/loader
DummyInMemoryCacheLoader.java
Log:
Updated to add debugging
Revision Changes Path
1.10 +22 -5 JBossCache/tests/functional/org/jboss/cache/loader/DummyInMemoryCacheLoader.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: DummyInMemoryCacheLoader.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/loader/DummyInMemoryCacheLoader.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- DummyInMemoryCacheLoader.java 18 Jun 2007 21:42:20 -0000 1.9
+++ DummyInMemoryCacheLoader.java 17 Jul 2007 00:00:19 -0000 1.10
@@ -31,9 +31,11 @@
protected Map<Fqn, DummyNode> nodes = new ConcurrentHashMap<Fqn, DummyNode>();
protected Log log = LogFactory.getLog(DummyInMemoryCacheLoader.class);
protected Map<Object, List<Modification>> transactions = new ConcurrentHashMap<Object, List<Modification>>();
+ protected boolean debug; // whether to dump System.out messages as well as log messages or not
public void setConfig(IndividualCacheLoaderConfig config)
{
+ debug = Boolean.parseBoolean(config.getProperties().getProperty("debug", "false"));
}
public IndividualCacheLoaderConfig getConfig()
@@ -44,14 +46,17 @@
public Set getChildrenNames(Fqn fqn) throws Exception
{
if (log.isDebugEnabled()) log.debug("Calling getChildrenNames on Fqn " + fqn + ". Data map = " + nodes);
+ debugMessage("Calling getChildrenNames on Fqn " + fqn + ". Data map = " + nodes);
if (!nodes.containsKey(fqn))
{
log.debug("node not in loader");
+ debugMessage("node not in loader");
return null;
}
Set children = findChildren(fqn);
log.debug("Fqn " + fqn + " has children " + children);
+ debugMessage("Fqn " + fqn + " has children " + children);
// to keep in line with the CacheLoader interface contract for this method.
return children.size() == 0 ? null : children;
}
@@ -75,11 +80,13 @@
Map d = dn != null ? dn.data : null;
if (log.isDebugEnabled()) log.debug("Getting data for fqn " + name + " = " + d);
+ debugMessage("Getting data for fqn " + name + " = " + d);
return d;
}
public boolean exists(Fqn name) throws Exception
{
+ debugMessage("Performing exists() on " + name);
return nodes.containsKey(name);
}
@@ -95,6 +102,7 @@
// we need to make sure parents get put in as well.
recursivelyPutParentsIfNeeded(name);
if (log.isDebugEnabled()) log.debug("Did a put on " + name + ", data is " + n.data);
+ debugMessage("Did a put on " + name + ", data is " + n.data);
return old;
}
@@ -110,6 +118,7 @@
// we need to make sure parents get put in as well.
recursivelyPutParentsIfNeeded(name);
if (log.isDebugEnabled()) log.debug("Did a put on " + name + ", data is " + n.data);
+ debugMessage("Did a put on " + name + ", data is " + n.data);
}
private void recursivelyPutParentsIfNeeded(Fqn node)
@@ -125,6 +134,7 @@
public Object remove(Fqn fqn, Object key) throws Exception
{
log.debug("Removing data from " + fqn);
+ debugMessage("Removing data from " + fqn);
DummyNode n = nodes.get(fqn);
if (n == null) n = new DummyNode(fqn);
Object old = n.data.remove(key);
@@ -135,6 +145,7 @@
public void remove(Fqn fqn) throws Exception
{
log.debug("Removing fqn " + fqn);
+ debugMessage("Removing fqn " + fqn);
nodes.remove(fqn);
// remove children.
recursivelyRemoveChildren(fqn);
@@ -157,6 +168,7 @@
public void removeData(Fqn fqn) throws Exception
{
log.debug("Removing data from " + fqn);
+ debugMessage("Removing data from " + fqn);
DummyNode n = nodes.get(fqn);
if (n == null) n = new DummyNode(fqn);
n.data.clear();
@@ -234,4 +246,9 @@
"nodes=" + nodes +
'}';
}
+
+ protected void debugMessage(String msg)
+ {
+ if (debug) System.out.println(" DummyInMemoryCacheLoader debug: " + msg);
+ }
}
More information about the jboss-cvs-commits
mailing list