![](https://lstatic.shangxueba.com/jiandati/h5/images/m_q_title.png)
分析下面两段代码执行的功能 (1)Sell命令: if $(hdfs dfs -test -e text.txt); then $(hdfs dfs -appendToFile local.txt text.txt); else $(hdfs dfs -copyFromLocal -f local.txt text.txt); fi (2)Java代码: import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.*; import java.io.*; public class HDFSApi { public static void copyToLocal(Configuration conf, String remoteFilePath, String localFilePath) throws IOException { FileSystem fs = FileSystem.get(conf); Path remotePath = new Path(remoteFilePath); File f = new File(localFilePath); /* 如果文件名存在,自动重命名(在文件名后面加上 _0, _1 ...) */ if (f.exists()) { System.out.println(localFilePath + " 已存在."); Integer i = 0; while (true) { f = new File(localFilePath + "_" + i.toString()); if (!f.exists()) { localFilePath = localFilePath + "_" + i.toString(); break; } } System.out.println("将重新命名为: " + localFilePath); } // 下载文件到本地 Path localPath = new Path(localFilePath); fs.copyToLocalFile(remotePath, localPath); fs.close(); } /** * 主函数 */ public static void main(String[] args) { Configuration conf = new Configuration(); conf.set("fs.default.name","hdfs://localhost:9000"); String localFilePath = "/home/hadoop/text.txt"; // 本地路径 String remoteFilePath = "/user/hadoop/text.txt"; // HDFS路径 try { HDFSApi.copyToLocal(conf, remoteFilePath, localFilePath); System.out.println("下载完成"); } catch (Exception e) { e.printStackTrace(); } } }
A、hdfs dfs -mkdir /user/test
B、hdfs dfs -get /user/test
C、hdfs dfs -cat /user/test
D、hdfs dfs -rmdir /user/test
A、将本地文件a.txt移动到HDFS的/user/test/下,并更名为b.txt;执行命令后本地文件将被删除
B、将本地文件a.txt移动到HDFS的/user/test/下,并更名为b.txt;执行命令后本地文件不会被删除
C、将HDFS下的a.txt文件移动到本地文件的/user/test/下,并更名为b.txt;执行命令后HDFS文件将被删除
D、将HDFS下的a.txt文件移动到本地文件的/user/test/下,并更名为b.txt;执行命令后HDFS文件不会被删除
B、DFSInputStream
C、DataInputStream
D、FSInputStream
A. 容错型Dfs信息被存储在Active Directory中
B. 容错型Dfs根能够支持多个级别的Dfs节点
C. 对容错型Dfs树状结构所进行的修改会自动复制到整个Active Directory中
D. 容错型Dfs根可以位于NTFS、FAT或FAT32卷中
为了保护您的账号安全,请在“简答题”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!