The node on which this program was running failed to connect to namenode. Check your configuration of hadoop cluster first, eg, the firewall.
2010/1/19 ztesoft <[email protected]>: > > Hi, I wrote a program to read a file in HDFS. > The codes are following: > import java.io.IOException; > import java.net.MalformedURLException; > import java.net.URI; > import org.apache.hadoop.conf.Configuration; > import org.apache.hadoop.fs.FSDataInputStream; > import org.apache.hadoop.fs.FileSystem; > import org.apache.hadoop.fs.Path; > import org.apache.hadoop.io.IOUtils; > > public class FileSystemCat { > public static void main(String[] args) throws IOException { > String uri = "hdfs://10.45.11.247:9000/user/root/test3.xml"; > Configuration conf = new Configuration(); > FileSystem fs = FileSystem.get(URI.create(uri),conf); > FSDataInputStream in = null; > try { > in = fs.open(new Path(uri)); > IOUtils.copyBytes(in, System.out, 4096,false); > in.seek(10); > IOUtils.copyBytes(in, System.out, 4096,false); > } catch (MalformedURLException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } catch (IOException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > }finally > { > IOUtils.closeStream(in); > } > } > } > > The error occurs like following: > Exception in thread "main" java.io.IOException: Call to /10.45.11.247:9000 > failed on local exception: java.io.EOFException > at org.apache.hadoop.ipc.Client.wrapException(Client.java:774) > at org.apache.hadoop.ipc.Client.call(Client.java:742) > at org.apache.hadoop.ipc.RPC$Invoker.invoke(RPC.java:220) > at $Proxy0.getProtocolVersion(Unknown Source) > at org.apache.hadoop.ipc.RPC.getProxy(RPC.java:359) > at > org.apache.hadoop.hdfs.DFSClient.createRPCNamenode(DFSClient.java:105) > at org.apache.hadoop.hdfs.DFSClient.<init>(DFSClient.java:177) > at > org.apache.hadoop.hdfs.DistributedFileSystem.initialize(DistributedFileSystem.java:82) > at > org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:1373) > at org.apache.hadoop.fs.FileSystem.access$200(FileSystem.java:66) > at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:1385) > at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:191) > at hadoopstudy.FileSystemCat.main(FileSystemCat.java:26) > Caused by: java.io.EOFException > at java.io.DataInputStream.readInt(DataInputStream.java:375) > at > org.apache.hadoop.ipc.Client$Connection.receiveResponse(Client.java:501) > at org.apache.hadoop.ipc.Client$Connection.run(Client.java:446) > Java Result: 1 > > Does anyone know how to solve it? > > > -- > View this message in context: > http://old.nabble.com/Exception-occurs-when-I-try-to-read-a-file-tp27221237p27221237.html > Sent from the Hadoop core-user mailing list archive at Nabble.com. > > -- [email protected]
