Skip to content

Commit

Permalink
DRILL-8482:Assign region throw exception when some region is deployed…
Browse files Browse the repository at this point in the history
… on affinity node and some on non-affinity node (#2885)
  • Loading branch information
shfshihuafeng authored Mar 3, 2024
1 parent b18ff8a commit ccc9b1a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ public void applyAssignments(List<DrillbitEndpoint> incomingEndpoints) {
PriorityQueue<List<HBaseSubScanSpec>> minHeap = new PriorityQueue<>(numSlots, LIST_SIZE_COMPARATOR);
PriorityQueue<List<HBaseSubScanSpec>> maxHeap = new PriorityQueue<>(numSlots, LIST_SIZE_COMPARATOR_REV);
for(List<HBaseSubScanSpec> listOfScan : endpointFragmentMapping.values()) {
if (listOfScan.size() < minPerEndpointSlot) {
if (listOfScan.size() < maxPerEndpointSlot) {
minHeap.offer(listOfScan);
} else if (listOfScan.size() > minPerEndpointSlot) {
maxHeap.offer(listOfScan);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,34 @@ public void testHBaseGroupScanAssignmentSomeAfinedWithOrphans() throws Exception
testParallelizationWidth(scan, endpoints.size());
}

@Test
public void testHBaseGroupScanAssignmentSomeAfinedAndSomeWithOrphans() throws Exception {
NavigableMap<HRegionInfo,ServerName> regionsToScan = Maps.newTreeMap();
regionsToScan.put(new HRegionInfo(TABLE_NAME, splits[0], splits[1]), SERVER_A);
regionsToScan.put(new HRegionInfo(TABLE_NAME, splits[1], splits[2]), SERVER_A);
regionsToScan.put(new HRegionInfo(TABLE_NAME, splits[2], splits[3]), SERVER_B);
regionsToScan.put(new HRegionInfo(TABLE_NAME, splits[3], splits[4]), SERVER_B);
regionsToScan.put(new HRegionInfo(TABLE_NAME, splits[6], splits[7]), SERVER_D);
regionsToScan.put(new HRegionInfo(TABLE_NAME, splits[7], splits[8]), SERVER_D);
regionsToScan.put(new HRegionInfo(TABLE_NAME, splits[8], splits[9]), SERVER_D);
regionsToScan.put(new HRegionInfo(TABLE_NAME, splits[9], splits[10]), SERVER_D);
final List<DrillbitEndpoint> endpoints = Lists.newArrayList();
endpoints.add(DrillbitEndpoint.newBuilder().setAddress(HOST_A).setControlPort(1234).build());
endpoints.add(DrillbitEndpoint.newBuilder().setAddress(HOST_B).setControlPort(1234).build());
endpoints.add(DrillbitEndpoint.newBuilder().setAddress(HOST_C).setControlPort(1234).build());

HBaseGroupScan scan = new HBaseGroupScan();
scan.setRegionsToScan(regionsToScan);
scan.setHBaseScanSpec(new HBaseScanSpec(TABLE_NAME_STR, splits[0], splits[0], null));
scan.applyAssignments(endpoints);

int i = 0;
assertEquals(3, scan.getSpecificScan(i++).getRegionScanSpecList().size()); // 'A'
assertEquals(2, scan.getSpecificScan(i++).getRegionScanSpecList().size()); // 'B'
assertEquals(3, scan.getSpecificScan(i++).getRegionScanSpecList().size()); // 'C'
testParallelizationWidth(scan, i);
}

@Test
public void testHBaseGroupScanAssignmentOneEach() throws Exception {
NavigableMap<HRegionInfo,ServerName> regionsToScan = Maps.newTreeMap();
Expand Down

0 comments on commit ccc9b1a

Please sign in to comment.