From: <bi...@us...> - 2008-12-10 04:58:28
|
Revision: 2655 http://archive-access.svn.sourceforge.net/archive-access/?rev=2655&view=rev Author: binzino Date: 2008-12-10 04:58:24 +0000 (Wed, 10 Dec 2008) Log Message: ----------- Change output of messages from stderr to stdout. Add code to check return status of job and pass back to command-line via System.exti() call. Modified Paths: -------------- trunk/archive-access/projects/nutchwax/archive/src/java/org/archive/nutchwax/Importer.java Modified: trunk/archive-access/projects/nutchwax/archive/src/java/org/archive/nutchwax/Importer.java =================================================================== --- trunk/archive-access/projects/nutchwax/archive/src/java/org/archive/nutchwax/Importer.java 2008-12-09 01:58:04 UTC (rev 2654) +++ trunk/archive-access/projects/nutchwax/archive/src/java/org/archive/nutchwax/Importer.java 2008-12-10 04:58:24 UTC (rev 2655) @@ -36,6 +36,8 @@ import org.apache.hadoop.mapred.OutputCollector; import org.apache.hadoop.mapred.Reporter; import org.apache.hadoop.mapred.TextInputFormat; +import org.apache.hadoop.mapred.RunningJob; +import org.apache.hadoop.mapred.JobStatus; import org.apache.hadoop.util.Tool; import org.apache.hadoop.util.ToolRunner; import org.apache.nutch.crawl.CrawlDatum; @@ -601,7 +603,7 @@ { if ( args.length < 2 ) { - System.err.println( "ERROR: Missing filename for option \"-e\"\n" ); + System.out.println( "ERROR: Missing filename for option \"-e\"\n" ); usage( ); return -1; } @@ -613,7 +615,7 @@ if ( args.length - pos < 1 ) { - System.err.println( "ERROR: Missing manifest file.\n" ); + System.out.println( "ERROR: Missing manifest file.\n" ); usage( ); return -1; } @@ -645,17 +647,20 @@ job.setOutputKeyClass ( Text.class ); job.setOutputValueClass( NutchWritable.class ); - JobClient.runJob( job ); + RunningJob rj = JobClient.runJob( job ); + + // Emit job id and status. + System.out.println( "JOB_STATUS: " + rj.getID( ) + ": " + (rj.isSuccessful( ) ? "SUCCESS" : "FAIL" ) ); + + return rj.isSuccessful( ) ? 0 : 1; } catch ( Exception e ) { LOG.fatal( "Importer: ", e ); - System.err.println( "Fatal error: " + e ); - e.printStackTrace( System.err ); + System.out.println( "Fatal error: " + e ); + e.printStackTrace( System.out ); return -1; } - - return 0; } /** @@ -673,7 +678,7 @@ + "necessary. This is to mirror the behavior of other Nutch actions.\n" ; - System.err.println( usage ); + System.out.println( usage ); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |