use of alluxio.grpc.FreePOptions in project alluxio by Alluxio.
the class BaseFileSystem method free.
@Override
public void free(AlluxioURI path, final FreePOptions options) throws FileDoesNotExistException, IOException, AlluxioException {
checkUri(path);
rpc(client -> {
FreePOptions mergedOptions = FileSystemOptions.freeDefaults(mFsContext.getPathConf(path)).toBuilder().mergeFrom(options).build();
client.free(path, mergedOptions);
LOG.debug("Freed {}, options: {}", path.getPath(), mergedOptions);
return null;
});
}
use of alluxio.grpc.FreePOptions in project alluxio by Alluxio.
the class FreeContext method mergeFrom.
/**
* Merges and embeds the given {@link FreePOptions} with the corresponding master options.
*
* @param optionsBuilder Builder for proto {@link FreePOptions} to merge with defaults
* @return the instance of {@link FreeContext} with default values for master
*/
public static FreeContext mergeFrom(FreePOptions.Builder optionsBuilder) {
FreePOptions masterOptions = FileSystemOptions.freeDefaults(ServerConfiguration.global());
FreePOptions.Builder mergedOptionsBuilder = masterOptions.toBuilder().mergeFrom(optionsBuilder.build());
return create(mergedOptionsBuilder);
}
use of alluxio.grpc.FreePOptions in project alluxio by Alluxio.
the class BaseFileSystemTest method free.
/**
* 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, FileSystemOptions.freeDefaults(mConf).toBuilder().mergeFrom(freeOptions).build());
verifyFilesystemContextAcquiredAndReleased();
}
use of alluxio.grpc.FreePOptions in project alluxio by Alluxio.
the class FreeCommand method runPlainPath.
@Override
protected void runPlainPath(AlluxioURI path, CommandLine cl) throws AlluxioException, IOException {
int interval = Math.toIntExact(mFsContext.getPathConf(path).getMs(PropertyKey.WORKER_BLOCK_HEARTBEAT_INTERVAL_MS));
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.", () -> {
try {
URIStatus fileStatus = mFileSystem.getStatus(path);
if (fileStatus.getLength() == 0 && !fileStatus.isFolder()) {
// but 'free' on an empty file should be a no-op
return true;
}
if (fileStatus.getInAlluxioPercentage() > 0) {
mFileSystem.free(path, options);
return fileStatus.getInAlluxioPercentage() == 0;
} else {
return true;
}
} catch (Exception e) {
Throwables.propagateIfPossible(e);
throw new RuntimeException(e);
}
}, WaitForOptions.defaults().setTimeoutMs(10 * Math.toIntExact(interval)).setInterval(interval));
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException(e);
} catch (TimeoutException e) {
throw new RuntimeException(e);
}
System.out.println(path + " was successfully freed from Alluxio space.");
}
use of alluxio.grpc.FreePOptions in project alluxio by Alluxio.
the class BaseFileSystemTest method freeException.
/**
* 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, FileSystemOptions.freeDefaults(mConf).toBuilder().mergeFrom(freeOptions).build());
try {
mFileSystem.free(file, freeOptions);
fail(SHOULD_HAVE_PROPAGATED_MESSAGE);
} catch (Exception e) {
assertSame(EXCEPTION, e);
}
verifyFilesystemContextAcquiredAndReleased();
}
Aggregations