https://download.csdn.net/download/qq_31293575/14928183

package com.qf.game.task2;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.*;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

public class Main {
    public static void main(String[] args) throws Exception {
        Configuration conf=new Configuration();
        Job job = Job.getInstance(conf);
        job.setJarByClass(Main.class);
        job.setMapperClass(map.class);
        job.setReducerClass(red.class);
        job .setOutputKeyClass(NullWritable.class);
        job.setOutputValueClass(Text.class);
//        hdfs://master:9000/test/
//        FileInputFormat.addInputPath(job,new Path("hdfs:/data/task2-Crawler"));
        FileInputFormat.addInputPath(job,new Path("hdfs://192.168.88.138:9000/data/task2-Crawler"));
        FileOutputFormat.setOutputPath(job,new Path("hdfs://192.168.88.138:9000/clean"));
        new Path("hdfs://192.168.88.138:9000/data").getFileSystem(conf).delete(new Path("hdfs://192.168.88.138:9000/clean"),true);
        System.exit(job.waitForCompletion(true) ? 0 : 1);
    }
}

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐