Search in sources :

Example 1 with Combiner

use of org.apache.tez.runtime.library.common.combine.Combiner in project tez by apache.

the class TezRuntimeUtils method instantiateCombiner.

@SuppressWarnings("unchecked")
public static Combiner instantiateCombiner(Configuration conf, TaskContext taskContext) throws IOException {
    Class<? extends Combiner> clazz;
    String className = conf.get(TezRuntimeConfiguration.TEZ_RUNTIME_COMBINER_CLASS);
    if (className == null) {
        return null;
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("Using Combiner class: " + className);
    }
    try {
        clazz = (Class<? extends Combiner>) conf.getClassByName(className);
    } catch (ClassNotFoundException e) {
        throw new IOException("Unable to load combiner class: " + className);
    }
    Combiner combiner = null;
    Constructor<? extends Combiner> ctor;
    try {
        ctor = clazz.getConstructor(TaskContext.class);
        combiner = ctor.newInstance(taskContext);
    } catch (SecurityException e) {
        throw new IOException(e);
    } catch (NoSuchMethodException e) {
        throw new IOException(e);
    } catch (IllegalArgumentException e) {
        throw new IOException(e);
    } catch (InstantiationException e) {
        throw new IOException(e);
    } catch (IllegalAccessException e) {
        throw new IOException(e);
    } catch (InvocationTargetException e) {
        throw new IOException(e);
    }
    return combiner;
}
Also used : TaskContext(org.apache.tez.runtime.api.TaskContext) Combiner(org.apache.tez.runtime.library.common.combine.Combiner) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 TaskContext (org.apache.tez.runtime.api.TaskContext)1 Combiner (org.apache.tez.runtime.library.common.combine.Combiner)1