@@ -93,14 +93,18 @@ public class TestDFSIOEnh extends Configured implements Tool {
9393 private static final String BASE_FILE_NAME = "test_io_" ;
9494 private static final String DEFAULT_RES_FILE_NAME = "TestDFSIOEnh_results.log" ;
9595
96- private static String TEST_ROOT_DIR = System .getProperty ("test.build.data" ,"/benchmarks/TestDFSIO-Enh" );
9796 private static Configuration fsConfig = new Configuration ();
98- private static Path CONTROL_DIR = new Path (TEST_ROOT_DIR , "io_control" );
99- protected static Path WRITE_DIR = new Path (TEST_ROOT_DIR , "io_write" );
100- protected static Path READ_DIR = new Path (TEST_ROOT_DIR , "io_read" );
101- private static Path DATA_DIR = new Path (TEST_ROOT_DIR , "io_data" );
102- private static Path REPORT_DIR = new Path (TEST_ROOT_DIR , "reports" );
103- private static Path REPORT_TMP = new Path (TEST_ROOT_DIR , "_merged_reports.txt" );
97+
98+ // NOTE: Access to these static variables have been replaced with a singleton config class, which gets the TEST_ROOT_DIR
99+ // from the job configuration (since it is not accessible via system properties)
100+ //
101+ // private static String TEST_ROOT_DIR = System.getProperty("test.build.data","/benchmarks/TestDFSIO-Enh");
102+ // private static Path CONTROL_DIR = new Path(TEST_ROOT_DIR, "io_control");
103+ // protected static Path WRITE_DIR = new Path(TEST_ROOT_DIR, "io_write");
104+ // protected static Path READ_DIR = new Path(TEST_ROOT_DIR, "io_read");
105+ // private static Path DATA_DIR = new Path(TEST_ROOT_DIR, "io_data");
106+ // private static Path REPORT_DIR = new Path(TEST_ROOT_DIR, "reports");
107+ // private static Path REPORT_TMP = new Path(TEST_ROOT_DIR, "_merged_reports.txt");
104108
105109
106110 static {
@@ -206,7 +210,7 @@ public Object doIO(Reporter reporter,
206210
207211 totalSize *= MEGA ;
208212 OutputStream out ;
209- out = fs .create (new Path (DATA_DIR , name ), true , bufferSize );
213+ out = fs .create (new Path (DfsioeConfig . getInstance (). getDataDir ( getConf ()) , name ), true , bufferSize );
210214 stats .objSize = totalSize ;
211215
212216 long lastTimeStamp =0 ;
@@ -257,15 +261,15 @@ private static String getFileName(int fIdx) {
257261 protected static void writeTest (FileSystem fs , Configuration fsConfig )
258262 throws IOException {
259263
260- fs .delete (DATA_DIR , true );
261- fs .delete (WRITE_DIR , true );
264+ fs .delete (DfsioeConfig . getInstance (). getDataDir ( fsConfig ) , true );
265+ fs .delete (DfsioeConfig . getInstance (). getWriteDir ( fsConfig ) , true );
262266
263267 //set write specific configurations
264268 JobConf job = new JobConf (fsConfig , TestDFSIOEnh .class );
265269 //should turn off speculative execution to avoid two attemps writing to the same file
266270 job .setMapSpeculativeExecution (false );
267271
268- runIOTest (WriteMapperEnh .class , WRITE_DIR ,job );
272+ runIOTest (WriteMapperEnh .class , DfsioeConfig . getInstance (). getWriteDir ( fsConfig ) ,job );
269273 }
270274
271275
@@ -286,7 +290,7 @@ public Object doIO(Reporter reporter,
286290
287291 totalSize *= MEGA ;
288292 // open file
289- DataInputStream in = fs .open (new Path (DATA_DIR , name ));
293+ DataInputStream in = fs .open (new Path (DfsioeConfig . getInstance (). getDataDir ( fsConfig ) , name ));
290294 stats .objSize = totalSize ;
291295
292296 long lastTimeStamp = 0 ;
@@ -331,12 +335,12 @@ public Object doIO(Reporter reporter,
331335 }
332336
333337 protected static void readTest (FileSystem fs ,Configuration fsConfig ) throws IOException {
334- fs .delete (READ_DIR , true );
338+ fs .delete (DfsioeConfig . getInstance (). getReadDir ( fsConfig ) , true );
335339 //set read job specific configurations
336340 JobConf job = new JobConf (fsConfig , TestDFSIOEnh .class );
337341 //turn on speculative execution to potentially improve performance.
338342 //job.setMapSpeculativeExecution(true);
339- runIOTest (ReadMapperEnh .class , READ_DIR ,job );
343+ runIOTest (ReadMapperEnh .class , DfsioeConfig . getInstance (). getReadDir ( fsConfig ) ,job );
340344 }
341345
342346 protected static void sequentialTest (
@@ -362,7 +366,7 @@ protected static void runIOTest( @SuppressWarnings("rawtypes") Class<? extends M
362366 Path outputDir ,
363367 JobConf job
364368 ) throws IOException {
365- FileInputFormat .setInputPaths (job , CONTROL_DIR );
369+ FileInputFormat .setInputPaths (job , DfsioeConfig . getInstance (). getControlDir ( fsConfig ) );
366370 job .setInputFormat (SequenceFileInputFormat .class );
367371
368372 job .setMapperClass (mapperClass );
@@ -571,7 +575,7 @@ else if (unit.equalsIgnoreCase("g"))
571575 fsConfig .setInt ("test.io.file.buffer.size" , bufferSize );
572576 fsConfig .setInt ("test.io.sampling.interval" ,tputSampleInterval );
573577
574- FileSystem fs = FileSystem .get (new Path ( TEST_ROOT_DIR ). toUri (), fsConfig );
578+ FileSystem fs = FileSystem .get (fsConfig );
575579
576580 //get the configuration of max number of concurrent maps
577581 JobConf dummyConf = new JobConf (fsConfig , TestDFSIOEnh .class );
@@ -633,11 +637,11 @@ private static void createControlFile(
633637 ) throws IOException {
634638 LOG .info ("creating control file: " +fileSize +" mega bytes, " +nrFiles +" files" );
635639
636- fs .delete (CONTROL_DIR , true );
640+ fs .delete (DfsioeConfig . getInstance (). getControlDir ( fsConfig ) , true );
637641
638642 for (int i =0 ; i < nrFiles ; i ++) {
639643 String name = getFileName (i );
640- Path controlFile = new Path (CONTROL_DIR , "in_file_" + name );
644+ Path controlFile = new Path (DfsioeConfig . getInstance (). getControlDir ( fsConfig ) , "in_file_" + name );
641645 SequenceFile .Writer writer = null ;
642646 try {
643647 writer = SequenceFile .createWriter (fs , fsConfig , controlFile ,
@@ -838,9 +842,9 @@ protected static void runAnalyse(FileSystem fs, Configuration fsConfig,
838842 long t1 = System .currentTimeMillis ();
839843 Path reduceFile ;
840844 if (testType == TEST_TYPE_WRITE )
841- reduceFile = new Path (WRITE_DIR , "part-00000" );
845+ reduceFile = new Path (DfsioeConfig . getInstance (). getWriteDir ( fsConfig ) , "part-00000" );
842846 else
843- reduceFile = new Path (READ_DIR , "part-00000" );
847+ reduceFile = new Path (DfsioeConfig . getInstance (). getReadDir ( fsConfig ) , "part-00000" );
844848
845849 int maxslot = (int )(execTime /plotInterval )+1 ;
846850 int [] concurrency = new int [maxslot +1 ];
@@ -923,7 +927,7 @@ protected static void runAnalyse(FileSystem fs, Configuration fsConfig,
923927 }
924928
925929 try {
926- fs .delete (REPORT_DIR , true );
930+ fs .delete (DfsioeConfig . getInstance (). getReportDir ( fsConfig ) , true );
927931 //set up env
928932 Configuration conf2 = new Configuration (fsConfig );
929933 conf2 .setLong ("ana_tStart" , tStart );
@@ -940,17 +944,17 @@ protected static void runAnalyse(FileSystem fs, Configuration fsConfig,
940944 job .setOutputValueClass (Text .class );
941945// job.setNumReduceTasks(1);
942946 org .apache .hadoop .mapreduce .lib .input .FileInputFormat .addInputPath (job , reduceFile );
943- org .apache .hadoop .mapreduce .lib .output .FileOutputFormat .setOutputPath (job , REPORT_DIR );
947+ org .apache .hadoop .mapreduce .lib .output .FileOutputFormat .setOutputPath (job , DfsioeConfig . getInstance (). getReportDir ( fsConfig ) );
944948 job .waitForCompletion (true );
945949 } catch (InterruptedException e ) {
946950 e .printStackTrace ();
947951 } catch (ClassNotFoundException e ) {
948952 e .printStackTrace ();
949953 } finally {
950- fs .delete (REPORT_TMP , true );
951- FileUtil .copyMerge (fs , REPORT_DIR , fs , REPORT_TMP , false , fsConfig , null );
952- LOG .info ("remote report file " + REPORT_TMP + " merged." );
953- BufferedReader lines = new BufferedReader (new InputStreamReader (new DataInputStream (fs .open (REPORT_TMP ))));
954+ fs .delete (DfsioeConfig . getInstance (). getReportTmp ( fsConfig ) , true );
955+ FileUtil .copyMerge (fs , DfsioeConfig . getInstance (). getReportDir ( fsConfig ) , fs , DfsioeConfig . getInstance (). getReportTmp ( fsConfig ) , false , fsConfig , null );
956+ LOG .info ("remote report file " + DfsioeConfig . getInstance (). getReportTmp ( fsConfig ) + " merged." );
957+ BufferedReader lines = new BufferedReader (new InputStreamReader (new DataInputStream (fs .open (DfsioeConfig . getInstance (). getReportTmp ( fsConfig ) ))));
954958 String line = null ;
955959 while ((line = lines .readLine ()) != null ) {
956960 StringTokenizer tokens = new StringTokenizer (line , " \t \n \r \f %" );
@@ -964,7 +968,7 @@ protected static void runAnalyse(FileSystem fs, Configuration fsConfig,
964968 }
965969 lines .close ();
966970 if (tputReportEach ) {
967- FileUtil .copy (fs , REPORT_TMP , new File (tputResFileName .split ("." )[0 ]+"test_io_.csv" ), false , fsConfig );
971+ FileUtil .copy (fs , DfsioeConfig . getInstance (). getReportTmp ( fsConfig ) , new File (tputResFileName .split ("." )[0 ]+"test_io_.csv" ), false , fsConfig );
968972 LOG .info ("*test_io_.csv fetched to local fs." );
969973 }
970974 //calculate the aggregated throughput
@@ -1028,9 +1032,9 @@ protected static void analyzeResult( FileSystem fs,
10281032
10291033 Path reduceFile ;
10301034 if (testType == TEST_TYPE_WRITE )
1031- reduceFile = new Path (WRITE_DIR , "part-00000" );
1035+ reduceFile = new Path (DfsioeConfig . getInstance (). getWriteDir ( fsConfig ) , "part-00000" );
10321036 else
1033- reduceFile = new Path (READ_DIR , "part-00000" );
1037+ reduceFile = new Path (DfsioeConfig . getInstance (). getReadDir ( fsConfig ) , "part-00000" );
10341038
10351039
10361040 //long time = 0;
@@ -1132,7 +1136,7 @@ protected static void analyzeResult( FileSystem fs,
11321136
11331137 private static void cleanup (FileSystem fs ) throws IOException {
11341138 LOG .info ("Cleaning up test files" );
1135- fs .delete (new Path (TEST_ROOT_DIR ), true );
1139+ fs .delete (new Path (DfsioeConfig . getInstance (). getTestRootDir ( fsConfig ) ), true );
11361140 }
11371141
11381142}//end
0 commit comments