HDDS-15175. Introduce StorageClass and storage policy#10191
HDDS-15175. Introduce StorageClass and storage policy#10191xichen01 wants to merge 2 commits intoapache:HDDS-11233from
Conversation
chungen0126
left a comment
There was a problem hiding this comment.
Thanks @xichen01 for the patch. Overall, looks good to me, but I have a few minor suggestions.
| return StoragePolicyProto.COLD; | ||
| default: | ||
| throw new IllegalArgumentException( | ||
| "Error: StoragePolicyType not found, type=" + this); |
There was a problem hiding this comment.
nit: The class name is OzoneStoragePolicy.
| "Error: StoragePolicyType not found, type=" + this); | |
| "Error: OzoneStoragePolicy not found, type=" + this); |
| if (storageTypes.isEmpty()) { | ||
| return Collections.emptyList(); | ||
| } | ||
| return new ArrayList<>(Collections.nCopies(numberOfNodes, storageTypes.get(0))); |
There was a problem hiding this comment.
Should we consider making the StorageType list read-only to ensure immutability?
| return new ArrayList<>(Collections.nCopies(numberOfNodes, storageTypes.get(0))); | |
| return Collections.unmodifiableList(new ArrayList<>(Collections.nCopies(numberOfNodes, storageTypes.get(0))); |
| if (Arrays.stream(storageTypes).distinct().count() <= 1) { | ||
| throw new IllegalArgumentException("StorageTier '" + tierName + | ||
| "' requires at least two different StorageType instances." + | ||
| " but only " + Arrays.stream(storageTypes).distinct().count() + | ||
| " StorageType were provided."); | ||
| } |
There was a problem hiding this comment.
While I understand that non-uniform storage tiers aren't supported yet (so this line might not be reachable), Arrays.stream(storageTypes).distinct().count() is called twice here. We could assign it to a variable instead.
| if (Arrays.stream(storageTypes).distinct().count() <= 1) { | |
| throw new IllegalArgumentException("StorageTier '" + tierName + | |
| "' requires at least two different StorageType instances." + | |
| " but only " + Arrays.stream(storageTypes).distinct().count() + | |
| " StorageType were provided."); | |
| } | |
| long distinctStorageTypes = Arrays.stream(storageTypes).distinct().count(); | |
| if (distinctStorageTypes <= 1) { | |
| throw new IllegalArgumentException("StorageTier '" + tierName + | |
| "' requires at least two different StorageType instances." + | |
| " but only " + distinctStorageTypes + | |
| " StorageType were provided."); | |
| } |
| import org.apache.hadoop.hdds.client.StorageTier; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| class StoragePolicyTest { |
There was a problem hiding this comment.
Could you please add some unit tests to cover the Protobuf/Java conversion?
| * Ozone specific storage tiers. | ||
| */ | ||
| public enum StorageTier { | ||
| SSD("SSD", StorageType.SSD), |
There was a problem hiding this comment.
Do you think we may introduce the NVME storage type (here and below where it's needed)?
|
LGTM |
What changes were proposed in this pull request?
Introduce StorageClass and storage policy, introducing storage policy related definitions
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-15175
How was this patch tested?
unit test