You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2020/09/14 16:58:08 UTC
[commons-vfs] 03/05: Sort methods in AB order.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-vfs.git
commit 999685b605db9b19adfde33925e63809df3927dc
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Sep 14 12:56:20 2020 -0400
Sort methods in AB order.
---
.../commons/vfs2/provider/hdfs/HdfsFileObject.java | 76 ++++----
.../provider/hdfs/HdfsFileSystemConfigBuilder.java | 210 ++++++++++-----------
2 files changed, 143 insertions(+), 143 deletions(-)
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/hdfs/HdfsFileObject.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/hdfs/HdfsFileObject.java
index 4cec2f4..19b367f 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/hdfs/HdfsFileObject.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/hdfs/HdfsFileObject.java
@@ -95,6 +95,24 @@ public class HdfsFileObject extends AbstractFileObject<HdfsFileSystem> {
}
/**
+ * @see org.apache.commons.vfs2.provider.AbstractFileObject#doCreateFolder()
+ * @since 2.7.0
+ */
+ @Override
+ protected void doCreateFolder() throws Exception {
+ hdfs.mkdirs(this.path);
+ }
+
+ /**
+ * @see org.apache.commons.vfs2.provider.AbstractFileObject#doDelete()
+ * @since 2.7.0
+ */
+ @Override
+ protected void doDelete() throws Exception {
+ hdfs.delete(this.path, true);
+ }
+
+ /**
* @see org.apache.commons.vfs2.provider.AbstractFileObject#doGetAttributes()
*/
@Override
@@ -130,54 +148,27 @@ public class HdfsFileObject extends AbstractFileObject<HdfsFileSystem> {
}
/**
- * @see org.apache.commons.vfs2.provider.AbstractFileObject#doGetOutputStream(boolean)
- * @since 2.7.0
+ * @see org.apache.commons.vfs2.provider.AbstractFileObject#doGetLastModifiedTime()
*/
@Override
- protected OutputStream doGetOutputStream(final boolean append) throws Exception {
- if (append) {
- throw new FileSystemException("vfs.provider/write-append-not-supported.error", this.path.getName());
+ protected long doGetLastModifiedTime() throws Exception {
+ doAttach();
+ if (null != this.stat) {
+ return this.stat.getModificationTime();
}
- return hdfs.create(this.path);
- }
-
- /**
- * @see org.apache.commons.vfs2.provider.AbstractFileObject#doDelete()
- * @since 2.7.0
- */
- @Override
- protected void doDelete() throws Exception {
- hdfs.delete(this.path, true);
- }
-
- /**
- * @see org.apache.commons.vfs2.provider.AbstractFileObject#doCreateFolder()
- * @since 2.7.0
- */
- @Override
- protected void doCreateFolder() throws Exception {
- hdfs.mkdirs(this.path);
+ return -1;
}
/**
- * @see org.apache.commons.vfs2.provider.AbstractFileObject#doRename(FileObject)
+ * @see org.apache.commons.vfs2.provider.AbstractFileObject#doGetOutputStream(boolean)
* @since 2.7.0
*/
@Override
- protected void doRename(FileObject newfile) throws Exception {
- hdfs.rename(this.path, new Path(newfile.getName().getPath()));
- }
-
- /**
- * @see org.apache.commons.vfs2.provider.AbstractFileObject#doGetLastModifiedTime()
- */
- @Override
- protected long doGetLastModifiedTime() throws Exception {
- doAttach();
- if (null != this.stat) {
- return this.stat.getModificationTime();
+ protected OutputStream doGetOutputStream(final boolean append) throws Exception {
+ if (append) {
+ throw new FileSystemException("vfs.provider/write-append-not-supported.error", this.path.getName());
}
- return -1;
+ return hdfs.create(this.path);
}
/**
@@ -274,6 +265,15 @@ public class HdfsFileObject extends AbstractFileObject<HdfsFileSystem> {
}
/**
+ * @see org.apache.commons.vfs2.provider.AbstractFileObject#doRename(FileObject)
+ * @since 2.7.0
+ */
+ @Override
+ protected void doRename(FileObject newfile) throws Exception {
+ hdfs.rename(this.path, new Path(newfile.getName().getPath()));
+ }
+
+ /**
* @see org.apache.commons.vfs2.provider.AbstractFileObject#doSetAttribute(java.lang.String, java.lang.Object)
*/
@Override
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/hdfs/HdfsFileSystemConfigBuilder.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/hdfs/HdfsFileSystemConfigBuilder.java
index 6e0114a..fb8630c 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/hdfs/HdfsFileSystemConfigBuilder.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/hdfs/HdfsFileSystemConfigBuilder.java
@@ -41,10 +41,6 @@ public final class HdfsFileSystemConfigBuilder extends FileSystemConfigBuilder {
private static final String KEY_CONFIG_STREAM = "configStream";
private static final String KEY_CONFIG_CONF = "configConf";
- private HdfsFileSystemConfigBuilder() {
- super("hdfs.");
- }
-
/**
* @return HdfsFileSystemConfigBuilder instance
*/
@@ -52,6 +48,10 @@ public final class HdfsFileSystemConfigBuilder extends FileSystemConfigBuilder {
return BUILDER;
}
+ private HdfsFileSystemConfigBuilder() {
+ super("hdfs.");
+ }
+
/**
* @return HDFSFileSystem
*/
@@ -61,6 +61,28 @@ public final class HdfsFileSystemConfigBuilder extends FileSystemConfigBuilder {
}
/**
+ * Get alternate configuration object.
+ *
+ * @return alternate configuration object or {@code null}.
+ * @param opts The FileSystemOptions.
+ * @see #setConfigConfiguration(FileSystemOptions, Configuration)
+ */
+ public Configuration getConfigConfiguration(final FileSystemOptions opts) {
+ return (Configuration) this.getParam(opts, KEY_CONFIG_CONF);
+ }
+
+ /**
+ * Get alternate configuration input stream.
+ *
+ * @return alternate configuration input stream or {@code null}.
+ * @param opts The FileSystemOptions.
+ * @see #setConfigInputStream(FileSystemOptions, InputStream)
+ */
+ public InputStream getConfigInputStream(final FileSystemOptions opts) {
+ return (InputStream) this.getParam(opts, KEY_CONFIG_STREAM);
+ }
+
+ /**
* Get names of alternate configuration resources.
*
* @return resource name list of alternate configurations or {@code null}.
@@ -73,6 +95,85 @@ public final class HdfsFileSystemConfigBuilder extends FileSystemConfigBuilder {
}
/**
+ * Get paths of alternate configuration file system files.
+ *
+ * @return list of full paths of alternate configuration files or {@code null}.
+ * @param opts The FileSystemOptions.
+ * @see #setConfigPath(FileSystemOptions, Path)
+ */
+ public Path[] getConfigPaths(final FileSystemOptions opts) {
+ final String pathNames = this.getString(opts, KEY_CONFIG_PATHS);
+ if (pathNames == null || pathNames.isEmpty()) {
+ return null;
+ }
+ final String[] paths = pathNames.split(",");
+ return Arrays.stream(paths).map(Path::new).toArray(Path[]::new);
+ }
+
+ /**
+ * Get URLs of alternate configurations.
+ *
+ * @return list of alternate configuration URLs or {@code null}.
+ * @param opts The FileSystemOptions.
+ * @see #setConfigURL(FileSystemOptions, URL)
+ */
+ public URL[] getConfigURLs(final FileSystemOptions opts) {
+ try {
+ final String urlNames = this.getString(opts, KEY_CONFIG_URLS);
+ if (urlNames == null || urlNames.isEmpty()) {
+ return null;
+ }
+ final String[] urls = urlNames.split(",");
+ final URL[] realURLs = new URL[urls.length];
+ for (int i = 0; i < urls.length; i++) {
+ realURLs[i] = new URL(urls[i]);
+ }
+ return realURLs;
+ } catch (final MalformedURLException mue) {
+ // This should never happen because we save it in the proper form
+ }
+ return null;
+ }
+
+ /**
+ * Sets the configuration object to be loaded after the defaults.
+ * <p>
+ * Specifies an already initialized configuration object to override any specific HDFS settings. The property will
+ * be passed on to {@code org.apache.hadoop.conf.Configuration#addResource(Configuration)} 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 configuration additional configuration object or {@code null} to unset any configuration object previously
+ * set.
+ */
+ public void setConfigConfiguration(final FileSystemOptions opts, final Configuration configuration) {
+ this.setParam(opts, KEY_CONFIG_CONF, configuration);
+ }
+
+ /**
+ * Sets the input stream of configuration file to be loaded after the defaults.
+ * <p>
+ * Specifies an input stream connected to a config file to override any specific HDFS settings. The property will be
+ * passed on to {@code org.apache.hadoop.conf.Configuration#addResource(InputStream)} 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 inputStream input stream of additional configuration file or {@code null} to unset the configuration input
+ * stream previously set up.
+ */
+ public void setConfigInputStream(final FileSystemOptions opts, final InputStream inputStream) {
+ this.setParam(opts, KEY_CONFIG_STREAM, inputStream);
+ }
+
+ /**
* Sets the name of configuration resource to be loaded after the defaults.
* <p>
* Specifies the name of a config resource to override any specific HDFS settings. The property will be passed on to
@@ -111,22 +212,6 @@ public final class HdfsFileSystemConfigBuilder extends FileSystemConfigBuilder {
}
/**
- * Get paths of alternate configuration file system files.
- *
- * @return list of full paths of alternate configuration files or {@code null}.
- * @param opts The FileSystemOptions.
- * @see #setConfigPath(FileSystemOptions, Path)
- */
- public Path[] getConfigPaths(final FileSystemOptions opts) {
- final String pathNames = this.getString(opts, KEY_CONFIG_PATHS);
- if (pathNames == null || pathNames.isEmpty()) {
- return null;
- }
- final String[] paths = pathNames.split(",");
- return Arrays.stream(paths).map(Path::new).toArray(Path[]::new);
- }
-
- /**
* Sets the full path of configuration file to be loaded after the defaults.
* <p>
* Specifies the path of a local file system config file to override any specific HDFS settings. The property will
@@ -158,31 +243,6 @@ public final class HdfsFileSystemConfigBuilder extends FileSystemConfigBuilder {
}
/**
- * Get URLs of alternate configurations.
- *
- * @return list of alternate configuration URLs or {@code null}.
- * @param opts The FileSystemOptions.
- * @see #setConfigURL(FileSystemOptions, URL)
- */
- public URL[] getConfigURLs(final FileSystemOptions opts) {
- try {
- final String urlNames = this.getString(opts, KEY_CONFIG_URLS);
- if (urlNames == null || urlNames.isEmpty()) {
- return null;
- }
- final String[] urls = urlNames.split(",");
- final URL[] realURLs = new URL[urls.length];
- for (int i = 0; i < urls.length; i++) {
- realURLs[i] = new URL(urls[i]);
- }
- return realURLs;
- } catch (final MalformedURLException mue) {
- // This should never happen because we save it in the proper form
- }
- return null;
- }
-
- /**
* Sets the URL of configuration file to be loaded after the defaults.
* <p>
* Specifies the URL of a config file to override any specific HDFS settings. The property will be passed on to
@@ -212,64 +272,4 @@ public final class HdfsFileSystemConfigBuilder extends FileSystemConfigBuilder {
}
}
- /**
- * Get alternate configuration input stream.
- *
- * @return alternate configuration input stream or {@code null}.
- * @param opts The FileSystemOptions.
- * @see #setConfigInputStream(FileSystemOptions, InputStream)
- */
- public InputStream getConfigInputStream(final FileSystemOptions opts) {
- return (InputStream) this.getParam(opts, KEY_CONFIG_STREAM);
- }
-
- /**
- * Sets the input stream of configuration file to be loaded after the defaults.
- * <p>
- * Specifies an input stream connected to a config file to override any specific HDFS settings. The property will be
- * passed on to {@code org.apache.hadoop.conf.Configuration#addResource(InputStream)} 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 inputStream input stream of additional configuration file or {@code null} to unset the configuration input
- * stream previously set up.
- */
- public void setConfigInputStream(final FileSystemOptions opts, final InputStream inputStream) {
- this.setParam(opts, KEY_CONFIG_STREAM, inputStream);
- }
-
- /**
- * Get alternate configuration object.
- *
- * @return alternate configuration object or {@code null}.
- * @param opts The FileSystemOptions.
- * @see #setConfigConfiguration(FileSystemOptions, Configuration)
- */
- public Configuration getConfigConfiguration(final FileSystemOptions opts) {
- return (Configuration) this.getParam(opts, KEY_CONFIG_CONF);
- }
-
- /**
- * Sets the configuration object to be loaded after the defaults.
- * <p>
- * Specifies an already initialized configuration object to override any specific HDFS settings. The property will
- * be passed on to {@code org.apache.hadoop.conf.Configuration#addResource(Configuration)} 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 configuration additional configuration object or {@code null} to unset any configuration object previously
- * set.
- */
- public void setConfigConfiguration(final FileSystemOptions opts, final Configuration configuration) {
- this.setParam(opts, KEY_CONFIG_CONF, configuration);
- }
-
}