浏览代码

HDFS-6309. Javadocs for Xattrs apis in DFSClient and other minor fixups. Contributed by Charles Lamb.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-2006@1591716 13f79535-47bb-0310-9956-ffa450edef68
Uma Maheswara Rao G 11 年之前
父节点
当前提交
64006137a6

+ 2 - 0
hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-2006.txt

@@ -12,6 +12,8 @@ HDFS-2006 (Unreleased)
 
    HDFS-6302. Implement XAttr as a INode feature. (Yi Liu via umamahesh)
 
+   HDFS-6309. Javadocs for Xattrs apis in DFSClient and other minor fixups. (Charles Lamb via umamahesh)
+
   OPTIMIZATIONS
 
   BUG FIXES

+ 18 - 16
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/fs/XAttr.java

@@ -20,23 +20,25 @@ package org.apache.hadoop.fs;
 import java.util.Arrays;
 
 /**
- * XAttr is POSIX Extended Attribute model, similar to the one in traditional 
- * Operating Systems. Extended Attribute consists of a name and associated 
- * data, and 4 namespaces are defined: user, trusted, security and system.
+ * XAttr is the POSIX Extended Attribute model similar to that found in
+ * traditional Operating Systems.  Extended Attributes consist of one
+ * or more name/value pairs associated with a file or directory. Four
+ * namespaces are defined: user, trusted, security and system.
+ *   1) USER namespace attributes may be used by any user to store
+ *   arbitrary information. Access permissions in this namespace are
+ *   defined by a file directory's permission bits.
  * <br>
- *   1). USER namespace extended attribute may be assigned for storing 
- *   arbitrary additional information, and its access permissions are 
- *   defined by file/directory permission bits.
- *   <br>
- *   2). TRUSTED namespace extended attribute are visible and accessible 
- *   only to privilege user (file/directory owner or fs admin), and it is 
- *   available from both user space (filesystem API) and fs kernel.
- *   <br>
- *   3). SYSTEM namespace extended attribute is used by fs kernel to store 
- *   system objects, and only available in fs kernel. It's not visible to users.
- *   <br>
- *   4). SECURITY namespace extended attribute is used by fs kernel for 
- *   security features, and it's not visible to users.
+ *   2) TRUSTED namespace attributes are only visible and accessible to
+ *   privileged users (a file or directory's owner or the fs
+ *   admin). This namespace is available from both user space
+ *   (filesystem API) and fs kernel.
+ * <br>
+ *   3) SYSTEM namespace attributes are used by the fs kernel to store
+ *   system objects.  This namespace is only available in the fs
+ *   kernel. It is not visible to users.
+ * <br>
+ *   4) SECURITY namespace attributes are used by the fs kernel for
+ *   security features. It is not visible to users.
  * <p/>
  * @see <a href="http://en.wikipedia.org/wiki/Extended_file_attributes">
  * http://en.wikipedia.org/wiki/Extended_file_attributes</a>

+ 6 - 6
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java

@@ -2771,7 +2771,7 @@ public class DFSClient implements java.io.Closeable, RemotePeerFactory {
     int prefixIndex = name.indexOf(".");
     if (prefixIndex == -1) {
       throw new HadoopIllegalArgumentException("XAttr name must be prefixed with" +
-          " user/trusted/security/system which followed by '.'");
+          " user/trusted/security/system and followed by '.'");
     } else if (prefixIndex == name.length() -1) {
       throw new HadoopIllegalArgumentException("XAttr name can not be empty.");
     }
@@ -2788,7 +2788,7 @@ public class DFSClient implements java.io.Closeable, RemotePeerFactory {
       ns = XAttr.NameSpace.SYSTEM;
     } else {
       throw new HadoopIllegalArgumentException("XAttr name must be prefixed with" +
-          " user/trusted/security/system which followed by '.'");
+          " user/trusted/security/system and followed by '.'");
     }
     XAttr xAttr = (new XAttr.Builder()).setNameSpace(ns).setName(name.
         substring(prefixIndex + 1)).setValue(value).build();
@@ -2815,12 +2815,12 @@ public class DFSClient implements java.io.Closeable, RemotePeerFactory {
   public byte[] getXAttr(String src, String name) throws IOException {
     checkOpen();
     try {
-      XAttr xAttr = buildXAttr(name, null);
-      List<XAttr> xAttrs = Lists.newArrayListWithCapacity(1);
+      final XAttr xAttr = buildXAttr(name, null);
+      final List<XAttr> xAttrs = Lists.newArrayListWithCapacity(1);
       xAttrs.add(xAttr);
-      List<XAttr> result = namenode.getXAttrs(src, xAttrs);
+      final List<XAttr> result = namenode.getXAttrs(src, xAttrs);
       byte[] value = null;
-      if (result != null && result.size() > 0) {
+      if (result != null && !result.isEmpty()) {
         XAttr a = result.get(0);
         value = a.getValue();
         if (value == null) {