Search in sources :

Example 1 with CountersScanMetrics

use of org.janusgraph.hadoop.CountersScanMetrics in project janusgraph by JanusGraph.

the class HadoopScanRunner method runJob.

public static ScanMetrics runJob(org.apache.hadoop.conf.Configuration hadoopConf, Class<? extends InputFormat> inputFormat, String jobName, Class<? extends Mapper> mapperClass) throws IOException, InterruptedException, ClassNotFoundException {
    Job job = Job.getInstance(hadoopConf);
    // job.setJarByClass(HadoopScanMapper.class);
    job.setJarByClass(mapperClass);
    // job.setJobName(HadoopScanMapper.class.getSimpleName() + "[" + scanJob + "]");
    job.setJobName(jobName);
    job.setOutputKeyClass(NullWritable.class);
    job.setOutputValueClass(NullWritable.class);
    job.setMapOutputKeyClass(NullWritable.class);
    job.setMapOutputValueClass(NullWritable.class);
    job.setNumReduceTasks(0);
    // job.setMapperClass(HadoopScanMapper.class);
    job.setMapperClass(mapperClass);
    job.setOutputFormatClass(NullOutputFormat.class);
    job.setInputFormatClass(inputFormat);
    boolean success = job.waitForCompletion(true);
    if (!success) {
        String f;
        try {
            // Just in case one of Job's methods throws an exception
            f = String.format("MapReduce JobID %s terminated abnormally: %s", job.getJobID().toString(), getJobFailureString(job));
        } catch (RuntimeException e) {
            f = "Job failed (unable to read job status programmatically -- see MapReduce logs for information)";
        }
        throw new IOException(f);
    } else {
        return new CountersScanMetrics(job.getCounters());
    }
}
Also used : CountersScanMetrics(org.janusgraph.hadoop.CountersScanMetrics) IOException(java.io.IOException) VertexScanJob(org.janusgraph.graphdb.olap.VertexScanJob) Job(org.apache.hadoop.mapreduce.Job) ScanJob(org.janusgraph.diskstorage.keycolumnvalue.scan.ScanJob)

Aggregations

IOException (java.io.IOException)1 Job (org.apache.hadoop.mapreduce.Job)1 ScanJob (org.janusgraph.diskstorage.keycolumnvalue.scan.ScanJob)1 VertexScanJob (org.janusgraph.graphdb.olap.VertexScanJob)1 CountersScanMetrics (org.janusgraph.hadoop.CountersScanMetrics)1