Search in sources :

Example 21 with AtomicMoveNotSupportedException

use of java.nio.file.AtomicMoveNotSupportedException in project atomix by atomix.

the class FileSnapshot method persistTemporaryFile.

private void persistTemporaryFile() throws IOException {
    final Path temporaryPath = file.temporaryFile().toPath();
    final Path persistedPath = file.file().toPath();
    try {
        Files.move(temporaryPath, persistedPath, StandardCopyOption.ATOMIC_MOVE);
    } catch (AtomicMoveNotSupportedException e) {
        try {
            Files.move(temporaryPath, persistedPath);
        } catch (FileAlreadyExistsException ignored) {
            LOGGER.debug("Snapshot {} was already previously completed", this);
        }
    }
}
Also used : Path(java.nio.file.Path) FileAlreadyExistsException(java.nio.file.FileAlreadyExistsException) AtomicMoveNotSupportedException(java.nio.file.AtomicMoveNotSupportedException)

Example 22 with AtomicMoveNotSupportedException

use of java.nio.file.AtomicMoveNotSupportedException in project graal by oracle.

the class IOHelper method move.

static void move(final Path source, final Path target, final FileSystem fileSystem, CopyOption... options) throws IOException {
    for (CopyOption option : options) {
        if (StandardCopyOption.ATOMIC_MOVE.equals(option)) {
            throw new AtomicMoveNotSupportedException(source.toString(), target.toString(), "Atomic move not supported");
        }
    }
    fileSystem.copy(source, target, options);
    fileSystem.delete(source);
}
Also used : StandardCopyOption(java.nio.file.StandardCopyOption) CopyOption(java.nio.file.CopyOption) AtomicMoveNotSupportedException(java.nio.file.AtomicMoveNotSupportedException)

Aggregations

AtomicMoveNotSupportedException (java.nio.file.AtomicMoveNotSupportedException)22 Path (java.nio.file.Path)12 IOException (java.io.IOException)9 DirectoryNotEmptyException (java.nio.file.DirectoryNotEmptyException)7 NoSuchFileException (java.nio.file.NoSuchFileException)7 FileAlreadyExistsException (java.nio.file.FileAlreadyExistsException)6 FileSystemException (java.nio.file.FileSystemException)5 AccessDeniedException (java.nio.file.AccessDeniedException)4 CopyOption (java.nio.file.CopyOption)4 FileSystemLoopException (java.nio.file.FileSystemLoopException)4 NotDirectoryException (java.nio.file.NotDirectoryException)4 StandardCopyOption (java.nio.file.StandardCopyOption)4 EOFException (java.io.EOFException)3 FileNotFoundException (java.io.FileNotFoundException)3 CorruptIndexException (org.apache.lucene.index.CorruptIndexException)3 IndexFormatTooNewException (org.apache.lucene.index.IndexFormatTooNewException)3 IndexFormatTooOldException (org.apache.lucene.index.IndexFormatTooOldException)3 AlreadyClosedException (org.apache.lucene.store.AlreadyClosedException)3 LockObtainFailedException (org.apache.lucene.store.LockObtainFailedException)3 ElasticsearchException (org.elasticsearch.ElasticsearchException)3