clintropolis commented on code in PR #19374: URL: https://github.com/apache/druid/pull/19374#discussion_r3149076354
########## server/src/main/java/org/apache/druid/server/coordinator/rules/PeriodPartialLoadRule.java: ########## @@ -0,0 +1,104 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.druid.server.coordinator.rules; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import org.joda.time.DateTime; +import org.joda.time.Interval; +import org.joda.time.Period; + +import javax.annotation.Nullable; +import java.util.Map; +import java.util.Objects; + +/** + * Period-based variant of {@link PartialLoadRule}. Mirrors {@link PeriodLoadRule} for time-window semantics and layers + * on {@link PartialLoadMatcher} for selection. + */ +public class PeriodPartialLoadRule extends PartialLoadRule +{ + public static final String TYPE = "loadPartialByPeriod"; + + private final Period period; + private final boolean includeFuture; + + @JsonCreator + public PeriodPartialLoadRule( + @JsonProperty("period") Period period, + @JsonProperty("includeFuture") @Nullable Boolean includeFuture, + @JsonProperty("tieredReplicants") Map<String, Integer> tieredReplicants, + @JsonProperty("useDefaultTierForNull") @Nullable Boolean useDefaultTierForNull, + @JsonProperty("matcher") PartialLoadMatcher matcher, + @JsonProperty("onCannotMatch") @Nullable CannotMatchBehavior onCannotMatch + ) + { + super(tieredReplicants, useDefaultTierForNull, matcher, onCannotMatch); + this.period = period; + this.includeFuture = includeFuture == null ? PeriodLoadRule.DEFAULT_INCLUDE_FUTURE : includeFuture; + } + + @Override + @JsonProperty + public String getType() + { + return TYPE; + } + + @JsonProperty + public Period getPeriod() + { + return period; + } + + @JsonProperty + public boolean isIncludeFuture() + { + return includeFuture; + } + + @Override + public boolean appliesTo(Interval interval, DateTime referenceTimestamp) + { + return Rules.eligibleForLoad(period, interval, referenceTimestamp, includeFuture); Review Comment: i switched isHandOffComplete to use the metadata snapshot to use the version of appliesTo that takes a segment so that it will work properly. I didn't make any changes for TieredBrokerHostSelector, since i'm not really sure how to improve that, i guess we can document it when we document the rest of this stuff. -- 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]
