You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by br...@apache.org on 2016/11/01 16:03:11 UTC
hadoop git commit: HDFS-10499.
TestNameNodeMetadataConsistency#testGenerationStampInFuture Fails
Intermittently. Contributed by Yiqun Lin.
Repository: hadoop
Updated Branches:
refs/heads/trunk 5b577f43a -> 808f5d898
HDFS-10499. TestNameNodeMetadataConsistency#testGenerationStampInFuture Fails Intermittently. Contributed by Yiqun Lin.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/808f5d89
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/808f5d89
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/808f5d89
Branch: refs/heads/trunk
Commit: 808f5d8985323bc1afa79a1c5d24b229f535ec3b
Parents: 5b577f4
Author: Brahma Reddy Battula <br...@apache.org>
Authored: Tue Nov 1 21:32:52 2016 +0530
Committer: Brahma Reddy Battula <br...@apache.org>
Committed: Tue Nov 1 21:32:52 2016 +0530
----------------------------------------------------------------------
.../TestNameNodeMetadataConsistency.java | 45 +++++++++++---------
1 file changed, 26 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/808f5d89/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeMetadataConsistency.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeMetadataConsistency.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeMetadataConsistency.java
index 6c2832e..fb9705d 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeMetadataConsistency.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeMetadataConsistency.java
@@ -27,6 +27,9 @@ import org.apache.hadoop.hdfs.MiniDFSCluster.DataNodeProperties;
import org.apache.hadoop.hdfs.protocol.ExtendedBlock;
import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo;
import org.apache.hadoop.hdfs.server.blockmanagement.BlockManagerTestUtil;
+import org.apache.hadoop.test.GenericTestUtils;
+
+import com.google.common.base.Supplier;
import org.junit.After;
import org.junit.Before;
@@ -34,7 +37,6 @@ import org.junit.Test;
import java.io.IOException;
import java.io.OutputStream;
-import java.util.concurrent.TimeUnit;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -73,8 +75,7 @@ public class TestNameNodeMetadataConsistency {
* safe mode while it is in startup mode.
*/
@Test
- public void testGenerationStampInFuture() throws
- IOException, InterruptedException {
+ public void testGenerationStampInFuture() throws Exception {
cluster.waitActive();
FileSystem fs = cluster.getFileSystem();
@@ -105,9 +106,7 @@ public class TestNameNodeMetadataConsistency {
cluster.getNameNode().getNamesystem().getBlockManager());
cluster.restartDataNode(dnProps);
- waitTil(TimeUnit.SECONDS.toMillis(SCAN_WAIT));
- cluster.triggerBlockReports();
- waitTil(TimeUnit.SECONDS.toMillis(SCAN_WAIT));
+ waitForNumBytes(TEST_DATA_IN_FUTURE.length());
// Make sure that we find all written bytes in future block
assertEquals(TEST_DATA_IN_FUTURE.length(),
@@ -122,9 +121,7 @@ public class TestNameNodeMetadataConsistency {
* hence we should not have positive count of Blocks in future.
*/
@Test
- public void testEnsureGenStampsIsStartupOnly() throws
- IOException, InterruptedException {
-
+ public void testEnsureGenStampsIsStartupOnly() throws Exception {
String testData = " This is test data";
cluster.restartDataNodes();
cluster.restartNameNodes();
@@ -153,21 +150,31 @@ public class TestNameNodeMetadataConsistency {
cluster.getNameNode().getNamesystem().writeUnlock();
cluster.restartDataNode(dnProps);
- waitTil(TimeUnit.SECONDS.toMillis(SCAN_WAIT));
- cluster.triggerBlockReports();
- waitTil(TimeUnit.SECONDS.toMillis(SCAN_WAIT));
-
+ waitForNumBytes(0);
// Make sure that there are no bytes in future since isInStartupSafe
// mode is not true.
assertEquals(0, cluster.getNameNode().getBytesWithFutureGenerationStamps());
}
- private void waitTil(long waitPeriod) {
- try {
- Thread.sleep(waitPeriod);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
+ private void waitForNumBytes(final int numBytes) throws Exception {
+ GenericTestUtils.waitFor(new Supplier<Boolean>() {
+
+ @Override
+ public Boolean get() {
+ try {
+ cluster.triggerBlockReports();
+ // Compare the number of bytes
+ if (cluster.getNameNode().getBytesWithFutureGenerationStamps()
+ == numBytes) {
+ return true;
+ }
+ } catch (Exception e) {
+ // Ignore the exception
+ }
+
+ return false;
+ }
+ }, SCAN_WAIT * 1000, 60000);
}
}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org