use of alluxio.grpc.RenamePOptions in project alluxio by Alluxio.
the class BaseFileSystem method rename.
@Override
public void rename(AlluxioURI src, AlluxioURI dst, RenamePOptions options) throws FileDoesNotExistException, IOException, AlluxioException {
checkUri(src);
checkUri(dst);
rpc(client -> {
RenamePOptions mergedOptions = FileSystemOptions.renameDefaults(mFsContext.getPathConf(dst)).toBuilder().mergeFrom(options).build();
// TODO(calvin): Update this code on the master side.
client.rename(src, dst, mergedOptions);
LOG.debug("Renamed {} to {}, options: {}", src.getPath(), dst.getPath(), mergedOptions);
return null;
});
}
use of alluxio.grpc.RenamePOptions in project alluxio by Alluxio.
the class UfsSyncIntegrationTest method renameFileSync.
@Test
public void renameFileSync() throws Exception {
RenamePOptions options = RenamePOptions.newBuilder().setCommonOptions(PSYNC_ALWAYS).build();
mFileSystem.rename(new AlluxioURI(alluxioPath(EXISTING_FILE)), new AlluxioURI(alluxioPath(NEW_FILE)), options);
}
use of alluxio.grpc.RenamePOptions in project alluxio by Alluxio.
the class UfsSyncIntegrationTest method renameFileNoSync.
@Test
public void renameFileNoSync() throws Exception {
RenamePOptions options = RenamePOptions.newBuilder().setCommonOptions(PSYNC_NEVER).build();
try {
mFileSystem.rename(new AlluxioURI(alluxioPath(EXISTING_FILE)), new AlluxioURI(alluxioPath(NEW_FILE)), options);
Assert.fail("Rename expected to fail.");
} catch (FileDoesNotExistException e) {
// expected
}
}
use of alluxio.grpc.RenamePOptions in project alluxio by Alluxio.
the class BaseFileSystemTest method rename.
/**
* Tests for the {@link BaseFileSystem#rename(AlluxioURI, AlluxioURI, RenamePOptions)}
* method.
*/
@Test
public void rename() throws Exception {
AlluxioURI src = new AlluxioURI("/file");
AlluxioURI dst = new AlluxioURI("/file2");
RenamePOptions renameOptions = RenamePOptions.getDefaultInstance();
doNothing().when(mFileSystemMasterClient).rename(src, dst, FileSystemOptions.renameDefaults(mConf).toBuilder().mergeFrom(renameOptions).build());
mFileSystem.rename(src, dst, renameOptions);
verify(mFileSystemMasterClient).rename(src, dst, FileSystemOptions.renameDefaults(mConf).toBuilder().mergeFrom(renameOptions).build());
}
use of alluxio.grpc.RenamePOptions in project alluxio by Alluxio.
the class BaseFileSystemTest method renameException.
/**
* Ensures that an exception is propagated successfully when renaming a file.
*/
@Test
public void renameException() throws Exception {
AlluxioURI src = new AlluxioURI("/file");
AlluxioURI dst = new AlluxioURI("/file2");
RenamePOptions renameOptions = RenamePOptions.getDefaultInstance();
doThrow(EXCEPTION).when(mFileSystemMasterClient).rename(src, dst, FileSystemOptions.renameDefaults(mConf).toBuilder().mergeFrom(renameOptions).build());
try {
mFileSystem.rename(src, dst, renameOptions);
fail(SHOULD_HAVE_PROPAGATED_MESSAGE);
} catch (Exception e) {
assertSame(EXCEPTION, e);
}
}
Aggregations