- package test;
- import org.apache.hadoop.conf.Configuration;
- import org.apache.hadoop.conf.Configured;
- import org.apache.hadoop.fs.Path;
- import org.apache.hadoop.hbase.HBaseConfiguration;
- import org.apache.hadoop.hbase.mapreduce.TableMapReduceUtil;
- import org.apache.hadoop.io.Text;
- import org.apache.hadoop.mapreduce.Job;
- import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
- import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
- import org.apache.hadoop.util.Tool;
- public class Driver extends Configured implements Tool{
- @Override
- public static void run(String[] arg0) throws Exception {
- // TODO Auto-generated method stub
- Configuration conf = HBaseConfiguration.create();
- conf.set("hbase.zookeeper.quorum.", "localhost");
- Job job = new Job(conf,"Hbase");
- job.setJarByClass(TxtHbase.class);
- job.setInputFormatClass(TextInputFormat.class);
- job.setMapOutputKeyClass(Text.class);
- job.setMapOutputValueClass(Text.class);
- TableMapReduceUtilinitTableMapperJob("table", args0[0],MapperClass.class, job); job.waitForCompletion(true); } }
主函数
- package test;
- import org.apache.hadoop.conf.Configuration;
- import org.apache.hadoop.util.ToolRunner;
- public class TxtHbase {
- public static void main(String [] args) throws Exception{
- Driver.run(new Configuration(),new THDriver(),args);
- }
- }
- --------------------------------------------------------------------------------
原文链接:http://www.cnblogs.com/liqizhou/archive/2012/05/17/2504279.html