use of java.nio.file.AtomicMoveNotSupportedException in project elasticsearch by elastic.
the class ExceptionSerializationTests method testFileSystemExceptions.
public void testFileSystemExceptions() throws IOException {
for (FileSystemException ex : Arrays.asList(new FileSystemException("a", "b", "c"), new NoSuchFileException("a", "b", "c"), new NotDirectoryException("a"), new DirectoryNotEmptyException("a"), new AtomicMoveNotSupportedException("a", "b", "c"), new FileAlreadyExistsException("a", "b", "c"), new AccessDeniedException("a", "b", "c"), new FileSystemLoopException("a"))) {
FileSystemException serialize = serialize(ex);
assertEquals(serialize.getClass(), ex.getClass());
assertEquals("a", serialize.getFile());
if (serialize.getClass() == NotDirectoryException.class || serialize.getClass() == FileSystemLoopException.class || serialize.getClass() == DirectoryNotEmptyException.class) {
assertNull(serialize.getOtherFile());
assertNull(serialize.getReason());
} else {
assertEquals(serialize.getClass().toString(), "b", serialize.getOtherFile());
assertEquals(serialize.getClass().toString(), "c", serialize.getReason());
}
}
}
use of java.nio.file.AtomicMoveNotSupportedException in project buck by facebook.
the class Main method moveToTrash.
private static void moveToTrash(ProjectFilesystem filesystem, Console console, BuildId buildId, Path... pathsToMove) throws IOException {
Path trashPath = filesystem.getBuckPaths().getTrashDir().resolve(buildId.toString());
filesystem.mkdirs(trashPath);
for (Path pathToMove : pathsToMove) {
try {
// Technically this might throw AtomicMoveNotSupportedException,
// but we're moving a path within buck-out, so we don't expect this
// to throw.
//
// If it does throw, we'll complain loudly and synchronously delete
// the file instead.
filesystem.move(pathToMove, trashPath.resolve(pathToMove.getFileName()), StandardCopyOption.ATOMIC_MOVE);
} catch (NoSuchFileException e) {
LOG.verbose(e, "Ignoring missing path %s", pathToMove);
} catch (AtomicMoveNotSupportedException e) {
console.getStdErr().format("Atomic moves not supported, falling back to synchronous delete: %s", e);
MoreFiles.deleteRecursivelyIfExists(pathToMove);
}
}
}
use of java.nio.file.AtomicMoveNotSupportedException in project google-cloud-java by GoogleCloudPlatform.
the class CloudStorageFileSystemProvider method move.
@Override
public void move(Path source, Path target, CopyOption... options) throws IOException {
initStorage();
for (CopyOption option : options) {
if (option == StandardCopyOption.ATOMIC_MOVE) {
throw new AtomicMoveNotSupportedException(source.toString(), target.toString(), "Google Cloud Storage does not support atomic move operations.");
}
}
copy(source, target, options);
delete(source);
}
Aggregations