smengcl commented on code in PR #3980:
URL: https://github.com/apache/ozone/pull/3980#discussion_r1145991037
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmMetadataManagerImpl.java:
##########
@@ -328,13 +330,46 @@ protected OmMetadataManagerImpl() {
this.omEpoch = 0;
}
+ public static OmMetadataManagerImpl createCheckpointMetadataManager(
+ OzoneConfiguration conf, DBCheckpoint checkpoint) throws IOException {
+ Path path = checkpoint.getCheckpointLocation();
+ try {
+ Path parent = path.getParent();
+ File dir = parent.toFile();
+ String name = path.getFileName().toString();
+ return new OmMetadataManagerImpl(conf, dir, name);
+ // NPE check forced by findbugs NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE
+ } catch (NullPointerException e) {
+ throw new IOException("Invalid database: " +
+ checkpoint.getCheckpointLocation());
+ }
+ }
Review Comment:
```suggestion
public static OmMetadataManagerImpl createCheckpointMetadataManager(
OzoneConfiguration conf, DBCheckpoint checkpoint) throws IOException {
Path path = checkpoint.getCheckpointLocation();
Path parent = path.getParent();
if (parent == null) {
throw new IllegalStateException("DB checkpoint parent path should not "
+ "have been null. Checkpoint path is " + path);
}
File dir = parent.toFile();
Path name = path.getFileName();
if (name == null) {
throw new IllegalStateException("DB checkpoint dir name should not "
+ "have been null. Checkpoint path is " + path);
}
return new OmMetadataManagerImpl(conf, dir, name.toString());
}
```
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]