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 2020/08/10 11:58:04 UTC

[GitHub] [hadoop-ozone] adoroszlai commented on a change in pull request #1272: HDDS-2660. Create insight point for datanode container protocol

adoroszlai commented on a change in pull request #1272:
URL: https://github.com/apache/hadoop-ozone/pull/1272#discussion_r467845835



##########
File path: hadoop-ozone/insight/src/main/java/org/apache/hadoop/ozone/insight/datanode/DatanodeDispatcherInsight.java
##########
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+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 org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.hdds.protocol.proto.ScmBlockLocationProtocolProtos;
+import org.apache.hadoop.hdds.scm.client.ScmClient;
+import org.apache.hadoop.ozone.container.common.impl.HddsDispatcher;
+import org.apache.hadoop.ozone.insight.BaseInsightPoint;
+import org.apache.hadoop.ozone.insight.Component.Type;
+import org.apache.hadoop.ozone.insight.InsightPoint;
+import org.apache.hadoop.ozone.insight.LoggerSource;
+import org.apache.hadoop.ozone.insight.MetricGroupDisplay;
+
+import static org.apache.hadoop.ozone.insight.datanode.PipelineComponentUtil.getPipelineIdFromFilters;
+import static org.apache.hadoop.ozone.insight.datanode.PipelineComponentUtil.withDatanodesFromPipeline;
+
+/**
+ * Insight definition for datanode/pipline metrics.
+ */
+public class DatanodeDispatcherInsight extends BaseInsightPoint
+    implements InsightPoint {
+
+  private OzoneConfiguration conf;
+
+  public DatanodeDispatcherInsight(
+      OzoneConfiguration conf) {
+    this.conf = conf;
+  }
+
+  @Override
+  public List<LoggerSource> getRelatedLoggers(boolean verbose,
+      Map<String, String> filters) {
+
+    List<LoggerSource> result = new ArrayList<>();
+
+    try (ScmClient scmClient = createScmClient(conf)) {
+      withDatanodesFromPipeline(scmClient,
+          getPipelineIdFromFilters(filters),
+          dn -> {
+            result
+                .add(new LoggerSource(dn,
+                    HddsDispatcher.class.getCanonicalName(),
+                    defaultLevel(verbose)));
+            return null;
+          });
+    } catch (IOException e) {
+      throw new UncheckedIOException("Can't enumerate required logs", e);
+    }
+    return result;
+  }
+
+  @Override
+  public List<MetricGroupDisplay> getMetrics() {
+    List<MetricGroupDisplay> metrics = new ArrayList<>();
+
+    addProtocolMessageMetrics(metrics, "hdds_dispatcher",
+        Type.SCM, ScmBlockLocationProtocolProtos.Type.values());

Review comment:
       Seems to be leftover from `ScmProtocolBlockLocationInsight`.  I think it should be something like `Type.DATANODE, ContainerProtos.Type.values()` instead.  (`BaseInsightPoint` needs to be tweaked to allow it.)

##########
File path: hadoop-ozone/insight/src/main/java/org/apache/hadoop/ozone/insight/datanode/DatanodeDispatcherInsight.java
##########
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+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 org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.hdds.protocol.proto.ScmBlockLocationProtocolProtos;
+import org.apache.hadoop.hdds.scm.client.ScmClient;
+import org.apache.hadoop.ozone.container.common.impl.HddsDispatcher;
+import org.apache.hadoop.ozone.insight.BaseInsightPoint;
+import org.apache.hadoop.ozone.insight.Component.Type;
+import org.apache.hadoop.ozone.insight.InsightPoint;
+import org.apache.hadoop.ozone.insight.LoggerSource;
+import org.apache.hadoop.ozone.insight.MetricGroupDisplay;
+
+import static org.apache.hadoop.ozone.insight.datanode.PipelineComponentUtil.getPipelineIdFromFilters;
+import static org.apache.hadoop.ozone.insight.datanode.PipelineComponentUtil.withDatanodesFromPipeline;
+
+/**
+ * Insight definition for datanode/pipline metrics.

Review comment:
       Seems to be leftover from `RatisInsight`.

##########
File path: hadoop-ozone/insight/src/main/java/org/apache/hadoop/ozone/insight/datanode/DatanodeDispatcherInsight.java
##########
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+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 org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.hdds.protocol.proto.ScmBlockLocationProtocolProtos;
+import org.apache.hadoop.hdds.scm.client.ScmClient;
+import org.apache.hadoop.ozone.container.common.impl.HddsDispatcher;
+import org.apache.hadoop.ozone.insight.BaseInsightPoint;
+import org.apache.hadoop.ozone.insight.Component.Type;
+import org.apache.hadoop.ozone.insight.InsightPoint;
+import org.apache.hadoop.ozone.insight.LoggerSource;
+import org.apache.hadoop.ozone.insight.MetricGroupDisplay;
+
+import static org.apache.hadoop.ozone.insight.datanode.PipelineComponentUtil.getPipelineIdFromFilters;
+import static org.apache.hadoop.ozone.insight.datanode.PipelineComponentUtil.withDatanodesFromPipeline;
+
+/**
+ * Insight definition for datanode/pipline metrics.
+ */
+public class DatanodeDispatcherInsight extends BaseInsightPoint
+    implements InsightPoint {
+
+  private OzoneConfiguration conf;
+
+  public DatanodeDispatcherInsight(
+      OzoneConfiguration conf) {
+    this.conf = conf;
+  }
+
+  @Override
+  public List<LoggerSource> getRelatedLoggers(boolean verbose,
+      Map<String, String> filters) {
+
+    List<LoggerSource> result = new ArrayList<>();
+
+    try (ScmClient scmClient = createScmClient(conf)) {
+      withDatanodesFromPipeline(scmClient,
+          getPipelineIdFromFilters(filters),
+          dn -> {
+            result
+                .add(new LoggerSource(dn,
+                    HddsDispatcher.class.getCanonicalName(),
+                    defaultLevel(verbose)));
+            return null;
+          });
+    } catch (IOException e) {
+      throw new UncheckedIOException("Can't enumerate required logs", e);
+    }
+    return result;
+  }
+
+  @Override
+  public List<MetricGroupDisplay> getMetrics() {
+    List<MetricGroupDisplay> metrics = new ArrayList<>();
+
+    addProtocolMessageMetrics(metrics, "hdds_dispatcher",
+        Type.SCM, ScmBlockLocationProtocolProtos.Type.values());
+
+    return metrics;
+  }
+
+  @Override
+  public String getDescription() {
+    return "Datanode client protocol";
+  }
+
+  @Override
+  public boolean filterLog(Map<String, String> filters, String logLine) {
+    return true;

Review comment:
       Can you please explain why this is needed?  I think this may cause logs from other pipelines to be printed.
   
   For example, I ran `ozone insight logs` on a 3-node pipeline, then:
   
   ```
   $ ozone sh key put -r ONE /vol1/bucket1/passwd /etc/passwd
   ```
   
   and the logs from the single datanode to which this block was written (part of the 3-node pipeline, too) appeared in the console.




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



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