use of org.apache.ignite.internal.processors.igfs.meta.IgfsMetaFileReserveSpaceProcessor in project ignite by apache.
the class IgfsMetaManager method reserveSpace.
/**
* Reserve space for file.
*
* @param fileId File ID.
* @param space Space.
* @param affRange Affinity range.
* @return New file info.
*/
public IgfsEntryInfo reserveSpace(IgniteUuid fileId, long space, IgfsFileAffinityRange affRange) throws IgniteCheckedException {
validTxState(false);
if (busyLock.enterBusy()) {
try {
if (log.isDebugEnabled())
log.debug("Reserve file space: " + fileId);
try (GridNearTxLocal tx = startTx()) {
// Lock file ID for this transaction.
IgfsEntryInfo oldInfo = info(fileId);
if (oldInfo == null)
throw fsException("File has been deleted concurrently: " + fileId);
IgfsEntryInfo newInfo = invokeAndGet(fileId, new IgfsMetaFileReserveSpaceProcessor(space, affRange));
tx.commit();
return newInfo;
} catch (GridClosureException e) {
throw U.cast(e);
}
} finally {
busyLock.leaveBusy();
}
} else
throw new IllegalStateException("Failed to reserve file space because Grid is stopping:" + fileId);
}
Aggregations