@Override public Void applyx() throws IgniteCheckedException { validTxState(true); // Lock file ID for this transaction. IgfsEntryInfo oldInfo = info(fileId); if (oldInfo == null) throw fsException(new IgfsPathNotFoundException("Failed to unlock file (file not " + "found): " + fileId)); if (!F.eq(lockId, oldInfo.lockId())) throw new IgniteCheckedException("Failed to unlock file (inconsistent file lock ID) " + "[fileId=" + fileId + ", lockId=" + lockId + ", actualLockId=" + oldInfo.lockId() + ']'); id2InfoPrj.invoke(fileId, new IgfsMetaFileUnlockProcessor(modificationTime, updateSpace, space, affRange)); return null; } });
assert entryInfo.isDirectory() || IgfsUtils.DELETE_LOCK_ID.equals(entryInfo.lockId());
assert IgfsUtils.DELETE_LOCK_ID.equals(lockedInfo.lockId());
/** * Constructs file output stream. * * @param igfsCtx IGFS context. * @param path Path to stored file. * @param fileInfo File info to write binary data to. * @param bufSize The size of the buffer to be used. * @param mode Grid IGFS mode. * @param batch Optional secondary file system batch. */ IgfsOutputStreamImpl(IgfsContext igfsCtx, IgfsPath path, IgfsEntryInfo fileInfo, int bufSize, IgfsMode mode, @Nullable IgfsFileWorkerBatch batch) { super(igfsCtx, path, bufSize, batch); assert fileInfo != null && fileInfo.isFile() : "Unexpected file info: " + fileInfo; assert mode != null && mode != PROXY && (mode == PRIMARY && batch == null || batch != null); // File hasn't been locked. if (fileInfo.lockId() == null) throw new IgfsException("Failed to acquire file lock (concurrently modified?): " + path); synchronized (mux) { this.fileInfo = fileInfo; this.mode = mode; streamRange = initialStreamRange(fileInfo); writeFut = igfsCtx.data().writeStart(fileInfo.id()); } }
return null; if (oldInfo.lockId() != null) return null; // The file is already locked, we cannot lock it.
if (info.lockId() != null) throw new IgfsException("File is already opened for write: " + path);
if (oldInfo.lockId() != null) throw new IgfsException("File is already opened for write: " + path);
@Override public Void applyx() throws IgniteCheckedException { validTxState(true); // Lock file ID for this transaction. IgfsEntryInfo oldInfo = info(fileId); if (oldInfo == null) throw fsException(new IgfsPathNotFoundException("Failed to unlock file (file not " + "found): " + fileId)); if (!F.eq(lockId, oldInfo.lockId())) throw new IgniteCheckedException("Failed to unlock file (inconsistent file lock ID) " + "[fileId=" + fileId + ", lockId=" + lockId + ", actualLockId=" + oldInfo.lockId() + ']'); id2InfoPrj.invoke(fileId, new IgfsMetaFileUnlockProcessor(modificationTime, updateSpace, space, affRange)); return null; } });
assert entryInfo.isDirectory() || IgfsUtils.DELETE_LOCK_ID.equals(entryInfo.lockId());
assert IgfsUtils.DELETE_LOCK_ID.equals(lockedInfo.lockId());
/** * Constructs file output stream. * * @param igfsCtx IGFS context. * @param path Path to stored file. * @param fileInfo File info to write binary data to. * @param bufSize The size of the buffer to be used. * @param mode Grid IGFS mode. * @param batch Optional secondary file system batch. */ IgfsOutputStreamImpl(IgfsContext igfsCtx, IgfsPath path, IgfsEntryInfo fileInfo, int bufSize, IgfsMode mode, @Nullable IgfsFileWorkerBatch batch) { super(igfsCtx, path, bufSize, batch); assert fileInfo != null && fileInfo.isFile() : "Unexpected file info: " + fileInfo; assert mode != null && mode != PROXY && (mode == PRIMARY && batch == null || batch != null); // File hasn't been locked. if (fileInfo.lockId() == null) throw new IgfsException("Failed to acquire file lock (concurrently modified?): " + path); synchronized (mux) { this.fileInfo = fileInfo; this.mode = mode; streamRange = initialStreamRange(fileInfo); writeFut = igfsCtx.data().writeStart(fileInfo.id()); } }
return null; if (oldInfo.lockId() != null) return null; // The file is already locked, we cannot lock it.