Author: manik.surtani(a)jboss.com
Date: 2009-03-03 19:18:45 -0500 (Tue, 03 Mar 2009)
New Revision: 7833
Modified:
core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java
Log:
JBCACHE-1487
Modified: core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java 2009-03-03 17:07:33
UTC (rev 7832)
+++ core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java 2009-03-04 00:18:45
UTC (rev 7833)
@@ -72,11 +72,13 @@
private BuddyFqnTransformer buddyFqnTransformer;
private Configuration config;
private boolean usingMvcc;
+ private volatile boolean started = false;
private static final InternalNode[] NULL_ARRAY = {null, null};
@Inject
public void injectDependencies(NodeFactory nodeFactory, LockManager lockManager,
BuddyFqnTransformer transformer, Configuration configuration)
{
+ started = false;
setDependencies(nodeFactory, lockManager);
// We need to create a root node even at this stage since certain components rely
on this being available before
@@ -114,11 +116,13 @@
}
if (usingMvcc && rootInternal == null) setRoot(root); // sets the
"internal root"
+ started = true;
}
@Stop(priority = 100)
public void stop()
{
+ started = false;
// empty in-memory state
if (root != null)
{
@@ -435,8 +439,15 @@
@ManagedOperation(description = "Returns the number of nodes in the data
container")
public int getNumberOfNodes()
{
- if (!usingMvcc) return numNodes(root) - 1;
- return numNodesMvcc(rootInternal) - 1;
+ if (started)
+ {
+ if (!usingMvcc) return numNodes(root) - 1;
+ return numNodesMvcc(rootInternal) - 1;
+ }
+ else
+ {
+ return 0;
+ }
}
private int numNodesMvcc(InternalNode node)
@@ -447,7 +458,7 @@
Set<InternalNode> children = node.getChildren();
for (InternalNode child : children)
{
- count += numNodesMvcc((InternalNode) child);
+ count += numNodesMvcc(child);
}
}
return count;
Show replies by date