From common-commits-return-82676-archive-asf-public=cust-asf.ponee.io@hadoop.apache.org Fri May 11 18:51:54 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 0313D180674 for ; Fri, 11 May 2018 18:51:53 +0200 (CEST) Received: (qmail 71057 invoked by uid 500); 11 May 2018 16:51:52 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 70717 invoked by uid 99); 11 May 2018 16:51:52 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 May 2018 16:51:52 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id DC3DBDFFAC; Fri, 11 May 2018 16:51:51 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: inigoiri@apache.org To: common-commits@hadoop.apache.org Date: Fri, 11 May 2018 16:51:54 -0000 Message-Id: In-Reply-To: <94555e1a2b9a4ea8a57d59c257e6b358@git.apache.org> References: <94555e1a2b9a4ea8a57d59c257e6b358@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [4/5] hadoop git commit: HDFS-13542. TestBlockManager#testNeededReplicationWhileAppending fails due to improper cluster shutdown in TestBlockManager#testBlockManagerMachinesArray on Windows. Contributed by Anbang Hu. HDFS-13542. TestBlockManager#testNeededReplicationWhileAppending fails due to improper cluster shutdown in TestBlockManager#testBlockManagerMachinesArray on Windows. Contributed by Anbang Hu. Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/d88d9f28 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/d88d9f28 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/d88d9f28 Branch: refs/heads/branch-2 Commit: d88d9f2874f5f4ce2b07ba9435094cd4a34fbb31 Parents: 11794e5 Author: Inigo Goiri Authored: Fri May 11 09:50:40 2018 -0700 Committer: Inigo Goiri Committed: Fri May 11 09:50:40 2018 -0700 ---------------------------------------------------------------------- .../blockmanagement/TestBlockManager.java | 155 ++++++++++--------- 1 file changed, 85 insertions(+), 70 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/d88d9f28/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestBlockManager.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestBlockManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestBlockManager.java index ad84805..dca3dc8 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestBlockManager.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestBlockManager.java @@ -441,8 +441,8 @@ public class TestBlockManager { String src = "/test-file"; Path file = new Path(src); MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).build(); - cluster.waitActive(); try { + cluster.waitActive(); BlockManager bm = cluster.getNamesystem().getBlockManager(); FileSystem fs = cluster.getFileSystem(); NamenodeProtocols namenode = cluster.getNameNodeRpc(); @@ -481,7 +481,9 @@ public class TestBlockManager { IOUtils.closeStream(out); } } finally { - cluster.shutdown(); + if (cluster != null) { + cluster.shutdown(); + } } } @@ -970,7 +972,9 @@ public class TestBlockManager { assertTrue(fs.exists(file1)); fs.delete(file1, true); assertTrue(!fs.exists(file1)); - cluster.shutdown(); + if (cluster != null) { + cluster.shutdown(); + } } } @@ -1070,7 +1074,9 @@ public class TestBlockManager { assertEquals(0, bm.getBlockOpQueueLength()); assertTrue(doneLatch.await(1, TimeUnit.SECONDS)); } finally { - cluster.shutdown(); + if (cluster != null) { + cluster.shutdown(); + } } } @@ -1145,7 +1151,9 @@ public class TestBlockManager { long batched = MetricsAsserts.getLongCounter("BlockOpsBatched", rb); assertTrue(batched > 0); } finally { - cluster.shutdown(); + if (cluster != null) { + cluster.shutdown(); + } } } @@ -1154,76 +1162,83 @@ public class TestBlockManager { final Configuration conf = new HdfsConfiguration(); final MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).numDataNodes(4).build(); - cluster.waitActive(); - BlockManager blockManager = cluster.getNamesystem().getBlockManager(); - FileSystem fs = cluster.getFileSystem(); - final Path filePath = new Path("/tmp.txt"); - final long fileLen = 1L; - DFSTestUtil.createFile(fs, filePath, fileLen, (short) 3, 1L); - DFSTestUtil.waitForReplication((DistributedFileSystem)fs, - filePath, (short) 3, 60000); - ArrayList datanodes = cluster.getDataNodes(); - assertEquals(datanodes.size(), 4); - FSNamesystem ns = cluster.getNamesystem(); - // get the block - final String bpid = cluster.getNamesystem().getBlockPoolId(); - File storageDir = cluster.getInstanceStorageDir(0, 0); - File dataDir = MiniDFSCluster.getFinalizedDir(storageDir, bpid); - assertTrue("Data directory does not exist", dataDir.exists()); - BlockInfo blockInfo = blockManager.blocksMap.getBlocks().iterator().next(); - ExtendedBlock blk = new ExtendedBlock(bpid, blockInfo.getBlockId(), - blockInfo.getNumBytes(), blockInfo.getGenerationStamp()); - DatanodeDescriptor failedStorageDataNode = - blockManager.getStoredBlock(blockInfo).getDatanode(0); - DatanodeDescriptor corruptStorageDataNode = - blockManager.getStoredBlock(blockInfo).getDatanode(1); - - ArrayList reports = new ArrayList(); - for(int i=0; i datanodes = cluster.getDataNodes(); + assertEquals(datanodes.size(), 4); + FSNamesystem ns = cluster.getNamesystem(); + // get the block + final String bpid = cluster.getNamesystem().getBlockPoolId(); + File storageDir = cluster.getInstanceStorageDir(0, 0); + File dataDir = MiniDFSCluster.getFinalizedDir(storageDir, bpid); + assertTrue("Data directory does not exist", dataDir.exists()); + BlockInfo blockInfo = + blockManager.blocksMap.getBlocks().iterator().next(); + ExtendedBlock blk = new ExtendedBlock(bpid, blockInfo.getBlockId(), + blockInfo.getNumBytes(), blockInfo.getGenerationStamp()); + DatanodeDescriptor failedStorageDataNode = + blockManager.getStoredBlock(blockInfo).getDatanode(0); + DatanodeDescriptor corruptStorageDataNode = + blockManager.getStoredBlock(blockInfo).getDatanode(1); + + ArrayList reports = new ArrayList(); + for(int i=0; i