Skip to content

Commit 2d3908c

Browse files
committed
HBASE-29612 Remove HBaseTestingUtil.forceChangeTaskLogDir
1 parent 04d48ee commit 2d3908c

4 files changed

Lines changed: 12 additions & 38 deletions

File tree

hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupBase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,8 @@ public static void setUpHelper() throws Exception {
310310
// Set MultiWAL (with 2 default WAL files per RS)
311311
conf1.set(WALFactory.WAL_PROVIDER, provider);
312312
TEST_UTIL.startMiniCluster();
313+
conf1 = TEST_UTIL.getConfiguration();
314+
TEST_UTIL.startMiniMapReduceCluster();
313315

314316
if (useSecondCluster) {
315317
conf2 = HBaseConfiguration.create(conf1);
@@ -322,9 +324,7 @@ public static void setUpHelper() throws Exception {
322324
CommonFSUtils.setWALRootDir(TEST_UTIL2.getConfiguration(), p);
323325
TEST_UTIL2.startMiniCluster();
324326
}
325-
conf1 = TEST_UTIL.getConfiguration();
326327

327-
TEST_UTIL.startMiniMapReduceCluster();
328328
BACKUP_ROOT_DIR =
329329
new Path(new Path(TEST_UTIL.getConfiguration().get("fs.defaultFS")), BACKUP_ROOT_DIR)
330330
.toString();

hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupHFileCleaner.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import org.apache.hadoop.hbase.TableName;
3434
import org.apache.hadoop.hbase.backup.impl.BackupSystemTable;
3535
import org.apache.hadoop.hbase.testclassification.MasterTests;
36-
import org.apache.hadoop.hbase.testclassification.SmallTests;
36+
import org.apache.hadoop.hbase.testclassification.MediumTests;
3737
import org.junit.After;
3838
import org.junit.AfterClass;
3939
import org.junit.Before;
@@ -46,7 +46,7 @@
4646

4747
import org.apache.hbase.thirdparty.com.google.common.collect.Sets;
4848

49-
@Category({ MasterTests.class, SmallTests.class })
49+
@Category({ MasterTests.class, MediumTests.class })
5050
public class TestBackupHFileCleaner {
5151

5252
@ClassRule

hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupSmallTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222
import org.apache.hadoop.fs.Path;
2323
import org.apache.hadoop.fs.permission.FsPermission;
2424
import org.apache.hadoop.hbase.HBaseClassTestRule;
25-
import org.apache.hadoop.hbase.testclassification.SmallTests;
25+
import org.apache.hadoop.hbase.testclassification.MediumTests;
2626
import org.apache.hadoop.hdfs.DFSTestUtil;
2727
import org.apache.hadoop.security.UserGroupInformation;
2828
import org.junit.ClassRule;
2929
import org.junit.Test;
3030
import org.junit.experimental.categories.Category;
3131

32-
@Category(SmallTests.class)
32+
@Category(MediumTests.class)
3333
public class TestBackupSmallTests extends TestBackupBase {
3434

3535
@ClassRule

hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtil.java

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import java.io.OutputStream;
2929
import java.io.UncheckedIOException;
3030
import java.lang.reflect.Field;
31-
import java.lang.reflect.Modifier;
3231
import java.net.BindException;
3332
import java.net.DatagramSocket;
3433
import java.net.InetAddress;
@@ -136,7 +135,6 @@
136135
import org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread;
137136
import org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread;
138137
import org.apache.hadoop.hbase.util.Pair;
139-
import org.apache.hadoop.hbase.util.ReflectionUtils;
140138
import org.apache.hadoop.hbase.util.RetryCounter;
141139
import org.apache.hadoop.hbase.util.Threads;
142140
import org.apache.hadoop.hbase.wal.WAL;
@@ -152,7 +150,6 @@
152150
import org.apache.hadoop.hdfs.server.namenode.EditLogFileOutputStream;
153151
import org.apache.hadoop.mapred.JobConf;
154152
import org.apache.hadoop.mapred.MiniMRCluster;
155-
import org.apache.hadoop.mapred.TaskLog;
156153
import org.apache.hadoop.minikdc.MiniKdc;
157154
import org.apache.yetus.audience.InterfaceAudience;
158155
import org.apache.yetus.audience.InterfaceStability;
@@ -2295,6 +2292,9 @@ public HRegionServer getRSForFirstRegionInTable(TableName tableName)
22952292

22962293
/**
22972294
* Starts a <code>MiniMRCluster</code> with a default number of <code>TaskTracker</code>'s.
2295+
* MiniMRCluster caches hadoop.log.dir when first started. It is not possible to start multiple
2296+
* MiniMRCluster instances with different log dirs. MiniMRCluster is only to be used from when the
2297+
* test is run from a separate VM (i.e not in SmallTests)
22982298
* @throws IOException When starting the cluster fails.
22992299
*/
23002300
public MiniMRCluster startMiniMapReduceCluster() throws IOException {
@@ -2305,35 +2305,11 @@ public MiniMRCluster startMiniMapReduceCluster() throws IOException {
23052305
return mrCluster;
23062306
}
23072307

2308-
/**
2309-
* Tasktracker has a bug where changing the hadoop.log.dir system property will not change its
2310-
* internal static LOG_DIR variable.
2311-
*/
2312-
private void forceChangeTaskLogDir() {
2313-
Field logDirField;
2314-
try {
2315-
logDirField = TaskLog.class.getDeclaredField("LOG_DIR");
2316-
logDirField.setAccessible(true);
2317-
2318-
Field modifiersField = ReflectionUtils.getModifiersField();
2319-
modifiersField.setAccessible(true);
2320-
modifiersField.setInt(logDirField, logDirField.getModifiers() & ~Modifier.FINAL);
2321-
2322-
logDirField.set(null, new File(hadoopLogDir, "userlogs"));
2323-
} catch (SecurityException e) {
2324-
throw new RuntimeException(e);
2325-
} catch (NoSuchFieldException e) {
2326-
throw new RuntimeException(e);
2327-
} catch (IllegalArgumentException e) {
2328-
throw new RuntimeException(e);
2329-
} catch (IllegalAccessException e) {
2330-
throw new RuntimeException(e);
2331-
}
2332-
}
2333-
23342308
/**
23352309
* Starts a <code>MiniMRCluster</code>. Call {@link #setFileSystemURI(String)} to use a different
2336-
* filesystem.
2310+
* filesystem. MiniMRCluster caches hadoop.log.dir when first started. It is not possible to start
2311+
* multiple MiniMRCluster instances with different log dirs. MiniMRCluster is only to be used from
2312+
* when the test is run from a separate VM (i.e not in SmallTests)
23372313
* @param servers The number of <code>TaskTracker</code>'s to start.
23382314
* @throws IOException When starting the cluster fails.
23392315
*/
@@ -2345,8 +2321,6 @@ private void startMiniMapReduceCluster(final int servers) throws IOException {
23452321
setupClusterTestDir();
23462322
createDirsAndSetProperties();
23472323

2348-
forceChangeTaskLogDir();
2349-
23502324
//// hadoop2 specific settings
23512325
// Tests were failing because this process used 6GB of virtual memory and was getting killed.
23522326
// we up the VM usable so that processes don't get killed.

0 commit comments

Comments
 (0)