You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mapreduce-user@hadoop.apache.org by Joe Buck <jb...@gmail.com> on 2010/05/29 08:28:44 UTC

Issue opening a RandomAccessFile in HDFS

Greetings,

I'm attempting to open a RandomAccessFile that is in HDFS for purely reading
purposes but I'm getting a FileNotFoundException.
I'm attaching a short Java program that tries to do the following:
1) read a local RandomAccessFile
2) read a File in hdfs
3) read a RandomAccessFile in hdfs (same file as step 2).

When step 3 attempts to open the file, the error is thrown. I'm attaching my
java program and here's the exception stack trace:

Opening local RandomAccessFile:/tmp/foo.txt
Opening remote File:file:/code/hadoop/hdfs_test/netcdf_input/file1.nc
Opening remote RandomAccessFile:file:/code/hadoop/hdfs_test/netcdf_input/
file1.nc
failed trying to open file:/code/hadoop/hdfs_test/netcdf_input/file1.nc
java.io.FileNotFoundException: file:/code/hadoop/hdfs_test/netcdf_input/
file1.nc (No such file or directory)
    at java.io.RandomAccessFile.open(Native Method)
    at java.io.RandomAccessFile.<init>(RandomAccessFile.java:212)
    at java.io.RandomAccessFile.<init>(RandomAccessFile.java:98)
    at HDFSReadWrite.main(HDFSReadWrite.java:42)
Exception in thread "main" java.lang.NullPointerException
    at HDFSReadWrite.main(HDFSReadWrite.java:47)


Should this work? I can see why writing to a RandomAccessFile wouldn't work
but shouldn't it be possible to open and read it?
Would I have a shot of this working if I went to the git trunk instead of
0.20.2?

Thanks,
-Joe Buck