use of org.apache.druid.server.initialization.jetty.ServiceUnavailableException in project druid by druid-io.
the class DruidCoordinator method computeUnderReplicationCountsPerDataSourcePerTierForSegmentsInternal.
private Map<String, Object2LongMap<String>> computeUnderReplicationCountsPerDataSourcePerTierForSegmentsInternal(Iterable<DataSegment> dataSegments, boolean computeUsingClusterView) {
final Map<String, Object2LongMap<String>> underReplicationCountsPerDataSourcePerTier = new HashMap<>();
if (segmentReplicantLookup == null) {
return underReplicationCountsPerDataSourcePerTier;
}
if (computeUsingClusterView && cluster == null) {
throw new ServiceUnavailableException("coordinator hasn't populated information about cluster yet, try again later");
}
final DateTime now = DateTimes.nowUtc();
for (final DataSegment segment : dataSegments) {
final List<Rule> rules = metadataRuleManager.getRulesWithDefault(segment.getDataSource());
for (final Rule rule : rules) {
if (!rule.appliesTo(segment, now)) {
// Rule did not match. Continue to the next Rule.
continue;
}
if (!rule.canLoadSegments()) {
// Hence, there is no need to update underReplicationCountsPerDataSourcePerTier map
break;
}
if (computeUsingClusterView) {
rule.updateUnderReplicatedWithClusterView(underReplicationCountsPerDataSourcePerTier, segmentReplicantLookup, cluster, segment);
} else {
rule.updateUnderReplicated(underReplicationCountsPerDataSourcePerTier, segmentReplicantLookup, segment);
}
// and match each segment with the first rule that applies. Each segment may only match a single rule.
break;
}
}
return underReplicationCountsPerDataSourcePerTier;
}
Aggregations