|
@@ -38,6 +38,7 @@ import org.apache.hadoop.hdfs.protocol.LocatedBlock;
|
|
|
import org.apache.hadoop.hdfs.server.balancer.Dispatcher.DBlock;
|
|
|
import org.apache.hadoop.hdfs.server.balancer.ExitStatus;
|
|
|
import org.apache.hadoop.hdfs.server.balancer.NameNodeConnector;
|
|
|
+import org.apache.hadoop.hdfs.server.balancer.TestBalancer;
|
|
|
import org.apache.hadoop.hdfs.server.mover.Mover.MLocation;
|
|
|
import org.apache.hadoop.hdfs.server.namenode.ha.HATestUtil;
|
|
|
import org.apache.hadoop.test.GenericTestUtils;
|
|
@@ -46,6 +47,21 @@ import org.junit.Assert;
|
|
|
import org.junit.Test;
|
|
|
|
|
|
public class TestMover {
|
|
|
+
|
|
|
+ static final int DEFAULT_BLOCK_SIZE = 100;
|
|
|
+
|
|
|
+ static {
|
|
|
+ TestBalancer.initTestSetup();
|
|
|
+ }
|
|
|
+
|
|
|
+ static void initConf(Configuration conf) {
|
|
|
+ conf.setLong(DFSConfigKeys.DFS_BLOCK_SIZE_KEY, DEFAULT_BLOCK_SIZE);
|
|
|
+ conf.setInt(DFSConfigKeys.DFS_BYTES_PER_CHECKSUM_KEY, DEFAULT_BLOCK_SIZE);
|
|
|
+ conf.setLong(DFSConfigKeys.DFS_HEARTBEAT_INTERVAL_KEY, 1L);
|
|
|
+ conf.setLong(DFSConfigKeys.DFS_NAMENODE_REPLICATION_INTERVAL_KEY, 1L);
|
|
|
+ conf.setLong(DFSConfigKeys.DFS_BALANCER_MOVEDWINWIDTH_KEY, 2000L);
|
|
|
+ }
|
|
|
+
|
|
|
static Mover newMover(Configuration conf) throws IOException {
|
|
|
final Collection<URI> namenodes = DFSUtil.getNsServiceRpcUris(conf);
|
|
|
Assert.assertEquals(1, namenodes.size());
|
|
@@ -97,6 +113,7 @@ public class TestMover {
|
|
|
@Test
|
|
|
public void testScheduleBlockWithinSameNode() throws Exception {
|
|
|
final Configuration conf = new HdfsConfiguration();
|
|
|
+ initConf(conf);
|
|
|
final MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf)
|
|
|
.numDataNodes(3)
|
|
|
.storageTypes(
|
|
@@ -285,6 +302,7 @@ public class TestMover {
|
|
|
public void testTwoReplicaSameStorageTypeShouldNotSelect() throws Exception {
|
|
|
// HDFS-8147
|
|
|
final Configuration conf = new HdfsConfiguration();
|
|
|
+ initConf(conf);
|
|
|
final MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf)
|
|
|
.numDataNodes(3)
|
|
|
.storageTypes(
|
|
@@ -361,6 +379,7 @@ public class TestMover {
|
|
|
public void testMoverFailedRetry() throws Exception {
|
|
|
// HDFS-8147
|
|
|
final Configuration conf = new HdfsConfiguration();
|
|
|
+ initConf(conf);
|
|
|
conf.set(DFSConfigKeys.DFS_MOVER_RETRY_MAX_ATTEMPTS_KEY, "2");
|
|
|
final MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf)
|
|
|
.numDataNodes(3)
|