kaijchen commented on code in PR #510:
URL: https://github.com/apache/incubator-uniffle/pull/510#discussion_r1089894549
##########
server/src/main/java/org/apache/uniffle/server/ShuffleFlushManager.java:
##########
@@ -145,6 +134,31 @@ public void addToFlushQueue(ShuffleDataFlushEvent event) {
}
}
+ public void processEvents(boolean endless) {
+ while (endless || !flushQueue.isEmpty()) {
+ try {
+ ShuffleDataFlushEvent event = flushQueue.take();
+ threadPoolExecutor.execute(() -> {
+ processEvent(event);
+ });
+ } catch (Exception e) {
+ LOG.error("Exception happened when process event.", e);
+ }
+ }
+ }
+
+ protected void processEvent(ShuffleDataFlushEvent event) {
Review Comment:
This method can be private.
##########
server/src/main/java/org/apache/uniffle/server/ShuffleFlushManager.java:
##########
@@ -145,6 +134,31 @@ public void addToFlushQueue(ShuffleDataFlushEvent event) {
}
}
+ public void processEvents(boolean endless) {
Review Comment:
Maybe we can create another method `eventLoop()`:
```java
private void startEventProcesser() {
// the thread for flush data
Thread processEventThread = new Thread(this::eventLoop);
processEventThread.setName("ProcessEventThread");
processEventThread.setDaemon(true);
processEventThread.start();
}
protected void eventLoop() {
while (true) {
processEvents();
}
}
public void processEvents() {
while (!flushQueue.isEmpty()) {
try {
ShuffleDataFlushEvent event = flushQueue.take();
threadPoolExecutor.execute(() -> {
processEvent(event);
});
} catch (Exception e) {
LOG.error("Exception happened when process event.", e);
}
}
}
```
Then override it in `TestShuffleFlushManager`:
```java
@Override
protected void eventLoop() {
// do nothing
}
```
--
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]