github-advanced-security[bot] commented on code in PR #19557:
URL: https://github.com/apache/druid/pull/19557#discussion_r3359008720
##########
server/src/main/java/org/apache/druid/server/coordinator/rules/PartialLoadMatcher.java:
##########
@@ -50,6 +51,37 @@
@Nullable
MatchResult match(DataSegment segment, Map<String, Object> baseLoadSpec);
+ /**
+ * Returns the "empty" {@link MatchResult} this matcher produces for the
given segment when {@link #match} would
+ * return {@code null}, or {@code null} if this matcher has no meaningful
empty form.
+ *
+ * <p>An empty match is the matcher's way of saying "I do not match this
segment's content, but I am willing to
+ * partial-load it with a zero-content load spec so the broker's shard-group
completeness check still treats the
+ * group as queryable." The {@link RunRules} duty applies this in a
post-pass: when at least one sibling in the
+ * same shard group (same dataSource, interval, version) had a positive
match from this matcher, {@code RunRules}
+ * dispatches {@code emptyMatch} loads for the unmatched siblings. The
post-pass only fires when there's a real
+ * positive match somewhere in the group.
+ *
+ * <p>Matchers that produce uniform per-segment decisions across a shard
group don't need this and can leave the
+ * default null. Matchers that resolve per-segment within a shard group must
implement this to opt into the post-pass.
+ *
+ * <p>The returned wire form should:
+ * <ul>
+ * <li>use the same {@code type} and structural shape as {@link #match}'s
output, so the historical's
+ * {@code PartialLoadSpec} subtype can deserialize it without
special-casing.</li>
+ * <li>carry a stable, deterministic fingerprint so the coordinator's
reconciler doesn't churn replicas across
+ * runs when the same matcher produces the same empty result on the
same segment.</li>
+ * <li>describe a load that's actually empty on the historical side (e.g.
an empty list of projections or
+ * cluster-group indices). The historical-side {@code PartialLoadSpec}
subtype must accept this form and
+ * perform no scheme-specific data download.</li>
+ * </ul>
+ */
+ @Nullable
+ default MatchResult emptyMatch(DataSegment segment, Map<String, Object>
baseLoadSpec)
Review Comment:
## CodeQL / Useless parameter
The parameter 'segment' is never used.
[Show more
details](https://github.com/apache/druid/security/code-scanning/11294)
##########
server/src/main/java/org/apache/druid/server/coordinator/rules/RuleRunResult.java:
##########
@@ -0,0 +1,38 @@
+/*
+ * 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 org.apache.druid.server.coordinator.duty.RunRules;
+
+/**
+ * Result of a {@link Rule#run} invocation. Rules return {@link #OK} when
there is nothing for the {@link RunRules}
+ * duty to do beyond the actions the rule has already queued on the {@link
SegmentActionHandler}. Rules that need
+ * follow-up coordination across siblings in a shard group return a typed
implementation (today only
+ * {@link ShardGroupFollowup}); the {@link RunRules} duty dispatches on the
concrete type and applies it at an
+ * appropriate point during iteration.
+ * <p>
+ * To add a new kind of post-processing, implement this interface and add a
dispatch branch in {@link RunRules}.
+ */
+public interface RuleRunResult
+{
+ RuleRunResult OK = new RuleRunResult()
Review Comment:
## CodeQL / Constant interface anti-pattern
Type implements constant interface [RuleRunResult](1).
[Show more
details](https://github.com/apache/druid/security/code-scanning/11293)
##########
server/src/main/java/org/apache/druid/server/coordinator/rules/ShardGroupFollowup.java:
##########
@@ -0,0 +1,42 @@
+/*
+ * 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 org.apache.druid.timeline.DataSegment;
+
+import java.util.Map;
+
+/**
+ * Signal returned by {@link Rule#run} that the entire shard group containing
{@link #matchedSegment} should be
+ * inspected for uniform partial-load placement. The {@code RunRules} duty
collects these and, after all rules have
+ * run, dispatches {@link PartialLoadMatcher#emptyMatch} loads to siblings
that did not get a positive match from
+ * the same {@link #matcher}.
+ *
+ * <p>Used to handle asymmetric matchers (e.g. {@link
ClusterGroupPartialLoadMatcher} over range-partitioned segments)
+ * where different partitions of a shard group resolve to different load specs
and the broker would otherwise drop
+ * the group as incomplete via {@code PartitionHolder.isComplete()}.
+ */
+public record ShardGroupFollowup(
Review Comment:
## CodeQL / Constant interface anti-pattern
Type ShardGroupFollowup implements constant interface [RuleRunResult](1).
[Show more
details](https://github.com/apache/druid/security/code-scanning/11292)
--
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]