/** * Get file descriptor for specified path. * * @param path Path to file. * @return Detailed file descriptor or {@code null}, if file does not exist. * @throws GridException If failed. */ @Nullable private FileDescriptor getFileDescriptor(GridGgfsPath path) throws GridException { List<GridUuid> ids = meta.fileIds(path); GridGgfsFileInfo fileInfo = meta.info(ids.get(ids.size() - 1)); if (fileInfo == null) return null; // File does not exist. // Resolve parent ID for removed file. GridUuid parentId = ids.size() >= 2 ? ids.get(ids.size() - 2) : null; return new FileDescriptor(parentId, path.name(), fileInfo.id(), fileInfo.isFile()); }
@Override public GridGgfsFileInfo onSuccess(Map<GridGgfsPath, GridGgfsFileInfo> infos) throws Exception { if (infos.get(path) == null) return null; fs.update(path, props); assert path.parent() == null || infos.get(path.parent()) != null; return updatePropertiesNonTx(infos.get(path.parent()).id(), infos.get(path).id(), path.name(), props); }
/** * Get file descriptor for specified path. * * @param path Path to file. * @return Detailed file descriptor or {@code null}, if file does not exist. * @throws GridException If failed. */ @Nullable private FileDescriptor getFileDescriptor(GridGgfsPath path) throws GridException { List<GridUuid> ids = meta.fileIds(path); GridGgfsFileInfo fileInfo = meta.info(ids.get(ids.size() - 1)); if (fileInfo == null) return null; // File does not exist. // Resolve parent ID for removed file. GridUuid parentId = ids.size() >= 2 ? ids.get(ids.size() - 2) : null; return new FileDescriptor(parentId, path.name(), fileInfo.id(), fileInfo.isFile()); }
@Override public GridGgfsFileInfo onSuccess(Map<GridGgfsPath, GridGgfsFileInfo> infos) throws Exception { if (infos.get(path) == null) return null; fs.update(path, props); assert path.parent() == null || infos.get(path.parent()) != null; return updatePropertiesNonTx(infos.get(path.parent()).id(), infos.get(path).id(), path.name(), props); }
@Override public Boolean onSuccess(Map<GridGgfsPath, GridGgfsFileInfo> infos) throws Exception { GridGgfsFileInfo info = infos.get(path); if (info == null) return false; // File doesn't exist in the secondary file system. if (!fs.delete(path, recursive)) return false; // Delete failed remotely. if (path.parent() != null) { assert infos.containsKey(path.parent()); softDeleteNonTx(infos.get(path.parent()).id(), path.name(), info.id()); } else { assert ROOT_ID.equals(info.id()); softDeleteNonTx(null, path.name(), info.id()); } // Update the deleted file info with path information for delete worker. id2InfoPrj.transform(info.id(), new UpdatePath(path)); return true; // No additional handling is required. }
@Override public Boolean onSuccess(Map<GridGgfsPath, GridGgfsFileInfo> infos) throws Exception { GridGgfsFileInfo info = infos.get(path); if (info == null) return false; // File doesn't exist in the secondary file system. if (!fs.delete(path, recursive)) return false; // Delete failed remotely. if (path.parent() != null) { assert infos.containsKey(path.parent()); softDeleteNonTx(infos.get(path.parent()).id(), path.name(), info.id()); } else { assert ROOT_ID.equals(info.id()); softDeleteNonTx(null, path.name(), info.id()); } // Update the deleted file info with path information for delete worker. id2InfoPrj.transform(info.id(), new UpdatePath(path)); return true; // No additional handling is required. }
moveNonTx(srcInfo.id(), src.name(), srcParentInfo.id(), dest.name(), destParentInfo.id()); "because destination path already exists and it is a file: " + dest); else moveNonTx(srcInfo.id(), src.name(), srcParentInfo.id(), src.name(), destInfo.id()); pendingEvts.add(new GridGgfsEvent( src, destInfo == null ? dest : new GridGgfsPath(dest, src.name()), locNode, EVT_GGFS_FILE_RENAMED));
moveNonTx(srcInfo.id(), src.name(), srcParentInfo.id(), dest.name(), destParentInfo.id()); "because destination path already exists and it is a file: " + dest); else moveNonTx(srcInfo.id(), src.name(), srcParentInfo.id(), src.name(), destInfo.id()); pendingEvts.add(new GridGgfsEvent( src, destInfo == null ? dest : new GridGgfsPath(dest, src.name()), locNode, EVT_GGFS_FILE_RENAMED));
files.add(child.name());
files.add(child.name());
GridGgfsFileInfo info = meta.updateProperties(parentId, fileId, path.name(), props);
fileName = path.name();
fileName = path.name();
GridGgfsFileInfo info = meta.updateProperties(parentId, fileId, path.name(), props);
mode == PRIMARY), props); GridUuid oldId = meta.putIfAbsent(parentId, path.name(), info);
mode == PRIMARY), props); GridUuid oldId = meta.putIfAbsent(parentId, path.name(), info);
throw new GridGgfsInvalidPathException("Failed to resolve parent directory: " + path); String fileName = path.name();