HDFS-12913. TestDNFencingWithReplication sometimes fails because of NameNode in standby state. Contributed by Zsolt Venczel.
This commit is contained in:
parent
2a48b3594c
commit
45a47198b4
|
@ -60,11 +60,14 @@ public class TestDNFencingWithReplication {
|
||||||
private static class ReplicationToggler extends RepeatingTestThread {
|
private static class ReplicationToggler extends RepeatingTestThread {
|
||||||
private final FileSystem fs;
|
private final FileSystem fs;
|
||||||
private final Path path;
|
private final Path path;
|
||||||
|
private final MiniDFSCluster cluster;
|
||||||
|
|
||||||
public ReplicationToggler(TestContext ctx, FileSystem fs, Path p) {
|
ReplicationToggler(TestContext ctx, FileSystem fs, Path p,
|
||||||
|
MiniDFSCluster cluster) {
|
||||||
super(ctx);
|
super(ctx);
|
||||||
this.fs = fs;
|
this.fs = fs;
|
||||||
this.path = p;
|
this.path = p;
|
||||||
|
this.cluster = cluster;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -81,6 +84,7 @@ public class TestDNFencingWithReplication {
|
||||||
@Override
|
@Override
|
||||||
public Boolean get() {
|
public Boolean get() {
|
||||||
try {
|
try {
|
||||||
|
cluster.waitActive();
|
||||||
BlockLocation[] blocks = fs.getFileBlockLocations(path, 0, 10);
|
BlockLocation[] blocks = fs.getFileBlockLocations(path, 0, 10);
|
||||||
Assert.assertEquals(1, blocks.length);
|
Assert.assertEquals(1, blocks.length);
|
||||||
return blocks[0].getHosts().length == replicas;
|
return blocks[0].getHosts().length == replicas;
|
||||||
|
@ -90,8 +94,8 @@ public class TestDNFencingWithReplication {
|
||||||
}
|
}
|
||||||
}, 100, 60000);
|
}, 100, 60000);
|
||||||
} catch (TimeoutException te) {
|
} catch (TimeoutException te) {
|
||||||
throw new IOException("Timed out waiting for " + replicas + " replicas " +
|
throw new IOException("Timed out waiting for " + replicas +
|
||||||
"on path " + path);
|
" replicas on path " + path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +126,7 @@ public class TestDNFencingWithReplication {
|
||||||
for (int i = 0; i < NUM_THREADS; i++) {
|
for (int i = 0; i < NUM_THREADS; i++) {
|
||||||
Path p = new Path("/test-" + i);
|
Path p = new Path("/test-" + i);
|
||||||
DFSTestUtil.createFile(fs, p, BLOCK_SIZE*10, (short)3, (long)i);
|
DFSTestUtil.createFile(fs, p, BLOCK_SIZE*10, (short)3, (long)i);
|
||||||
togglers.addThread(new ReplicationToggler(togglers, fs, p));
|
togglers.addThread(new ReplicationToggler(togglers, fs, p, cluster));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start a separate thread which will make sure that replication
|
// Start a separate thread which will make sure that replication
|
||||||
|
|
Loading…
Reference in New Issue