hadoop-hdfs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Blanca Hernandez <Blanca.Hernan...@willhaben.at>
Subject MRUnit tests with mongo hadoop
Date Thu, 25 Sep 2014 12:09:43 GMT

I am not sure if this question must be posted in the Hadoop forum or in the mongoDB one. Let´s

I am using the mongo-hadoop integration and wrote a MR job. I want to test it, and foud the
framework MRUnit (https://mrunit.apache.org/), which sounds great.

I am facing some difficulties with it, since apparently there mongoDB classes are not supported
by the framework (?).
A simple example:

public class MrUnitBasicTests {

    public void testVeryBasicOneAttributeDocument() throws Exception {
        Mapper<Object, BSONObject, BSONObject, BSONObject> mapper = new Mapper<Object,
BSONObject, BSONObject, BSONObject>(){
            protected void map(Object key, BSONObject value, org.apache.hadoop.mapreduce.Mapper.Context
                    throws IOException, InterruptedException {
                Object writeKey = createOutputKey();
                Object writeValue = createOutputValue();
                context.write(writeKey, writeValue);
        BSONObject input = new BasicDBObject("key", "value");
//        ParseMetadataAsTextIntoAvroMapper mapper = new ParseMetadataAsTextIntoAvroMapper();
        MapDriver<Object, BSONObject, BSONObject, BSONObject> mapDriver = MapDriver.newMapDriver(mapper);
        mapDriver.withInput(new LongWritable(1), input);
        mapDriver.withOutput(createOutputKey(), createOutputValue());

    private BasicDBObject createOutputKey() {
        return new BasicDBObject("zonid", new ObjectId("5179577adb2da69ad0ee98e9"));

    private BasicDBObject createOutputValue() {
        return new BasicDBObject("key", "value");

And the exception:
java.lang.IllegalStateException: No applicable class implementing Serialization in conf at
io.serializations for class com.mongodb.BasicDBObject

The io.serializations configuration property contains WritableSerialization which implements
I saw that the com.mongodb.BasicDBObject implements the java.io.Serializable.

Is there any connection among them? How could I go on with the tests? Any experience with

Many thanks

View raw message