You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by GitBox <gi...@apache.org> on 2021/09/25 14:50:14 UTC
[GitHub] [hadoop] ferhui commented on a change in pull request #3471: HDFS-16231. Fix TestDataNodeMetrics#testReceivePacketSlowMetrics
ferhui commented on a change in pull request #3471:
URL: https://github.com/apache/hadoop/pull/3471#discussion_r716051187
##########
File path: hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeMetrics.java
##########
@@ -190,18 +190,28 @@ public Object answer(InvocationOnMock invocationOnMock)
DataNodeFaultInjector.set(injector);
Path testFile = new Path("/testFlushNanosMetric.txt");
FSDataOutputStream fout = fs.create(testFile);
+ DFSOutputStream dout = (DFSOutputStream) fout.getWrappedStream();
fout.write(new byte[1]);
fout.hsync();
+ DatanodeInfo[] pipeline = dout.getPipeline();
fout.close();
+ dout.close();
+ DatanodeInfo headDatanodeInfo = pipeline[0];
+ DataNode headNode = null;
List<DataNode> datanodes = cluster.getDataNodes();
- DataNode datanode = datanodes.get(0);
- MetricsRecordBuilder dnMetrics = getMetrics(datanode.getMetrics().name());
+ for (DataNode datanode : datanodes) {
Review comment:
Could we change this to lambda like this
` DataNode headNode = datanodes.stream()
.filter(d -> d.getDatanodeId().equals(headDatanodeInfo))
.findFirst().orElseGet(() -> null);
`
--
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.
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org