fmorg-git commented on code in PR #12222:
URL: https://github.com/apache/ozone/pull/12222#discussion_r4776446489
##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmLifecycleConfiguration.java:
##########
@@ -99,6 +103,52 @@ public BucketLayout getBucketLayout() {
return bucketLayout;
}
+ /**
+ * Returns when a multipart upload becomes eligible for abort and the rule
that aborts it. Among the enabled rules
+ * with an AbortIncompleteMultipartUpload action that match the multipart
upload, it is the one with the earliest
+ * abort time, and of rules with the same abort time the one listed first.
+ *
+ * @param keyName the key name of the multipart upload
+ * @param uploadCreationTime the creation time of the multipart upload in
milliseconds since epoch
+ * @param openKeyInfo supplies the open key of the multipart upload, which
has its tags, or null if there is none;
+ * it is called at most once, and only if a rule with a
tag filter has to be checked
+ * @return the abort time and the rule ID, or null if no rule applies to the
multipart upload
+ */
+ @Nullable
+ public LifecycleAbortInfo getAbortInfo(String keyName, long
uploadCreationTime,
+ CheckedSupplier<OmKeyInfo, IOException> openKeyInfo) throws IOException {
+ OmLCRule abortRule = null;
+ long abortTime = 0;
+ OmKeyInfo openKey = null;
+ for (OmLCRule rule : rules) {
+ OmLCAbortIncompleteMultipartUpload abort =
rule.getAbortIncompleteMultipartUpload();
+ if (!rule.isEnabled() || abort == null) {
+ continue;
+ }
+ String prefix = rule.getEffectivePrefix();
+ if (prefix != null && !keyName.startsWith(prefix)) {
+ continue;
+ }
+ // The time OmLCAbortIncompleteMultipartUpload#shouldAbort compares
with: a day is 24 hours, without rounding.
+ long ruleAbortTime = uploadCreationTime + abort.getDaysInMilli();
+ if (abortRule != null && ruleAbortTime >= abortTime) {
+ continue;
+ }
+ if (rule.isTagEnable()) {
+ if (openKey == null) {
+ openKey = openKeyInfo.get();
Review Comment:
could a `boolean` be used to ensure `openKeyInfo.get()` isn't called
multiple times across rules if `openKey` is null?
--
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]