HADOOP-7024. Create a test method for adding file systems during tests. Contributed by Kan Zhang.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1034184 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jakob Homan 2010-11-11 22:34:52 +00:00
parent 50659f1a76
commit ca3ef069cb
3 changed files with 23 additions and 0 deletions

View File

@ -168,6 +168,9 @@ Trunk (unreleased changes)
HADOOP-6977. Herriot daemon clients should vend statistics (cos) HADOOP-6977. Herriot daemon clients should vend statistics (cos)
HADOOP-7024. Create a test method for adding file systems during tests.
(Kan Zhang via jghoman)
OPTIMIZATIONS OPTIMIZATIONS
HADOOP-6884. Add LOG.isDebugEnabled() guard for each LOG.debug(..). HADOOP-6884. Add LOG.isDebugEnabled() guard for each LOG.debug(..).

View File

@ -103,6 +103,19 @@ public abstract class FileSystem extends Configured implements Closeable {
*/ */
private Set<Path> deleteOnExit = new TreeSet<Path>(); private Set<Path> deleteOnExit = new TreeSet<Path>();
/**
* This method adds a file system for testing so that we can find it later. It
* is only for testing.
* @param uri the uri to store it under
* @param conf the configuration to store it under
* @param fs the file system to store
* @throws IOException
*/
static void addFileSystemForTesting(URI uri, Configuration conf,
FileSystem fs) throws IOException {
CACHE.map.put(new Cache.Key(uri, conf), fs);
}
/** /**
* Get a filesystem instance based on the uri, the passed * Get a filesystem instance based on the uri, the passed
* configuration and the user * configuration and the user

View File

@ -20,8 +20,10 @@ package org.apache.hadoop.fs;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.net.URI;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.IOUtils; import org.apache.hadoop.io.IOUtils;
import org.junit.Assert; import org.junit.Assert;
@ -40,6 +42,11 @@ public final class FileSystemTestHelper {
/** Hidden constructor */ /** Hidden constructor */
private FileSystemTestHelper() {} private FileSystemTestHelper() {}
public static void addFileSystemForTesting(URI uri, Configuration conf,
FileSystem fs) throws IOException {
FileSystem.addFileSystemForTesting(uri, conf, fs);
}
public static int getDefaultBlockSize() { public static int getDefaultBlockSize() {
return DEFAULT_BLOCK_SIZE; return DEFAULT_BLOCK_SIZE;
} }