-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support set/get xattr #18053
Support set/get xattr #18053
Conversation
� Conflicts: � dora/core/server/proxy/src/main/java/alluxio/proxy/s3/S3BucketTask.java � dora/core/server/proxy/src/main/java/alluxio/proxy/s3/S3RestUtils.java � dora/core/server/worker/src/main/java/alluxio/worker/dora/PagedDoraWorker.java � dora/underfs/web/src/main/java/alluxio/underfs/web/WebUnderFileSystem.java
byte[] value) { | ||
try { | ||
UserDefinedFileAttributeView attributeView = | ||
Files.getFileAttributeView(Paths.get(filePath), UserDefinedFileAttributeView.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a comment to explain what is an attribute view what is this for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the attr only set locally and will lose after a worker restarts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the attr only set locally and will lose after a worker restarts?
No, it sets the attribute to the local file system, so it will not change after a worker restarts. (works in CentOS, not work in MacOS)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to add an example in javadoc.
* @return a FileInfo | ||
*/ | ||
public alluxio.grpc.FileInfo buildFileInfoFromUfsStatus(UfsStatus status, String ufsFullPath) { | ||
public alluxio.grpc.FileInfo buildFileInfoFromUfsStatus(UfsStatus status, String ufsFullPath, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: add a nullable annotation here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for the work! I left some comments PTAL
dora/core/common/src/main/java/alluxio/underfs/UnderFileSystem.java
Outdated
Show resolved
Hide resolved
dora/core/common/src/main/java/alluxio/underfs/UnderFileSystemWithLogging.java
Outdated
Show resolved
Hide resolved
dora/core/common/src/main/java/alluxio/underfs/ObjectUnderFileSystem.java
Show resolved
Hide resolved
byte[] value) { | ||
try { | ||
UserDefinedFileAttributeView attributeView = | ||
Files.getFileAttributeView(Paths.get(filePath), UserDefinedFileAttributeView.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to add an example in javadoc.
dora/underfs/obs/src/main/java/alluxio/underfs/obs/OBSUnderFileSystem.java
Show resolved
Hide resolved
dora/underfs/oss/src/main/java/alluxio/underfs/oss/OSSUnderFileSystem.java
Show resolved
Hide resolved
dora/underfs/s3a/src/main/java/alluxio/underfs/s3a/S3AUnderFileSystem.java
Show resolved
Hide resolved
dora/underfs/s3a/src/main/java/alluxio/underfs/s3a/S3AUnderFileSystem.java
Outdated
Show resolved
Hide resolved
dora/core/common/src/main/java/alluxio/underfs/UnderFileSystem.java
Outdated
Show resolved
Hide resolved
@@ -214,7 +214,12 @@ public Response continueTask() { | |||
try { | |||
List<URIStatus> children = mHandler.getMetaFS().listStatus(new AlluxioURI( | |||
S3RestUtils.MULTIPART_UPLOADS_METADATA_DIR)); | |||
return ListMultipartUploadsResult.buildFromStatuses(bucket, children); | |||
List<URIStatus> mpuList = new ArrayList<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add an annotation to explain why we need to get file status again.
dora/core/common/src/main/java/alluxio/underfs/UnderFileSystem.java
Outdated
Show resolved
Hide resolved
dora/core/common/src/main/java/alluxio/underfs/UnderFileSystemWithLogging.java
Outdated
Show resolved
Hide resolved
dora/core/common/src/main/java/alluxio/underfs/ObjectUnderFileSystem.java
Show resolved
Hide resolved
// GetListing doesn't contain the xattr info, so get status for MPU files. | ||
List<URIStatus> mpuList = new ArrayList<>(); | ||
for (URIStatus status : children) { | ||
URIStatus filemeta = mHandler.getMetaFS().getStatus(new AlluxioURI(status.getPath())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, when we use the MPU APIs of the north bound s3 api
@@ -457,6 +461,11 @@ public alluxio.grpc.FileInfo buildFileInfoFromUfsStatus(UfsStatus status, String | |||
.setGroup(status.getGroup()) | |||
.setCompleted(true) | |||
.setPersisted(true); | |||
if (xattrMap != null) { | |||
for (Map.Entry<String, String> entry : xattrMap.entrySet()) { | |||
infoBuilder.putXattr(entry.getKey(), ByteString.copyFromUtf8(entry.getValue())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
@@ -220,7 +220,6 @@ public synchronized void close() throws IOException { | |||
} | |||
mClosed = true; | |||
mPositionReader.close(); | |||
mUfs.close(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a bugfix that is already in main branch, cherrypick it for testing. will remove it.
@@ -232,8 +232,9 @@ public void listStatus(ListStatusPRequest request, | |||
UfsStatus status = statuses[i]; | |||
String ufsFullPath = PathUtils.concatPath(request.getPath(), status.getName()); | |||
|
|||
// the list statues do not include xattr now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
Tag tag = new Tag(name, value); | ||
tagList.add(tag); | ||
} | ||
mClient.setObjectTagging( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a comment like this to mention the case:
// It's a read-and-update race condition. When there is a competive conflict scenario,
// it may lead to inconsistent final results. The final conflict occurs in UFS,
// UFS will determine the final result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly LGTM with some relatively minor comments. Good to go when you see fit, and I'm stamping ahead of time. Thanks a lot for the work!
We might be able to add more UT cases, but you can do that in follow up PRs (and not necessarily but you alone)
@@ -1172,17 +1173,17 @@ public String methodName() { | |||
|
|||
@Override | |||
public String toString() { | |||
return String.format("path=%s, name=%s, value=%s", path, name, value); | |||
return String.format("path=%s, name=%s, value=%s", path, name, Arrays.toString(value)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we have helpers you can use, it's fine as-is here but you have more options next time
return MoreObjects.toStringHelper(this).add(xxx,xxx).toString();
Map<String, String> attrMap = new HashMap<>(); | ||
for (String attributeName : attributeView.list()) { | ||
int attributeSize = attributeView.size(attributeName); | ||
ByteBuffer attributeBuffer = ByteBuffer.allocate(attributeSize); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sanity check ^
dora/underfs/hdfs/src/main/java/alluxio/underfs/hdfs/HdfsUnderFileSystem.java
Outdated
Show resolved
Hide resolved
Map<String, String> attrMap = mUfs.getAttributes(testFilePath); | ||
assertEquals(attrMap.size(), 1); | ||
assertEquals(attrMap.get(attrKey), attrValue2); | ||
mUfs.deleteFile(testFilePath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete at the end of the test is not guaranted to happen. Could you move that to @After
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will move it to the finally
part. I'm not sure if deletion is necessary. I haven't seen it in other test cases, I just follow my personal habits.
What is the max size of tagging? |
we have the configuration property to limit the tag number we can set, the max size is 10. |
alluxio-bot, merge this please |
merge failed: |
alluxio-bot, merge this please |
### What changes are proposed in this pull request? Supports setXattr API of Alluxio FileSystem, it will set the corresponding attributes to UFS. If UFS is a filesystem, it's set through the setXattr interface of UFS. if UFS is object storage, it's set through setTagging API. ### Why are the changes needed? Based on the 3.x architecture, recover support for the setXattr interface. There are still many places where the interface is used, and it should not be supported at present. pr-link: Alluxio#18053 change-id: cid-4f8c96c88cced4374d54b6387bfc618b47d2a423
What changes are proposed in this pull request?
Supports setXattr API of Alluxio FileSystem, it will set the corresponding attributes to UFS. If UFS is a filesystem, it's set through the setXattr interface of UFS. if UFS is object storage, it's set through setTagging API.
Why are the changes needed?
Based on the 3.x architecture, recover support for the setXattr interface. There are still many places where the interface is used, and it should not be supported at present.