From dcb0b853332046f8bf5bb02b8ddbba5b3464fe8f Mon Sep 17 00:00:00 2001 From: Andrew Wang Date: Thu, 17 Oct 2013 20:31:13 +0000 Subject: [PATCH] HDFS-5383. fix broken caching unit tests (Andrew Wang) git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-4949@1533253 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-4949.txt | 2 ++ .../hadoop/hdfs/server/namenode/CacheManager.java | 1 - ...tClientNamenodeProtocolServerSideTranslatorPB.java | 1 + .../hdfs/server/datanode/TestFsDatasetCache.java | 11 ++++++----- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-4949.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-4949.txt index 863a8a1a304..b654ac448d3 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-4949.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-4949.txt @@ -99,3 +99,5 @@ HDFS-4949 (Unreleased) HDFS-5373. hdfs cacheadmin -addDirective short usage does not mention -replication parameter. (cnauroth) + + HDFS-5383. fix broken caching unit tests. (Andrew Wang) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/CacheManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/CacheManager.java index 39a0aab2d61..9661ae2155b 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/CacheManager.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/CacheManager.java @@ -662,7 +662,6 @@ public final class CacheManager { * @throws IOException */ public void loadState(DataInput in) throws IOException { - assert namesystem.hasWriteLock(); nextEntryId = in.readLong(); // pools need to be loaded first since entries point to their parent pool loadPools(in); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/protocolPB/TestClientNamenodeProtocolServerSideTranslatorPB.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/protocolPB/TestClientNamenodeProtocolServerSideTranslatorPB.java index 4cf53253c18..cfc09c7cfad 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/protocolPB/TestClientNamenodeProtocolServerSideTranslatorPB.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/protocolPB/TestClientNamenodeProtocolServerSideTranslatorPB.java @@ -41,6 +41,7 @@ public class TestClientNamenodeProtocolServerSideTranslatorPB { setDirective(PathBasedCacheDirectiveProto.newBuilder(). setPath(""). setPool("pool"). + setReplication(1). build()). build(); ClientNamenodeProtocolServerSideTranslatorPB translator = diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestFsDatasetCache.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestFsDatasetCache.java index e35a480f0e3..ce22c951ffe 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestFsDatasetCache.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestFsDatasetCache.java @@ -18,7 +18,8 @@ package org.apache.hadoop.hdfs.server.datanode; import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.*; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyInt; import static org.mockito.Mockito.doReturn; import java.io.FileInputStream; @@ -41,7 +42,7 @@ import org.apache.hadoop.hdfs.protocolPB.DatanodeProtocolClientSideTranslatorPB; import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsDatasetSpi; import org.apache.hadoop.hdfs.server.namenode.FSImage; import org.apache.hadoop.hdfs.server.namenode.NameNode; -import org.apache.hadoop.hdfs.server.protocol.BlockCommand; +import org.apache.hadoop.hdfs.server.protocol.BlockIdCommand; import org.apache.hadoop.hdfs.server.protocol.CacheReport; import org.apache.hadoop.hdfs.server.protocol.DatanodeCommand; import org.apache.hadoop.hdfs.server.protocol.DatanodeProtocol; @@ -139,11 +140,11 @@ public class TestFsDatasetCache { private static DatanodeCommand getResponse(HdfsBlockLocation[] locs, int action) { String bpid = locs[0].getLocatedBlock().getBlock().getBlockPoolId(); - Block[] blocks = new Block[locs.length]; + long[] blocks = new long[locs.length]; for (int i=0; i