diff --git a/CHANGES.txt b/CHANGES.txt index bdbfad7aa7..0ed450c0a8 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -622,6 +622,9 @@ Release 0.22.0 - Unreleased HADOOP-7184. Remove deprecated config local.cache.size from core-default.xml (todd) + HADOOP-7245. FsConfig should use constants in CommonConfigurationKeys. + (tomwhite via eli) + Release 0.21.1 - Unreleased IMPROVEMENTS diff --git a/src/java/org/apache/hadoop/fs/CommonConfigurationKeysPublic.java b/src/java/org/apache/hadoop/fs/CommonConfigurationKeysPublic.java index a401630cfd..3ea4ed70c2 100644 --- a/src/java/org/apache/hadoop/fs/CommonConfigurationKeysPublic.java +++ b/src/java/org/apache/hadoop/fs/CommonConfigurationKeysPublic.java @@ -118,6 +118,11 @@ public class CommonConfigurationKeysPublic { /** Default value for IO_SEQFILE_COMPRESS_BLOCKSIZE_KEY */ public static final int IO_SEQFILE_COMPRESS_BLOCKSIZE_DEFAULT = 1000000; /** See core-default.xml */ + public static final String IO_FILE_BUFFER_SIZE_KEY = + "io.file.buffer.size"; + /** Default value for IO_FILE_BUFFER_SIZE_KEY */ + public static final int IO_FILE_BUFFER_SIZE_DEFAULT = 4096; + /** See core-default.xml */ public static final String IO_SKIP_CHECKSUM_ERRORS_KEY = "io.skip.checksum.errors"; /** Default value for IO_SKIP_CHECKSUM_ERRORS_KEY */ diff --git a/src/java/org/apache/hadoop/fs/FsConfig.java b/src/java/org/apache/hadoop/fs/FsConfig.java index 5af30dee25..ffb3fec302 100644 --- a/src/java/org/apache/hadoop/fs/FsConfig.java +++ b/src/java/org/apache/hadoop/fs/FsConfig.java @@ -17,6 +17,13 @@ */ package org.apache.hadoop.fs; +import static org.apache.hadoop.fs.CommonConfigurationKeys.FS_HOME_DIR_DEFAULT; +import static org.apache.hadoop.fs.CommonConfigurationKeys.FS_HOME_DIR_KEY; +import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.FS_DEFAULT_NAME_DEFAULT; +import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY; +import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.IO_FILE_BUFFER_SIZE_DEFAULT; +import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.IO_FILE_BUFFER_SIZE_KEY; + import java.net.URI; import org.apache.hadoop.conf.Configuration; @@ -37,30 +44,24 @@ private FsConfig() {} // The Keys - static final String FS_DEFAULT_NAME_KEY = "fs.default.name"; - static final String FS_HOME_DIR_ROOT_KEY = "fs.homeDir"; static final String FS_REPLICATION_FACTOR_KEY = "dfs.replication"; static final String FS_BLOCK_SIZE_KEY = "dfs.block.size"; - static final String IO_BUFFER_SIZE_KEY ="io.file.buffer.size"; // The default values // Default values of SERVER_DEFAULT(-1) implies use the ones from // the target file system where files are created. - static final String FS_DEFAULT_NAME = "file:///"; - static final String FS_HOME_DIR_ROOT = "/user"; // relative to FS_DEFAULT static final short FS_DEFAULT_REPLICATION_FACTOR = 3; static final long FS_DEFAULT_BLOCK_SIZE = 32 * 1024 * 1024; - static final int IO_BUFFER_SIZE =4096; public static String getDefaultFsURI(final Configuration conf) { - return conf.get(FS_DEFAULT_NAME_KEY, FS_DEFAULT_NAME); + return conf.get(FS_DEFAULT_NAME_KEY, FS_DEFAULT_NAME_DEFAULT); } public static String getHomeDir(final Configuration conf) { - return conf.get(FS_HOME_DIR_ROOT_KEY, FS_HOME_DIR_ROOT); + return conf.get(FS_HOME_DIR_KEY, FS_HOME_DIR_DEFAULT); } public static short getDefaultReplicationFactor(final Configuration conf) { @@ -74,7 +75,7 @@ public static long getDefaultBlockSize(final Configuration conf) { public static int getDefaultIOBuffersize(final Configuration conf) { - return conf.getInt(IO_BUFFER_SIZE_KEY, IO_BUFFER_SIZE); + return conf.getInt(IO_FILE_BUFFER_SIZE_KEY, IO_FILE_BUFFER_SIZE_DEFAULT); } public static Class getImplClass(URI uri, Configuration conf) { @@ -95,7 +96,7 @@ public static void setDefaultFS(final Configuration conf, String uri) { } public static void setHomeDir(final Configuration conf, String path) { - conf.set(FS_HOME_DIR_ROOT_KEY, path); + conf.set(FS_HOME_DIR_KEY, path); } public static void setDefaultReplicationFactor(final Configuration conf, @@ -108,6 +109,6 @@ public static void setDefaultBlockSize(final Configuration conf, long bs) { } public static void setDefaultIOBuffersize(final Configuration conf, int bs) { - conf.setInt(IO_BUFFER_SIZE_KEY, bs); + conf.setInt(IO_FILE_BUFFER_SIZE_KEY, bs); } } diff --git a/src/test/core/org/apache/hadoop/fs/TestLocal_S3FileContextURI.java b/src/test/core/org/apache/hadoop/fs/TestLocal_S3FileContextURI.java index 2dac557c71..512567a8d5 100644 --- a/src/test/core/org/apache/hadoop/fs/TestLocal_S3FileContextURI.java +++ b/src/test/core/org/apache/hadoop/fs/TestLocal_S3FileContextURI.java @@ -18,7 +18,7 @@ package org.apache.hadoop.fs; - +import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.FS_DEFAULT_NAME_DEFAULT; import org.apache.hadoop.conf.Configuration; import org.junit.Before; @@ -29,7 +29,7 @@ public void setUp() throws Exception { Configuration S3Conf = new Configuration(); Configuration localConf = new Configuration(); - S3Conf.set(FsConfig.FS_DEFAULT_NAME, S3Conf.get("test.fs.s3.name")); + S3Conf.set(FS_DEFAULT_NAME_DEFAULT, S3Conf.get("test.fs.s3.name")); fc1 = FileContext.getFileContext(S3Conf); fc2 = FileContext.getFileContext(localConf); } diff --git a/src/test/core/org/apache/hadoop/fs/TestS3_LocalFileContextURI.java b/src/test/core/org/apache/hadoop/fs/TestS3_LocalFileContextURI.java index 16c9e41702..c6324f8dc9 100644 --- a/src/test/core/org/apache/hadoop/fs/TestS3_LocalFileContextURI.java +++ b/src/test/core/org/apache/hadoop/fs/TestS3_LocalFileContextURI.java @@ -18,7 +18,7 @@ package org.apache.hadoop.fs; - +import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.FS_DEFAULT_NAME_DEFAULT; import org.apache.hadoop.conf.Configuration; import org.junit.Before; @@ -31,8 +31,7 @@ public void setUp() throws Exception { fc2 = FileContext.getFileContext(localConf); Configuration s3conf = new Configuration(); - s3conf.set(FsConfig.FS_DEFAULT_NAME, s3conf.get("test.fs.s3.name")); + s3conf.set(FS_DEFAULT_NAME_DEFAULT, s3conf.get("test.fs.s3.name")); fc1 = FileContext.getFileContext(s3conf); - } }