ChenSammi commented on code in PR #9688:
URL: https://github.com/apache/ozone/pull/9688#discussion_r2781210374
##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmLifecycleConfiguration.java:
##########
@@ -312,14 +312,52 @@ public Builder setUpdateID(long uID) {
}
@Override
- public OmLifecycleConfiguration buildObject() {
- return new OmLifecycleConfiguration(this);
+ protected void validate() {
+ super.validate();
+ try {
+ if (StringUtils.isBlank(volume)) {
+ throw new OMException("Invalid lifecycle configuration: Volume
cannot be blank.",
+ OMException.ResultCodes.INVALID_REQUEST);
+ }
+
+ if (StringUtils.isBlank(bucket)) {
+ throw new OMException("Invalid lifecycle configuration: Bucket
cannot be blank.",
+ OMException.ResultCodes.INVALID_REQUEST);
+ }
+
+ if (rules.isEmpty()) {
+ throw new OMException("At least one rules needs to be specified in a
lifecycle configuration.",
+ OMException.ResultCodes.INVALID_REQUEST);
+ }
+
+ if (rules.size() > LC_MAX_RULES) {
+ throw new OMException("The number of lifecycle rules must not exceed
the allowed limit of "
+ + LC_MAX_RULES + " rules",
OMException.ResultCodes.INVALID_REQUEST);
+ }
+
+ if (!hasNoDuplicateID()) {
+ throw new OMException("Invalid lifecycle configuration: Duplicate
rule IDs found.",
+ OMException.ResultCodes.INVALID_REQUEST);
+ }
+
+ for (OmLCRule rule : rules) {
+ rule.valid(bucketLayout, creationTime);
+ }
+ } catch (OMException e) {
+ throw new IllegalArgumentException(e.getMessage(), e);
Review Comment:
@YutaLin , thanks for working on this task. Overall it looks good.
Since we have the verification in builder, can we remove the valid() and
hasNoDuplicateID() in outer class? or can we consolidate to have one function?
the main purpose if to remove the code duplication.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]