Skip to content

Commit 1dd647c

Browse files
committed
HDFS-6090. Use MiniDFSCluster.Builder instead of deprecated constructors. Contributed by Akira AJISAKA.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1578669 13f79535-47bb-0310-9956-ffa450edef68
1 parent f60a1fb commit 1dd647c

37 files changed

+79
-62
lines changed

hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,9 @@ Release 2.4.0 - UNRELEASED
409409
HDFS-6106. Reduce default for
410410
dfs.namenode.path.based.cache.refresh.interval.ms (cmccabe)
411411

412+
HDFS-6090. Use MiniDFSCluster.Builder instead of deprecated constructors.
413+
(Akira AJISAKA via jing9)
414+
412415
OPTIMIZATIONS
413416

414417
HDFS-5790. LeaseManager.findPath is very slow when many leases need recovery

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/fs/TestFileSystem.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,8 @@ static void runTestCache(int port) throws Exception {
523523
Configuration conf = new Configuration();
524524
MiniDFSCluster cluster = null;
525525
try {
526-
cluster = new MiniDFSCluster(port, conf, 2, true, true, null, null);
526+
cluster = new MiniDFSCluster.Builder(conf).nameNodePort(port)
527+
.numDataNodes(2).build();
527528
URI uri = cluster.getFileSystem().getUri();
528529
LOG.info("uri=" + uri);
529530

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/HadoopTestCase.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ protected void setUp() throws Exception {
146146
fileSystem = FileSystem.getLocal(new JobConf());
147147
}
148148
else {
149-
dfsCluster = new MiniDFSCluster(new JobConf(), dataNodes, true, null);
149+
dfsCluster = new MiniDFSCluster.Builder(new JobConf())
150+
.numDataNodes(dataNodes).build();
150151
fileSystem = dfsCluster.getFileSystem();
151152
}
152153
if (localMR) {

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/TestCommandLineJobSubmission.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public void testJobShell() throws Exception {
5151
try {
5252
Configuration conf = new Configuration();
5353
//start the mini mr and dfs cluster.
54-
dfs = new MiniDFSCluster(conf, 2 , true, null);
54+
dfs = new MiniDFSCluster.Builder(conf).numDataNodes(2).build();
5555
fs = dfs.getFileSystem();
5656
FSDataOutputStream stream = fs.create(testFile);
5757
stream.write("teststring".getBytes());

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/TestJobSysDirWithDFS.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public void testWithDFS() throws IOException {
125125

126126
JobConf conf = new JobConf();
127127
conf.set(JTConfig.JT_SYSTEM_DIR, "/tmp/custom/mapred/system");
128-
dfs = new MiniDFSCluster(conf, 4, true, null);
128+
dfs = new MiniDFSCluster.Builder(conf).numDataNodes(4).build();
129129
fileSys = dfs.getFileSystem();
130130
mr = new MiniMRCluster(taskTrackers, fileSys.getUri().toString(), 1, null, null, conf);
131131

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/TestLazyOutput.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ public void testLazyOutput() throws Exception {
141141
Configuration conf = new Configuration();
142142

143143
// Start the mini-MR and mini-DFS clusters
144-
dfs = new MiniDFSCluster(conf, NUM_HADOOP_SLAVES, true, null);
144+
dfs = new MiniDFSCluster.Builder(conf).numDataNodes(NUM_HADOOP_SLAVES)
145+
.build();
145146
fileSys = dfs.getFileSystem();
146147
mr = new MiniMRCluster(NUM_HADOOP_SLAVES, fileSys.getUri().toString(), 1);
147148

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/TestMRCJCFileInputFormat.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,10 @@ public class TestMRCJCFileInputFormat extends TestCase {
4444
MiniDFSCluster dfs = null;
4545

4646
private MiniDFSCluster newDFSCluster(JobConf conf) throws Exception {
47-
return new MiniDFSCluster(conf, 4, true,
48-
new String[]{"/rack0", "/rack0",
49-
"/rack1", "/rack1"},
50-
new String[]{"host0", "host1",
51-
"host2", "host3"});
47+
return new MiniDFSCluster.Builder(conf).numDataNodes(4)
48+
.racks(new String[]{"/rack0", "/rack0", "/rack1", "/rack1"})
49+
.hosts(new String[]{"host0", "host1", "host2", "host3"})
50+
.build();
5251
}
5352

5453
public void testLocality() throws Exception {
@@ -162,7 +161,7 @@ public void testMultiLevelInput() throws Exception {
162161
JobConf job = new JobConf(conf);
163162

164163
job.setBoolean("dfs.replication.considerLoad", false);
165-
dfs = new MiniDFSCluster(job, 1, true, rack1, hosts1);
164+
dfs = new MiniDFSCluster.Builder(job).racks(rack1).hosts(hosts1).build();
166165
dfs.waitActive();
167166

168167
String namenode = (dfs.getFileSystem()).getUri().getHost() + ":" +

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/TestMerge.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ public void testMerge() throws Exception {
7676
try {
7777
Configuration conf = new Configuration();
7878
// Start the mini-MR and mini-DFS clusters
79-
dfsCluster = new MiniDFSCluster(conf, NUM_HADOOP_DATA_NODES, true, null);
79+
dfsCluster = new MiniDFSCluster.Builder(conf)
80+
.numDataNodes(NUM_HADOOP_DATA_NODES).build();
8081
fileSystem = dfsCluster.getFileSystem();
8182
mrCluster = MiniMRClientClusterFactory.create(this.getClass(),
8283
NUM_HADOOP_DATA_NODES, conf);

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/TestMiniMRChildTask.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ public void reduce(WritableComparable key, Iterator<Writable> values,
324324
@BeforeClass
325325
public static void setup() throws IOException {
326326
// create configuration, dfs, file system and mapred cluster
327-
dfs = new MiniDFSCluster(conf, 1, true, null);
327+
dfs = new MiniDFSCluster.Builder(conf).build();
328328
fileSys = dfs.getFileSystem();
329329

330330
if (!(new File(MiniMRYarnCluster.APPJAR)).exists()) {

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/TestMiniMRClasspath.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public void testClassPath() throws IOException {
169169
final int jobTrackerPort = 60050;
170170

171171
Configuration conf = new Configuration();
172-
dfs = new MiniDFSCluster(conf, 1, true, null);
172+
dfs = new MiniDFSCluster.Builder(conf).build();
173173
fileSys = dfs.getFileSystem();
174174
namenode = fileSys.getUri().toString();
175175
mr = new MiniMRCluster(taskTrackers, namenode, 3);
@@ -201,7 +201,7 @@ public void testExternalWritable()
201201
final int taskTrackers = 4;
202202

203203
Configuration conf = new Configuration();
204-
dfs = new MiniDFSCluster(conf, 1, true, null);
204+
dfs = new MiniDFSCluster.Builder(conf).build();
205205
fileSys = dfs.getFileSystem();
206206
namenode = fileSys.getUri().toString();
207207
mr = new MiniMRCluster(taskTrackers, namenode, 3);

0 commit comments

Comments
 (0)