github-code-scanning[bot] commented on code in PR #13197:
URL: https://github.com/apache/druid/pull/13197#discussion_r1167765355
##########
server/src/test/java/org/apache/druid/server/coordinator/rules/BroadcastDistributionRuleTest.java:
##########
@@ -402,18 +411,41 @@
largeSegments.get(2),
largeSegments2.get(0),
largeSegments2.get(1)
- ),
- smallSegment
+ )
);
- Assert.assertEquals(5L, stats.getGlobalStat(LoadRule.ASSIGNED_COUNT));
- Assert.assertFalse(stats.hasPerTierStats());
+ Assert.assertEquals(2L,
stats.getSegmentStat(Stats.Segments.ASSIGNED_BROADCAST, TIER_1, DS_SMALL));
+ Assert.assertEquals(3L,
stats.getSegmentStat(Stats.Segments.ASSIGNED_BROADCAST, TIER_2, DS_SMALL));
Assert.assertTrue(
- druidCluster
- .getAllServers()
- .stream()
- .allMatch(holder -> holder.isLoadingSegment(smallSegment) ||
holder.isServingSegment(smallSegment))
+ druidCluster.getAllServers().stream().allMatch(
+ holder -> holder.isLoadingSegment(smallSegment) ||
holder.isServingSegment(smallSegment)
+ )
+ );
+ }
+
+ private CoordinatorRunStats runRuleAndGetStats(
+ Rule rule,
+ DataSegment segment,
+ DruidCoordinatorRuntimeParams params
+ )
+ {
+ final CoordinatorDynamicConfig dynamicConfig =
params.getCoordinatorDynamicConfig();
+ ReplicationThrottler throttler = new ReplicationThrottler(
+ Sets.newHashSet(params.getDruidCluster().getTierNames()),
+ dynamicConfig.getReplicationThrottleLimit(),
+ dynamicConfig.getReplicantLifetime(),
+ 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/4830)
##########
server/src/test/java/org/apache/druid/server/coordinator/CuratorDruidCoordinatorTest.java:
##########
@@ -497,4 +439,27 @@
.size(0)
.build();
}
+
+ private StrategicSegmentAssigner createSegmentAssigner(
+ SegmentLoadQueueManager loadQueueManager,
+ DruidCoordinatorRuntimeParams params,
+ String... tiersEligibleForReplication
+ )
+ {
+ final CoordinatorDynamicConfig dynamicConfig =
params.getCoordinatorDynamicConfig();
+ ReplicationThrottler throttler = new ReplicationThrottler(
+ new HashSet<>(Arrays.asList(tiersEligibleForReplication)),
+ dynamicConfig.getReplicationThrottleLimit(),
+ dynamicConfig.getReplicantLifetime(),
+ 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/4828)
##########
server/src/test/java/org/apache/druid/server/coordinator/rules/LoadRuleTest.java:
##########
@@ -117,397 +101,290 @@
@Before
public void setUp()
{
- EmittingLogger.registerEmitter(EMITTER);
- EMITTER.start();
- throttler = EasyMock.createMock(ReplicationThrottler.class);
-
exec = MoreExecutors.listeningDecorator(Execs.multiThreaded(1,
"LoadRuleTest-%d"));
balancerStrategy = new
CostBalancerStrategyFactory().createBalancerStrategy(exec);
cachingCostBalancerStrategy = new
CachingCostBalancerStrategy(ClusterCostCache.builder().build(), exec);
mockBalancerStrategy = EasyMock.createMock(BalancerStrategy.class);
+ stateManager = new SegmentLoadQueueManager(null, null, null);
}
@After
- public void tearDown() throws Exception
+ public void tearDown()
{
exec.shutdown();
- EMITTER.close();
}
@Test
public void testLoad()
{
-
EasyMock.expect(throttler.canCreateReplicant(EasyMock.anyString())).andReturn(true).anyTimes();
-
final LoadQueuePeon mockPeon = createEmptyPeon();
- mockPeon.loadSegment(EasyMock.anyObject(), EasyMock.anyObject());
+ mockPeon.loadSegment(EasyMock.anyObject(), EasyMock.anyObject(),
EasyMock.anyObject());
EasyMock.expectLastCall().atLeastOnce();
- LoadRule rule = createLoadRule(ImmutableMap.of(
- "hot", 1,
- DruidServer.DEFAULT_TIER, 2
- ));
-
- final DataSegment segment = createDataSegment("foo");
-
- throttler.registerReplicantCreation(DruidServer.DEFAULT_TIER,
segment.getId(), "hostNorm");
- EasyMock.expectLastCall().once();
-
if (!useRoundRobinAssignment) {
EasyMock.expect(mockBalancerStrategy.findNewSegmentHomeReplicator(EasyMock.anyObject(),
EasyMock.anyObject()))
.andDelegateTo(balancerStrategy)
- .times(3);
+ .times(2);
}
+ EasyMock.replay(mockPeon, mockBalancerStrategy);
- EasyMock.replay(throttler, mockPeon, mockBalancerStrategy);
-
- DruidCluster druidCluster = DruidClusterBuilder
- .newBuilder()
- .addTier(
- "hot",
- new ServerHolder(
- new DruidServer("serverHot", "hostHot", null, 1000,
ServerType.HISTORICAL, "hot", 1)
- .toImmutableDruidServer(),
- mockPeon
- )
- )
- .addTier(
- DruidServer.DEFAULT_TIER,
- new ServerHolder(
- new DruidServer(
- "serverNorm",
- "hostNorm",
- null,
- 1000,
- ServerType.HISTORICAL,
- DruidServer.DEFAULT_TIER,
- 0
- ).toImmutableDruidServer(),
- mockPeon
- )
- )
+ DruidCluster druidCluster = DruidCluster
+ .builder()
+ .addTier(Tier.T1, createServerHolder(Tier.T1, mockPeon, false))
+ .addTier(Tier.T2, createServerHolder(Tier.T2, mockPeon, false))
.build();
- CoordinatorStats stats = rule.run(null,
makeCoordinatorRuntimeParams(druidCluster, segment), segment);
+ final DataSegment segment = createDataSegment(DS_WIKI);
+ LoadRule rule = loadForever(ImmutableMap.of(Tier.T1, 1, Tier.T2, 2));
+ CoordinatorRunStats stats = runRuleAndGetStats(rule, segment,
druidCluster);
+
+ Assert.assertEquals(1L, stats.getSegmentStat(Stats.Segments.ASSIGNED,
Tier.T1, DS_WIKI));
+ Assert.assertEquals(1L, stats.getSegmentStat(Stats.Segments.ASSIGNED,
Tier.T2, DS_WIKI));
- Assert.assertEquals(1L, stats.getTieredStat(LoadRule.ASSIGNED_COUNT,
"hot"));
- Assert.assertEquals(1L, stats.getTieredStat(LoadRule.ASSIGNED_COUNT,
DruidServer.DEFAULT_TIER));
+ EasyMock.verify(mockPeon, mockBalancerStrategy);
+ }
- EasyMock.verify(throttler, mockPeon, mockBalancerStrategy);
+ private CoordinatorRunStats runRuleAndGetStats(
+ LoadRule rule,
+ DataSegment segment,
+ DruidCluster cluster
+ )
+ {
+ return runRuleAndGetStats(rule, segment,
makeCoordinatorRuntimeParams(cluster, segment));
+ }
+
+ private CoordinatorRunStats runRuleAndGetStats(
+ LoadRule rule,
+ DataSegment segment,
+ DruidCoordinatorRuntimeParams params
+ )
+ {
+ final CoordinatorDynamicConfig dynamicConfig =
params.getCoordinatorDynamicConfig();
+ ReplicationThrottler throttler = new ReplicationThrottler(
+ Sets.newHashSet(params.getDruidCluster().getTierNames()),
+ dynamicConfig.getReplicationThrottleLimit(),
+ dynamicConfig.getReplicantLifetime(),
+ 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/4829)
--
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]