github-code-scanning[bot] commented on code in PR #13197:
URL: https://github.com/apache/druid/pull/13197#discussion_r1066812010
##########
server/src/test/java/org/apache/druid/server/coordinator/BalanceSegmentsTest.java:
##########
@@ -538,69 +536,61 @@
mockDruidServer(druidServer3, "3", "normal", 0L, 100L,
Collections.emptyList());
mockDruidServer(druidServer4, "4", "normal", 0L, 100L,
Collections.emptyList());
- // Mock stuff that the coordinator needs
- mockCoordinator(coordinator);
+ DruidCoordinatorRuntimeParams params =
defaultRuntimeParamsBuilder(servers).build();
- DruidCoordinatorRuntimeParams params =
defaultRuntimeParamsBuilder(druidServers, peons).build();
-
- params = new BalanceSegmentsTester(coordinator).run(params);
+ params = new BalanceSegments(stateManager).run(params);
Assert.assertTrue(params.getCoordinatorStats().getTieredStat("movedCount",
"normal") > 0);
}
- /**
- * Testing that the dynamic coordinator config value,
percentOfSegmentsToConsiderPerMove, is honored when calling
- * out to pickSegmentToMove. This config limits the number of segments that
are considered when looking for a segment
- * to move.
- */
@Test
- public void testThatDynamicConfigIsHonoredWhenPickingSegmentToMove()
+ public void testThatMaxSegmentsToMoveIsHonored()
{
mockDruidServer(druidServer1, "1", "normal", 50L, 100L,
Arrays.asList(segment1, segment2));
mockDruidServer(druidServer2, "2", "normal", 30L, 100L,
Arrays.asList(segment3, segment4));
mockDruidServer(druidServer3, "3", "normal", 0L, 100L,
Collections.emptyList());
EasyMock.replay(druidServer4);
- mockCoordinator(coordinator);
-
BalancerStrategy strategy = EasyMock.createMock(BalancerStrategy.class);
// Move from non-decomissioning servers
+ final ServerHolder holder2 = new ServerHolder(druidServer2, peon2);
+
EasyMock.expect(
strategy.pickSegmentsToMove(
ImmutableList.of(
new ServerHolder(druidServer3, peon3, false),
- new ServerHolder(druidServer2, peon2, false),
+ holder2,
new ServerHolder(druidServer1, peon1, false)
),
broadcastDatasources,
- 40.0
+ 1
)
)
- .andReturn(ImmutableList.of(new
BalancerSegmentHolder(druidServer2, segment3)).iterator());
+ .andReturn(ImmutableList.of(new BalancerSegmentHolder(holder2,
segment3)).iterator());
EasyMock.expect(strategy.findNewSegmentHomeBalancer(EasyMock.anyObject(),
EasyMock.anyObject()))
.andReturn(new ServerHolder(druidServer3, peon3))
.anyTimes();
EasyMock.replay(strategy);
DruidCoordinatorRuntimeParams params = defaultRuntimeParamsBuilder(
- ImmutableList.of(druidServer1, druidServer2, druidServer3),
- ImmutableList.of(peon1, peon2, peon3),
- ImmutableList.of(false, false, false)
+ new ServerHolder(druidServer1, peon1),
+ new ServerHolder(druidServer2, peon2),
+ new ServerHolder(druidServer3, peon3)
)
.withDynamicConfigs(
CoordinatorDynamicConfig.builder()
.withMaxSegmentsToMove(1)
- .withUseBatchedSegmentSampler(false)
+ .withUseBatchedSegmentSampler(true)
Review Comment:
## Deprecated method or constructor invocation
Invoking [Builder.withUseBatchedSegmentSampler](1) should be avoided because
it has been deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/3652)
--
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]