hadoop-ozone-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bha...@apache.org
Subject [hadoop-ozone] branch master updated: HDDS-2502. Close ScmClient in RatisInsight. (#199)
Date Sat, 16 Nov 2019 03:26:07 GMT
This is an automated email from the ASF dual-hosted git repository.

bharat pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hadoop-ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new ee6f22d  HDDS-2502. Close ScmClient in RatisInsight. (#199)
ee6f22d is described below

commit ee6f22dd9cbcae9eb6f6f73c0a1c08c2577522bd
Author: Siddharth <swagle@hortonworks.com>
AuthorDate: Fri Nov 15 19:25:56 2019 -0800

    HDDS-2502. Close ScmClient in RatisInsight. (#199)
---
 .../apache/hadoop/ozone/insight/LogSubcommand.java |  2 +-
 .../ozone/insight/datanode/RatisInsight.java       | 32 ++++++++++++----------
 2 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/hadoop-ozone/insight/src/main/java/org/apache/hadoop/ozone/insight/LogSubcommand.java
b/hadoop-ozone/insight/src/main/java/org/apache/hadoop/ozone/insight/LogSubcommand.java
index c0fd59d..d3a8eb3 100644
--- a/hadoop-ozone/insight/src/main/java/org/apache/hadoop/ozone/insight/LogSubcommand.java
+++ b/hadoop-ozone/insight/src/main/java/org/apache/hadoop/ozone/insight/LogSubcommand.java
@@ -83,7 +83,7 @@ public class LogSubcommand extends BaseInsightSubCommand
         .collect(Collectors.toSet());
     try {
       streamLog(conf, sources, loggers,
-          (logLine) -> insight.filterLog(filters, logLine));
+          logLine -> insight.filterLog(filters, logLine));
     } finally {
       for (LoggerSource logger : loggers) {
         setLogLevel(conf, logger.getLoggerName(), logger.getComponent(),
diff --git a/hadoop-ozone/insight/src/main/java/org/apache/hadoop/ozone/insight/datanode/RatisInsight.java
b/hadoop-ozone/insight/src/main/java/org/apache/hadoop/ozone/insight/datanode/RatisInsight.java
index 4113067..ae6a22c 100644
--- a/hadoop-ozone/insight/src/main/java/org/apache/hadoop/ozone/insight/datanode/RatisInsight.java
+++ b/hadoop-ozone/insight/src/main/java/org/apache/hadoop/ozone/insight/datanode/RatisInsight.java
@@ -18,9 +18,11 @@
 package org.apache.hadoop.ozone.insight.datanode;
 
 import java.io.IOException;
+import java.io.UncheckedIOException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 
 import org.apache.hadoop.hdds.conf.OzoneConfiguration;
 import org.apache.hadoop.hdds.protocol.DatanodeDetails;
@@ -47,22 +49,24 @@ public class RatisInsight extends BaseInsightPoint implements InsightPoint
{
   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 UncheckedIOException("Can't enumerate required logs", e);
     }
 
     return result;


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


Mime
View raw message