private void lockNodes(GlobalTransaction gtx) throws Exception
{
TransactionWorkspace workspace = getTransactionWorkspace(gtx);
TransactionEntry te = cache.getTransactionTable().get(gtx);
log.debug("locking nodes");
// should be an ordered list
Collection nodes = workspace.getNodes().values();
for (Iterator it = nodes.iterator(); it.hasNext();)
{
WorkspaceNode workspaceNode = (WorkspaceNode) it.next();
DataNode node = workspaceNode.getNode();
boolean writeLock = workspaceNode.isDirty() || workspaceNode.isCreated() || workspaceNode.isDeleted() || (workspaceNode.isChildrenModified() && cache.getLockParentForChildInsertRemove());
boolean acquired = node.acquire(gtx, lockAcquisitionTimeout, writeLock ? DataNode.LOCK_TYPE_WRITE : DataNode.LOCK_TYPE_READ);
if (acquired)
{
if (log.isTraceEnabled()) log.trace("acquired lock on node " + node.getName());
te.addLock(node.getLock());
}
else
{
throw new CacheException("unable to acquire lock on node " + node.getName());
}