kfaraz commented on code in PR #15015:
URL: https://github.com/apache/druid/pull/15015#discussion_r1330928192
##########
server/src/main/java/org/apache/druid/server/coordinator/rules/ForeverBroadcastDistributionRule.java:
##########
@@ -56,6 +56,12 @@ public boolean appliesTo(Interval interval, DateTime
referenceTimestamp)
return true;
}
+ @Override
+ public Interval getInterval(DateTime referenceTimestamp)
+ {
+ return Rules.FOREVER_INTERVAL;
Review Comment:
Better use `Intervals.ETERNITY`.
##########
server/src/main/java/org/apache/druid/server/coordinator/rules/Rule.java:
##########
@@ -50,4 +50,6 @@ public interface Rule
boolean appliesTo(Interval interval, DateTime referenceTimestamp);
void run(DataSegment segment, SegmentActionHandler segmentHandler);
+
+ Interval getInterval(DateTime referenceTimestamp);
Review Comment:
Rename to `getApplicableInterval` or `getEligibleInterval`.
##########
server/src/main/java/org/apache/druid/server/coordinator/rules/Rules.java:
##########
@@ -19,12 +19,15 @@
package org.apache.druid.server.coordinator.rules;
+import org.apache.druid.java.util.common.DateTimes;
import org.joda.time.DateTime;
import org.joda.time.Interval;
import org.joda.time.Period;
public class Rules
{
+ public static final Interval FOREVER_INTERVAL = new
Interval(DateTimes.utc(Long.MIN_VALUE), DateTimes.utc(Long.MAX_VALUE));
Review Comment:
Not needed, you can use `Intervals.ETERNITY`.
##########
server/src/main/java/org/apache/druid/server/coordinator/rules/Rules.java:
##########
@@ -19,12 +19,15 @@
package org.apache.druid.server.coordinator.rules;
+import org.apache.druid.java.util.common.DateTimes;
import org.joda.time.DateTime;
import org.joda.time.Interval;
import org.joda.time.Period;
public class Rules
{
+ public static final Interval FOREVER_INTERVAL = new
Interval(DateTimes.utc(Long.MIN_VALUE), DateTimes.utc(Long.MAX_VALUE));
+
public static boolean eligibleForLoad(Interval src, Interval target)
Review Comment:
The eligibility methods should probably now use the newly added
`getInterval` method. This would simplify the code and would have the added
benefit of testing the `getInterval` method through existing unit tests.
##########
server/src/main/java/org/apache/druid/server/coordinator/rules/PeriodBroadcastDistributionRule.java:
##########
@@ -65,6 +65,12 @@ public boolean appliesTo(Interval interval, DateTime
referenceTimestamp)
return Rules.eligibleForLoad(period, interval, referenceTimestamp,
includeFuture);
}
+ @Override
+ public Interval getInterval(DateTime referenceTimestamp)
+ {
+ return new Interval(referenceTimestamp.minus(period), referenceTimestamp);
Review Comment:
You can use `new Interval(period, referenceTimestamp)` instead.
##########
server/src/main/java/org/apache/druid/server/http/RulesResource.java:
##########
@@ -181,4 +186,37 @@ private List<AuditEntry> getRuleHistory(
return auditManager.fetchAuditHistory(AUDIT_HISTORY_TYPE, theInterval);
}
+ /**
+ * Validate rules. Throws an exception if a rule contain an interval that
will overshadow another rules' interval.
+ * Rules that will be evaluated at some point are considered to be
non-overshadowing.
+ * @param rules Datasource rules.
+ */
+ private void validateRules(final List<Rule> rules)
Review Comment:
The logic here can be error prone and would require thorough testing. Best
move it out into a separate class called `RulesValidator` or as a public static
method in `Rules` utility class itself.
##########
server/src/main/java/org/apache/druid/server/http/RulesResource.java:
##########
@@ -181,4 +186,37 @@ private List<AuditEntry> getRuleHistory(
return auditManager.fetchAuditHistory(AUDIT_HISTORY_TYPE, theInterval);
}
+ /**
+ * Validate rules. Throws an exception if a rule contain an interval that
will overshadow another rules' interval.
Review Comment:
I would prefer not using the word overshadow as it has a very specific
meaning in Druid. Better use simpler words like "fully cover" or "fully hide"
or anything else that works.
--
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]