Database Reference
In-Depth Information
enum Temperature {
OVER_100
}
private NcdcRecordParser parser = new NcdcRecordParser ();
@Override
public void map ( LongWritable key , Text value , Context context )
throws IOException , InterruptedException {
parser . parse ( value );
if ( parser . isValidTemperature ()) {
int airTemperature = parser . getAirTemperature ();
if ( airTemperature > 1000 ) {
System . err . println ( "Temperature over 100 degrees for input:
" + value );
context . setStatus ( "Detected possibly corrupt record: see
logs." );
context . getCounter ( Temperature . OVER_100 ). increment ( 1 );
}
context . write ( new Text ( parser . getYear ()), new
IntWritable ( airTemperature ));
}
}
}
If the temperature is over 100°C (represented by 1000, because temperatures are in tenths
of a degree), we print a line to standard error with the suspect line, as well as updating the
map's status message using the setStatus() method on Context , directing us to
look in the log. We also increment a counter, which in Java is represented by a field of an
enum type. In this program, we have defined a single field, OVER_100 , as a way to count
the number of records with a temperature of over 100°C.
With this modification, we recompile the code, re-create the JAR file, then rerun the job
and, while it's running, go to the tasks page.
The tasks and task attempts pages
The job page has a number of links for viewing the tasks in a job in more detail. For ex-
ample, clicking on the “Map” link brings us to a page that lists information for all of the
map tasks. The screenshot in Figure 6-3 shows this page for the job run with our debug-
ging statements in the “Status” column for the task.
Search WWH ::




Custom Search