You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by wa...@apache.org on 2014/04/28 21:48:19 UTC
svn commit: r1590767 - in
/hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common: ./
src/main/java/org/apache/hadoop/fs/
src/main/java/org/apache/hadoop/fs/viewfs/
src/test/java/org/apache/hadoop/fs/
Author: wang
Date: Mon Apr 28 19:48:18 2014
New Revision: 1590767
URL: http://svn.apache.org/r1590767
Log:
HADOOP-10520. Extended attributes definition and FileSystem APIs for extended attributes. Contributed by Yi Liu.
Added:
hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/XAttrSetFlag.java (with props)
Modified:
hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/CHANGES-HDFS-2006.txt
hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java
hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileContext.java
hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java
hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FilterFileSystem.java
hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FilterFs.java
hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ChRootedFileSystem.java
hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java
hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHarFileSystem.java
Modified: hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/CHANGES-HDFS-2006.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/CHANGES-HDFS-2006.txt?rev=1590767&r1=1590766&r2=1590767&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/CHANGES-HDFS-2006.txt (original)
+++ hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/CHANGES-HDFS-2006.txt Mon Apr 28 19:48:18 2014
@@ -8,6 +8,9 @@ HDFS-2006 (Unreleased)
IMPROVEMENTS
+ HADOOP-10520. Extended attributes definition and FileSystem APIs for
+ extended attributes. (Yi Liu via wang)
+
OPTIMIZATIONS
BUG FIXES
Modified: hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java?rev=1590767&r1=1590766&r2=1590767&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java (original)
+++ hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java Mon Apr 28 19:48:18 2014
@@ -1039,6 +1039,154 @@ public abstract class AbstractFileSystem
+ " doesn't support getAclStatus");
}
+ /**
+ * Set the xattr of a file or directory.
+ * Name must be prefixed with user/trusted/security/system which
+ * followed by ".", For example "user.attr".
+ * <p/>
+ * A regular user only can set xattr of "user" namespace.
+ * A super user can set xattr of "user" and "trusted" namespace.
+ * XAttr of "security" and "system" namespace is only used/exposed
+ * internally to the FS impl.
+ * <p/>
+ * For xattr of "user" namespace, its access permissions are
+ * defined by the file or directory permission bits.
+ * XAttr will be set only when login user has correct permissions.
+ * If the xattr exists, it will be replaced.
+ * <p/>
+ * @see <a href="http://en.wikipedia.org/wiki/Extended_file_attributes">
+ * http://en.wikipedia.org/wiki/Extended_file_attributes</a>
+ *
+ * @param path Path to modify
+ * @param name xattr name.
+ * @param value xattr value.
+ * @throws IOException
+ */
+ public void setXAttr(Path path, String name, byte[] value)
+ throws IOException {
+ setXAttr(path, name, value, EnumSet.of(XAttrSetFlag.CREATE,
+ XAttrSetFlag.REPLACE));
+ }
+
+ /**
+ * Set the xattr of a file or directory.
+ * Name must be prefixed with user/trusted/security/system which
+ * followed by ".", For example "user.attr".
+ * <p/>
+ * A regular user only can set xattr of "user" namespace.
+ * A super user can set xattr of "user" and "trusted" namespace.
+ * XAttr of "security" and "system" namespace is only used/exposed
+ * internally to the FS impl.
+ * <p/>
+ * For xattr of "user" namespace, its access permissions are
+ * defined by the file or directory permission bits.
+ * XAttr will be set only when login user has correct permissions.
+ * <p/>
+ * @see <a href="http://en.wikipedia.org/wiki/Extended_file_attributes">
+ * http://en.wikipedia.org/wiki/Extended_file_attributes</a>
+ *
+ * @param path Path to modify
+ * @param name xattr name.
+ * @param value xattr value.
+ * @param flag xattr set flag
+ * @throws IOException
+ */
+ public void setXAttr(Path path, String name, byte[] value,
+ EnumSet<XAttrSetFlag> flag) throws IOException {
+ throw new UnsupportedOperationException(getClass().getSimpleName()
+ + " doesn't support setXAttr");
+ }
+
+ /**
+ * Get xattr of a file or directory.
+ * Name must be prefixed with user/trusted/security/system.
+ * <p/>
+ * A regular user only can get xattr of "user" namespace.
+ * A super user can get xattr of "user" and "trusted" namespace.
+ * XAttr of "security" and "system" namespace is only used/exposed
+ * internally to the FS impl.
+ * <p/>
+ * XAttr will be returned only when login user has correct permissions.
+ * <p/>
+ * @see <a href="http://en.wikipedia.org/wiki/Extended_file_attributes">
+ * http://en.wikipedia.org/wiki/Extended_file_attributes</a>
+ *
+ * @param path Path to get extended attribute
+ * @param name xattr name.
+ * @return byte[] xattr value.
+ * @throws IOException
+ */
+ public byte[] getXAttr(Path path, String name) throws IOException {
+ throw new UnsupportedOperationException(getClass().getSimpleName()
+ + " doesn't support getXAttr");
+ }
+
+ /**
+ * Get all xattrs of a file or directory.
+ * Only xattrs which login user has correct permissions will be returned.
+ * <p/>
+ * A regular user only can get xattr of "user" namespace.
+ * A super user can get xattr of "user" and "trusted" namespace.
+ * XAttr of "security" and "system" namespace is only used/exposed
+ * internally to the FS impl.
+ * <p/>
+ * @see <a href="http://en.wikipedia.org/wiki/Extended_file_attributes">
+ * http://en.wikipedia.org/wiki/Extended_file_attributes</a>
+ *
+ * @param path Path to get extended attributes
+ * @return Map<String, byte[]> describing the XAttrs of the file or directory
+ * @throws IOException
+ */
+ public Map<String, byte[]> getXAttrs(Path path) throws IOException {
+ throw new UnsupportedOperationException(getClass().getSimpleName()
+ + " doesn't support getXAttrs");
+ }
+
+ /**
+ * Get the xattrs of a file or directory.
+ * Name must be prefixed with user/trusted/security/system.
+ * Only xattrs which login user has correct permissions will be returned.
+ * <p/>
+ * A regular user only can get xattr of "user" namespace.
+ * A super user can get xattr of "user" and "trusted" namespace.
+ * XAttr of "security" and "system" namespace is only used/exposed
+ * internally to the FS impl.
+ * <p/>
+ * @see <a href="http://en.wikipedia.org/wiki/Extended_file_attributes">
+ * http://en.wikipedia.org/wiki/Extended_file_attributes</a>
+ *
+ * @param path Path to get extended attributes
+ * @param names XAttr names.
+ * @return Map<String, byte[]> describing the XAttrs of the file or directory
+ * @throws IOException
+ */
+ public Map<String, byte[]> getXAttrs(Path path, List<String> names)
+ throws IOException {
+ throw new UnsupportedOperationException(getClass().getSimpleName()
+ + " doesn't support getXAttrs");
+ }
+
+ /**
+ * Remove xattr of a file or directory.
+ * Name must be prefixed with user/trusted/security/system.
+ * <p/>
+ * A regular user only can remove xattr of "user" namespace.
+ * A super user can remove xattr of "user" and "trusted" namespace.
+ * XAttr of "security" and "system" namespace is only used/exposed
+ * internally to the FS impl.
+ * <p/>
+ * @see <a href="http://en.wikipedia.org/wiki/Extended_file_attributes">
+ * http://en.wikipedia.org/wiki/Extended_file_attributes</a>
+ *
+ * @param path Path to remove extended attribute
+ * @param name xattr name
+ * @throws IOException
+ */
+ public void removeXAttr(Path path, String name) throws IOException {
+ throw new UnsupportedOperationException(getClass().getSimpleName()
+ + " doesn't support removeXAttr");
+ }
+
@Override //Object
public int hashCode() {
return myUri.hashCode();
Modified: hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileContext.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileContext.java?rev=1590767&r1=1590766&r2=1590767&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileContext.java (original)
+++ hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileContext.java Mon Apr 28 19:48:18 2014
@@ -2294,4 +2294,184 @@ public final class FileContext {
}
}.resolve(this, absF);
}
+
+ /**
+ * Set the xattr of a file or directory.
+ * Name must be prefixed with user/trusted/security/system which
+ * followed by ".", For example "user.attr".
+ * <p/>
+ * A regular user only can set xattr of "user" namespace.
+ * A super user can set xattr of "user" and "trusted" namespace.
+ * XAttr of "security" and "system" namespace is only used/exposed
+ * internally to the FS impl.
+ * <p/>
+ * For xattr of "user" namespace, its access permissions are
+ * defined by the file or directory permission bits.
+ * XAttr will be set only when login user has correct permissions.
+ * If the xattr exists, it will be replaced.
+ * <p/>
+ * @see <a href="http://en.wikipedia.org/wiki/Extended_file_attributes">
+ * http://en.wikipedia.org/wiki/Extended_file_attributes</a>
+ *
+ * @param path Path to modify
+ * @param name xattr name.
+ * @param value xattr value.
+ * @throws IOException
+ */
+ public void setXAttr(Path path, String name, byte[] value)
+ throws IOException {
+ setXAttr(path, name, value, EnumSet.of(XAttrSetFlag.CREATE,
+ XAttrSetFlag.REPLACE));
+ }
+
+ /**
+ * Set the xattr of a file or directory.
+ * Name must be prefixed with user/trusted/security/system which
+ * followed by ".", For example "user.attr".
+ * <p/>
+ * A regular user only can set xattr of "user" namespace.
+ * A super user can set xattr of "user" and "trusted" namespace.
+ * XAttr of "security" and "system" namespace is only used/exposed
+ * internally to the FS impl.
+ * <p/>
+ * For xattr of "user" namespace, its access permissions are
+ * defined by the file or directory permission bits.
+ * XAttr will be set only when login user has correct permissions.
+ * <p/>
+ * @see <a href="http://en.wikipedia.org/wiki/Extended_file_attributes">
+ * http://en.wikipedia.org/wiki/Extended_file_attributes</a>
+ *
+ * @param path Path to modify
+ * @param name xattr name.
+ * @param value xattr value.
+ * @param flag xattr set flag
+ * @throws IOException
+ */
+ public void setXAttr(Path path, final String name, final byte[] value,
+ final EnumSet<XAttrSetFlag> flag) throws IOException {
+ Path absF = fixRelativePart(path);
+ new FSLinkResolver<Void>() {
+ @Override
+ public Void next(final AbstractFileSystem fs, final Path p)
+ throws IOException {
+ fs.setXAttr(p, name, value, flag);
+ return null;
+ }
+ }.resolve(this, absF);
+ }
+
+ /**
+ * Get xattr of a file or directory.
+ * Name must be prefixed with user/trusted/security/system.
+ * <p/>
+ * A regular user only can get xattr of "user" namespace.
+ * A super user can get xattr of "user" and "trusted" namespace.
+ * XAttr of "security" and "system" namespace is only used/exposed
+ * internally to the FS impl.
+ * <p/>
+ * XAttr will be returned only when login user has correct permissions.
+ * <p/>
+ * @see <a href="http://en.wikipedia.org/wiki/Extended_file_attributes">
+ * http://en.wikipedia.org/wiki/Extended_file_attributes</a>
+ *
+ * @param path Path to get extended attribute
+ * @param name xattr name.
+ * @return byte[] xattr value.
+ * @throws IOException
+ */
+ public byte[] getXAttr(Path path, final String name) throws IOException {
+ Path absF = fixRelativePart(path);
+ return new FSLinkResolver<byte[]>() {
+ @Override
+ public byte[] next(final AbstractFileSystem fs, final Path p)
+ throws IOException {
+ return fs.getXAttr(p, name);
+ }
+ }.resolve(this, absF);
+ }
+
+ /**
+ * Get all xattrs of a file or directory.
+ * Only xattrs which login user has correct permissions will be returned.
+ * <p/>
+ * A regular user only can get xattr of "user" namespace.
+ * A super user can get xattr of "user" and "trusted" namespace.
+ * XAttr of "security" and "system" namespace is only used/exposed
+ * internally to the FS impl.
+ * <p/>
+ * @see <a href="http://en.wikipedia.org/wiki/Extended_file_attributes">
+ * http://en.wikipedia.org/wiki/Extended_file_attributes</a>
+ *
+ * @param path Path to get extended attributes
+ * @return Map<String, byte[]> describing the XAttrs of the file or directory
+ * @throws IOException
+ */
+ public Map<String, byte[]> getXAttrs(Path path) throws IOException {
+ Path absF = fixRelativePart(path);
+ return new FSLinkResolver<Map<String, byte[]>>() {
+ @Override
+ public Map<String, byte[]> next(final AbstractFileSystem fs, final Path p)
+ throws IOException {
+ return fs.getXAttrs(p);
+ }
+ }.resolve(this, absF);
+ }
+
+ /**
+ * Get the xattrs of a file or directory.
+ * Name must be prefixed with user/trusted/security/system.
+ * Only xattrs which login user has correct permissions will be returned.
+ * <p/>
+ * A regular user only can get xattr of "user" namespace.
+ * A super user can get xattr of "user" and "trusted" namespace.
+ * XAttr of "security" and "system" namespace is only used/exposed
+ * internally to the FS impl.
+ * <p/>
+ * @see <a href="http://en.wikipedia.org/wiki/Extended_file_attributes">
+ * http://en.wikipedia.org/wiki/Extended_file_attributes</a>
+ *
+ * @param path Path to get extended attributes
+ * @param names XAttr names.
+ * @return Map<String, byte[]> describing the XAttrs of the file or directory
+ * @throws IOException
+ */
+ public Map<String, byte[]> getXAttrs(Path path, final List<String> names)
+ throws IOException {
+ Path absF = fixRelativePart(path);
+ return new FSLinkResolver<Map<String, byte[]>>() {
+ @Override
+ public Map<String, byte[]> next(final AbstractFileSystem fs, final Path p)
+ throws IOException {
+ return fs.getXAttrs(p, names);
+ }
+ }.resolve(this, absF);
+ }
+
+ /**
+ * Remove xattr of a file or directory.
+ * Name must be prefixed with user/trusted/security/system.
+ * <p/>
+ * A regular user only can remove xattr of "user" namespace.
+ * A super user can remove xattr of "user" and "trusted" namespace.
+ * XAttr of "security" and "system" namespace is only used/exposed
+ * internally to the FS impl.
+ * <p/>
+ * @see <a href="http://en.wikipedia.org/wiki/Extended_file_attributes">
+ * http://en.wikipedia.org/wiki/Extended_file_attributes</a>
+ *
+ * @param path Path to remove extended attribute
+ * @param name xattr name
+ * @throws IOException
+ */
+ public void removeXAttr(Path path, final String name) throws IOException {
+ Path absF = fixRelativePart(path);
+ new FSLinkResolver<Void>() {
+ @Override
+ public Void next(final AbstractFileSystem fs, final Path p)
+ throws IOException {
+ fs.removeXAttr(p, name);
+ return null;
+ }
+ }.resolve(this, absF);
+ }
}
Modified: hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java?rev=1590767&r1=1590766&r2=1590767&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java (original)
+++ hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java Mon Apr 28 19:48:18 2014
@@ -2350,6 +2350,154 @@ public abstract class FileSystem extends
+ " doesn't support getAclStatus");
}
+ /**
+ * Set the xattr of a file or directory.
+ * Name must be prefixed with user/trusted/security/system which
+ * followed by ".", For example "user.attr".
+ * <p/>
+ * A regular user only can set xattr of "user" namespace.
+ * A super user can set xattr of "user" and "trusted" namespace.
+ * XAttr of "security" and "system" namespace is only used/exposed
+ * internally to the FS impl.
+ * <p/>
+ * For xattr of "user" namespace, its access permissions are
+ * defined by the file or directory permission bits.
+ * XAttr will be set only when login user has correct permissions.
+ * If the xattr exists, it will be replaced.
+ * <p/>
+ * @see <a href="http://en.wikipedia.org/wiki/Extended_file_attributes">
+ * http://en.wikipedia.org/wiki/Extended_file_attributes</a>
+ *
+ * @param path Path to modify
+ * @param name xattr name.
+ * @param value xattr value.
+ * @throws IOException
+ */
+ public void setXAttr(Path path, String name, byte[] value)
+ throws IOException {
+ setXAttr(path, name, value, EnumSet.of(XAttrSetFlag.CREATE,
+ XAttrSetFlag.REPLACE));
+ }
+
+ /**
+ * Set the xattr of a file or directory.
+ * Name must be prefixed with user/trusted/security/system which
+ * followed by ".", For example "user.attr".
+ * <p/>
+ * A regular user only can set xattr of "user" namespace.
+ * A super user can set xattr of "user" and "trusted" namespace.
+ * XAttr of "security" and "system" namespace is only used/exposed
+ * internally to the FS impl.
+ * <p/>
+ * For xattr of "user" namespace, its access permissions are
+ * defined by the file or directory permission bits.
+ * XAttr will be set only when login user has correct permissions.
+ * <p/>
+ * @see <a href="http://en.wikipedia.org/wiki/Extended_file_attributes">
+ * http://en.wikipedia.org/wiki/Extended_file_attributes</a>
+ *
+ * @param path Path to modify
+ * @param name xattr name.
+ * @param value xattr value.
+ * @param flag xattr set flag
+ * @throws IOException
+ */
+ public void setXAttr(Path path, String name, byte[] value,
+ EnumSet<XAttrSetFlag> flag) throws IOException {
+ throw new UnsupportedOperationException(getClass().getSimpleName()
+ + " doesn't support setXAttr");
+ }
+
+ /**
+ * Get xattr of a file or directory.
+ * Name must be prefixed with user/trusted/security/system.
+ * <p/>
+ * A regular user only can get xattr of "user" namespace.
+ * A super user can get xattr of "user" and "trusted" namespace.
+ * XAttr of "security" and "system" namespace is only used/exposed
+ * internally to the FS impl.
+ * <p/>
+ * XAttr will be returned only when login user has correct permissions.
+ * <p/>
+ * @see <a href="http://en.wikipedia.org/wiki/Extended_file_attributes">
+ * http://en.wikipedia.org/wiki/Extended_file_attributes</a>
+ *
+ * @param path Path to get extended attribute
+ * @param name xattr name.
+ * @return byte[] xattr value.
+ * @throws IOException
+ */
+ public byte[] getXAttr(Path path, String name) throws IOException {
+ throw new UnsupportedOperationException(getClass().getSimpleName()
+ + " doesn't support getXAttr");
+ }
+
+ /**
+ * Get all xattrs of a file or directory.
+ * Only xattrs which login user has correct permissions will be returned.
+ * <p/>
+ * A regular user only can get xattr of "user" namespace.
+ * A super user can get xattr of "user" and "trusted" namespace.
+ * XAttr of "security" and "system" namespace is only used/exposed
+ * internally to the FS impl.
+ * <p/>
+ * @see <a href="http://en.wikipedia.org/wiki/Extended_file_attributes">
+ * http://en.wikipedia.org/wiki/Extended_file_attributes</a>
+ *
+ * @param path Path to get extended attributes
+ * @return Map<String, byte[]> describing the XAttrs of the file or directory
+ * @throws IOException
+ */
+ public Map<String, byte[]> getXAttrs(Path path) throws IOException {
+ throw new UnsupportedOperationException(getClass().getSimpleName()
+ + " doesn't support getXAttrs");
+ }
+
+ /**
+ * Get the xattrs of a file or directory.
+ * Name must be prefixed with user/trusted/security/system.
+ * Only xattrs which login user has correct permissions will be returned.
+ * <p/>
+ * A regular user only can get xattr of "user" namespace.
+ * A super user can get xattr of "user" and "trusted" namespace.
+ * XAttr of "security" and "system" namespace is only used/exposed
+ * internally to the FS impl.
+ * <p/>
+ * @see <a href="http://en.wikipedia.org/wiki/Extended_file_attributes">
+ * http://en.wikipedia.org/wiki/Extended_file_attributes</a>
+ *
+ * @param path Path to get extended attributes
+ * @param names XAttr names.
+ * @return Map<String, byte[]> describing the XAttrs of the file or directory
+ * @throws IOException
+ */
+ public Map<String, byte[]> getXAttrs(Path path, List<String> names)
+ throws IOException {
+ throw new UnsupportedOperationException(getClass().getSimpleName()
+ + " doesn't support getXAttrs");
+ }
+
+ /**
+ * Remove xattr of a file or directory.
+ * Name must be prefixed with user/trusted/security/system.
+ * <p/>
+ * A regular user only can remove xattr of "user" namespace.
+ * A super user can remove xattr of "user" and "trusted" namespace.
+ * XAttr of "security" and "system" namespace is only used/exposed
+ * internally to the FS impl.
+ * <p/>
+ * @see <a href="http://en.wikipedia.org/wiki/Extended_file_attributes">
+ * http://en.wikipedia.org/wiki/Extended_file_attributes</a>
+ *
+ * @param path Path to remove extended attribute
+ * @param name xattr name
+ * @throws IOException
+ */
+ public void removeXAttr(Path path, String name) throws IOException {
+ throw new UnsupportedOperationException(getClass().getSimpleName()
+ + " doesn't support removeXAttr");
+ }
+
// making it volatile to be able to do a double checked locking
private volatile static boolean FILE_SYSTEMS_LOADED = false;
Modified: hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FilterFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FilterFileSystem.java?rev=1590767&r1=1590766&r2=1590767&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FilterFileSystem.java (original)
+++ hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FilterFileSystem.java Mon Apr 28 19:48:18 2014
@@ -23,6 +23,7 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.util.EnumSet;
import java.util.List;
+import java.util.Map;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
@@ -538,4 +539,37 @@ public class FilterFileSystem extends Fi
public AclStatus getAclStatus(Path path) throws IOException {
return fs.getAclStatus(path);
}
+
+ @Override
+ public void setXAttr(Path path, String name, byte[] value)
+ throws IOException {
+ fs.setXAttr(path, name, value);
+ }
+
+ @Override
+ public void setXAttr(Path path, String name, byte[] value,
+ EnumSet<XAttrSetFlag> flag) throws IOException {
+ fs.setXAttr(path, name, value, flag);
+ }
+
+ @Override
+ public byte[] getXAttr(Path path, String name) throws IOException {
+ return fs.getXAttr(path, name);
+ }
+
+ @Override
+ public Map<String, byte[]> getXAttrs(Path path) throws IOException {
+ return fs.getXAttrs(path);
+ }
+
+ @Override
+ public Map<String, byte[]> getXAttrs(Path path, List<String> names)
+ throws IOException {
+ return fs.getXAttrs(path, names);
+ }
+
+ @Override
+ public void removeXAttr(Path path, String name) throws IOException {
+ fs.removeXAttr(path, name);
+ }
}
Modified: hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FilterFs.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FilterFs.java?rev=1590767&r1=1590766&r2=1590767&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FilterFs.java (original)
+++ hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FilterFs.java Mon Apr 28 19:48:18 2014
@@ -22,6 +22,7 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.util.EnumSet;
import java.util.List;
+import java.util.Map;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
@@ -316,4 +317,37 @@ public abstract class FilterFs extends A
public AclStatus getAclStatus(Path path) throws IOException {
return myFs.getAclStatus(path);
}
+
+ @Override
+ public void setXAttr(Path path, String name, byte[] value)
+ throws IOException {
+ myFs.setXAttr(path, name, value);
+ }
+
+ @Override
+ public void setXAttr(Path path, String name, byte[] value,
+ EnumSet<XAttrSetFlag> flag) throws IOException {
+ myFs.setXAttr(path, name, value, flag);
+ }
+
+ @Override
+ public byte[] getXAttr(Path path, String name) throws IOException {
+ return myFs.getXAttr(path, name);
+ }
+
+ @Override
+ public Map<String, byte[]> getXAttrs(Path path) throws IOException {
+ return myFs.getXAttrs(path);
+ }
+
+ @Override
+ public Map<String, byte[]> getXAttrs(Path path, List<String> names)
+ throws IOException {
+ return myFs.getXAttrs(path, names);
+ }
+
+ @Override
+ public void removeXAttr(Path path, String name) throws IOException {
+ myFs.removeXAttr(path, name);
+ }
}
Added: hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/XAttrSetFlag.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/XAttrSetFlag.java?rev=1590767&view=auto
==============================================================================
--- hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/XAttrSetFlag.java (added)
+++ hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/XAttrSetFlag.java Mon Apr 28 19:48:18 2014
@@ -0,0 +1,71 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.fs;
+
+import java.io.IOException;
+import java.util.EnumSet;
+
+import org.apache.hadoop.HadoopIllegalArgumentException;
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.classification.InterfaceStability;
+
+@InterfaceAudience.Public
+@InterfaceStability.Stable
+public enum XAttrSetFlag {
+ /**
+ * Create a new xattr.
+ * If the xattr exists already, exception will be thrown.
+ */
+ CREATE((short) 0x01),
+
+ /**
+ * Replace a existing xattr.
+ * If the xattr does not exist, exception will be thrown.
+ */
+ REPLACE((short) 0x02);
+
+ private final short flag;
+
+ private XAttrSetFlag(short flag) {
+ this.flag = flag;
+ }
+
+ short getFlag() {
+ return flag;
+ }
+
+ public static void validate(String xAttrName, boolean xAttrExists,
+ EnumSet<XAttrSetFlag> flag) throws IOException {
+ if (flag == null || flag.isEmpty()) {
+ throw new HadoopIllegalArgumentException("Should specify set flag");
+ }
+
+ if (xAttrExists) {
+ if (!flag.contains(REPLACE)) {
+ throw new IOException("XAttr: " + xAttrName +
+ " already exists. REPLACE flag must be specified.");
+ }
+ } else {
+ if (!flag.contains(CREATE)) {
+ throw new IOException("XAttr: " + xAttrName +
+ " does not exist. CREATE flag must be specified.");
+ }
+ }
+ }
+}
Propchange: hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/XAttrSetFlag.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ChRootedFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ChRootedFileSystem.java?rev=1590767&r1=1590766&r2=1590767&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ChRootedFileSystem.java (original)
+++ hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ChRootedFileSystem.java Mon Apr 28 19:48:18 2014
@@ -21,6 +21,7 @@ import java.io.IOException;
import java.net.URI;
import java.util.EnumSet;
import java.util.List;
+import java.util.Map;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
@@ -37,6 +38,7 @@ import org.apache.hadoop.fs.FilterFileSy
import org.apache.hadoop.fs.FsServerDefaults;
import org.apache.hadoop.fs.FsStatus;
import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.XAttrSetFlag;
import org.apache.hadoop.fs.permission.AclEntry;
import org.apache.hadoop.fs.permission.AclStatus;
import org.apache.hadoop.fs.permission.FsPermission;
@@ -314,6 +316,33 @@ class ChRootedFileSystem extends FilterF
}
@Override
+ public void setXAttr(Path path, String name, byte[] value,
+ EnumSet<XAttrSetFlag> flag) throws IOException {
+ super.setXAttr(fullPath(path), name, value, flag);
+ }
+
+ @Override
+ public byte[] getXAttr(Path path, String name) throws IOException {
+ return super.getXAttr(fullPath(path), name);
+ }
+
+ @Override
+ public Map<String, byte[]> getXAttrs(Path path) throws IOException {
+ return super.getXAttrs(fullPath(path));
+ }
+
+ @Override
+ public Map<String, byte[]> getXAttrs(Path path, List<String> names)
+ throws IOException {
+ return super.getXAttrs(fullPath(path), names);
+ }
+
+ @Override
+ public void removeXAttr(Path path, String name) throws IOException {
+ super.removeXAttr(fullPath(path), name);
+ }
+
+ @Override
public Path resolvePath(final Path p) throws IOException {
return super.resolvePath(fullPath(p));
}
Modified: hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java?rev=1590767&r1=1590766&r2=1590767&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java (original)
+++ hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java Mon Apr 28 19:48:18 2014
@@ -27,6 +27,7 @@ import java.util.Arrays;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
@@ -46,6 +47,7 @@ import org.apache.hadoop.fs.FsConstants;
import org.apache.hadoop.fs.FsServerDefaults;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.UnsupportedFileSystemException;
+import org.apache.hadoop.fs.XAttrSetFlag;
import org.apache.hadoop.fs.permission.AclEntry;
import org.apache.hadoop.fs.permission.AclStatus;
import org.apache.hadoop.fs.permission.FsPermission;
@@ -520,6 +522,43 @@ public class ViewFileSystem extends File
}
@Override
+ public void setXAttr(Path path, String name, byte[] value,
+ EnumSet<XAttrSetFlag> flag) throws IOException {
+ InodeTree.ResolveResult<FileSystem> res =
+ fsState.resolve(getUriPath(path), true);
+ res.targetFileSystem.setXAttr(res.remainingPath, name, value, flag);
+ }
+
+ @Override
+ public byte[] getXAttr(Path path, String name) throws IOException {
+ InodeTree.ResolveResult<FileSystem> res =
+ fsState.resolve(getUriPath(path), true);
+ return res.targetFileSystem.getXAttr(res.remainingPath, name);
+ }
+
+ @Override
+ public Map<String, byte[]> getXAttrs(Path path) throws IOException {
+ InodeTree.ResolveResult<FileSystem> res =
+ fsState.resolve(getUriPath(path), true);
+ return res.targetFileSystem.getXAttrs(res.remainingPath);
+ }
+
+ @Override
+ public Map<String, byte[]> getXAttrs(Path path, List<String> names)
+ throws IOException {
+ InodeTree.ResolveResult<FileSystem> res =
+ fsState.resolve(getUriPath(path), true);
+ return res.targetFileSystem.getXAttrs(res.remainingPath, names);
+ }
+
+ @Override
+ public void removeXAttr(Path path, String name) throws IOException {
+ InodeTree.ResolveResult<FileSystem> res = fsState.resolve(getUriPath(path),
+ true);
+ res.targetFileSystem.removeXAttr(res.remainingPath, name);
+ }
+
+ @Override
public void setVerifyChecksum(final boolean verifyChecksum) {
List<InodeTree.MountPoint<FileSystem>> mountPoints =
fsState.getMountPoints();
Modified: hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHarFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHarFileSystem.java?rev=1590767&r1=1590766&r2=1590767&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHarFileSystem.java (original)
+++ hadoop/common/branches/HDFS-2006/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHarFileSystem.java Mon Apr 28 19:48:18 2014
@@ -36,6 +36,7 @@ import java.lang.reflect.Modifier;
import java.util.EnumSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import static org.apache.hadoop.fs.Options.ChecksumOpt;
import static org.apache.hadoop.fs.Options.CreateOpts;
@@ -181,6 +182,21 @@ public class TestHarFileSystem {
public void setAcl(Path path, List<AclEntry> aclSpec) throws IOException;
+ public void setXAttr(Path path, String name, byte[] value)
+ throws IOException;
+
+ public void setXAttr(Path path, String name, byte[] value,
+ EnumSet<XAttrSetFlag> flag) throws IOException;
+
+ public byte[] getXAttr(Path path, String name) throws IOException;
+
+ public Map<String, byte[]> getXAttrs(Path path) throws IOException;
+
+ public Map<String, byte[]> getXAttrs(Path path, List<String> names)
+ throws IOException;
+
+ public void removeXAttr(Path path, String name) throws IOException;
+
public AclStatus getAclStatus(Path path) throws IOException;
}