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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]