-
Notifications
You must be signed in to change notification settings - Fork 588
HDDS-9079. Implement a lightweight listKeys API #5115
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
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
03c9632
HDDS-9079. Implement a lightweight listKeys API
f02142f
Resolve compilation failures
bb205c0
Modify Java doc
1a0d457
Resolve Git CI/CD check failures
tanvipenumudy 0306141
Add extra lines
tanvipenumudy 8b295f3
Resolve checkstyle indentation errors
tanvipenumudy 3d51405
Update hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozo…
tanvipenumudy b7ca7e4
Revert "Update hadoop-ozone/ozone-manager/src/main/java/org/apache/ha…
tanvipenumudy 03709f3
Add a helper method to convert OmKeyInfo to BasicOmKeyInfo
tanvipenumudy 40dc2cf
Incorporate review comments
tanvipenumudy 912ed8e
Remove volumeName, bucketName from BasicKeyInfo
tanvipenumudy 997f1b5
Remove isFile field from BasicKeyInfo proto message
tanvipenumudy f722a70
Implement equals(), hashcode() in BasicOmKeyInfo
tanvipenumudy 7b99e85
Add isTruncated field to ListKeysLight Response
tanvipenumudy b53e630
Remove changes added for testing
tanvipenumudy 4a1c4f7
Change proto fields to optional
tanvipenumudy fae6690
Resolved merge conflicts in HDDS-9079
tanvipenumudy 5df6c0b
Merge remote-tracking branch 'origin' into HDDS-9079
tanvipenumudy 688f53c
Resolve xcompat-cluster-1.0.0-client-1.4.0-write issue
tanvipenumudy 35fe6a8
Remove xcompat/test.sh changes made for testing
tanvipenumudy c0621b2
Merge remote-tracking branch 'origin' into HDDS-9079
tanvipenumudy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
222 changes: 222 additions & 0 deletions
222
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/BasicOmKeyInfo.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,222 @@ | ||
| /** | ||
| * 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 | ||
| * <p> | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * <p> | ||
| * 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.ozone.om.helpers; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.Objects; | ||
|
|
||
| import org.apache.hadoop.hdds.client.ECReplicationConfig; | ||
| import org.apache.hadoop.hdds.client.ReplicationConfig; | ||
| import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.BasicKeyInfo; | ||
| import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListKeysRequest; | ||
|
|
||
| /** | ||
| * Lightweight OmKeyInfo class. | ||
| */ | ||
| public class BasicOmKeyInfo { | ||
|
|
||
| private String volumeName; | ||
| private String bucketName; | ||
| private String keyName; | ||
| private long dataSize; | ||
| private long creationTime; | ||
| private long modificationTime; | ||
| private ReplicationConfig replicationConfig; | ||
| private boolean isFile; | ||
|
|
||
| @SuppressWarnings("parameternumber") | ||
| public BasicOmKeyInfo(String volumeName, String bucketName, String keyName, | ||
| long dataSize, long creationTime, long modificationTime, | ||
| ReplicationConfig replicationConfig, boolean isFile) { | ||
| this.volumeName = volumeName; | ||
| this.bucketName = bucketName; | ||
| this.keyName = keyName; | ||
| this.dataSize = dataSize; | ||
| this.creationTime = creationTime; | ||
| this.modificationTime = modificationTime; | ||
| this.replicationConfig = replicationConfig; | ||
| this.isFile = isFile; | ||
| } | ||
|
|
||
| public String getVolumeName() { | ||
| return volumeName; | ||
| } | ||
|
|
||
| public String getBucketName() { | ||
| return bucketName; | ||
| } | ||
|
|
||
| public String getKeyName() { | ||
| return keyName; | ||
| } | ||
|
|
||
| public long getDataSize() { | ||
| return dataSize; | ||
| } | ||
|
|
||
| public long getCreationTime() { | ||
| return creationTime; | ||
| } | ||
|
|
||
| public long getModificationTime() { | ||
| return modificationTime; | ||
| } | ||
|
|
||
| public ReplicationConfig getReplicationConfig() { | ||
| return replicationConfig; | ||
| } | ||
|
|
||
| public boolean isFile() { | ||
| return isFile; | ||
| } | ||
|
|
||
| /** | ||
| * Builder of BasicOmKeyInfo. | ||
| */ | ||
| public static class Builder { | ||
| private String volumeName; | ||
| private String bucketName; | ||
| private String keyName; | ||
| private long dataSize; | ||
| private long creationTime; | ||
| private long modificationTime; | ||
| private ReplicationConfig replicationConfig; | ||
| private boolean isFile; | ||
|
|
||
| public Builder setVolumeName(String volumeName) { | ||
| this.volumeName = volumeName; | ||
| return this; | ||
| } | ||
|
|
||
| public Builder setBucketName(String bucketName) { | ||
| this.bucketName = bucketName; | ||
| return this; | ||
| } | ||
|
|
||
| public Builder setKeyName(String keyName) { | ||
| this.keyName = keyName; | ||
| return this; | ||
| } | ||
|
|
||
| public Builder setDataSize(long dataSize) { | ||
| this.dataSize = dataSize; | ||
| return this; | ||
| } | ||
|
|
||
| public Builder setCreationTime(long creationTime) { | ||
| this.creationTime = creationTime; | ||
| return this; | ||
| } | ||
|
|
||
| public Builder setModificationTime(long modificationTime) { | ||
| this.modificationTime = modificationTime; | ||
| return this; | ||
| } | ||
|
|
||
| public Builder setReplicationConfig(ReplicationConfig replicationConfig) { | ||
| this.replicationConfig = replicationConfig; | ||
| return this; | ||
| } | ||
|
|
||
| public Builder setIsFile(boolean isFile) { | ||
| this.isFile = isFile; | ||
| return this; | ||
| } | ||
|
|
||
| public BasicOmKeyInfo build() { | ||
| return new BasicOmKeyInfo(volumeName, bucketName, keyName, dataSize, | ||
| creationTime, modificationTime, replicationConfig, isFile); | ||
| } | ||
| } | ||
|
|
||
| public BasicKeyInfo getProtobuf() { | ||
| BasicKeyInfo.Builder builder = BasicKeyInfo.newBuilder() | ||
| .setKeyName(keyName) | ||
| .setDataSize(dataSize) | ||
| .setCreationTime(creationTime) | ||
| .setModificationTime(modificationTime) | ||
| .setType(replicationConfig.getReplicationType()); | ||
| if (replicationConfig instanceof ECReplicationConfig) { | ||
| builder.setEcReplicationConfig( | ||
| ((ECReplicationConfig) replicationConfig).toProto()); | ||
| } else { | ||
| builder.setFactor(ReplicationConfig.getLegacyFactor(replicationConfig)); | ||
| } | ||
|
|
||
| return builder.build(); | ||
| } | ||
|
|
||
| public static BasicOmKeyInfo getFromProtobuf(BasicKeyInfo basicKeyInfo, | ||
| ListKeysRequest request) | ||
| throws IOException { | ||
| if (basicKeyInfo == null || request == null) { | ||
| return null; | ||
| } | ||
|
|
||
| String keyName = basicKeyInfo.getKeyName(); | ||
|
|
||
| Builder builder = new Builder() | ||
tanvipenumudy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| .setVolumeName(request.getVolumeName()) | ||
| .setBucketName(request.getBucketName()) | ||
| .setKeyName(keyName) | ||
| .setDataSize(basicKeyInfo.getDataSize()) | ||
| .setCreationTime(basicKeyInfo.getCreationTime()) | ||
| .setModificationTime(basicKeyInfo.getModificationTime()) | ||
| .setReplicationConfig(ReplicationConfig.fromProto( | ||
| basicKeyInfo.getType(), | ||
| basicKeyInfo.getFactor(), | ||
| basicKeyInfo.getEcReplicationConfig())) | ||
| .setIsFile(!keyName.endsWith("/")); | ||
|
|
||
| return builder.build(); | ||
| } | ||
|
|
||
| public boolean equals(Object o) { | ||
| if (this == o) { | ||
| return true; | ||
| } | ||
| if (o == null || getClass() != o.getClass()) { | ||
| return false; | ||
| } | ||
| BasicOmKeyInfo basicOmKeyInfo = (BasicOmKeyInfo) o; | ||
| return volumeName.equals(basicOmKeyInfo.volumeName) && | ||
| bucketName.equals(basicOmKeyInfo.bucketName) && | ||
| keyName.equals(basicOmKeyInfo.keyName) && | ||
| dataSize == basicOmKeyInfo.dataSize && | ||
| creationTime == basicOmKeyInfo.creationTime && | ||
| modificationTime == basicOmKeyInfo.modificationTime && | ||
| replicationConfig.equals(basicOmKeyInfo.replicationConfig) && | ||
| isFile == basicOmKeyInfo.isFile; | ||
| } | ||
|
|
||
| public int hashCode() { | ||
| return Objects.hash(volumeName, bucketName, keyName); | ||
| } | ||
|
|
||
| public static BasicOmKeyInfo fromOmKeyInfo(OmKeyInfo omKeyInfo) { | ||
| return new BasicOmKeyInfo( | ||
| omKeyInfo.getVolumeName(), | ||
| omKeyInfo.getBucketName(), | ||
| omKeyInfo.getKeyName(), | ||
| omKeyInfo.getDataSize(), | ||
| omKeyInfo.getCreationTime(), | ||
| omKeyInfo.getModificationTime(), | ||
| omKeyInfo.getReplicationConfig(), | ||
| omKeyInfo.isFile()); | ||
| } | ||
| } | ||
tanvipenumudy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
43 changes: 43 additions & 0 deletions
43
...op-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/ListKeysLightResult.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| /** | ||
| * 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 | ||
| * <p> | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * <p> | ||
| * 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.ozone.om.helpers; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| /** | ||
| * Encapsulates the result of listKeys. It contains a list of | ||
| * {@link BasicOmKeyInfo} and a boolean flag indicating if the listing is | ||
| * truncated. | ||
| */ | ||
| public class ListKeysLightResult { | ||
| private List<BasicOmKeyInfo> keys; | ||
| private boolean isTruncated; | ||
|
|
||
| public ListKeysLightResult(List<BasicOmKeyInfo> keys, boolean isTruncated) { | ||
| this.keys = keys; | ||
| this.isTruncated = isTruncated; | ||
| } | ||
|
|
||
| public List<BasicOmKeyInfo> getKeys() { | ||
| return keys; | ||
| } | ||
|
|
||
| public boolean isTruncated() { | ||
| return isTruncated; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.