HBase映射/减少依赖性问题


  1. 概述

我开发了一个基于resteasy框架的restapi服务。在服务中,我将把数据存储到HBase数据库中。然后,执行某些条件触发的映射/减少过程(例如插入一条记录)。

  1. 需要

在Map类中,我导入了一些第三部分库。我不想把那些库打包到war文件中。

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();
  1. 问题

如果将所有库打包在war文件中,并将其部署到jetty容器中,则工作良好。如果不将第三部分库打包到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();

尝试TableMapReduceUtil.addHBaseDependencyJars()

最新更新