@Override public void createDirectory(AlluxioURI path, CreateDirectoryPOptions options) throws FileAlreadyExistsException, InvalidPathException, IOException, AlluxioException { checkUri(path); FileSystemMasterClient masterClient = mFsContext.acquireMasterClient(); try { masterClient.createDirectory(path, options); LOG.debug("Created directory {}, options: {}", path.getPath(), options); } catch (AlreadyExistsException e) { throw new FileAlreadyExistsException(e.getMessage()); } catch (InvalidArgumentException e) { throw new InvalidPathException(e.getMessage()); } catch (UnavailableException e) { throw e; } catch (AlluxioStatusException e) { throw e.toAlluxioException(); } finally { mFsContext.releaseMasterClient(masterClient); } }
@Test public void moveFileToExistingDestinationWithoutOverwrite() throws Exception { createFile("/src"); createFile("/dst"); // Test with source being a file. try { assignMovesFail("/src", "/dst"); } catch (FileAlreadyExistsException e) { Assert.assertEquals(ExceptionMessage.MOVE_NEED_OVERWRITE.getMessage("/dst"), e.getMessage()); } }
LOG.debug("Failed to load file metadata: {}", e.toString());
throw new FileAlreadyExistsException( ExceptionMessage.MOUNT_POINT_ALREADY_EXISTS.getMessage(alluxioPath));
@Test public void moveDirectoryToExistingDestinationWithoutOverwrite() throws Exception { // Test with the source being a folder. createDirectory("/src"); createDirectory("/dst"); try { assignMovesFail("/src", "/dst"); } catch (FileAlreadyExistsException e) { Assert.assertEquals(ExceptionMessage.MOVE_NEED_OVERWRITE.getMessage("/dst"), e.getMessage()); } }
private FileOutStream createFile(FileSystem fileSystem, AlluxioURI filePath, boolean deleteIfExists) throws IOException, AlluxioException { CreateFilePOptions options = CreateFilePOptions.newBuilder().setWriteType(mWriteType.toProto()) .setRecursive(true).build(); if (!fileSystem.exists(filePath)) { // file doesn't exist yet, so create it return fileSystem.createFile(filePath, options); } else if (deleteIfExists) { // file exists, so delete it and recreate fileSystem.delete(filePath); return fileSystem.createFile(filePath, options); } // file exists and deleteIfExists is false throw new FileAlreadyExistsException("File exists and deleteIfExists is false"); }
assertEquals( ExceptionMessage.FILE_ALREADY_EXISTS.getMessage(new AlluxioURI("alluxio:/a")), e.getMessage()); assertEquals( ExceptionMessage.FILE_ALREADY_EXISTS.getMessage(new AlluxioURI("alluxio:/a/f2")), e.getMessage());
throw new FileAlreadyExistsException( ExceptionMessage.MOVE_NEED_OVERWRITE.getMessage(destination));
assertTrue("createPath should throw FileAlreadyExistsException", false); } catch (FileAlreadyExistsException e) { assertEquals(e.getMessage(), ExceptionMessage.FILE_ALREADY_EXISTS.getMessage(NESTED_URI));
LOG.debug("Created file {}, options: {}", path.getPath(), options); } catch (AlreadyExistsException e) { throw new FileAlreadyExistsException(e.getMessage()); } catch (InvalidArgumentException e) { throw new InvalidPathException(e.getMessage());
} catch (FileAlreadyExistsException e) { assertEquals(ExceptionMessage.FILE_ALREADY_EXISTS.getMessage(NESTED_URI.getPath()), e.getMessage());
String errorMessage = ExceptionMessage.FILE_ALREADY_EXISTS.getMessage(path); LOG.error(errorMessage); throw new FileAlreadyExistsException(errorMessage); return new ArrayList<>(); } else { throw new FileAlreadyExistsException(path);
throw new FileAlreadyExistsException( ExceptionMessage.FILE_ALREADY_EXISTS.getMessage(dstInodePath.getUri()));
private void createStoreInternal(long fileId) throws FileAlreadyExistsException { if (mIncompleteStoreToPartitions.containsKey(fileId)) { // TODO(binfan): throw a better exception throw new FileAlreadyExistsException(String .format("Failed to createStore: KeyValueStore (fileId=%d) is already created", fileId)); } mIncompleteStoreToPartitions.put(fileId, new ArrayList<PartitionInfo>()); }
@Override public synchronized void renameStore(AlluxioURI oldUri, AlluxioURI newUri) throws IOException, AlluxioException { long oldFileId = getFileId(oldUri); checkIsCompletePartition(oldFileId, oldUri); try { mFileSystemMaster.rename(oldUri, newUri, RenameOptions.defaults()); } catch (FileAlreadyExistsException e) { throw new FileAlreadyExistsException( String.format("failed to rename store:the path %s has been used", newUri), e); } final long newFileId = mFileSystemMaster.getFileId(newUri); Preconditions.checkState(newFileId != IdUtils.INVALID_FILE_ID); try (JournalContext journalContext = createJournalContext()) { renameStoreInternal(oldFileId, newFileId); journalContext.append(newRenameStoreEntry(oldFileId, newFileId)); } }
private FileOutStream createFile(FileSystem fileSystem, AlluxioURI filePath, boolean deleteIfExists) throws IOException, AlluxioException { CreateFileOptions options = CreateFileOptions.defaults().setWriteType(mWriteType); if (!fileSystem.exists(filePath)) { // file doesn't exist yet, so create it return fileSystem.createFile(filePath, options); } else if (deleteIfExists) { // file exists, so delete it and recreate fileSystem.delete(filePath); return fileSystem.createFile(filePath, options); } // file exists and deleteIfExists is false throw new FileAlreadyExistsException("File exists and deleteIfExists is false"); }
throw new FileAlreadyExistsException( ExceptionMessage.MOUNT_POINT_ALREADY_EXISTS.getMessage(alluxioPath));
String errorMessage = ExceptionMessage.FILE_ALREADY_EXISTS.getMessage(path); LOG.error(errorMessage); throw new FileAlreadyExistsException(errorMessage); throw new FileAlreadyExistsException(path); String errorMessage = ExceptionMessage.FILE_ALREADY_EXISTS.getMessage(path); LOG.error(errorMessage); throw new FileAlreadyExistsException(errorMessage);