Example usage for org.apache.hadoop.mapreduce.lib.map WrappedMapper getMapContext

List of usage examples for org.apache.hadoop.mapreduce.lib.map WrappedMapper getMapContext

Introduction

In this page you can find the example usage for org.apache.hadoop.mapreduce.lib.map WrappedMapper getMapContext.

Prototype

public Mapper<KEYIN, VALUEIN, KEYOUT, VALUEOUT>.Context getMapContext(
        MapContext<KEYIN, VALUEIN, KEYOUT, VALUEOUT> mapContext) 

Source Link

Document

Get a wrapped Mapper.Context for custom implementations.

Usage

From source file:org.apache.giraph.yarn.GiraphYarnTask.java

License:Apache License

/**
 * Utility to generate dummy Mapper#Context for use in Giraph internals.
 * This is the "key hack" to inject MapReduce-related data structures
 * containing YARN cluster metadata (and our GiraphConf from the AppMaster)
 * into our Giraph BSP task code./*w  ww  .  j  av  a 2 s . co  m*/
 * @param tid the TaskAttemptID to construct this Mapper#Context from.
 * @return sort of a Mapper#Context if you squint just right.
 */
private Context buildProxyMapperContext(final TaskAttemptID tid) {
    MapContext mc = new MapContextImpl<Object, Object, Object, Object>(conf, // our Configuration, populated back at the GiraphYarnClient.
            tid, // our TaskAttemptId, generated w/YARN app, container, attempt IDs
            null, // RecordReader here will never be used by Giraph
            null, // RecordWriter here will never be used by Giraph
            null, // OutputCommitter here will never be used by Giraph
            new TaskAttemptContextImpl.DummyReporter() { // goes in task logs for now
                @Override
                public void setStatus(String msg) {
                    LOG.info("[STATUS: task-" + bspTaskId + "] " + msg);
                }
            }, null); // Input split setting here will never be used by Giraph

    // now, we wrap our MapContext ref so we can produce a Mapper#Context
    WrappedMapper<Object, Object, Object, Object> wrappedMapper = new WrappedMapper<Object, Object, Object, Object>();
    return wrappedMapper.getMapContext(mc);
}