{
int parentLevel = parentFqn.size();
int targetLevel = parentLevel + 1;
Fqn fqn;
int size;
NodeData nd = nodeDataIterator.hasNext() ? nodeDataIterator.next() : null;
while (nd != null && !nd.isMarker())
{
fqn = nd.getFqn();
if (trace) log.trace("Integrating state for children: " + fqn);
// If we need to integrate into the buddy backup subtree,
// change the Fqn to fit under it
if (offset > 0)
{
fqn = Fqn.fromRelativeFqn(parentFqn.getAncestor(offset), fqn);
}
size = fqn.size();
if (size <= parentLevel)
{
return nd;
}
else if (size > targetLevel)
{
throw new IllegalStateException("NodeData " + fqn + " is not a direct child of " + parentFqn);
}
Map attrs = nd.getAttributes();
prepareContextOptions();
cache.clearData(fqn);
prepareContextOptions();
cache.put(fqn, attrs);
cache.getNode(fqn).setDataLoaded(false);
cache.getNode(fqn).setChildrenLoaded(false);
// Recursively call, which will walk down the tree
// and return the next NodeData that's a child of our parent
nd = integrateStateTransferChildren(fqn, offset, nodeDataIterator);
}
if (nd != null && nd.isExceptionMarker())
{
NodeDataExceptionMarker ndem = (NodeDataExceptionMarker) nd;
throw new CacheException("State provider node " + ndem.getCacheNodeIdentity()
+ " threw exception during loadState", ndem.getCause());
}