tomscut commented on a change in pull request #3643:
URL: https://github.com/apache/hadoop/pull/3643#discussion_r748867878
##########
File path:
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/TestFsDatasetImpl.java
##########
@@ -1830,4 +1830,58 @@ public void testReleaseVolumeRefIfExceptionThrown()
throws IOException {
cluster.shutdown();
}
}
+
+ @Test(timeout = 30000)
+ public void testTransferAndNativeCopyMetrics() {
+ Configuration config = new HdfsConfiguration();
+ config.setInt(
+ DFSConfigKeys.DFS_DATANODE_FILEIO_PROFILING_SAMPLING_PERCENTAGE_KEY,
+ 100);
+ config.set(DFSConfigKeys.DFS_METRICS_PERCENTILES_INTERVALS_KEY,
+ "60,300,1500");
+ MiniDFSCluster cluster = null;
+ try {
+ cluster = new MiniDFSCluster.Builder(config)
+ .numDataNodes(1)
+ .storageTypes(new StorageType[]{StorageType.DISK, StorageType.DISK})
+ .storagesPerDatanode(2)
+ .build();
+ FileSystem fs = cluster.getFileSystem();
+ DataNode dataNode = cluster.getDataNodes().get(0);
+
+ // Create file that has one block with one replica.
+ Path filePath = new Path(name.getMethodName());
+ DFSTestUtil.createFile(fs, filePath, 100, (short) 1, 0);
+ ExtendedBlock block = DFSTestUtil.getFirstBlock(fs, filePath);
+
+ // Copy a new replica to other volume.
+ FsDatasetImpl fsDataSetImpl = (FsDatasetImpl) dataNode.getFSDataset();
+ ReplicaInfo newReplicaInfo = createNewReplicaObj(block, fsDataSetImpl);
+ fsDataSetImpl.finalizeNewReplica(newReplicaInfo, block);
+
+ // Get the volume where the original replica resides.
+ FsVolumeSpi volume = null;
+ for (FsVolumeSpi fsVolumeReference :
+ fsDataSetImpl.getFsVolumeReferences()) {
+ if (!fsVolumeReference.getStorageID()
+ .equals(newReplicaInfo.getStorageUuid())) {
+ volume = fsVolumeReference;
+ }
+ }
+
+ // Assert metrics.
+ DataNodeVolumeMetrics metrics = volume.getMetrics();
+ assertEquals(2, metrics.getTransferIoSampleCount());
+ assertEquals(3, metrics.getTransferIoQuantiles().length);
+ assertEquals(2, metrics.getNativeCopyIoSampleCount());
+ assertEquals(3, metrics.getNativeCopyIoQuantiles().length);
+ } catch (Exception ex) {
+ LOG.info("Exception in testTransferAndNativeCopyMetrics ", ex);
+ fail("MoveBlock operation should succeed");
Review comment:
Thanks @ayushtkn for your advice, I will fix it.
--
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]