mchades commented on code in PR #8753:
URL: https://github.com/apache/gravitino/pull/8753#discussion_r2418320116
##########
clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/GravitinoVirtualFileSystem.java:
##########
@@ -173,117 +178,115 @@ public FSDataOutputStream create(
blockSize,
operations.create(
newPath, permission, overwrite, bufferSize, replication,
blockSize, progress));
- } catch (NoSuchCatalogException
- | CatalogNotInUseException
- | NoSuchFilesetException
- | NoSuchLocationNameException
- | FilesetPathNotFoundException e) {
- String message =
- "Fileset is not found for path: "
- + path
- + " for operation CREATE. "
- + "This may be caused by fileset related metadata not found or
not in use in "
- + "Gravitino, please check the fileset metadata in Gravitino.";
- throw new IOException(message, e);
+ } catch (Exception e) {
+ return hook.onCreateFailure(
+ path, permission, overwrite, bufferSize, replication, blockSize,
progress, e);
}
}
@Override
public FSDataOutputStream append(Path path, int bufferSize, Progressable
progress)
throws IOException {
- Path newPath = hook.preAppend(path, bufferSize);
- return hook.postAppend(
- newPath,
- bufferSize,
- runWithExceptionTranslation(
- () -> operations.append(newPath, bufferSize, progress),
FilesetDataOperation.APPEND));
+ try {
+ Path newPath = hook.preAppend(path, bufferSize);
+ return hook.postAppend(
+ newPath,
+ bufferSize,
+ runWithExceptionTranslation(
+ () -> operations.append(newPath, bufferSize, progress),
FilesetDataOperation.APPEND));
+ } catch (Exception e) {
+ return hook.onAppendFailure(path, bufferSize, progress, e);
+ }
}
@Override
public boolean rename(Path src, Path dst) throws IOException {
- Pair<Path, Path> pair = hook.preRename(src, dst);
- return hook.postRename(
- pair.getLeft(),
- pair.getRight(),
- runWithExceptionTranslation(
- () -> operations.rename(pair.getLeft(), pair.getRight()),
FilesetDataOperation.RENAME));
+ try {
+ Pair<Path, Path> pair = hook.preRename(src, dst);
+ return hook.postRename(
+ pair.getLeft(),
+ pair.getRight(),
+ runWithExceptionTranslation(
+ () -> operations.rename(pair.getLeft(), pair.getRight()),
+ FilesetDataOperation.RENAME));
+ } catch (Exception e) {
+ return hook.onRenameFailure(src, dst, e);
+ }
}
@Override
public boolean delete(Path path, boolean recursive) throws IOException {
- Path newPath = hook.preDelete(path, recursive);
try {
+ Path newPath = hook.preDelete(path, recursive);
return hook.postDelete(
newPath,
recursive,
runWithExceptionTranslation(
() -> operations.delete(newPath, recursive),
FilesetDataOperation.DELETE));
- } catch (FilesetPathNotFoundException e) {
- return false;
+ } catch (Exception e) {
+ return hook.onDeleteFailure(path, recursive, e);
}
}
@Override
public FileStatus getFileStatus(Path path) throws IOException {
- Path newPath = hook.preGetFileStatus(path);
- return hook.postGetFileStatus(
- runWithExceptionTranslation(
- () -> operations.getFileStatus(newPath),
FilesetDataOperation.GET_FILE_STATUS));
+ try {
+ Path newPath = hook.preGetFileStatus(path);
+ return hook.postGetFileStatus(
+ runWithExceptionTranslation(
+ () -> operations.getFileStatus(newPath),
FilesetDataOperation.GET_FILE_STATUS));
+ } catch (Exception e) {
+ return hook.onGetFileStatusFailure(path, e);
+ }
}
@Override
public FileStatus[] listStatus(Path path) throws IOException {
- Path newPath = hook.preListStatus(path);
- return hook.postListStatus(
- runWithExceptionTranslation(
- () -> operations.listStatus(newPath),
FilesetDataOperation.LIST_STATUS));
+ try {
+ Path newPath = hook.preListStatus(path);
+ return hook.postListStatus(
+ runWithExceptionTranslation(
+ () -> operations.listStatus(newPath),
FilesetDataOperation.LIST_STATUS));
+ } catch (Exception e) {
+ return hook.onListStatusFailure(path, e);
+ }
}
@Override
public boolean mkdirs(Path path, FsPermission permission) throws IOException
{
- Path newPath = hook.preMkdirs(path, permission);
try {
+ Path newPath = hook.preMkdirs(path, permission);
return hook.postMkdirs(newPath, permission, operations.mkdirs(newPath,
permission));
- } catch (NoSuchCatalogException
- | CatalogNotInUseException
- | NoSuchFilesetException
- | NoSuchLocationNameException
- | FilesetPathNotFoundException e) {
- String message =
- "Fileset is not found for path: "
- + newPath
- + " for operation MKDIRS. "
- + "This may be caused by fileset related metadata not found or
not in use in "
- + "Gravitino, please check the fileset metadata in Gravitino.";
- throw new IOException(message, e);
Review Comment:
When these exceptions occur, does the code change break backward
compatibility?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]