private IN findINInTree(Tree tree, DatabaseImpl db, IN inClone, long lsn)
throws DatabaseException {
/* Check if inClone is the root. */
if (inClone.isDbRoot()) {
IN rootIN = isRoot(tree, db, inClone, lsn);
if (rootIN == null) {
/*
* inClone is a root, but no longer in use. Return now, because
* a call to tree.getParentNode will return something
* unexpected since it will try to find a parent.
*/
return null;
} else {
return rootIN;
}
}
/* It's not the root. Can we find it, and if so, is it current? */
inClone.latch(false);
SearchResult result = null;
try {
result = tree.getParentINForChildIN
(inClone,
true, // requireExactMatch
false, // updateGeneration
inClone.getLevel(),
null); // trackingList
if (!result.exactParentFound) {
return null;
}
int compareVal =
DbLsn.compareTo(result.parent.getLsn(result.index), lsn);
if (compareVal > 0) {
/* Log entry is obsolete. */
return null;
} else {
/*
* Log entry is same or newer than what's in the tree. Dirty
* the IN and let checkpoint write it out.
*/
IN in = (IN) result.parent.fetchTarget(result.index);
in.latch(false);
return in;
}
} finally {
if ((result != null) && (result.exactParentFound)) {
result.parent.releaseLatch();