Search in sources :

Example 1 with IgfsMetaFileReserveSpaceProcessor

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);
}
Also used : GridClosureException(org.apache.ignite.internal.util.lang.GridClosureException) IgfsMetaFileReserveSpaceProcessor(org.apache.ignite.internal.processors.igfs.meta.IgfsMetaFileReserveSpaceProcessor) GridNearTxLocal(org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal)

Aggregations

GridNearTxLocal (org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal)1 IgfsMetaFileReserveSpaceProcessor (org.apache.ignite.internal.processors.igfs.meta.IgfsMetaFileReserveSpaceProcessor)1 GridClosureException (org.apache.ignite.internal.util.lang.GridClosureException)1