2017-06-01 54 views
0

在Hadoop中,我們可以獲取地圖輸入文件路徑爲;從MapReduce獲取Azure Blob路徑

Path pt = new Path(((FileSplit) context.getInputSplit()).getPath().toString()); 

但我找不到任何文檔如何從Azure Blob存儲帳戶實現此目的。有沒有辦法從mapreduce程序中獲取Azure Blob路徑?

回答

0

如果您想要獲取當前mapper或reducer進程的輸入文件路徑,您的代碼是通過MapContext/ReduceContext獲取路徑的唯一方法。

如果不是,要獲取core-site.xml文件中定義的容器的文件列表,請嘗試下面的代碼。

Configuration configuration = new Configuration(); 
FileSystem hdfs = FileSystem.get(configuration); 
Path home = hdfs.getHomeDirectory(); 
FileStatus[] files = hdfs.listStatus(home); 

希望它有幫助。