c-w commented on a change in pull request #452: HADOOP-16005: Add XAttr support
to WASB and ABFS
URL: https://github.com/apache/hadoop/pull/452#discussion_r352264786
##########
File path:
hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AzureBlobFileSystem.java
##########
@@ -632,6 +634,85 @@ public void setOwner(final Path path, final String owner,
final String group)
}
}
+ /**
+ * Set the value of an attribute for a path.
+ *
+ * @param path The path on which to set the attribute
+ * @param name The attribute to set
+ * @param value The byte value of the attribute to set (encoded in latin-1)
+ * @param flag The mode in which to set the attribute
+ * @throws IOException If there was an issue setting the attribute on Azure
+ * @throws IllegalArgumentException If name is null or empty or if value is
null
+ */
+ @Override
+ public void setXAttr(Path path, String name, byte[] value,
EnumSet<XAttrSetFlag> flag)
+ throws IOException {
+ LOG.debug(
+ "AzureBlobFileSystem.setXAttr path: {}", path);
+
+ if (name == null || name.isEmpty() || value == null) {
+ throw new IllegalArgumentException("A valid name and value must be
specified.");
+ }
+
+ Path qualifiedPath = makeQualified(path);
+ performAbfsAuthCheck(FsAction.READ_WRITE, qualifiedPath);
+
+ try {
+ Hashtable<String, String> properties = abfsStore.getPathStatus(path);
+ String xAttrName = ensureValidAttributeName(name);
+ boolean xAttrExists = properties.containsKey(xAttrName);
+ XAttrSetFlag.validate(name, xAttrExists, flag);
+
+ String xAttrValue = new String(value,
AzureBlobFileSystemStore.XMS_PROPERTIES_ENCODING);
+ properties.put(xAttrName, xAttrValue);
+ abfsStore.setPathProperties(path, properties);
+ } catch (AzureBlobFileSystemException ex) {
+ checkException(path, ex);
+ }
+ }
+
+ /**
+ * Get the value of an attribute for a path.
+ *
+ * @param path The path on which to get the attribute
+ * @param name The attribute to get
+ * @return The bytes of the attribute's value (encoded in latin-1)
+ * or null if the attribute does not exist
+ * @throws IOException If there was an issue getting the attribute from Azure
+ * @throws IllegalArgumentException If name is null or empty
+ */
+ @Override
+ public byte[] getXAttr(Path path, String name)
+ throws IOException {
+ LOG.debug(
+ "AzureBlobFileSystem.getXAttr path: {}", path);
Review comment:
Done in 54dcb1deae3420eebcb90f3ddca42903393a730e.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]