/** * Set lock on file info. * * @param info File info. * @return New file info with lock set. * @throws GridException In case lock is already set on that file. */ public GridGgfsFileInfo lockInfo(GridGgfsFileInfo info) throws GridException { if (busyLock.enterBusy()) { try { assert info != null; if (info.lockId() != null) throw new GridException("Failed to lock file (file is being concurrently written) [fileId=" + info.id() + ", lockId=" + info.lockId() + ']'); return new GridGgfsFileInfo(info, GridUuid.randomUuid(), info.modificationTime()); } finally { busyLock.leaveBusy(); } } else throw new IllegalStateException("Failed to get lock info because Grid is stopping: " + info); }
/** * Set lock on file info. * * @param info File info. * @return New file info with lock set. * @throws GridException In case lock is already set on that file. */ public GridGgfsFileInfo lockInfo(GridGgfsFileInfo info) throws GridException { if (busyLock.enterBusy()) { try { assert info != null; if (info.lockId() != null) throw new GridException("Failed to lock file (file is being concurrently written) [fileId=" + info.id() + ", lockId=" + info.lockId() + ']'); return new GridGgfsFileInfo(info, GridUuid.randomUuid(), info.modificationTime()); } finally { busyLock.leaveBusy(); } } else throw new IllegalStateException("Failed to get lock info because Grid is stopping: " + info); }
GridUuid lockId = info.lockId(); throw new GridGgfsFileNotFoundException("Failed to unlock file (file not found): " + fileId); if (!info.lockId().equals(oldInfo.lockId())) throw new GridException("Failed to unlock file (inconsistent file lock ID) [fileId=" + fileId + ", lockId=" + info.lockId() + ", actualLockId=" + oldInfo.lockId() + ']');
GridUuid lockId = info.lockId(); throw new GridGgfsFileNotFoundException("Failed to unlock file (file not found): " + fileId); if (!info.lockId().equals(oldInfo.lockId())) throw new GridException("Failed to unlock file (inconsistent file lock ID) [fileId=" + fileId + ", lockId=" + info.lockId() + ", actualLockId=" + oldInfo.lockId() + ']');
if (fileInfo.lockId() == null) throw new GridGgfsException("Failed to acquire file lock (concurrently modified?): " + path);
if (fileInfo.lockId() == null) throw new GridGgfsException("Failed to acquire file lock (concurrently modified?): " + path);