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_r254043661
########## File path: hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azure/NativeAzureFileSystem.java ########## @@ -3525,6 +3526,89 @@ public void setOwner(Path p, String username, String groupname) } } + /** + * 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 utf-8) + * @throws IOException If there was an issue setting the attribute on Azure + */ + @Override + public void setXAttr(Path path, String name, byte[] value, EnumSet<XAttrSetFlag> flag) throws IOException { + Path absolutePath = makeAbsolute(path); + + performAuthCheck(absolutePath, WasbAuthorizationOperations.WRITE, "setXAttr", absolutePath); + + String key = pathToKey(absolutePath); + + FileMetadata metadata; + + try { + metadata = store.retrieveMetadata(key); + } catch (IOException ex) { + Throwable innerException = NativeAzureFileSystemHelper.checkForAzureStorageException(ex); + + if (innerException instanceof StorageException + && NativeAzureFileSystemHelper.isFileNotFoundException((StorageException) innerException)) { + + throw new FileNotFoundException("File " + path + " doesn't exists."); + } + + throw ex; + } + + if (metadata == null) { + throw new FileNotFoundException("File doesn't exist: " + path); + } + + boolean xAttrExists = store.retrieveAttribute(key, name) != null; + + XAttrSetFlag.validate(name, xAttrExists, flag); + + store.storeAttribute(key, name, value); Review comment: There was the same naming in `getXAttr` so I also renamed it there in d076235. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-issues-h...@hadoop.apache.org