[GitHub] [hadoop] sunchao commented on a change in pull request #2578: [HDFS-15754] Add DataNode packet metrics

2021-01-06 Thread GitBox


sunchao commented on a change in pull request #2578:
URL: https://github.com/apache/hadoop/pull/2578#discussion_r553128834



##
File path: 
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeMetrics.java
##
@@ -161,6 +163,53 @@ public void testReceivePacketMetrics() throws Exception {
 }
   }
 
+  @Test
+  public void testReceivePacketSlowMetrics() throws Exception {
+Configuration conf = new HdfsConfiguration();
+final int interval = 1;
+conf.setInt(DFSConfigKeys.DFS_METRICS_PERCENTILES_INTERVALS_KEY, interval);
+MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf)
+.numDataNodes(3).build();
+try {
+  cluster.waitActive();
+  DistributedFileSystem fs = cluster.getFileSystem();
+  final DataNodeFaultInjector injector =
+  Mockito.mock(DataNodeFaultInjector.class);
+  Answer answer = new Answer() {
+@Override
+public Object answer(InvocationOnMock invocationOnMock)
+throws Throwable {
+  // make the op taking longer time
+  Thread.sleep(1000);
+  return null;
+}
+  };
+  Mockito.doAnswer(answer).when(injector).
+  stopSendingPacketDownstream(Mockito.anyString());
+  Mockito.doAnswer(answer).when(injector).delayWriteToOsCache();
+  Mockito.doAnswer(answer).when(injector).delayWriteToDisk();
+  DataNodeFaultInjector.set(injector);
+  Path testFile = new Path("/testFlushNanosMetric.txt");
+  FSDataOutputStream fout = fs.create(testFile);
+  fout.write(new byte[1]);
+  fout.hsync();
+  fout.close();
+  List datanodes = cluster.getDataNodes();
+  DataNode datanode = datanodes.get(0);
+  MetricsRecordBuilder dnMetrics = 
getMetrics(datanode.getMetrics().name());
+  assertTrue("More than 1 packet received",
+  getLongCounter("TotalPacketsReceived", dnMetrics) > 1L);
+  assertTrue("More than 1 slow packet to mirror",
+  getLongCounter("TotalPacketsSlowWriteToMirror", dnMetrics) > 1L);
+  assertCounter("TotalPacketsSlowWriteToDisk", 1L, dnMetrics);
+  assertCounter("TotalPacketsSlowWriteOsCache", 0L, dnMetrics);

Review comment:
   I think this also needs update.





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:
us...@infra.apache.org



-
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org



[GitHub] [hadoop] sunchao commented on a change in pull request #2578: [HDFS-15754] Add DataNode packet metrics

2021-01-06 Thread GitBox


sunchao commented on a change in pull request #2578:
URL: https://github.com/apache/hadoop/pull/2578#discussion_r55296



##
File path: 
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/metrics/DataNodeMetrics.java
##
@@ -690,4 +695,20 @@ public void addCheckAndUpdateOp(long latency) {
   public void addUpdateReplicaUnderRecoveryOp(long latency) {
 updateReplicaUnderRecoveryOp.add(latency);
   }
+
+  public void incrPacketsReceived() {
+packetsReceived.incr();
+  }
+
+  public void incrPacketsSlowWriteToMirror() {
+packetsSlowWriteToMirror.incr();
+  }
+
+  public void incrPacketsSlowWriteToDisk() {
+packetsSlowWriteToDisk.incr();
+  }
+
+  public void incrPacketsSlowWriteOsCache() {

Review comment:
   nit: name this to `incrPacketsSlowWriteToOsCache`?

##
File path: 
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/metrics/DataNodeMetrics.java
##
@@ -183,6 +183,11 @@
   @Metric private MutableRate checkAndUpdateOp;
   @Metric private MutableRate updateReplicaUnderRecoveryOp;
 
+  @Metric MutableCounterLong packetsReceived;
+  @Metric MutableCounterLong packetsSlowWriteToMirror;
+  @Metric MutableCounterLong packetsSlowWriteToDisk;
+  @Metric MutableCounterLong packetsSlowWriteOsCache;

Review comment:
   ditto





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:
us...@infra.apache.org



-
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org



[GitHub] [hadoop] sunchao commented on a change in pull request #2578: [HDFS-15754] Add DataNode packet metrics

2020-12-29 Thread GitBox


sunchao commented on a change in pull request #2578:
URL: https://github.com/apache/hadoop/pull/2578#discussion_r549883080



##
File path: 
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/metrics/DataNodeMetrics.java
##
@@ -183,6 +183,11 @@
   @Metric private MutableRate checkAndUpdateOp;
   @Metric private MutableRate updateReplicaUnderRecoveryOp;
 
+  @Metric MutableCounterLong totalPacketsReceived;

Review comment:
   We'll need to add these new metrics to 
[here](https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-common/Metrics.html#datanode)
 right?

##
File path: 
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeMetrics.java
##
@@ -161,6 +163,65 @@ public void testReceivePacketMetrics() throws Exception {
 }
   }
 
+  @Test
+  public void testReceivePacketSlowMetrics() throws Exception {
+Configuration conf = new HdfsConfiguration();
+final int interval = 1;
+conf.set(DFSConfigKeys.DFS_METRICS_PERCENTILES_INTERVALS_KEY, "" + 
interval);
+MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf)
+.numDataNodes(3).build();
+try {
+  cluster.waitActive();
+  DistributedFileSystem fs = cluster.getFileSystem();
+  final DataNodeFaultInjector injector =
+  Mockito.mock(DataNodeFaultInjector.class);
+  Mockito.doAnswer(new Answer() {
+@Override
+public Object answer(InvocationOnMock invocationOnMock)
+throws Throwable {
+  // make the op taking longer time
+  Thread.sleep(1000);
+  return null;
+}
+  }).when(injector).stopSendingPacketDownstream(Mockito.anyString());
+  Mockito.doAnswer(new Answer() {
+@Override
+public Object answer(InvocationOnMock invocationOnMock)
+throws Throwable {
+  // make the op taking longer time
+  Thread.sleep(1000);
+  return null;
+}
+  }).when(injector).delayWriteToOsCache();
+  Mockito.doAnswer(new Answer() {
+@Override
+public Object answer(InvocationOnMock invocationOnMock)
+throws Throwable {
+  // make the op taking longer time
+  Thread.sleep(1000);
+  return null;
+}
+  }).when(injector).delayWriteToDisk();
+  DataNodeFaultInjector.set(injector);
+  Path testFile = new Path("/testFlushNanosMetric.txt");
+  FSDataOutputStream fout = fs.create(testFile);
+  fout.write(new byte[1]);
+  fout.hsync();
+  fout.close();
+  List datanodes = cluster.getDataNodes();
+  DataNode datanode = datanodes.get(0);
+  MetricsRecordBuilder dnMetrics = 
getMetrics(datanode.getMetrics().name());
+  assertTrue("More than 1 packet received",
+  getLongCounter("TotalPacketsReceived", dnMetrics) > 1L);
+  assertTrue("More than 1 slow packet to mirror",
+  getLongCounter("TotalPacketsSlowWriteToMirror", dnMetrics) > 1L);
+  assertCounter("TotalPacketsSlowWriteToDisk", 1L, dnMetrics);
+  assertCounter("TotalPacketsSlowWriteOsCache", 0L, dnMetrics);
+} finally {
+  if (cluster != null) {cluster.shutdown();}

Review comment:
   nit: code style





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:
us...@infra.apache.org



-
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org