public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder() {
/** * <code>optional .alluxio.grpc.file.FreePOptions options = 2;</code> */ public Builder mergeOptions(alluxio.grpc.FreePOptions value) { if (optionsBuilder_ == null) { if (((bitField0_ & 0x00000002) == 0x00000002) && options_ != null && options_ != alluxio.grpc.FreePOptions.getDefaultInstance()) { options_ = alluxio.grpc.FreePOptions.newBuilder(options_).mergeFrom(value).buildPartial(); } else { options_ = value; } onChanged(); } else { optionsBuilder_.mergeFrom(value); } bitField0_ |= 0x00000002; return this; } /**
.getMs(PropertyKey.WORKER_BLOCK_HEARTBEAT_INTERVAL_MS)); FreePOptions options = FreePOptions.newBuilder().setRecursive(true).setForced(cl.hasOption("f")).build(); mFileSystem.free(path, options); try {
/** * @return Master side defaults for {@link FreePOptions} */ public static FreePOptions freeDefaults() { return FreePOptions.newBuilder() .setCommonOptions(commonDefaults()) .setForced(false) .setRecursive(false) .build(); }
/** * Tests for the {@link BaseFileSystem#free(AlluxioURI, FreePOptions)} method. */ @Test public void free() throws Exception { AlluxioURI file = new AlluxioURI("/file"); FreePOptions freeOptions = FreePOptions.newBuilder().setRecursive(true).build(); mFileSystem.free(file, freeOptions); verify(mFileSystemMasterClient).free(file, freeOptions); verifyFilesystemContextAcquiredAndReleased(); }
.defaults(FreePOptions.newBuilder().setForced(true).setRecursive(true))); } else { mFileSystemMaster.free(path, FreeContext.defaults(FreePOptions.newBuilder().setForced(true)));
/** * Ensures that an exception is propagated correctly when freeing a file. */ @Test public void freeException() throws Exception { AlluxioURI file = new AlluxioURI("/file"); FreePOptions freeOptions = FreePOptions.newBuilder().setRecursive(true).build(); doThrow(EXCEPTION).when(mFileSystemMasterClient).free(file, freeOptions); try { mFileSystem.free(file, freeOptions); fail(SHOULD_HAVE_PROPAGATED_MESSAGE); } catch (Exception e) { assertSame(EXCEPTION, e); } verifyFilesystemContextAcquiredAndReleased(); }
/** * Tests the {@link FileSystemMaster#free} method with a directory. */ @Test public void freeDir() throws Exception { mNestedFileContext.setPersisted(true); long blockId = createFileWithSingleBlock(NESTED_FILE_URI); assertEquals(1, mBlockMaster.getBlockInfo(blockId).getLocations().size()); // free the dir mFileSystemMaster.free(NESTED_FILE_URI.getParent(), FreeContext.defaults(FreePOptions.newBuilder().setForced(true).setRecursive(true))); // Update the heartbeat of removedBlockId received from worker 1. Command heartbeat3 = mBlockMaster.workerHeartbeat(mWorkerId1, null, ImmutableMap.of("MEM", (long) Constants.KB), ImmutableList.of(blockId), ImmutableMap.<String, List<Long>>of(), mMetrics); // Verify the muted Free command on worker1. assertEquals(Command.newBuilder().setCommandType(CommandType.Nothing).build(), heartbeat3); assertEquals(0, mBlockMaster.getBlockInfo(blockId).getLocations().size()); }
/** * Tests {@link FileSystemMaster#free} on persisted file. */ @Test public void free() throws Exception { mNestedFileContext.setPersisted(true); long blockId = createFileWithSingleBlock(NESTED_FILE_URI); assertEquals(1, mBlockMaster.getBlockInfo(blockId).getLocations().size()); // free the file mFileSystemMaster.free(NESTED_FILE_URI, FreeContext.defaults(FreePOptions.newBuilder() .setForced(false).setRecursive(false))); // Update the heartbeat of removedBlockId received from worker 1. Command heartbeat2 = mBlockMaster.workerHeartbeat(mWorkerId1, null, ImmutableMap.of("MEM", (long) Constants.KB), ImmutableList.of(blockId), ImmutableMap.<String, List<Long>>of(), mMetrics); // Verify the muted Free command on worker1. assertEquals(Command.newBuilder().setCommandType(CommandType.Nothing).build(), heartbeat2); assertEquals(0, mBlockMaster.getBlockInfo(blockId).getLocations().size()); }
private void verifyFree(TestUser user, String path, boolean recursive) throws Exception { try (Closeable r = new AuthenticatedUserRule(user.getUser(), ServerConfiguration.global()).toResource()) { mFileSystemMaster.free(new AlluxioURI(path), FreeContext.defaults(FreePOptions.newBuilder().setRecursive(recursive))); } }
/** * Tests {@link FileSystemMaster#free} on pinned file when forced flag is true. */ @Test public void freePinnedFileWithForce() throws Exception { mNestedFileContext.setPersisted(true); long blockId = createFileWithSingleBlock(NESTED_FILE_URI); mFileSystemMaster.setAttribute(NESTED_FILE_URI, SetAttributeContext.defaults(SetAttributePOptions.newBuilder().setPinned(true))); assertEquals(1, mBlockMaster.getBlockInfo(blockId).getLocations().size()); // free the file mFileSystemMaster.free(NESTED_FILE_URI, FreeContext.defaults(FreePOptions.newBuilder().setForced(true))); // Update the heartbeat of removedBlockId received from worker 1. Command heartbeat = mBlockMaster.workerHeartbeat(mWorkerId1, null, ImmutableMap.of("MEM", (long) Constants.KB), ImmutableList.of(blockId), ImmutableMap.<String, List<Long>>of(), mMetrics); // Verify the muted Free command on worker1. assertEquals(Command.newBuilder().setCommandType(CommandType.Nothing).build(), heartbeat); assertEquals(0, mBlockMaster.getBlockInfo(blockId).getLocations().size()); }
/** * Tests the {@link FileSystemMaster#free} method with a directory with a file pinned when * forced flag is true. */ @Test public void freeDirWithPinnedFileAndForced() throws Exception { mNestedFileContext.setPersisted(true); long blockId = createFileWithSingleBlock(NESTED_FILE_URI); mFileSystemMaster.setAttribute(NESTED_FILE_URI, SetAttributeContext.defaults(SetAttributePOptions.newBuilder().setPinned(true))); // free the parent dir of a pinned file with "forced" mFileSystemMaster.free(NESTED_FILE_URI.getParent(), FreeContext.defaults(FreePOptions.newBuilder().setForced(true).setRecursive(true))); // Update the heartbeat of removedBlockId received from worker 1. Command heartbeat = mBlockMaster.workerHeartbeat(mWorkerId1, null, ImmutableMap.of("MEM", (long) Constants.KB), ImmutableList.of(blockId), ImmutableMap.<String, List<Long>>of(), mMetrics); // Verify the muted Free command on worker1. assertEquals(Command.newBuilder().setCommandType(CommandType.Nothing).build(), heartbeat); assertEquals(0, mBlockMaster.getBlockInfo(blockId).getLocations().size()); }
/** * Tests the {@link FileSystemMaster#free} method with a directory but recursive to false. */ @Test public void freeDirNonRecursive() throws Exception { mNestedFileContext.setPersisted(true); createFileWithSingleBlock(NESTED_FILE_URI); mThrown.expect(UnexpectedAlluxioException.class); mThrown.expectMessage(ExceptionMessage.CANNOT_FREE_NON_EMPTY_DIR.getMessage(NESTED_URI)); // cannot free directory with recursive argument to false mFileSystemMaster.free(NESTED_FILE_URI.getParent(), FreeContext.defaults(FreePOptions.newBuilder().setRecursive(false))); }
/** * Tests the {@link FileSystemMaster#free} method with a directory with a file non-persisted. */ @Test public void freeDirWithNonPersistedFile() throws Exception { createFileWithSingleBlock(NESTED_FILE_URI); mThrown.expect(UnexpectedAlluxioException.class); mThrown.expectMessage(ExceptionMessage.CANNOT_FREE_NON_PERSISTED_FILE .getMessage(NESTED_FILE_URI.getPath())); // cannot free the parent dir of a non-persisted file mFileSystemMaster.free(NESTED_FILE_URI.getParent(), FreeContext.defaults(FreePOptions.newBuilder().setForced(false).setRecursive(true))); }
/** * Tests the {@link FileSystemMaster#free} method with a directory with a file pinned when * forced flag is false. */ @Test public void freeDirWithPinnedFileAndNotForced() throws Exception { mNestedFileContext.setPersisted(true); createFileWithSingleBlock(NESTED_FILE_URI); mFileSystemMaster.setAttribute(NESTED_FILE_URI, SetAttributeContext.defaults(SetAttributePOptions.newBuilder().setPinned(true))); mThrown.expect(UnexpectedAlluxioException.class); mThrown.expectMessage(ExceptionMessage.CANNOT_FREE_PINNED_FILE .getMessage(NESTED_FILE_URI.getPath())); // cannot free the parent dir of a pinned file without "forced" mFileSystemMaster.free(NESTED_FILE_URI.getParent(), FreeContext.defaults(FreePOptions.newBuilder().setForced(false).setRecursive(true))); }