You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2019/11/15 23:55:52 UTC

[GitHub] [hadoop-ozone] adoroszlai commented on a change in pull request #199: HDDS-2502. Close ScmClient in RatisInsight.

adoroszlai commented on a change in pull request #199: HDDS-2502. Close ScmClient in RatisInsight.
URL: https://github.com/apache/hadoop-ozone/pull/199#discussion_r347055507
 
 

 ##########
 File path: hadoop-ozone/insight/src/main/java/org/apache/hadoop/ozone/insight/datanode/RatisInsight.java
 ##########
 @@ -47,22 +48,24 @@ public RatisInsight(OzoneConfiguration conf) {
   public List<LoggerSource> getRelatedLoggers(boolean verbose) {
     List<LoggerSource> result = new ArrayList<>();
     try {
-      ScmClient scmClient = createScmClient(conf);
-      Pipeline pipeline = scmClient.listPipelines()
-          .stream()
-          .filter(d -> d.getNodes().size() > 1)
-          .findFirst()
-          .get();
-      for (DatanodeDetails datanode : pipeline.getNodes()) {
-        Component dn =
-            new Component(Type.DATANODE, datanode.getUuid().toString(),
-                datanode.getHostName(), 9882);
-        result
-            .add(new LoggerSource(dn, "org.apache.ratis.server.impl",
-                defaultLevel(verbose)));
+      Optional<Pipeline> pipeline;
+      try (ScmClient scmClient = createScmClient(conf)) {
+        pipeline = scmClient.listPipelines()
+            .stream()
+            .filter(d -> d.getNodes().size() > 1)
+            .findFirst();
+      }
+      if (pipeline.isPresent()) {
+        for (DatanodeDetails datanode : pipeline.get().getNodes()) {
+          Component dn = new Component(
+              Type.DATANODE, datanode.getUuid().toString(),
+              datanode.getHostName(), 9882);
+          result.add(new LoggerSource(dn, "org.apache.ratis.server.impl",
+              defaultLevel(verbose)));
+        }
       }
     } catch (IOException e) {
-      throw new RuntimeException("Can't enumerate required logs", e);
+      throw new ExceptionInInitializerError(e);
 
 Review comment:
   > `ExceptionInInitializerError`: Signals that an unexpected exception has occurred in a static initializer.
   
   Wouldn't `UncheckedIOException` be more appropriate?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: ozone-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: ozone-issues-help@hadoop.apache.org