From b71907b2ae3d8f05b4332e06d52ec2096681ea6b Mon Sep 17 00:00:00 2001 From: Arpit Agarwal Date: Thu, 3 Nov 2016 10:27:52 -0700 Subject: [PATCH] HDFS-11097. Fix warnings for deprecated StorageReceivedDeletedBlocks constructor. Contributed by Yiqun Lin. --- .../DatanodeProtocolServerSideTranslatorPB.java | 4 +++- .../protocol/StorageReceivedDeletedBlocks.java | 7 +++++++ .../blockmanagement/TestPendingReconstruction.java | 12 ++++++++---- .../server/datanode/TestIncrementalBrVariations.java | 4 +++- .../hdfs/server/namenode/NNThroughputBenchmark.java | 5 +++-- .../hdfs/server/namenode/TestDeadDatanode.java | 3 ++- 6 files changed, 26 insertions(+), 9 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/DatanodeProtocolServerSideTranslatorPB.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/DatanodeProtocolServerSideTranslatorPB.java index b3d5f0d2d4..257adf9792 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/DatanodeProtocolServerSideTranslatorPB.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/DatanodeProtocolServerSideTranslatorPB.java @@ -52,6 +52,7 @@ import org.apache.hadoop.hdfs.server.protocol.DatanodeCommand; import org.apache.hadoop.hdfs.server.protocol.DatanodeProtocol; import org.apache.hadoop.hdfs.server.protocol.DatanodeRegistration; +import org.apache.hadoop.hdfs.server.protocol.DatanodeStorage; import org.apache.hadoop.hdfs.server.protocol.HeartbeatResponse; import org.apache.hadoop.hdfs.server.protocol.NamespaceInfo; import org.apache.hadoop.hdfs.server.protocol.ReceivedDeletedBlockInfo; @@ -230,7 +231,8 @@ public BlockReceivedAndDeletedResponseProto blockReceivedAndDeleted( info[i] = new StorageReceivedDeletedBlocks( PBHelperClient.convert(sBlock.getStorage()), rdBlocks); } else { - info[i] = new StorageReceivedDeletedBlocks(sBlock.getStorageUuid(), rdBlocks); + info[i] = new StorageReceivedDeletedBlocks( + new DatanodeStorage(sBlock.getStorageUuid()), rdBlocks); } } try { diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/protocol/StorageReceivedDeletedBlocks.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/protocol/StorageReceivedDeletedBlocks.java index 29216cf063..12b03514ed 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/protocol/StorageReceivedDeletedBlocks.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/protocol/StorageReceivedDeletedBlocks.java @@ -28,6 +28,9 @@ public class StorageReceivedDeletedBlocks { final DatanodeStorage storage; private final ReceivedDeletedBlockInfo[] blocks; + /** + * @deprecated Use {@link #getStorage()} instead + */ @Deprecated public String getStorageID() { return storage.getStorageID(); @@ -41,6 +44,10 @@ public ReceivedDeletedBlockInfo[] getBlocks() { return blocks; } + /** + * @deprecated Use {@link #StorageReceivedDeletedBlocks( + * DatanodeStorage, ReceivedDeletedBlockInfo[])} instead + */ @Deprecated public StorageReceivedDeletedBlocks(final String storageID, final ReceivedDeletedBlockInfo[] blocks) { diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestPendingReconstruction.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestPendingReconstruction.java index c30f63089f..ba3be914e7 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestPendingReconstruction.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestPendingReconstruction.java @@ -40,6 +40,7 @@ import org.apache.hadoop.hdfs.server.namenode.INodeFile; import org.apache.hadoop.hdfs.server.namenode.NameNodeAdapter; import org.apache.hadoop.hdfs.server.protocol.DatanodeRegistration; +import org.apache.hadoop.hdfs.server.protocol.DatanodeStorage; import org.apache.hadoop.hdfs.server.protocol.ReceivedDeletedBlockInfo; import org.apache.hadoop.hdfs.server.protocol.ReceivedDeletedBlockInfo.BlockStatus; import org.apache.hadoop.hdfs.server.protocol.StorageReceivedDeletedBlocks; @@ -312,7 +313,8 @@ public void testBlockReceived() throws Exception { DatanodeRegistration dnR = datanodes.get(i).getDNRegistrationForBP( poolId); StorageReceivedDeletedBlocks[] report = { - new StorageReceivedDeletedBlocks("Fake-storage-ID-Ignored", + new StorageReceivedDeletedBlocks( + new DatanodeStorage("Fake-storage-ID-Ignored"), new ReceivedDeletedBlockInfo[] { new ReceivedDeletedBlockInfo( blocks[0], BlockStatus.RECEIVED_BLOCK, "") }) }; cluster.getNameNodeRpc().blockReceivedAndDeleted(dnR, poolId, report); @@ -330,9 +332,11 @@ public void testBlockReceived() throws Exception { DatanodeRegistration dnR = datanodes.get(i).getDNRegistrationForBP( poolId); StorageReceivedDeletedBlocks[] report = - { new StorageReceivedDeletedBlocks("Fake-storage-ID-Ignored", - new ReceivedDeletedBlockInfo[] { new ReceivedDeletedBlockInfo( - blocks[0], BlockStatus.RECEIVED_BLOCK, "") }) }; + { new StorageReceivedDeletedBlocks( + new DatanodeStorage("Fake-storage-ID-Ignored"), + new ReceivedDeletedBlockInfo[] { + new ReceivedDeletedBlockInfo( + blocks[0], BlockStatus.RECEIVED_BLOCK, "")}) }; cluster.getNameNodeRpc().blockReceivedAndDeleted(dnR, poolId, report); reportDnNum++; } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestIncrementalBrVariations.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestIncrementalBrVariations.java index f2570c205d..78b5cf91c0 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestIncrementalBrVariations.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestIncrementalBrVariations.java @@ -42,6 +42,7 @@ import org.apache.hadoop.hdfs.server.namenode.FSNamesystem; import org.apache.hadoop.hdfs.server.namenode.NameNode; import org.apache.hadoop.hdfs.server.protocol.*; +import org.apache.hadoop.hdfs.server.protocol.DatanodeStorage; import org.apache.hadoop.hdfs.server.protocol.ReceivedDeletedBlockInfo.BlockStatus; import org.apache.hadoop.test.GenericTestUtils; import org.apache.log4j.Level; @@ -172,7 +173,8 @@ public void verifyIncrementalBlockReports(boolean splitReports) throws IOExcepti assertTrue(foundBlockOnStorage); reports[i] = - new StorageReceivedDeletedBlocks(volume.getStorageID(), rdbi); + new StorageReceivedDeletedBlocks( + new DatanodeStorage(volume.getStorageID()), rdbi); if (splitReports) { // If we are splitting reports then send the report for this storage now. diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/NNThroughputBenchmark.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/NNThroughputBenchmark.java index ad336ef255..4b9db07c2b 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/NNThroughputBenchmark.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/NNThroughputBenchmark.java @@ -1037,7 +1037,7 @@ private int transferBlocks( Block blocks[], blocks[i], ReceivedDeletedBlockInfo.BlockStatus.RECEIVED_BLOCK, null) }; StorageReceivedDeletedBlocks[] report = { new StorageReceivedDeletedBlocks( - targetStorageID, rdBlocks) }; + new DatanodeStorage(targetStorageID), rdBlocks) }; dataNodeProto.blockReceivedAndDeleted(receivedDNReg, bpid, report); } } @@ -1157,7 +1157,8 @@ private ExtendedBlock addBlocks(String fileName, String clientName) loc.getBlock().getLocalBlock(), ReceivedDeletedBlockInfo.BlockStatus.RECEIVED_BLOCK, null) }; StorageReceivedDeletedBlocks[] report = { new StorageReceivedDeletedBlocks( - datanodes[dnIdx].storage.getStorageID(), rdBlocks) }; + new DatanodeStorage(datanodes[dnIdx].storage.getStorageID()), + rdBlocks) }; dataNodeProto.blockReceivedAndDeleted(datanodes[dnIdx].dnRegistration, bpid, report); } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestDeadDatanode.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestDeadDatanode.java index 14b14b2f81..69989346af 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestDeadDatanode.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestDeadDatanode.java @@ -102,7 +102,8 @@ public void testDeadDatanode() throws Exception { ReceivedDeletedBlockInfo.BlockStatus.RECEIVED_BLOCK, null) }; StorageReceivedDeletedBlocks[] storageBlocks = { - new StorageReceivedDeletedBlocks(reg.getDatanodeUuid(), blocks) }; + new StorageReceivedDeletedBlocks( + new DatanodeStorage(reg.getDatanodeUuid()), blocks) }; // Ensure blockReceived call from dead datanode is not rejected with // IOException, since it's async, but the node remains unregistered.