-
Notifications
You must be signed in to change notification settings - Fork 537
HDDS-12983. Validator Registry Changes for Supporting Version based validations #8404
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
base: master
Are you sure you want to change the base?
Conversation
…alidations Change-Id: I939888c989eaec0a62884aa564e2f24a594122ef
Change-Id: Icec10ce7bb452753db0936212b0757c01279b533
Change-Id: I9a010c86d0128da8140fa33b46eaeef9da0dc283
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 @swamirishi for the patch.
public List<Method> validationsFor(RequestType requestType, | ||
RequestProcessingPhase phase, | ||
Map<Class<? extends Annotation>, ? extends Versioned> requestVersions) { |
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.
Please do not format method signature like this. Whenever visibility / return type / method name / other modifiers are changed, we would have to reindent all parameters.
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.
done
Validator validator, String methodName, Class<ReturnValue> returnValueType) { | ||
try { | ||
return (ReturnValue) validator.getClass().getMethod(methodName).invoke(validator); |
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.
Use returnValueType
(currently unused) to cast the result, instead of using unchecked cast (ReturnValue)
.
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.
done
processingPhase = RequestProcessingPhase.PRE_PROCESS, | ||
requestType = Type.CreateBucket | ||
requestType = Type.CreateBucket, | ||
applyBefore = ClientVersion.BUCKET_LAYOUT_SUPPORT |
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:
applyBefore = ClientVersion.BUCKET_LAYOUT_SUPPORT | |
applyBefore = ClientVersion.BUCKET_LAYOUT_SUPPORT |
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.
done
* One validator can be applied in multiple, E.g. | ||
* {@link org.apache.hadoop.ozone.om.request.validation.OMClientVersionValidator}, | ||
* {@link org.apache.hadoop.ozone.om.request.validation.OMLayoutVersionValidator} |
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 don't think this sentence makes sense.
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.
updated the sentence lmk if it is ok now
ValidatorRegistry<OzoneManagerProtocolProtos.Type> registry = | ||
new ValidatorRegistry<>(OzoneManagerProtocolProtos.Type.class, PACKAGE, | ||
Arrays.stream(VersionExtractor.values()).map(VersionExtractor::getValidatorClass).collect(Collectors.toSet()), | ||
REQUEST_PROCESSING_PHASES); |
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 we avoid duplicating this logic in each test case?
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.
done
* @return All the items which has an index value greater than given index value. | ||
*/ | ||
public List<T> getItemsEqualToIdx(IDX indexValue) { |
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.
Javadoc mismatch ("greater than" vs. EqualTo
)
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.
done
*/ | ||
private static final class IndexedItems<T, IDX extends Comparable<IDX>> { | ||
private final List<T> items; | ||
private final TreeMap<IDX, Integer> indexMap; |
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.
Declare as interface: NavigableMap
.
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.
done
.sorted((validatorMethodPair1, validatorMethodPair2) -> | ||
Integer.compare( | ||
this.getApplyBeforeVersion(validatorMethodPair1.getKey()).version(), | ||
this.getApplyBeforeVersion(validatorMethodPair2.getKey()).version())) |
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.
Extract this lambda to a static method.
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.
done
List<Method> validations = registry.validationsFor(request.getCmdType(), PRE_PROCESS, | ||
this.getVersions(request)); |
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: remove this.
and do not wrap line.
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.
done
Change-Id: Ibf524d42e3d8535377105a07f8ca3213c8c62199
Change-Id: I67634e5517239bdec3965ed8819f9af6ecf577dd
Change-Id: Idf26bbc7e83877a71f46bafdf0216d70733a92ee
Change-Id: Idecefb392dbf5c01227d7c3702db1781b9edb073
Change-Id: I174cea546d6fd021e58966b3a5bca3672e9d567e # Conflicts: # hadoop-ozone/client/pom.xml # hadoop-ozone/interface-storage/pom.xml # hadoop-ozone/recon-codegen/pom.xml # hadoop-ozone/s3gateway/pom.xml
Change-Id: I132006b2b5a638e7f19d9ec1beb33b332d105e98
What changes were proposed in this pull request?
Making changes to the ValidatorRegistry class to be able to pull the validators registered and inturn being able to get all the underlying validator methods based on the usage of the registered feature validator based on a specified version, request processing phase and request type efficiently.
This is the last PR for completing the request validator fixes after breaking down
#6932 into smaller PRs
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-12983
How was this patch tested?
Adding unit tests