github-code-scanning[bot] commented on code in PR #13197:
URL: https://github.com/apache/druid/pull/13197#discussion_r1177684726
##########
server/src/main/java/org/apache/druid/server/coordinator/duty/RunRules.java:
##########
@@ -24,125 +24,96 @@
import org.apache.druid.java.util.common.DateTimes;
import org.apache.druid.java.util.emitter.EmittingLogger;
import org.apache.druid.metadata.MetadataRuleManager;
-import org.apache.druid.server.coordinator.CoordinatorStats;
+import org.apache.druid.server.coordinator.CoordinatorDynamicConfig;
import org.apache.druid.server.coordinator.DruidCluster;
-import org.apache.druid.server.coordinator.DruidCoordinator;
import org.apache.druid.server.coordinator.DruidCoordinatorRuntimeParams;
import org.apache.druid.server.coordinator.ReplicationThrottler;
+import org.apache.druid.server.coordinator.StrategicSegmentAssigner;
+import org.apache.druid.server.coordinator.loadqueue.SegmentLoadQueueManager;
import org.apache.druid.server.coordinator.rules.BroadcastDistributionRule;
import org.apache.druid.server.coordinator.rules.Rule;
+import org.apache.druid.server.coordinator.stats.CoordinatorRunStats;
import org.apache.druid.timeline.DataSegment;
import org.apache.druid.timeline.SegmentId;
import org.joda.time.DateTime;
-import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import java.util.stream.Collectors;
/**
+ * Duty to run retention rules.
+ * <p>
+ * The params returned from {@code run()} must have these fields initialized:
+ * <ul>
+ * <li>{@link DruidCoordinatorRuntimeParams#getBroadcastDatasources()}</li>
+ * <li>{@link DruidCoordinatorRuntimeParams#getReplicationManager()}</li>
+ * </ul>
+ * These fields are used by the downstream coordinator duty, {@link
BalanceSegments}.
*/
public class RunRules implements CoordinatorDuty
{
private static final EmittingLogger log = new EmittingLogger(RunRules.class);
private static final int MAX_MISSING_RULES = 10;
- private final ReplicationThrottler replicatorThrottler;
+ private final SegmentLoadQueueManager loadQueueManager;
- private final DruidCoordinator coordinator;
-
- public RunRules(DruidCoordinator coordinator)
- {
- this(
- new ReplicationThrottler(
- coordinator.getDynamicConfigs().getReplicationThrottleLimit(),
- coordinator.getDynamicConfigs().getReplicantLifetime(),
- false
- ),
- coordinator
- );
- }
-
- public RunRules(ReplicationThrottler replicatorThrottler, DruidCoordinator
coordinator)
+ public RunRules(SegmentLoadQueueManager loadQueueManager)
{
- this.replicatorThrottler = replicatorThrottler;
- this.coordinator = coordinator;
+ this.loadQueueManager = loadQueueManager;
}
@Override
public DruidCoordinatorRuntimeParams run(DruidCoordinatorRuntimeParams
params)
{
- replicatorThrottler.updateParams(
- coordinator.getDynamicConfigs().getReplicationThrottleLimit(),
- coordinator.getDynamicConfigs().getReplicantLifetime(),
- false
- );
-
- CoordinatorStats stats = new CoordinatorStats();
- DruidCluster cluster = params.getDruidCluster();
-
+ final DruidCluster cluster = params.getDruidCluster();
if (cluster.isEmpty()) {
- log.warn("Uh... I have no servers. Not assigning anything...");
+ log.warn("Cluster has no servers. Not running any rules.");
return params;
}
// Get used segments which are overshadowed by other used segments. Those
would not need to be loaded and
// eventually will be unloaded from Historical servers. Segments
overshadowed by *served* used segments are marked
// as unused in MarkAsUnusedOvershadowedSegments, and then eventually
Coordinator sends commands to Historical nodes
// to unload such segments in UnloadUnusedSegments.
- Set<DataSegment> overshadowed =
params.getDataSourcesSnapshot().getOvershadowedSegments();
-
- for (String tier : cluster.getTierNames()) {
- replicatorThrottler.updateReplicationState(tier);
- }
+ final Set<DataSegment> overshadowed =
params.getDataSourcesSnapshot().getOvershadowedSegments();
+ final Set<DataSegment> usedSegments = params.getUsedSegments();
+ log.info(
+ "Running rules for [%d] used segments. Skipping [%d] overshadowed
segments.",
+ usedSegments.size(), overshadowed.size()
+ );
- DruidCoordinatorRuntimeParams paramsWithReplicationManager = params
- .buildFromExistingWithoutSegmentsMetadata()
- .withReplicationManager(replicatorThrottler)
- .build();
+ final CoordinatorDynamicConfig dynamicConfig =
params.getCoordinatorDynamicConfig();
+ final ReplicationThrottler replicationThrottler = new ReplicationThrottler(
+ dynamicConfig.getReplicationThrottleLimit(),
+ dynamicConfig.getMaxNonPrimaryReplicantsToLoad()
Review Comment:
## Deprecated method or constructor invocation
Invoking [CoordinatorDynamicConfig.getMaxNonPrimaryReplicantsToLoad](1)
should be avoided because it has been deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/4898)
--
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]