use of org.apache.ignite.internal.processors.igfs.meta.IgfsMetaUpdateTimesProcessor in project ignite by apache.
the class IgfsMetaManager method updateTimes.
/**
* Update times.
*
* @param path Path.
* @param accessTime Access time.
* @param modificationTime Modification time.
* @param secondaryFs Secondary file system.
* @throws IgniteCheckedException If failed.
*/
public void updateTimes(IgfsPath path, long modificationTime, long accessTime, IgfsSecondaryFileSystem secondaryFs) throws IgniteCheckedException {
while (true) {
if (busyLock.enterBusy()) {
try {
validTxState(false);
// Prepare path IDs.
IgfsPathIds pathIds = pathIds(path);
// Prepare lock IDs.
Set<IgniteUuid> lockIds = new TreeSet<>(PATH_ID_SORTING_COMPARATOR);
pathIds.addExistingIds(lockIds, relaxed);
// Start TX.
try (GridNearTxLocal tx = startTx()) {
Map<IgniteUuid, IgfsEntryInfo> lockInfos = lockIds(lockIds);
if (secondaryFs != null && isRetryForSecondary(pathIds, lockInfos))
continue;
if (!pathIds.verifyIntegrity(lockInfos, relaxed))
// Directory structure changed concurrently. So we re-try.
continue;
if (pathIds.allExists()) {
// All files are in place. Update both primary and secondary file systems.
if (secondaryFs != null)
secondaryFs.setTimes(path, modificationTime, accessTime);
IgniteUuid targetId = pathIds.lastExistingId();
IgfsEntryInfo targetInfo = lockInfos.get(targetId);
id2InfoPrj.invoke(targetId, new IgfsMetaUpdateTimesProcessor(accessTime == -1 ? targetInfo.accessTime() : accessTime, modificationTime == -1 ? targetInfo.modificationTime() : modificationTime));
tx.commit();
return;
} else {
// Propagate call to the secondary FS, as we might haven't cache this part yet.
if (secondaryFs != null) {
secondaryFs.setTimes(path, modificationTime, accessTime);
return;
} else
throw new IgfsPathNotFoundException("Failed to update times (path not found): " + path);
}
}
} catch (IgniteException | IgniteCheckedException e) {
throw e;
} catch (Exception e) {
throw new IgniteCheckedException("setTimes failed due to unexpected exception: " + path, e);
} finally {
busyLock.leaveBusy();
}
} else
throw new IllegalStateException("Failed to update times because Grid is stopping: " + path);
}
}
Aggregations