2016-06-16 7 views
1

hadoop jarを使用してhdfsに書き込む予定です。ここに私のコードです:newFolderPath = HadoopのPath.mergePaths(workingDir、newFolderPath)JAr

import org.apache.hadoop.conf.Configuration; 
import org.apache.hadoop.fs.FileSystem; 
import org.apache.hadoop.fs.Path; 

public class WriteInrix { 
    public static void main(String[] args) throws Exception { 
     FileSystem hdfs = FileSystem.get(new Configuration()); 
     Path homeDir = hdfs.getHomeDirectory(); 
     System.out.println("Home folder -" + homeDir); 
     Path workingDir = hdfs.getWorkingDirectory(); 
     System.out.println(workingDir); 

     Path newFolderPath = new Path("/MyDataFolder"); 
     newFolderPath = Path.mergePaths(workingDir, newFolderPath); 

     if (hdfs.exists(newFolderPath)) { 
      hdfs.delete(newFolderPath, true); 
     } 

     hdfs.mkdirs(newFolderPath); 

     Path localFilePath = new Path("test.csv"); 
     Path hdfsFilePath = new Path(newFolderPath + "test1.csv"); 
     hdfs.copyFromLocalFile(localFilePath, hdfsFilePath); 
    } 
} 

ここでの問題は、ラインnewFolderPath = Path.mergePaths(workingDir, newFolderPath);です。 PathにはmergePaths()の定義がないため、この行にエラーがあります。しかし、私は信頼できるソースからコードをコピーしました。どうしたの?どのような代替手段をとるべきですか?

+0

実際のスタックトレースとstdoutメッセージを提供する必要があります。 –

答えて

0

正確なエラーが表示されます。コードから、打つ唯一のことは、私は、あなたが代わりにこのやるべきことさ。

Path homeDir = new Path(hdfs.getHomeDirectory()); 

Path workingDir = new Path(hdfs.getWorkingDirectory()); 

私はJavaの/ Hadoopのを学ぶために始めていますが私は間違っている可能性があります。これが動作すれば教えてください。

+0

同じエラーに直面していますが、上記の解決策が機能していません –

関連する問題