You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ec...@apache.org on 2015/02/03 01:47:12 UTC
svn commit: r1656611 - in /commons/proper/vfs/trunk:
core/src/main/java/org/apache/commons/vfs2/provider/hdfs/HdfsFileSystem.java
core/src/main/java/org/apache/commons/vfs2/provider/hdfs/HdfsFileSystemConfigBuilder.java
src/changes/changes.xml
Author: ecki
Date: Tue Feb 3 00:47:12 2015
New Revision: 1656611
URL: http://svn.apache.org/r1656611
Log:
[VFS-555] additional javadoc, changes.xml and cleanup.
Modified:
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/hdfs/HdfsFileSystem.java
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/hdfs/HdfsFileSystemConfigBuilder.java
commons/proper/vfs/trunk/src/changes/changes.xml
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/hdfs/HdfsFileSystem.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/hdfs/HdfsFileSystem.java?rev=1656611&r1=1656610&r2=1656611&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/hdfs/HdfsFileSystem.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/hdfs/HdfsFileSystem.java Tue Feb 3 00:47:12 2015
@@ -96,25 +96,29 @@ public class HdfsFileSystem extends Abst
}
/**
- * @see org.apache.commons.vfs2.provider.AbstractFileSystem#resolveFile(org.apache.commons.vfs2.FileName)
+ * Resolve FileName into FileObject.
+ * @param name The name of a file on the HdfsFileSystem.
+ * @return resolved FileObject.
+ * @throws FileSystemException if an error occurred.
*/
@Override
public FileObject resolveFile(final FileName name) throws FileSystemException
{
-
synchronized (this)
{
- if (null == this.fs)
+ if (this.fs == null)
{
final String hdfsUri = name.getRootURI();
+ final String configName = HdfsFileSystemConfigBuilder.getInstance().getConfigName(getFileSystemOptions());
+
final Configuration conf = new Configuration(true);
conf.set(FileSystem.FS_DEFAULT_NAME_KEY, hdfsUri);
- String configName = HdfsFileSystemConfigBuilder.getInstance().getConfigName(getFileSystemOptions());
- if (configName != null) {
- log.debug("Adding alternate configuration file: " + configName);
+ if (configName != null)
+ {
+ log.debug("Adding HDFS configuration file: " + configName);
conf.addResource(configName);
}
- this.fs = null;
+
try
{
fs = FileSystem.get(conf);
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/hdfs/HdfsFileSystemConfigBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/hdfs/HdfsFileSystemConfigBuilder.java?rev=1656611&r1=1656610&r2=1656611&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/hdfs/HdfsFileSystemConfigBuilder.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/hdfs/HdfsFileSystemConfigBuilder.java Tue Feb 3 00:47:12 2015
@@ -25,11 +25,13 @@ import org.apache.commons.vfs2.FileSyste
*
* @since 2.1
*/
-public class HdfsFileSystemConfigBuilder extends FileSystemConfigBuilder
+public final class HdfsFileSystemConfigBuilder extends FileSystemConfigBuilder
{
private static final HdfsFileSystemConfigBuilder BUILDER = new HdfsFileSystemConfigBuilder();
+ private static final String KEY_CONFIG_NAME = "configName";
- private HdfsFileSystemConfigBuilder() {
+ private HdfsFileSystemConfigBuilder()
+ {
super("hdfs.");
}
@@ -50,18 +52,35 @@ public class HdfsFileSystemConfigBuilder
return HdfsFileSystem.class;
}
- private static final String CONFIG_NAME = "config.name";
-
- public String getConfigName(final FileSystemOptions opts) {
- return this.getString(opts, CONFIG_NAME);
+ /**
+ * Get name of alternate configuration file.
+ *
+ * @return resource name of alternate configuration file or null.
+ * @param opts The FileSystemOptions.
+ * @see #setConfigName(FileSystemOptions, String)
+ */
+ public String getConfigName(final FileSystemOptions opts)
+ {
+ return this.getString(opts, KEY_CONFIG_NAME);
}
/**
- * Sets the name of an alternate configuration file to be loaded after the defaults.
+ * Sets the name of configuration file to be loaded after the defaults.
+ * <p>
+ * Specifies the name of a config file to override any specific HDFS settings.
+ * The property will be passed on to {@code org.apache.hadoop.conf.Configuration#addResource(String)}
+ * after the URL was set as the default name with: {@code Configuration#set(FileSystem.FS_DEFAULT_NAME_KEY, url)}.
+ * <p>
+ * One use for this is to set a different value for the {@code dfs.client.use.datanode.hostname}
+ * property in order to access HDFS files stored in an AWS installation (from outside their
+ * firewall). There are other possible uses too.
+ *
+ * @param opts The FileSystemOptions to modify.
+ * @param name resource name of additional configuration file or null.
*/
- public void setConfigName(final FileSystemOptions opts, final String name) {
- this.setParam(opts, CONFIG_NAME, name);
+ public void setConfigName(final FileSystemOptions opts, final String name)
+ {
+ this.setParam(opts, KEY_CONFIG_NAME, name);
}
-
}
Modified: commons/proper/vfs/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/src/changes/changes.xml?rev=1656611&r1=1656610&r2=1656611&view=diff
==============================================================================
--- commons/proper/vfs/trunk/src/changes/changes.xml (original)
+++ commons/proper/vfs/trunk/src/changes/changes.xml Tue Feb 3 00:47:12 2015
@@ -26,6 +26,9 @@
<!-- <action issue="VFS-443" dev="ggregory" type="update" due-to="nickallen"> -->
<!-- [Local] Need an easy way to convert from a FileObject to a File. -->
<!-- </action> -->
+ <action issue="VFS-555" dev="rwhitcomb" type="add">
+ [hdfs] Add the ability to specify an HDFS configuration file with HdfsFileSystemConfigBuilder.
+ </action>
<action issue="VFS-557" dev="ecki" type="fix">
[webdav][test] Create WebDav test directory in target/test. Avoid creating core/jackrabbit/tmp.
Logfiles of Jackrabbit are preserved when -DWebdavProviderTestCase.Debug=true is specified.