|
@@ -18,6 +18,7 @@
|
|
|
|
|
|
package org.apache.hadoop.hdfs.server.namenode;
|
|
|
|
|
|
+import static org.apache.hadoop.hdfs.MiniDFSCluster.HDFS_MINIDFS_BASEDIR;
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
import static org.junit.Assert.assertFalse;
|
|
|
import static org.junit.Assert.assertNotNull;
|
|
@@ -195,7 +196,9 @@ public class TestFsck {
|
|
|
conf.setLong(DFSConfigKeys.DFS_NAMENODE_ACCESSTIME_PRECISION_KEY,
|
|
|
precision);
|
|
|
conf.setLong(DFSConfigKeys.DFS_BLOCKREPORT_INTERVAL_MSEC_KEY, 10000L);
|
|
|
- cluster = new MiniDFSCluster.Builder(conf).numDataNodes(4).build();
|
|
|
+ File builderBaseDir = new File(GenericTestUtils.getRandomizedTempPath());
|
|
|
+ cluster = new MiniDFSCluster.Builder(conf, builderBaseDir)
|
|
|
+ .numDataNodes(4).build();
|
|
|
fs = cluster.getFileSystem();
|
|
|
final String fileName = "/srcdat";
|
|
|
util.createFiles(fs, fileName);
|
|
@@ -283,7 +286,9 @@ public class TestFsck {
|
|
|
setNumFiles(20).build();
|
|
|
FileSystem fs = null;
|
|
|
conf.setLong(DFSConfigKeys.DFS_BLOCKREPORT_INTERVAL_MSEC_KEY, 10000L);
|
|
|
- cluster = new MiniDFSCluster.Builder(conf).numDataNodes(4).build();
|
|
|
+ File builderBaseDir = new File(GenericTestUtils.getRandomizedTempPath());
|
|
|
+ cluster = new MiniDFSCluster.Builder(conf, builderBaseDir)
|
|
|
+ .numDataNodes(4).build();
|
|
|
fs = cluster.getFileSystem();
|
|
|
util.createFiles(fs, "/srcdat");
|
|
|
util.waitReplication(fs, "/srcdat", (short)3);
|
|
@@ -301,7 +306,9 @@ public class TestFsck {
|
|
|
conf.setLong(DFSConfigKeys.DFS_BLOCKREPORT_INTERVAL_MSEC_KEY, 10000L);
|
|
|
|
|
|
// Create a cluster with the current user, write some files
|
|
|
- cluster = new MiniDFSCluster.Builder(conf).numDataNodes(4).build();
|
|
|
+ File builderBaseDir = new File(GenericTestUtils.getRandomizedTempPath());
|
|
|
+ cluster = new MiniDFSCluster.Builder(conf, builderBaseDir)
|
|
|
+ .numDataNodes(4).build();
|
|
|
final MiniDFSCluster c2 = cluster;
|
|
|
final String dir = "/dfsck";
|
|
|
final Path dirpath = new Path(dir);
|
|
@@ -347,8 +354,9 @@ public class TestFsck {
|
|
|
DFSTestUtil util = new DFSTestUtil("TestFsck", 5, 3,
|
|
|
(5 * dfsBlockSize) + (dfsBlockSize - 1), 5 * dfsBlockSize);
|
|
|
FileSystem fs = null;
|
|
|
- cluster = new MiniDFSCluster.Builder(conf).
|
|
|
- numDataNodes(numDatanodes).build();
|
|
|
+ File builderBaseDir = new File(GenericTestUtils.getRandomizedTempPath());
|
|
|
+ cluster = new MiniDFSCluster.Builder(conf, builderBaseDir)
|
|
|
+ .numDataNodes(numDatanodes).build();
|
|
|
String topDir = "/srcdat";
|
|
|
fs = cluster.getFileSystem();
|
|
|
cluster.waitActive();
|
|
@@ -546,7 +554,9 @@ public class TestFsck {
|
|
|
FileSystem fs = null;
|
|
|
conf.setLong(DFSConfigKeys.DFS_BLOCKREPORT_INTERVAL_MSEC_KEY, 10000L);
|
|
|
conf.setInt(DFSConfigKeys.DFS_DATANODE_DIRECTORYSCAN_INTERVAL_KEY, 1);
|
|
|
- cluster = new MiniDFSCluster.Builder(conf).numDataNodes(4).build();
|
|
|
+ File builderBaseDir = new File(GenericTestUtils.getRandomizedTempPath());
|
|
|
+ cluster = new MiniDFSCluster.Builder(conf, builderBaseDir)
|
|
|
+ .numDataNodes(4).build();
|
|
|
String topDir = "/srcdat";
|
|
|
fs = cluster.getFileSystem();
|
|
|
cluster.waitActive();
|
|
@@ -610,7 +620,9 @@ public class TestFsck {
|
|
|
setNumFiles(4).build();
|
|
|
FileSystem fs = null;
|
|
|
conf.setLong(DFSConfigKeys.DFS_BLOCKREPORT_INTERVAL_MSEC_KEY, 10000L);
|
|
|
- cluster = new MiniDFSCluster.Builder(conf).numDataNodes(4).build();
|
|
|
+ File builderBaseDir = new File(GenericTestUtils.getRandomizedTempPath());
|
|
|
+ cluster = new MiniDFSCluster.Builder(conf, builderBaseDir)
|
|
|
+ .numDataNodes(4).build();
|
|
|
String topDir = "/srcdat";
|
|
|
String randomString = "HADOOP ";
|
|
|
fs = cluster.getFileSystem();
|
|
@@ -661,7 +673,9 @@ public class TestFsck {
|
|
|
String outStr = null;
|
|
|
short factor = 1;
|
|
|
|
|
|
- cluster = new MiniDFSCluster.Builder(conf).numDataNodes(1).build();
|
|
|
+ File builderBaseDir = new File(GenericTestUtils.getRandomizedTempPath());
|
|
|
+ cluster = new MiniDFSCluster.Builder(conf, builderBaseDir)
|
|
|
+ .numDataNodes(1).build();
|
|
|
cluster.waitActive();
|
|
|
fs = cluster.getFileSystem();
|
|
|
Path file1 = new Path("/testCorruptBlock");
|
|
@@ -732,7 +746,9 @@ public class TestFsck {
|
|
|
Random random = new Random();
|
|
|
String outStr = null;
|
|
|
short factor = 1;
|
|
|
- cluster = new MiniDFSCluster.Builder(conf).numDataNodes(2).build();
|
|
|
+ File builderBaseDir = new File(GenericTestUtils.getRandomizedTempPath());
|
|
|
+ cluster = new MiniDFSCluster.Builder(conf, builderBaseDir)
|
|
|
+ .numDataNodes(2).build();
|
|
|
cluster.waitActive();
|
|
|
fs = cluster.getFileSystem();
|
|
|
Path file1 = new Path("/testUnderMinReplicatedBlock");
|
|
@@ -803,9 +819,9 @@ public class TestFsck {
|
|
|
conf.setLong(DFSConfigKeys.DFS_BLOCK_SIZE_KEY, blockSize);
|
|
|
conf.setInt(DFSConfigKeys.DFS_REPLICATION_KEY, 1);
|
|
|
|
|
|
- cluster =
|
|
|
- new MiniDFSCluster.Builder(conf).numDataNodes(numDn).hosts(hosts)
|
|
|
- .racks(racks).build();
|
|
|
+ File builderBaseDir = new File(GenericTestUtils.getRandomizedTempPath());
|
|
|
+ cluster = new MiniDFSCluster.Builder(conf, builderBaseDir)
|
|
|
+ .numDataNodes(numDn).hosts(hosts).racks(racks).build();
|
|
|
cluster.waitClusterUp();
|
|
|
final DistributedFileSystem dfs = cluster.getFileSystem();
|
|
|
|
|
@@ -952,7 +968,8 @@ public class TestFsck {
|
|
|
@Test
|
|
|
public void testFsckError() throws Exception {
|
|
|
// bring up a one-node cluster
|
|
|
- cluster = new MiniDFSCluster.Builder(conf).build();
|
|
|
+ File builderBaseDir = new File(GenericTestUtils.getRandomizedTempPath());
|
|
|
+ cluster = new MiniDFSCluster.Builder(conf, builderBaseDir).build();
|
|
|
String fileName = "/test.txt";
|
|
|
Path filePath = new Path(fileName);
|
|
|
FileSystem fs = cluster.getFileSystem();
|
|
@@ -984,7 +1001,8 @@ public class TestFsck {
|
|
|
conf.setInt(DFSConfigKeys.DFS_DATANODE_DIRECTORYSCAN_INTERVAL_KEY, 1);
|
|
|
FileSystem fs = null;
|
|
|
|
|
|
- cluster = new MiniDFSCluster.Builder(conf).build();
|
|
|
+ File builderBaseDir = new File(GenericTestUtils.getRandomizedTempPath());
|
|
|
+ cluster = new MiniDFSCluster.Builder(conf, builderBaseDir).build();
|
|
|
cluster.waitActive();
|
|
|
fs = cluster.getFileSystem();
|
|
|
DFSTestUtil util = new DFSTestUtil.Builder().
|
|
@@ -1047,7 +1065,8 @@ public class TestFsck {
|
|
|
@Test
|
|
|
public void testToCheckTheFsckCommandOnIllegalArguments() throws Exception {
|
|
|
// bring up a one-node cluster
|
|
|
- cluster = new MiniDFSCluster.Builder(conf).build();
|
|
|
+ File builderBaseDir = new File(GenericTestUtils.getRandomizedTempPath());
|
|
|
+ cluster = new MiniDFSCluster.Builder(conf, builderBaseDir).build();
|
|
|
String fileName = "/test.txt";
|
|
|
Path filePath = new Path(fileName);
|
|
|
FileSystem fs = cluster.getFileSystem();
|
|
@@ -1091,8 +1110,9 @@ public class TestFsck {
|
|
|
DistributedFileSystem dfs = null;
|
|
|
|
|
|
// Startup a minicluster
|
|
|
- cluster =
|
|
|
- new MiniDFSCluster.Builder(conf).numDataNodes(numReplicas).build();
|
|
|
+ File builderBaseDir = new File(GenericTestUtils.getRandomizedTempPath());
|
|
|
+ cluster = new MiniDFSCluster.Builder(conf, builderBaseDir)
|
|
|
+ .numDataNodes(numReplicas).build();
|
|
|
assertNotNull("Failed Cluster Creation", cluster);
|
|
|
cluster.waitClusterUp();
|
|
|
dfs = cluster.getFileSystem();
|
|
@@ -1151,9 +1171,9 @@ public class TestFsck {
|
|
|
DistributedFileSystem dfs = null;
|
|
|
|
|
|
// Startup a minicluster
|
|
|
- cluster =
|
|
|
- new MiniDFSCluster.Builder(conf).numDataNodes(numDn).hosts(hosts)
|
|
|
- .racks(racks).build();
|
|
|
+ File builderBaseDir = new File(GenericTestUtils.getRandomizedTempPath());
|
|
|
+ cluster = new MiniDFSCluster.Builder(conf, builderBaseDir)
|
|
|
+ .numDataNodes(numDn).hosts(hosts).racks(racks).build();
|
|
|
assertNotNull("Failed Cluster Creation", cluster);
|
|
|
cluster.waitClusterUp();
|
|
|
dfs = cluster.getFileSystem();
|
|
@@ -1263,7 +1283,9 @@ public class TestFsck {
|
|
|
conf.setLong(DFSConfigKeys.DFS_NAMENODE_ACCESSTIME_PRECISION_KEY,
|
|
|
precision);
|
|
|
conf.setLong(DFSConfigKeys.DFS_BLOCKREPORT_INTERVAL_MSEC_KEY, 10000L);
|
|
|
- cluster = new MiniDFSCluster.Builder(conf).numDataNodes(4).build();
|
|
|
+ File builderBaseDir = new File(GenericTestUtils.getRandomizedTempPath());
|
|
|
+ cluster = new MiniDFSCluster.Builder(conf, builderBaseDir)
|
|
|
+ .numDataNodes(4).build();
|
|
|
fs = cluster.getFileSystem();
|
|
|
final String fileName = "/srcdat";
|
|
|
util.createFiles(fs, fileName);
|
|
@@ -1290,7 +1312,8 @@ public class TestFsck {
|
|
|
*/
|
|
|
@Test
|
|
|
public void testFsckForSnapshotFiles() throws Exception {
|
|
|
- cluster = new MiniDFSCluster.Builder(conf).numDataNodes(1)
|
|
|
+ File builderBaseDir = new File(GenericTestUtils.getRandomizedTempPath());
|
|
|
+ cluster = new MiniDFSCluster.Builder(conf, builderBaseDir).numDataNodes(1)
|
|
|
.build();
|
|
|
String runFsck = runFsck(conf, 0, true, "/", "-includeSnapshots",
|
|
|
"-files");
|
|
@@ -1325,9 +1348,9 @@ public class TestFsck {
|
|
|
conf.setInt(DFSConfigKeys.DFS_REPLICATION_KEY, 2);
|
|
|
|
|
|
DistributedFileSystem dfs = null;
|
|
|
- cluster =
|
|
|
- new MiniDFSCluster.Builder(conf).numDataNodes(numDn).hosts(hosts)
|
|
|
- .racks(racks).build();
|
|
|
+ File builderBaseDir = new File(GenericTestUtils.getRandomizedTempPath());
|
|
|
+ cluster = new MiniDFSCluster.Builder(conf, builderBaseDir)
|
|
|
+ .numDataNodes(numDn).hosts(hosts).racks(racks).build();
|
|
|
|
|
|
assertNotNull("Failed Cluster Creation", cluster);
|
|
|
cluster.waitClusterUp();
|
|
@@ -1380,9 +1403,9 @@ public class TestFsck {
|
|
|
conf.setInt(DFSConfigKeys.DFS_REPLICATION_KEY, 2);
|
|
|
|
|
|
DistributedFileSystem dfs;
|
|
|
- cluster =
|
|
|
- new MiniDFSCluster.Builder(conf).numDataNodes(numDn).hosts(hosts)
|
|
|
- .racks(racks).build();
|
|
|
+ File builderBaseDir = new File(GenericTestUtils.getRandomizedTempPath());
|
|
|
+ cluster = new MiniDFSCluster.Builder(conf, builderBaseDir)
|
|
|
+ .numDataNodes(numDn).hosts(hosts).racks(racks).build();
|
|
|
|
|
|
assertNotNull("Failed Cluster Creation", cluster);
|
|
|
cluster.waitClusterUp();
|
|
@@ -1464,7 +1487,8 @@ public class TestFsck {
|
|
|
conf.setInt(DFSConfigKeys.DFS_NAMENODE_MAINTENANCE_REPLICATION_MIN_KEY,
|
|
|
replFactor);
|
|
|
|
|
|
- cluster = new MiniDFSCluster.Builder(conf)
|
|
|
+ File builderBaseDir = new File(GenericTestUtils.getRandomizedTempPath());
|
|
|
+ cluster = new MiniDFSCluster.Builder(conf, builderBaseDir)
|
|
|
.numDataNodes(numDn)
|
|
|
.hosts(hosts)
|
|
|
.racks(racks)
|
|
@@ -1584,9 +1608,9 @@ public class TestFsck {
|
|
|
conf.setLong(DFSConfigKeys.DFS_BLOCK_SIZE_KEY, blockSize);
|
|
|
conf.setInt(DFSConfigKeys.DFS_REPLICATION_KEY, 1);
|
|
|
|
|
|
- cluster =
|
|
|
- new MiniDFSCluster.Builder(conf).numDataNodes(numDn).hosts(hosts)
|
|
|
- .racks(racks).build();
|
|
|
+ File builderBaseDir = new File(GenericTestUtils.getRandomizedTempPath());
|
|
|
+ cluster = new MiniDFSCluster.Builder(conf, builderBaseDir)
|
|
|
+ .numDataNodes(numDn).hosts(hosts).racks(racks).build();
|
|
|
|
|
|
assertNotNull("Failed Cluster Creation", cluster);
|
|
|
cluster.waitClusterUp();
|
|
@@ -1653,7 +1677,8 @@ public class TestFsck {
|
|
|
*/
|
|
|
@Test
|
|
|
public void testStoragePoliciesCK() throws Exception {
|
|
|
- cluster = new MiniDFSCluster.Builder(conf)
|
|
|
+ File builderBaseDir = new File(GenericTestUtils.getRandomizedTempPath());
|
|
|
+ cluster = new MiniDFSCluster.Builder(conf, builderBaseDir)
|
|
|
.numDataNodes(3)
|
|
|
.storageTypes(
|
|
|
new StorageType[] {StorageType.DISK, StorageType.ARCHIVE})
|
|
@@ -1696,9 +1721,9 @@ public class TestFsck {
|
|
|
conf.setInt(DFSConfigKeys.DFS_REPLICATION_KEY, 1);
|
|
|
|
|
|
DistributedFileSystem dfs;
|
|
|
- cluster =
|
|
|
- new MiniDFSCluster.Builder(conf).numDataNodes(numDn).hosts(hosts)
|
|
|
- .racks(racks).build();
|
|
|
+ File builderBaseDir = new File(GenericTestUtils.getRandomizedTempPath());
|
|
|
+ cluster = new MiniDFSCluster.Builder(conf, builderBaseDir)
|
|
|
+ .numDataNodes(numDn).hosts(hosts).racks(racks).build();
|
|
|
|
|
|
assertNotNull("Failed Cluster Creation", cluster);
|
|
|
cluster.waitClusterUp();
|
|
@@ -1777,7 +1802,8 @@ public class TestFsck {
|
|
|
conf.setInt(DFSConfigKeys.DFS_NAMENODE_MAINTENANCE_REPLICATION_MIN_KEY,
|
|
|
replFactor);
|
|
|
|
|
|
- cluster = new MiniDFSCluster.Builder(conf)
|
|
|
+ File builderBaseDir = new File(GenericTestUtils.getRandomizedTempPath());
|
|
|
+ cluster = new MiniDFSCluster.Builder(conf, builderBaseDir)
|
|
|
.numDataNodes(numDn)
|
|
|
.hosts(hosts)
|
|
|
.racks(racks)
|
|
@@ -1886,7 +1912,8 @@ public class TestFsck {
|
|
|
|
|
|
int numFiles = 3;
|
|
|
int numSnapshots = 0;
|
|
|
- cluster = new MiniDFSCluster.Builder(conf).build();
|
|
|
+ File builderBaseDir = new File(GenericTestUtils.getRandomizedTempPath());
|
|
|
+ cluster = new MiniDFSCluster.Builder(conf, builderBaseDir).build();
|
|
|
cluster.waitActive();
|
|
|
hdfs = cluster.getFileSystem();
|
|
|
DFSTestUtil util = new DFSTestUtil.Builder().
|
|
@@ -1966,7 +1993,8 @@ public class TestFsck {
|
|
|
conf.setLong(DFSConfigKeys.DFS_BLOCKREPORT_INTERVAL_MSEC_KEY, 1000L);
|
|
|
conf.setInt(DFSConfigKeys.DFS_DATANODE_DIRECTORYSCAN_INTERVAL_KEY, 1);
|
|
|
conf.setInt(DFSConfigKeys.DFS_REPLICATION_KEY, replication);
|
|
|
- cluster = new MiniDFSCluster.Builder(conf).build();
|
|
|
+ File builderBaseDir = new File(GenericTestUtils.getRandomizedTempPath());
|
|
|
+ cluster = new MiniDFSCluster.Builder(conf, builderBaseDir).build();
|
|
|
DistributedFileSystem dfs = cluster.getFileSystem();
|
|
|
cluster.waitActive();
|
|
|
|
|
@@ -2061,6 +2089,7 @@ public class TestFsck {
|
|
|
HostsFileWriter hostsFileWriter = new HostsFileWriter();
|
|
|
conf.setLong(DFSConfigKeys.DFS_BLOCK_SIZE_KEY, blockSize);
|
|
|
conf.setInt(DFSConfigKeys.DFS_REPLICATION_KEY, replFactor);
|
|
|
+ conf.set(HDFS_MINIDFS_BASEDIR, GenericTestUtils.getRandomizedTempPath());
|
|
|
if (defineUpgradeDomain) {
|
|
|
conf.setClass(DFSConfigKeys.DFS_NAMENODE_HOSTS_PROVIDER_CLASSNAME_KEY,
|
|
|
CombinedHostFileManager.class, HostConfigManager.class);
|
|
@@ -2107,7 +2136,8 @@ public class TestFsck {
|
|
|
@Test(timeout = 300000)
|
|
|
public void testFsckCorruptWhenOneReplicaIsCorrupt()
|
|
|
throws Exception {
|
|
|
- try (MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf)
|
|
|
+ try (MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf,
|
|
|
+ new File(GenericTestUtils.getRandomizedTempPath()))
|
|
|
.nnTopology(MiniDFSNNTopology.simpleHATopology()).numDataNodes(2)
|
|
|
.build()) {
|
|
|
cluster.waitActive();
|