-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Coordinator loadstatus API full format does not consider Broadcast rules #10048
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,6 +69,7 @@ | |
| import org.apache.druid.server.coordinator.duty.MarkAsUnusedOvershadowedSegments; | ||
| import org.apache.druid.server.coordinator.duty.RunRules; | ||
| import org.apache.druid.server.coordinator.duty.UnloadUnusedSegments; | ||
| import org.apache.druid.server.coordinator.rules.BroadcastDistributionRule; | ||
| import org.apache.druid.server.coordinator.rules.LoadRule; | ||
| import org.apache.druid.server.coordinator.rules.Rule; | ||
| import org.apache.druid.server.initialization.ZkPathsConfig; | ||
|
|
@@ -262,13 +263,25 @@ public Map<String, Object2LongMap<String>> computeUnderReplicationCountsPerDataS | |
| } | ||
|
|
||
| /** | ||
| * segmentReplicantLookup use in this method could potentially be stale since it is only updated on coordinator runs. | ||
| * However, this is ok as long as the {@param dataSegments} is refreshed/latest as this would at least still ensure | ||
| * that the stale data in segmentReplicantLookup would be under counting replication levels, | ||
| * rather than potentially falsely reporting that everything is available. | ||
| * | ||
| * @return tier -> { dataSource -> underReplicationCount } map | ||
| */ | ||
| public Map<String, Object2LongMap<String>> computeUnderReplicationCountsPerDataSourcePerTierForSegments( | ||
| Iterable<DataSegment> dataSegments | ||
| ) | ||
| { | ||
| final Map<String, Object2LongMap<String>> underReplicationCountsPerDataSourcePerTier = new HashMap<>(); | ||
| final Set<String> decommissioningServers = getDynamicConfigs().getDecommissioningNodes(); | ||
| final List<ImmutableDruidServer> broadcastTargetServers = serverInventoryView | ||
| .getInventory() | ||
| .stream() | ||
| .filter(druidServer -> druidServer.isSegmentBroadcastTarget() && !decommissioningServers.contains(druidServer.getHost())) | ||
| .map(DruidServer::toImmutableDruidServer) | ||
| .collect(Collectors.toList()); | ||
|
|
||
| if (segmentReplicantLookup == null) { | ||
| return underReplicationCountsPerDataSourcePerTier; | ||
|
|
@@ -280,20 +293,38 @@ public Map<String, Object2LongMap<String>> computeUnderReplicationCountsPerDataS | |
| final List<Rule> rules = metadataRuleManager.getRulesWithDefault(segment.getDataSource()); | ||
|
|
||
| for (final Rule rule : rules) { | ||
| if (!(rule instanceof LoadRule && rule.appliesTo(segment, now))) { | ||
| if (!rule.appliesTo(segment, now)) { | ||
| continue; | ||
| } | ||
|
|
||
| ((LoadRule) rule) | ||
| .getTieredReplicants() | ||
| .forEach((final String tier, final Integer ruleReplicants) -> { | ||
| int currentReplicants = segmentReplicantLookup.getLoadedReplicants(segment.getId(), tier); | ||
| Object2LongMap<String> underReplicationPerDataSource = underReplicationCountsPerDataSourcePerTier | ||
| .computeIfAbsent(tier, ignored -> new Object2LongOpenHashMap<>()); | ||
| if (rule instanceof LoadRule) { | ||
| ((LoadRule) rule) | ||
| .getTieredReplicants() | ||
| .forEach((final String tier, final Integer ruleReplicants) -> { | ||
| int currentReplicants = segmentReplicantLookup.getLoadedReplicants(segment.getId(), tier); | ||
| Object2LongMap<String> underReplicationPerDataSource = underReplicationCountsPerDataSourcePerTier | ||
| .computeIfAbsent(tier, ignored -> new Object2LongOpenHashMap<>()); | ||
| ((Object2LongOpenHashMap<String>) underReplicationPerDataSource) | ||
| .addTo(segment.getDataSource(), Math.max(ruleReplicants - currentReplicants, 0)); | ||
| }); | ||
| } | ||
|
|
||
| if (rule instanceof BroadcastDistributionRule) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not right now. A Rule subclass may not always be needed to be considered in this method. Also not sure how the test will be able to automatically create new Rule subclass
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe adding some comments to somewhere like
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| for (ImmutableDruidServer server : broadcastTargetServers) { | ||
| Object2LongMap<String> underReplicationPerDataSource = underReplicationCountsPerDataSourcePerTier | ||
| .computeIfAbsent(server.getTier(), ignored -> new Object2LongOpenHashMap<>()); | ||
| if (server.getSegment(segment.getId()) == null) { | ||
| ((Object2LongOpenHashMap<String>) underReplicationPerDataSource) | ||
| .addTo(segment.getDataSource(), Math.max(ruleReplicants - currentReplicants, 0)); | ||
| }); | ||
| break; // only the first matching rule applies | ||
| .addTo(segment.getDataSource(), 1); | ||
| } else { | ||
| // This make sure that every datasource has a entry even if the all segments are loaded | ||
| underReplicationPerDataSource.putIfAbsent(segment.getDataSource(), 0); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // only the first matching rule applies | ||
| break; | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a previous PR there was a discussion about why it's ok for
segmentReplicantLookupto be stale in this method: https://github.com/apache/druid/pull/9965/files#r440541949What do you think about having that explanation as a code comment for this method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done