Jackie-Jiang commented on code in PR #10118:
URL: https://github.com/apache/pinot/pull/10118#discussion_r1070156509
##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/relocation/SegmentRelocator.java:
##########
@@ -91,10 +97,66 @@ public SegmentRelocator(PinotHelixResourceManager
pinotHelixResourceManager,
Math.min(taskIntervalInMs,
config.getSegmentRelocatorExternalViewCheckIntervalInMs());
_externalViewStabilizationTimeoutInMs =
Math.min(taskIntervalInMs,
config.getSegmentRelocatorExternalViewStabilizationTimeoutInMs());
+ if (config.isSegmentRelocatorRebalanceTablesSequentially()) {
+ _waitingTables = ConcurrentHashMap.newKeySet();
+ _waitingQueue = new LinkedBlockingQueue<>();
+ _executorService.submit(() -> {
+ LOGGER.info("Rebalance tables sequentially");
+ while (!Thread.currentThread().isInterrupted()) {
+ rebalanceWaitingTable(this::rebalanceTable);
+ }
+ return null;
+ });
+ } else {
+ _waitingTables = null;
+ _waitingQueue = null;
+ }
}
@Override
protected void processTable(String tableNameWithType) {
+ if (_waitingTables == null) {
+ LOGGER.debug("Rebalance table: {} immediately", tableNameWithType);
+ _executorService.submit(() -> rebalanceTable(tableNameWithType));
+ return;
+ }
+ putTableToWait(tableNameWithType);
+ }
+
+ @VisibleForTesting
+ synchronized void putTableToWait(String tableNameWithType) {
Review Comment:
Since we are using a concurrent set, and there is no capacity limit for the
waiting queuem we can remove the `synchronized` and do:
```
if (_waitingTables.add(tableNameWithType)) {
_waitingQueue.offer(tableNameWithType);
} else {
LOGGER.debug(already exist...);
}
```
##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/relocation/SegmentRelocator.java:
##########
@@ -91,10 +97,66 @@ public SegmentRelocator(PinotHelixResourceManager
pinotHelixResourceManager,
Math.min(taskIntervalInMs,
config.getSegmentRelocatorExternalViewCheckIntervalInMs());
_externalViewStabilizationTimeoutInMs =
Math.min(taskIntervalInMs,
config.getSegmentRelocatorExternalViewStabilizationTimeoutInMs());
+ if (config.isSegmentRelocatorRebalanceTablesSequentially()) {
+ _waitingTables = ConcurrentHashMap.newKeySet();
+ _waitingQueue = new LinkedBlockingQueue<>();
+ _executorService.submit(() -> {
+ LOGGER.info("Rebalance tables sequentially");
+ while (!Thread.currentThread().isInterrupted()) {
Review Comment:
`while (true)` should be good here. Pulling from blocking queue can throw
InterruptedException and stop the thread, which is desired behavior.
If you want better logging information, you may consider catching the
exception and log a warning to indicate the thread is interrupted. If the
exception is handled, no need to `return null;` as well
--
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]