我正在尝试使用listofwords文件只计算任何输入文件中的单词。作为filenotfound获取错误,即使我已经验证了文件在hdfs中的正确位置。
内部驱动器:
Configuration conf = new Configuration();
DistributedCache.addCacheFile(new URI("/user/training/listOfWords"), conf);
Job job = new Job(conf,"CountEachWord Job");
内部Map器:
private Path[] ref_file;
ArrayList<String> globalList = new ArrayList<String>();
public void setup(Context context) throws IOException{
this.ref_file = DistributedCache.getLocalCacheFiles(context.getConfiguration());
FileSystem fs = FileSystem.get(context.getConfiguration());
FSDataInputStream in_file = fs.open(ref_file[0]);
System.out.println("File opened");
BufferedReader br = new BufferedReader(new InputStreamReader(in_file));//each line of reference file
System.out.println("BufferReader invoked");
String eachLine = null;
while((eachLine = br.readLine()) != null)
{
System.out.println("eachLine is: "+ eachLine);
globalList.add(eachLine);
}
}
错误消息:
hadoop jar CountOnlyMatchWords.jar CountEachWordDriver Rhymes CountMatchWordsOut1
Warning: $HADOOP_HOME is deprecated.
14/10/07 22:28:59 WARN mapred.JobClient: Use GenericOptionsParser for parsing the arguments. Applications should implement Tool for the same.
14/10/07 22:28:59 INFO input.FileInputFormat: Total input paths to process : 1
14/10/07 22:28:59 INFO util.NativeCodeLoader: Loaded the native-hadoop library
14/10/07 22:28:59 WARN snappy.LoadSnappy: Snappy native library not loaded
14/10/07 22:29:00 INFO mapred.JobClient: Running job: job_201409300531_0041
14/10/07 22:29:01 INFO mapred.JobClient: map 0% reduce 0%
14/10/07 22:29:14 INFO mapred.JobClient: Task Id : attempt_201409300531_0041_m_000000_0, Status : FAILED
java.io.FileNotFoundException: File does not exist: /home/training/hadoop-temp/mapred/local /taskTracker/distcache/5910352135771601888_2043607380_1633197895/localhost/user/training/listOfWords
我已经验证了上述文件存在于hdfs中。我也试过使用localrunner。还是不行。
4条答案
按热度按时间ecfdbz9o1#
ewm0tg9j2#
您可以尝试此方法来检索文件。
uri[]files=distributedcache.getcachefiles(context.getconfiguration());
你可以遍历文件。
jgwigjjp3#
在主要方法中,我使用这个。
然后在mapper里我用了这个样板。
我正在处理这些依赖项
对我来说,诀窍在于使用
path.getName
在FileReader
如果不是,我会得到FileNotFoundException
6ie5vjzr4#
像这样试试
在驱动器中
在mapper setup()中