use of org.apache.ignite.internal.processors.igfs.client.IgfsClientRenameCallable in project ignite by apache.
the class IgfsImpl method rename.
/** {@inheritDoc} */
@Override
public void rename(final IgfsPath src, final IgfsPath dest) {
A.notNull(src, "src");
A.notNull(dest, "dest");
if (meta.isClient()) {
meta.runClientTask(new IgfsClientRenameCallable(cfg.getName(), IgfsUserContext.currentUser(), src, dest));
return;
}
safeOp(new Callable<Void>() {
@Override
public Void call() throws Exception {
if (log.isDebugEnabled())
log.debug("Rename file [src=" + src + ", dest=" + dest + ']');
IgfsMode mode = resolveMode(src);
if (src.equals(dest))
// Rename to itself is a no-op.
return null;
// Cannot rename root directory.
if (src.parent() == null)
throw new IgfsInvalidPathException("Root directory cannot be renamed.");
// Cannot move directory of upper level to self sub-dir.
if (dest.isSubDirectoryOf(src))
throw new IgfsInvalidPathException("Failed to rename directory (cannot move directory of " + "upper level to self sub-dir) [src=" + src + ", dest=" + dest + ']');
if (evictExclude(src, mode == PRIMARY) != evictExclude(dest, modeRslvr.resolveMode(dest) == PRIMARY))
throw new IgfsInvalidPathException("Cannot move file to a path with different eviction " + "exclude setting (need to copy and remove)");
switch(mode) {
case PRIMARY:
meta.move(src, dest);
break;
case DUAL_ASYNC:
case DUAL_SYNC:
await(src, dest);
meta.renameDual(secondaryFs, src, dest);
break;
default:
assert mode == PROXY : "Unknown mode: " + mode;
secondaryFs.rename(src, dest);
break;
}
return null;
}
});
}
Aggregations