FreePOptions options = FreePOptions.newBuilder().setRecursive(true).setForced(cl.hasOption("f")).build(); mFileSystem.free(path, options); try { CommonUtils.waitFor("file to be freed. Another user may be loading it.", () -> { boolean freed = mFileSystem.getStatus(path).getInAlluxioPercentage() == 0; if (!freed) { mFileSystem.free(path, options);
/** * 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(); }
/** * 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(); }