[[PageOutline]] ◢ <[wiki:III131019/Lab9 實作九]> | <[wiki:III131019 回課程大綱]> ▲ | <[wiki:III131019/Lab11 實作十一]> ◣ = 實作十 Lab10 = * 在上一個實作中,我們可以觀察 FsShell.java 是如何使用 Path、Configration、!FileSystem 這幾個類別。 * 我們從模仿 hadoop fs -put 對應的函數 copyFromLocal(Path[] srcs, String dstf) 可以重新撰寫一個 Java Application 來學習 Hadoop !FileSystem API {{{ #!java 121 /** 122 * Add local files to the indicated FileSystem name. src is kept. 123 */ 124 void copyFromLocal(Path[] srcs, String dstf) throws IOException { 125 Path dstPath = new Path(dstf); 126 FileSystem dstFs = dstPath.getFileSystem(getConf()); 127 if (srcs.length == 1 && srcs[0].toString().equals("-")) 128 copyFromStdin(dstPath, dstFs); 129 else 130 dstFs.copyFromLocalFile(false, false, srcs, dstPath); 131 } }}} * 讓我們先來觀察程式運作的情形,請剪貼以下步驟,並嘗試思考觀察到的現象(特別是 hadoop fs -ls 列出的結果差異): {{{ cd ~/hadoop_labs/lab004 ant hadoop fs -ls hadoop fs -rmr input hadoop jar copyFromLocal.jar doc input hadoop fs -ls touch test hadoop jar copyFromLocal.jar test file hadoop fs -ls export HADOOP_CONF_DIR=~/hadoop/conf.local/ hadoop fs -ls hadoop jar copyFromLocal.jar doc input hadoop fs -ls hadoop jar copyFromLocal.jar test file hadoop fs -ls unset HADOOP_CONF_DIR ant clean }}} == 實作習題 == <問題 1> 根據 ${HOME}/hadoop/src/core/org/apache/hadoop/fs 目錄的內容,試猜測 Hadoop 1.0.4 支援哪幾種檔案系統: (複選) <提示> http://answers.oreilly.com/topic/456-get-to-know-hadoop-filesystems/ {{{ #!text (A) HDFS (hdfs://namenode:port) (B) Amazon S3 (s3:// , s3n://) (C) KFS (D) Local File System (file:///) (F) FTP (ftp://user:passwd@ftp-server:port) (G) RAMFS (ramfs://) (H) HAR (Hadoop Archive Filesystem, har://underlyingfsscheme-host:port/archivepath or har:///archivepath ) }}}