replaced special NullNode class with a generic Node object
built with a special constructor.
This commit is contained in:
parent
f9386a2286
commit
c3f4b73fe3
1 changed files with 11 additions and 8 deletions
|
@ -52,7 +52,7 @@ public final class NodeManager {
|
||||||
app.logEvent ("set up node cache ("+cacheSize+")");
|
app.logEvent ("set up node cache ("+cacheSize+")");
|
||||||
|
|
||||||
safe = new WrappedNodeManager (this);
|
safe = new WrappedNodeManager (this);
|
||||||
// nullNode = new Node ("nullNode", "nullNode", null, safe);
|
// nullNode = new Node ();
|
||||||
|
|
||||||
String replicationUrl = props.getProperty ("replicationUrl");
|
String replicationUrl = props.getProperty ("replicationUrl");
|
||||||
if (replicationUrl != null) {
|
if (replicationUrl != null) {
|
||||||
|
@ -184,7 +184,7 @@ public final class NodeManager {
|
||||||
if (node != null) {
|
if (node != null) {
|
||||||
synchronized (cache) {
|
synchronized (cache) {
|
||||||
Node oldnode = (Node) cache.put (node.getKey (), node);
|
Node oldnode = (Node) cache.put (node.getKey (), node);
|
||||||
if (oldnode != null && oldnode.getState () != Node.INVALID && !(oldnode instanceof NullNode)) {
|
if (oldnode != null && oldnode.getState () != Node.INVALID && !oldnode.isNullNode ()) {
|
||||||
cache.put (node.getKey (), oldnode);
|
cache.put (node.getKey (), oldnode);
|
||||||
node = oldnode;
|
node = oldnode;
|
||||||
}
|
}
|
||||||
|
@ -236,7 +236,7 @@ public final class NodeManager {
|
||||||
// we need further checks for subnodes fetched by name if the subnodes were changed.
|
// we need further checks for subnodes fetched by name if the subnodes were changed.
|
||||||
if (!rel.virtual && rel.subnodesAreProperties && node != null && node.getState() != Node.INVALID) {
|
if (!rel.virtual && rel.subnodesAreProperties && node != null && node.getState() != Node.INVALID) {
|
||||||
// check if node is null node (cached null)
|
// check if node is null node (cached null)
|
||||||
if (node instanceof NullNode) {
|
if (node.isNullNode ()) {
|
||||||
if (node.created() < rel.other.getLastDataChange ())
|
if (node.created() < rel.other.getLastDataChange ())
|
||||||
node = null; // cached null not valid anymore
|
node = null; // cached null not valid anymore
|
||||||
} else if (app.doesSubnodeChecking () && home.contains (node) < 0) {
|
} else if (app.doesSubnodeChecking () && home.contains (node) < 0) {
|
||||||
|
@ -258,7 +258,7 @@ public final class NodeManager {
|
||||||
// check if node is already in cache with primary key
|
// check if node is already in cache with primary key
|
||||||
Node oldnode = (Node) cache.put (primKey, node);
|
Node oldnode = (Node) cache.put (primKey, node);
|
||||||
// no need to check for oldnode != node because we fetched a new node from db
|
// no need to check for oldnode != node because we fetched a new node from db
|
||||||
if (oldnode != null && !(oldnode instanceof NullNode) && oldnode.getState () != Node.INVALID) {
|
if (oldnode != null && !oldnode.isNullNode() && oldnode.getState () != Node.INVALID) {
|
||||||
cache.put (primKey, oldnode);
|
cache.put (primKey, oldnode);
|
||||||
if (!keyIsPrimary) {
|
if (!keyIsPrimary) {
|
||||||
cache.put (key, oldnode);
|
cache.put (key, oldnode);
|
||||||
|
@ -272,12 +272,12 @@ public final class NodeManager {
|
||||||
} else {
|
} else {
|
||||||
// node fetched from db is null, cache result using nullNode
|
// node fetched from db is null, cache result using nullNode
|
||||||
synchronized (cache) {
|
synchronized (cache) {
|
||||||
Node oldnode = (Node) cache.put (key, new NullNode ());
|
Node oldnode = (Node) cache.put (key, new Node ());
|
||||||
// we ignore the case that onother thread has created the node in the meantime
|
// we ignore the case that onother thread has created the node in the meantime
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (node instanceof NullNode) {
|
} else if (node.isNullNode ()) {
|
||||||
// the nullNode caches a null value, i.e. an object that doesn't exist
|
// the nullNode caches a null value, i.e. an object that doesn't exist
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
|
@ -634,9 +634,12 @@ public final class NodeManager {
|
||||||
(Key) new SyntheticKey (k, kstr);
|
(Key) new SyntheticKey (k, kstr);
|
||||||
retval.add (new NodeHandle (key));
|
retval.add (new NodeHandle (key));
|
||||||
// if these are groupby nodes, evict nullNode keys
|
// if these are groupby nodes, evict nullNode keys
|
||||||
if (rel.groupby != null && cache.get (key) instanceof NullNode)
|
if (rel.groupby != null) {
|
||||||
|
Node n = (Node) cache.get (key);
|
||||||
|
if (n != null && n.isNullNode ())
|
||||||
evictKey (key);
|
evictKey (key);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
// tx.timer.endEvent ("getNodeIDs "+home);
|
// tx.timer.endEvent ("getNodeIDs "+home);
|
||||||
|
|
Loading…
Add table
Reference in a new issue