KKcorps commented on code in PR #14811:
URL: https://github.com/apache/pinot/pull/14811#discussion_r1920075761
##########
pinot-controller/src/test/java/org/apache/pinot/controller/helix/core/realtime/PinotLLCRealtimeSegmentManagerTest.java:
##########
@@ -1247,6 +1253,150 @@ public void testGetPartitionIds()
Assert.assertEquals(partitionIds.size(), 2);
}
+ @Test
+ public void testGetInstanceToConsumingSegments() {
+ PinotHelixResourceManager mockHelixResourceManager =
mock(PinotHelixResourceManager.class);
+ FakePinotLLCRealtimeSegmentManager realtimeSegmentManager =
+ new FakePinotLLCRealtimeSegmentManager(mockHelixResourceManager);
+ IdealState idealState = mock(IdealState.class);
+ Map<String, Map<String, String>> map = ImmutableMap.of(
+ "seg0", ImmutableMap.of("i1", "CONSUMING", "i4", "ONLINE"),
+ "seg1", ImmutableMap.of("i2", "CONSUMING"),
+ "seg2", ImmutableMap.of("i3", "CONSUMING", "i2", "OFFLINE"),
+ "seg3", ImmutableMap.of("i4", "CONSUMING", "i2", "CONSUMING", "i3",
"CONSUMING"),
+ "seg4", ImmutableMap.of("i5", "CONSUMING", "i1", "CONSUMING", "i3",
"CONSUMING")
+ );
+
+ ZNRecord znRecord = mock(ZNRecord.class);
+ when(znRecord.getMapFields()).thenReturn(map);
+ when(idealState.getRecord()).thenReturn(znRecord);
+ Set<String> targetConsumingSegment = new HashSet<>(map.keySet());
+
+ Map<String, Queue<String>> instanceToConsumingSegments =
+ realtimeSegmentManager.getInstanceToConsumingSegments(idealState,
targetConsumingSegment);
+ List<String> instanceList = ImmutableList.of("i1", "i2", "i3", "i4", "i5");
+
+ StringBuilder expectedSegNames = new StringBuilder();
+ for (String instanceName : instanceList) {
+ SortedSet<String> sortedSegNames = new
TreeSet<>(instanceToConsumingSegments.get(instanceName));
+ expectedSegNames.append(sortedSegNames);
+ }
+ assert expectedSegNames.toString()
+ .equals("[seg0, seg4][seg1, seg3][seg2, seg3, seg4][seg3][seg4]");
+ }
+
+ @Test
+ public void getSegmentBatchList() {
+ PinotHelixResourceManager mockHelixResourceManager =
mock(PinotHelixResourceManager.class);
+ FakePinotLLCRealtimeSegmentManager realtimeSegmentManager =
+ new FakePinotLLCRealtimeSegmentManager(mockHelixResourceManager);
+ IdealState idealState = mock(IdealState.class);
+
+ Map<String, Map<String, String>> map = ImmutableMap.of(
+ "seg0", ImmutableMap.of("i1", "CONSUMING", "i4", "ONLINE"),
+ "seg1", ImmutableMap.of("i2", "CONSUMING"),
+ "seg2", ImmutableMap.of("i3", "CONSUMING", "i2", "OFFLINE"),
+ "seg3", ImmutableMap.of("i4", "CONSUMING", "i2", "CONSUMING", "i3",
"CONSUMING"),
+ "seg4", ImmutableMap.of("i5", "CONSUMING", "i1", "CONSUMING", "i3",
"CONSUMING"),
+ "seg5", ImmutableMap.of("i6", "CONSUMING", "i1", "CONSUMING", "i3",
"CONSUMING"),
+ "seg6", ImmutableMap.of("i7", "CONSUMING", "i1", "CONSUMING", "i3",
"CONSUMING")
+ );
+
+ ZNRecord znRecord = mock(ZNRecord.class);
+ when(znRecord.getMapFields()).thenReturn(map);
+ when(idealState.getRecord()).thenReturn(znRecord);
+ Set<String> targetConsumingSegment = new HashSet<>(map.keySet());
+
+ List<Set<String>> segmentBatchList =
+ realtimeSegmentManager.getSegmentBatchList(idealState,
targetConsumingSegment, 2);
+
+ // i1 = [seg0, seg4, seg5, seg6]
Review Comment:
remove these comments
--
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]