2828import java .io .OutputStream ;
2929import java .io .UncheckedIOException ;
3030import java .lang .reflect .Field ;
31- import java .lang .reflect .Modifier ;
3231import java .net .BindException ;
3332import java .net .DatagramSocket ;
3433import java .net .InetAddress ;
136135import org .apache .hadoop .hbase .util .JVMClusterUtil .MasterThread ;
137136import org .apache .hadoop .hbase .util .JVMClusterUtil .RegionServerThread ;
138137import org .apache .hadoop .hbase .util .Pair ;
139- import org .apache .hadoop .hbase .util .ReflectionUtils ;
140138import org .apache .hadoop .hbase .util .RetryCounter ;
141139import org .apache .hadoop .hbase .util .Threads ;
142140import org .apache .hadoop .hbase .wal .WAL ;
152150import org .apache .hadoop .hdfs .server .namenode .EditLogFileOutputStream ;
153151import org .apache .hadoop .mapred .JobConf ;
154152import org .apache .hadoop .mapred .MiniMRCluster ;
155- import org .apache .hadoop .mapred .TaskLog ;
156153import org .apache .hadoop .minikdc .MiniKdc ;
157154import org .apache .yetus .audience .InterfaceAudience ;
158155import 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