From 37bf6141f10d6f4be138c965ea08032420b01f56 Mon Sep 17 00:00:00 2001 From: Lei Xu Date: Mon, 26 Oct 2015 15:16:09 -0700 Subject: [PATCH] HDFS-9291. Fix TestInterDatanodeProtocol to be FsDataset-agnostic. (lei) --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 2 ++ .../hadoop/hdfs/server/datanode/FsDatasetTestUtils.java | 7 +++++++ .../datanode/fsdataset/impl/FsDatasetImplTestUtils.java | 7 +++++++ .../datanode/fsdataset/impl/TestInterDatanodeProtocol.java | 2 +- 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 397cb19c1f..55c77f8021 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -1576,6 +1576,8 @@ Release 2.8.0 - UNRELEASED HDFS-9284. fsck command should not print exception trace when file not found. (Jagadesh Kiran N via wang) + HDFS-9291. Fix TestInterDatanodeProtocol to be FsDataset-agnostic. (lei) + OPTIMIZATIONS HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/FsDatasetTestUtils.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/FsDatasetTestUtils.java index 252b285b5b..eb986ff107 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/FsDatasetTestUtils.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/FsDatasetTestUtils.java @@ -192,4 +192,11 @@ Replica createReplicaWaitingToBeRecovered( */ Replica createReplicaUnderRecovery(ExtendedBlock block, long recoveryId) throws IOException; + + /** + * Check the stored files / data of a replica. + * @param replica a replica object. + * @throws IOException + */ + void checkStoredReplica(final Replica replica) throws IOException; } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImplTestUtils.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImplTestUtils.java index 3058b549b7..ed32faec79 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImplTestUtils.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImplTestUtils.java @@ -285,4 +285,11 @@ public Replica createReplicaUnderRecovery( return rur; } } + + @Override + public void checkStoredReplica(Replica replica) throws IOException { + Preconditions.checkArgument(replica instanceof ReplicaInfo); + ReplicaInfo r = (ReplicaInfo) replica; + FsDatasetImpl.checkReplicaFiles(r); + } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/TestInterDatanodeProtocol.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/TestInterDatanodeProtocol.java index 6cc3d7e3f2..8581807913 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/TestInterDatanodeProtocol.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/TestInterDatanodeProtocol.java @@ -359,7 +359,7 @@ public void testUpdateReplicaUnderRecovery() throws IOException { Assert.assertEquals(ReplicaState.RUR, replica.getState()); //check meta data before update - FsDatasetImpl.checkReplicaFiles(replica); + cluster.getFsDatasetTestUtils(datanode).checkStoredReplica(replica); //case "THIS IS NOT SUPPOSED TO HAPPEN" //with (block length) != (stored replica's on disk length).