peterxcli commented on code in PR #10456:
URL: https://github.com/apache/ozone/pull/10456#discussion_r3570432870
##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/local/LocalOzoneCluster.java:
##########
@@ -151,12 +221,18 @@ public String getDisplayHost() {
@Override
public int getScmPort() {
+ if (scm != null) {
+ return scm.getClientRpcAddress().getPort();
+ }
return preparedConfiguration == null ? config.getScmPort()
: preparedConfiguration.getScmPort();
}
@Override
public int getOmPort() {
+ if (om != null) {
+ return om.getOmRpcServerAddr().getPort();
+ }
Review Comment:
om cant be null.
```suggestion
return om.getOmRpcServerAddr().getPort();
```
##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/local/LocalOzoneCluster.java:
##########
@@ -151,12 +221,18 @@ public String getDisplayHost() {
@Override
public int getScmPort() {
+ if (scm != null) {
+ return scm.getClientRpcAddress().getPort();
+ }
Review Comment:
scm cant be null.
```suggestion
return scm.getClientRpcAddress().getPort();
```
##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/local/LocalOzoneCluster.java:
##########
@@ -173,14 +243,50 @@ public String getS3Endpoint() {
@Override
public void close() throws IOException {
- // Ephemeral mode owns the data directory lifecycle for short-lived runs.
- if (config.isEphemeral()) {
- deleteDirectory(config.getDataDir());
+ if (closed) {
+ return;
+ }
+ closed = true;
+
+ try {
+ stopServices();
+ } finally {
+ // Ephemeral mode owns the data directory lifecycle for short-lived runs.
+ if (config.isEphemeral()) {
+ try {
+ deleteDirectory(config.getDataDir());
+ } catch (IOException ex) {
+ LOG.warn("Failed to delete local Ozone data dir {} during shutdown.",
+ config.getDataDir(), ex);
+ }
+ }
+ }
+ }
+
+ private void stopServices() {
+ try {
+ // Shutdown is best-effort so one failed service cannot leak the other.
+ stopQuietly("OM", om, service -> {
Review Comment:
use `IOUtils.closeQuietly`
https://github.com/apache/ozone/blob/040a28a17819aa366d3a4e85d93012e054dfae61/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/utils/IOUtils.java#L96-L101
##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/local/LocalOzoneCluster.java:
##########
@@ -344,11 +621,14 @@ private static void deleteDirectory(Path directory) {
for (Path path : deleteOrder) {
Files.deleteIfExists(path);
}
- } catch (IOException ex) {
- LOG.error("Failed to delete local Ozone directory {}", directory, ex);
}
}
+ @FunctionalInterface
Review Comment:
remove
##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/local/LocalOzoneCluster.java:
##########
@@ -334,7 +594,24 @@ private static String address(String host, int port) {
return host + ":" + port;
}
- private static void deleteDirectory(Path directory) {
+ private static String initializedClusterId(Storage storage) {
+ return storage.getState() == INITIALIZED ? storage.getClusterID() : null;
+ }
+
+ private static <T> void stopQuietly(String serviceName, T service,
Review Comment:
remove
--
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]