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/16 00:14:01 UTC

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

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

 ##########
 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:
   @adoroszlai Agree, much better exception to throw.

----------------------------------------------------------------
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