.defaults(SetAttributePOptions.newBuilder().setRecursive(false).setPinned(false)); setAttributeSingleFile(rpcContext, descedant, true, opTimeMs, setAttributeContext);
/** * 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()); }
public Builder mergeFrom(alluxio.grpc.SetAttributePOptions other) { if (other == alluxio.grpc.SetAttributePOptions.getDefaultInstance()) return this; if (other.hasPinned()) { setPinned(other.getPinned());
/** * Tests the {@link FileSystemMaster#setAttribute(AlluxioURI, SetAttributeContext)} method and * that an exception is thrown when trying to set a TTL for a directory. */ @Test public void setAttribute() throws Exception { mFileSystemMaster.createFile(NESTED_FILE_URI, mNestedFileContext); FileInfo fileInfo = mFileSystemMaster.getFileInfo(NESTED_FILE_URI, GET_STATUS_CONTEXT); assertFalse(fileInfo.isPinned()); assertEquals(Constants.NO_TTL, fileInfo.getTtl()); // No State. mFileSystemMaster.setAttribute(NESTED_FILE_URI, SetAttributeContext.defaults()); fileInfo = mFileSystemMaster.getFileInfo(NESTED_FILE_URI, GET_STATUS_CONTEXT); assertFalse(fileInfo.isPinned()); assertEquals(Constants.NO_TTL, fileInfo.getTtl()); // Just set pinned flag. mFileSystemMaster.setAttribute(NESTED_FILE_URI, SetAttributeContext.defaults(SetAttributePOptions.newBuilder().setPinned(true))); fileInfo = mFileSystemMaster.getFileInfo(NESTED_FILE_URI, GET_STATUS_CONTEXT); assertTrue(fileInfo.isPinned()); assertEquals(Constants.NO_TTL, fileInfo.getTtl()); // Both pinned flag and ttl value. mFileSystemMaster.setAttribute(NESTED_FILE_URI, SetAttributeContext.defaults(SetAttributePOptions.newBuilder().setPinned(false).setTtl(1))); fileInfo = mFileSystemMaster.getFileInfo(NESTED_FILE_URI, GET_STATUS_CONTEXT); assertFalse(fileInfo.isPinned()); assertEquals(1, fileInfo.getTtl()); mFileSystemMaster.setAttribute(NESTED_URI, SetAttributeContext.defaults(SetAttributePOptions.newBuilder().setTtl(1))); }
/** * 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))); }
/** * Tests {@link FileSystemMaster#free} on pinned file when forced flag is false. */ @Test public void freePinnedFileWithoutForce() 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 a pinned file without "forced" mFileSystemMaster.free(NESTED_FILE_URI, FreeContext.defaults()); }
/** * Sets pin state for the input path. * * @param fs The {@link FileSystem} client * @param path The {@link AlluxioURI} path as the input of the command * @param pinned the state to be set */ public static void setPinned(FileSystem fs, AlluxioURI path, boolean pinned) throws AlluxioException, IOException { SetAttributePOptions options = SetAttributePOptions.newBuilder().setPinned(pinned).build(); fs.setAttribute(path, options); } }
private SetAttributePOptions verifySetState(TestUser user, String path, SetAttributePOptions options) throws Exception { try (Closeable r = new AuthenticatedUserRule(user.getUser(), ServerConfiguration.global()).toResource()) { mFileSystemMaster.setAttribute(new AlluxioURI(path), SetAttributeContext.defaults(options.toBuilder())); FileInfo fileInfo = mFileSystemMaster.getFileInfo(new AlluxioURI(path), GetStatusContext.defaults()); return FileSystemMasterOptions.setAttributesDefaults().toBuilder() .setPinned(fileInfo.isPinned()).setTtl(fileInfo.getTtl()) .setPersisted(fileInfo.isPersisted()).build(); } }
private SetAttributePOptions getNonDefaultSetState() { return SetAttributePOptions.newBuilder().setPinned(true).setTtl(11) .setTtlAction(TtlAction.DELETE).build(); }