I'm trying get working a hadoop hello world code that is 100% based on wordcount, but the fiware platform returns a error while I'm trying to run this code as a job with his rest api.
The following code just runs fine in my private hadoop cluster that I use for testing proposes, but no inside the fi-ware platform and I don't know why.
The code is just this:
package smartive;
import java.io.IOException;
import java.util.*;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.conf.*;
import org.apache.hadoop.io.*;
import org.apache.hadoop.mapred.*;
import org.apache.hadoop.util.*;
public class Hello {
public static class Map extends MapReduceBase implements Mapper < LongWritable, Text, Text, IntWritable > {
private final static IntWritable one = new IntWritable(1);
private Text word = new Text();
public void map(LongWritable key, Text value, OutputCollector < Text, IntWritable > output, Reporter reporter) throws IOException {
String line = value.toString();
StringTokenizer tokenizer = new StringTokenizer(line);
while (tokenizer.hasMoreTokens()) {
word.set(tokenizer.nextToken());
output.collect(word, one);
}
}
}
public static class Reduce extends MapReduceBase implements Reducer < Text,
IntWritable,
Text,
IntWritable > {
public void reduce(Text key, Iterator < IntWritable > values, OutputCollector < Text, IntWritable > output, Reporter reporter) throws IOException {
int sum = 0;
while (values.hasNext()) {
sum += values.next().get();
}
output.collect(key, new IntWritable(sum));
}
}
public static void main(String[] args) throws Exception {
JobConf conf = new JobConf(Hello.class);
conf.setJobName("Hello");
conf.setOutputKeyClass(Text.class);
conf.setOutputValueClass(IntWritable.class);
conf.setMapperClass(Map.class);
conf.setCombinerClass(Reduce.class);
conf.setReducerClass(Reduce.class);
conf.setInputFormat(TextInputFormat.class);
conf.setOutputFormat(TextOutputFormat.class);
FileInputFormat.setInputPaths(conf, new Path(args[0]));
FileOutputFormat.setOutputPath(conf, new Path(args[1]));
JobClient.runJob(conf);
}
}
I compile the previously code with javac the I make a jar package with the entry point set as smartive.Hello.
The, I run the following rest call to cosmos.lab.fiware:
curl -X POST "http://computing.cosmos.lab.fiware.org:12000/tidoop/v1/user/myuser/jobs" -d '{"jar":"Hello.jar","class_name":"Hello","lib_jars":"","input":"data/in","output":"data/out"}' -H "Content-Type: application/json" -H "X-Auth-Token: myOauth2token"
But I got as a result
{"success":"false","error":1}
The expected response must be like this:
{"success":"true","job_id": "job_1460639183882_0001"}
But I don't know how I can debug on the new cosmos since there is no ssh interface and no error msg on the response.
The files are ok inside data/in folder (test.txt file) and the folder data and data/in has 777 permissions.
Anyone has some hint / idea where/what I'm doing wrong?
Many thanks.