com.nikoo28.excel.mapreduce.ExcelDriver.java Source code

Java tutorial

Introduction

Here is the source code for com.nikoo28.excel.mapreduce.ExcelDriver.java

Source

/*
 * Copyright 2014 Nikhil Lohia
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.nikoo28.excel.mapreduce;

import org.apache.hadoop.fs.Path;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ExcelDriver {

    private static Logger logger = LoggerFactory.getLogger(ExcelDriver.class);

    /**
     * Main entry point for the example.
     *
     * @param args arguments
     * @throws Exception when something goes wrong
     */
    public static void main(String[] args) throws Exception {
        logger.info("Driver started");

        Job job = new Job();
        job.setJarByClass(ExcelDriver.class);
        job.setJobName("Excel Record Reader");

        job.setMapperClass(ExcelMapper.class);
        job.setNumReduceTasks(0);

        FileInputFormat.addInputPath(job, new Path(args[0]));
        FileOutputFormat.setOutputPath(job, new Path(args[1]));

        job.setInputFormatClass(ExcelInputFormat.class);

        job.waitForCompletion(true);
    }

}