Ich probiere etwas einfachen Java-Code aus, um eine Datei von meinem lokalen System nach HDFS zu kopieren. Dies ist, wie meine einfache Methode wie folgt aussieht:"Eine bestehende Verbindung wurde von der Software in Ihrem Hostcomputer abgebrochen" beim Kopieren von Datei nach Hadoop HDFS aus dem Java-Code
private static void copyFileToHDFS() throws IOException
{
config.set("fs.defaultFS","hdfs://127.0.0.1:9000");
FileSystem hdfs = FileSystem.get(config);
Path localfsSourceDir = new Path("D:\\file1");
Path hdfsTargetDir = new Path ("hdfs://127.0.0.1:9000/dir/");
hdfs.copyFromLocalFile(localfsSourceDir, hdfsTargetDir); //throws Exception
}
Dies gibt mir folgende Ausnahme auf letzte Zeile:
Exception in thread "main" java.io.IOException: Failed on local exception: java.io.IOException: An established connection was aborted by the software in your host machine; Host Details : local host is: "01hw713648/10.163.5.139"; destination host is: "127.0.0.1":9000;
at org.apache.hadoop.net.NetUtils.wrapException(NetUtils.java:773)
at org.apache.hadoop.ipc.Client.call(Client.java:1479)
at org.apache.hadoop.ipc.Client.call(Client.java:1412)
at org.apache.hadoop.ipc.ProtobufRpcEngine$Invoker.invoke(ProtobufRpcEngine.java:229)
at $Proxy9.getFileInfo(Unknown Source)
at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolTranslatorPB.getFileInfo(ClientNamenodeProtocolTranslatorPB.java:771)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.hadoop.io.retry.RetryInvocationHandler.invokeMethod(RetryInvocationHandler.java:191)
at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:102)
at $Proxy10.getFileInfo(Unknown Source)
at org.apache.hadoop.hdfs.DFSClient.getFileInfo(DFSClient.java:2108)
at org.apache.hadoop.hdfs.DistributedFileSystem$22.doCall(DistributedFileSystem.java:1305)
at org.apache.hadoop.hdfs.DistributedFileSystem$22.doCall(DistributedFileSystem.java:1301)
at org.apache.hadoop.fs.FileSystemLinkResolver.resolve(FileSystemLinkResolver.java:81)
at org.apache.hadoop.hdfs.DistributedFileSystem.getFileStatus(DistributedFileSystem.java:1301)
at org.apache.hadoop.fs.FileSystem.exists(FileSystem.java:1424)
at org.apache.hadoop.fs.FileUtil.checkDest(FileUtil.java:496)
at org.apache.hadoop.fs.FileUtil.copy(FileUtil.java:348)
at org.apache.hadoop.fs.FileUtil.copy(FileUtil.java:338)
at org.apache.hadoop.fs.FileSystem.copyFromLocalFile(FileSystem.java:1965)
at org.apache.hadoop.fs.FileSystem.copyFromLocalFile(FileSystem.java:1933)
at org.apache.hadoop.fs.FileSystem.copyFromLocalFile(FileSystem.java:1898)
at HBaseImportTsvBulkLoader.copyFileToHDFS(HBaseImportTsvBulkLoader.java:64)
at HBaseImportTsvBulkLoader.main(HBaseImportTsvBulkLoader.java:37)
Caused by: java.io.IOException: An established connection was aborted by the software in your host machine
at sun.nio.ch.SocketDispatcher.read0(Native Method)
at sun.nio.ch.SocketDispatcher.read(Unknown Source)
at sun.nio.ch.IOUtil.readIntoNativeBuffer(Unknown Source)
at sun.nio.ch.IOUtil.read(Unknown Source)
at sun.nio.ch.SocketChannelImpl.read(Unknown Source)
at org.apache.hadoop.net.SocketInputStream$Reader.performIO(SocketInputStream.java:57)
at org.apache.hadoop.net.SocketIOWithTimeout.doIO(SocketIOWithTimeout.java:142)
at org.apache.hadoop.net.SocketInputStream.read(SocketInputStream.java:161)
at org.apache.hadoop.net.SocketInputStream.read(SocketInputStream.java:131)
at java.io.FilterInputStream.read(Unknown Source)
at java.io.FilterInputStream.read(Unknown Source)
at org.apache.hadoop.ipc.Client$Connection$PingInputStream.read(Client.java:520)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at java.io.DataInputStream.readInt(Unknown Source)
at org.apache.hadoop.ipc.Client$Connection.receiveRpcResponse(Client.java:1084)
at org.apache.hadoop.ipc.Client$Connection.run(Client.java:979)
Mein Setup
Ich bin mit Hadoop-Cluster in Ubuntu VM läuft auf VirtualBox (die wiederum unter Windows läuft). Ich habe Cluster perfekt laufen. Ich verwende diesen Java-Code unter Windows. Ich habe Port-Forwarding Regeln für Virtual Box wie folgt festgelegt:
Name Protocol Host-ip Host-port Guest-Ip Guest-port
datanode tcp <left empty> 50075 <guest-ip> 50075
dfs web ui tcp <left empty> 50070 <guest-ip> 50070
mapred apps tcp <left empty> 8088 <guest-ip> 8088
hbase web ui tcp <left empty> 16010 <guest-ip> 16010
hdfs tcp <left empty> 9000 <guest-ip> 9000
regionserver web ui tcp <left empty> 16301 <guest-ip> 16301
ssh tcp <left empty> 22 <guest-ip> 22
, die mich zu verschiedenen Diensten auf VM anschließen können:
- ich in der Lage bin
- auch auf VM mit Kitt verbinden Lage in Windows verschiedenen hadoop Web-UIs in Browser zu öffnen: NameNode web ui, webui HMaster, Regionserver webui
aktualisieren
Einige Online-Lösungen für ähnliche Fehler, aber nicht im Hadoop-Kontext vorgeschlagen, Eclipse neu zu starten. Also habe ich das gerade versucht. Jetzt wird ein geringfügig anderer Fehler angezeigt:
Exception in thread "main" java.io.IOException: Failed on local exception: java.io.IOException: An existing connection was forcibly closed by the remote host; Host Details : local host is: "01hw713648/10.163.5.139"; destination host is: "127.0.0.1":9000;
mit genau gleichen Stack-Trace.