【发布时间】:2015-03-17 07:11:00
【问题描述】:
- 概述
我基于resteasy框架开发了一个Rest api服务。在服务中,我会将数据存储到 HBase 数据库中。然后,执行某些条件(例如插入一条记录)触发的map/reduce过程。
- 需要
在 Map 类中,我导入了一些第三方库。我不想将这些库打包到战争文件中。
TableMapReduceUtil.initTableMapperJob(HBaseInitializer.TABLE_DATA, // input HBase table name
scan, // Scan instance to control CF and attribute selection
LuceneMapper.class, // mapper
null, // mapper output key
null, // mapper output value
job);
FileOutputFormat.setOutputPath(job, new Path("hdfs://master:9000/qin/luceneFile"));
job.submit();
- 问题
如果将要部署到码头容器的war文件中的所有库打包,它就可以正常工作。如果不将第三方库打包到war中,而是将这些库上传到hdfs并将它们添加到类路径中,它就不起作用。如下所示
conf.set("fs.defaultFS","hdfs://master:9000");
FileSystem hdfs = FileSystem.get(conf);
Path classpathFilesDir = new Path("bjlibs");
FileStatus[] jarFiles = hdfs.listStatus(classpathFilesDir);
for (FileStatus fs : jarFiles) {
Path disqualified = new Path(fs.getPath().toUri().getPath());
DistributedCache.addFileToClassPath(disqualified, conf);
}
hdfs.close();
【问题讨论】:
-
您是从运行 Jetty 的主机提交 MapReduce 作业吗?
-
是的。码头实例与 hadoop 集群分开。即在不同的网络中
-
你也可以看看分布式缓存的概念。hadoopi.wordpress.com/2014/06/05/…
-
提交作业时,会找到一些jar文件(如hdfs://tmp/jetty-0.0.0.0-war.dir/webapp/lib/netty-3.3.6.jar),它没有找到它。因为它位于本地文件系统中(例如 file://tmp/jetty-0.0.0.0-war.dir/webapp/lib/netty-3.3.6.jar)。
-
在您的博客中,您通过 hadoop 工具运行 mapreduce。但在我的场景中,我远程提交工作
标签: hadoop mapreduce hbase resteasy hadoop2