Example usage for org.apache.hadoop.mapreduce TaskInputOutputContext getJobName

List of usage examples for org.apache.hadoop.mapreduce TaskInputOutputContext getJobName

Introduction

In this page you can find the example usage for org.apache.hadoop.mapreduce TaskInputOutputContext getJobName.

Prototype

public String getJobName();

Source Link

Document

Get the user-specified job name.

Usage

From source file:com.moz.fiji.mapreduce.util.SerializeLoggerAspect.java

License:Apache License

/**
 * Logic to write a profiling content for a single method signature to a file on HDFS.
 * The format of the file is as follows: Job Name, Job ID, Task Attempt, Function Signature,
 * Aggregate Time (nanoseconds), Number of Invocations, Time per call (nanoseconds)'\n'
 *
 * @param out The {@link OutputStreamWriter} for writing to the file.
 * @param context The {@link TaskInputOutputContext} for this job.
 * @param signature The method signature for the profile.
 * @param loggingInfo The profiling information for the method.
 * @throws IOException If the writes to HDFS fail.
 *///w w  w .  j a  v a 2 s. com
private void writeProfileInformation(OutputStreamWriter out, TaskInputOutputContext context, String signature,
        LoggingInfo loggingInfo) throws IOException {
    // ensure that files do not end up with x.yzE7 format for floats. Instead of 1.0E3, we want
    // 1000.000
    NumberFormat nf = NumberFormat.getInstance();
    nf.setGroupingUsed(false);
    nf.setMinimumFractionDigits(1);
    nf.setMaximumFractionDigits(3);

    out.write(context.getJobName() + ", " + context.getJobID() + ", " + context.getTaskAttemptID() + ", "
            + signature + ", " + loggingInfo.toString() + ", " + nf.format(loggingInfo.perCallTime()) + "\n");
}

From source file:org.apache.nutch.mapreduce.NutchCounter.java

License:Apache License

@SuppressWarnings("rawtypes")
public NutchCounter(TaskInputOutputContext context) {
    this.context = context;
    this.conf = context.getConfiguration();
    this.id = counterSequence.incrementAndGet();
    this.name = "NutchCounter" + "-" + id;

    String jobName = context.getJobName();
    jobName = StringUtils.substringBeforeLast(jobName, "-");
    jobName = jobName.replaceAll("(\\[.+\\])", "");
    this.LOG = LoggerFactory.getLogger(name + "-" + jobName);

    this.hostname = NetUtil.getHostname();

    crawlFilters = CrawlFilters.create(conf);
}