[ https://issues.apache.org/jira/browse/CASSANDRA-18202?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17688378#comment-17688378 ]
Jacek Lewandowski commented on CASSANDRA-18202: ----------------------------------------------- [~benedict] could you elaborate on your statement? For example, we have something like this: {code:java} if (replica.isSelf()) { PAXOS_PROPOSE_REQ.stage.execute(() -> { try { Message<Boolean> response = message.responseWith(doPropose(proposal)); callback.onResponse(response); } catch (Exception ex) { logger.error("Failed paxos propose locally", ex); } }); } else { MessagingService.instance().sendWithCallback(message, replica.endpoint(), callback); } {code} where in the verb handling method we have pretty similar code: {code:java} public void doVerb(Message<Commit> message) { Boolean response = doPropose(message.payload); Message<Boolean> reply = message.responseWith(response); MessagingService.instance().send(reply, message.from()); } {code} There is a similar pattern repeated across the code. Was your intention to keep that redundancy or you meant something else? > MessagingService should be able deliver local messages (messages to self) > without using a network interface. > ------------------------------------------------------------------------------------------------------------ > > Key: CASSANDRA-18202 > URL: https://issues.apache.org/jira/browse/CASSANDRA-18202 > Project: Cassandra > Issue Type: Improvement > Components: Messaging/Internode > Reporter: Jaroslaw Grabowski > Priority: Normal > > At the moment, in various places in the code, there are special code paths > for local message handling. It usually looks like this: > > {code:java} > if (replica.isSelf) > // deal with the message locally by manually invoking a handling method > else > messagingService.send(...){code} > > This pattern is error-prone, as failing to recognize local messages results > in pushing them through a local network interface. This may introduce a > significant performance penalty. > It also makes understanding the code harder, as there are two separate code > paths for message handling (local path and IVerbHandler). > Instead, MessagingService should pass local messages directly to the > appropriate IVerbHandler. Once this is done, all the `if (replica.isSelf) ... > else ...` occurrences could be refactored to simply calling > `messagingService.send(...)`. This would move message handling logic into a > single place (IVerbHandler). -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org