我在opensuse linux上使用hadoop 19,我没有使用任何集群,而是在我的机器上运行我的hadoop代码。我遵循关于放入分布式缓存的标准技术,但不是一次又一次地从分布式缓存中获取文件,而是将文件内容存储在一个数组中。这个从文件中提取的部分是在configure()函数中完成的。当我尝试使用场名时,我得到nullPointerException。这是代码的一部分:分布式缓存
.
..part of main()
..
DistributedCache.addCacheFile(new URI("/home/hmobile/hadoop-0.19.2/output/part-00000"), conf2);
DistributedCache.addCacheFile(new URI("/home/hmobile/hadoop-0.19.2/output/part-00001"), conf2);
.
.part of mapper
public void configure(JobConf conf2)
{
String wrd; String line; try {
localFiles = DistributedCache.getLocalCacheFiles(conf2);
System.out.println(localFiles[0].getName());// error NULLPOINTEREXCEPTION
} catch (IOException ex) {
Logger.getLogger(blur2.class.getName()).log(Level.SEVERE, null, ex);
}
for(Path f:localFiles)// error NULLPOINTEREXCEPTION
{
if(!f.getName().endsWith("crc"))
{
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader(f.toString()));
这样的处理不能在configure()中完成吗?
或者如果有人能够告诉我们是否有可能在我们的本地机器上使用分布式缓存时,当我们没有尝试在实际的HDFS上? – 2010-07-10 07:52:04