skoppu22 commented on code in PR #345:
URL: https://github.com/apache/cassandra-sidecar/pull/345#discussion_r3268606797
##########
server/src/main/java/org/apache/cassandra/sidecar/cdc/CdcPublisher.java:
##########
@@ -321,26 +321,30 @@ else if (conf.cdcEnabled())
// EventBus handlers
@Override
- public synchronized void handle(Message<Object> msg)
+ public void handle(Message<Object> msg)
{
- if
(msg.address().equals(RangeManager.RangeManagerEvents.ON_TOKEN_RANGE_CHANGED.address()))
+ String address = msg.address();
+ if
(address.equals(RangeManager.RangeManagerEvents.ON_TOKEN_RANGE_CHANGED.address()))
{
- handleTokenRangeChange();
+ executorPools.executeBlocking(() -> { handleTokenRangeChange();
return null; });
}
- else if
(msg.address().equals(RangeManager.LeadershipEvents.ON_TOKEN_RANGE_GAINED.address()))
+ else if
(address.equals(RangeManager.LeadershipEvents.ON_TOKEN_RANGE_GAINED.address()))
{
- handleRangeGained((RangeManager.RangeChangeEvent) msg.body());
+ RangeManager.RangeChangeEvent event =
(RangeManager.RangeChangeEvent) msg.body();
+ executorPools.executeBlocking(() -> { handleRangeGained(event);
return null; });
}
- else if
(msg.address().equals(RangeManager.LeadershipEvents.ON_TOKEN_RANGE_LOST.address()))
+ else if
(address.equals(RangeManager.LeadershipEvents.ON_TOKEN_RANGE_LOST.address()))
{
- handleRangeLost((RangeManager.RangeChangeEvent) msg.body());
+ RangeManager.RangeChangeEvent event =
(RangeManager.RangeChangeEvent) msg.body();
+ executorPools.executeBlocking(() -> { handleRangeLost(event);
return null; });
}
- else if (msg.address().equals(ON_SERVER_STOP.address()))
+ else if (address.equals(ON_SERVER_STOP.address()))
{
- stop();
+ executorPools.executeBlocking(() -> { stop(); return null; });
Review Comment:
Before this change, stop() would have completed before the event loop
closed. After this change, there is a possibility of stop() not completing
before event loop closed. Better to keep stop() on the event loop, it is not
doing heavy work.
--
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]