⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testdfsmkdirs.java

📁 hadoop:Nutch集群平台
💻 JAVA
字号:
package org.apache.hadoop.dfs;import junit.framework.TestCase;import java.io.*;import org.apache.hadoop.conf.Configuration;import org.apache.hadoop.fs.FileSystem;import org.apache.hadoop.fs.Path;/** * This class tests that the DFS command mkdirs cannot create subdirectories * from a file when passed an illegal path.  HADOOP-281. * @author Wendy Chien */public class TestDFSMkdirs extends TestCase {  private void writeFile(FileSystem fileSys, Path name) throws IOException {    DataOutputStream stm = fileSys.create(name);    stm.writeBytes("wchien");    stm.close();  }    /**   * Tests mkdirs can create a directory that does not exist and will   * not create a subdirectory off a file.   */  public void testDFSMkdirs() throws IOException {    Configuration conf = new Configuration();    MiniDFSCluster cluster = new MiniDFSCluster(65312, conf, false);    FileSystem fileSys = cluster.getFileSystem();    try {    	// First create a new directory with mkdirs    	Path myPath = new Path("/test/mkdirs");    	assertTrue(fileSys.mkdirs(myPath));    	assertTrue(fileSys.exists(myPath));    	    	// Second, create a file in that directory.    	Path myFile = new Path("/test/mkdirs/myFile");    	writeFile(fileSys, myFile);       	// Third, use mkdir to create a subdirectory off of that file,    	// and check that it fails.    	Path myIllegalPath = new Path("/test/mkdirs/myFile/subdir");    	assertFalse(fileSys.mkdirs(myIllegalPath));    	assertFalse(fileSys.exists(myIllegalPath));    	fileSys.delete(myFile);    	    } finally {      fileSys.close();      cluster.shutdown();    }  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -