I have the following java code:
import java.io.IOException;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.fs.Path;
public class HotColdDay {
public static class Map extends
Mapper<LongWritable, Text, Text, Text> {
static long counter = 0;
@Override
public void map(LongWritable key, Text value, Context context)
throws IOException, InterruptedException {
counter++;
String line = value.toString();
String[] lineInputs = line.split("\\s+");
Text date = new Text();
date.set(lineInputs[1]);
Double maxTemp = Double.parseDouble(lineInputs[5]);
Double minTemp = Double.parseDouble(lineInputs[6]);
System.out.println("counter=" + counter +"date="+ date + "minTemp=" + minTemp + "maxTemp=" + maxTemp);
String coldDay = "";
if(minTemp < 10 ) {
coldDay = "Cold Day";
}
else if (maxTemp > 40)
coldDay = "Hot Day";
else coldDay = "Normal Day";
Text coldDayText = new Text();
coldDayText.set(coldDay);
context.write(date, coldDayText);
}
}
public static void main(String[] args) throws Exception {
Configuration conf = new Configuration();
Job job = new Job(conf, "HotColdDay");
job.setJarByClass(HotColdDay.class);
job.setMapperClass(Map.class);
//job.setReducerClass(Reduce.class);
job.setMapOutputKeyClass(Text.class);
job.setMapOutputValueClass(Text.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(Text.class);
job.setInputFormatClass(TextInputFormat.class);
job.setOutputFormatClass(TextOutputFormat.class);
job.setNumReduceTasks(0);
Path outputPath = new Path(args[1]);
FileInputFormat.addInputPath(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
outputPath.getFileSystem(conf).delete(outputPath);
System.exit(job.waitForCompletion(true) ? 0 : 1);
}
}
I am getting the following error: