[ 
https://issues.apache.org/jira/browse/CASSANDRA-15066?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16801276#comment-16801276
 ] 

Aleksey Yeschenko commented on CASSANDRA-15066:
-----------------------------------------------

There are two improvements responsible for a large number of files touched, 
that might make the change set seem scarier than it is - despite most of the 
files affected in a very minor, mechanical way. One of them is the merge of 
{{MessageIn}} and {{MessageOut}} into single {{Message}} class; the other is 
the improvements to {{Verb}} enum.

{{MessageIn}} and {{MessageOut}} classes are almost exact duplicates of each 
other, except {{MessageOut}} has no {{id}} field. Folding them into one class 
allowed to both get rid of this duplication, and to place ser/deser logic next 
to each other, in a single {{Serializer}} class, as it always should’ve been - 
reducing the risk of people forgetting to update one half but not the other.

{{Verb}} was improved in multiple ways. Firstly, we realized that important 
information was unnecessarily detached from Verb class. Namely, 
{{DROPPABLE_VERBS}} {{EnumSet}}, {{verbStages}} {{EnumMap}}, 
{{verbSerializers}} {{EnumMap}}, and {{callbackDeserializers}} {{EnumMap}} in 
{{MessagingService}}. Now everything is properly encapsulated in {{Verb}} 
fields. Secondly, we introduced matching response verbs for every request verb, 
replacing the single {{REQUEST_RESPONSE}} verb. Doing this allowed us to make 
deserialization of {{Message}} no longer rely on global state (callbacks 
expiring map). Thirdly, to allow cleaning up serialization logic further, we 
introduced a dedicated {{FAILURE_RSP}} verb to replace {{FAILURE_RESPONSE}} and 
{{FAILURE_REASON}} parameter types. As a result of all this, {{Verb}} bulked up 
a little and was promoted to a non-inner class of its own.

While there, we also made a small semantic change. Having a separate set of 
droppable verbs made every newly introduced verb implicitly undroppable by 
default. This led, over the years, to multiple verbs being made undroppable by 
omission - sometimes those that don’t even have a callback attached to them. 
Additionally, no verb in Cassandra has ever been truly droppable - as this is 
simply not a guarantee we can physically provide. So we replaced the concept 
with explicit longish timeouts instead - rpc timeout or 5 minutes, whichever is 
longer.

Other minor improvements to {{Verb}} and {{Message}}, in no particular order:
 - {{flags}} field was introduced to replace all effectively-boolean parameters 
that were previously wastefully serialized as {{ONE_BYTE}} 
({{FAILURE_RESPONSE}}, {{FAILURE_CALLBACK}}, and {{TRACK_REPAIRED_DATA}})
 - {{Verb}} is serialized as unsigned vint instead of 4-byte int
 - {{PROTOCOL_MAGIC}} bytes are gone (see the comment on framing and CRC)
 - params are serialized more efficiently now:
 ** param name uses {{ParamType}} ordinal instead of encoding {{ParamType}} 
name as a utf8 string
 ** we switched back to encoding param count rather than param byte length - so 
on read we don’t need to allocate extra byte arrays and {{DataInputBuffer}}, 
and on write to avoid unnecessary garbage in {{DataOutputBuffer}} to 
pre-calculate serialized size

When combined, the changes to these two classes are responsible for a large 
number of files touched (class renames and import changes), but they are 
mechanical and not a risk. But we strongly believe that cleanup like this is 
important and needs to happen, or else we’ll forever drown in technical debt.

> Improvements to Internode Messaging
> -----------------------------------
>
>                 Key: CASSANDRA-15066
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-15066
>             Project: Cassandra
>          Issue Type: Improvement
>          Components: Messaging/Internode
>            Reporter: Benedict
>            Assignee: Benedict
>            Priority: Normal
>             Fix For: 4.0
>
>
> CASSANDRA-8457 introduced asynchronous networking to internode messaging, but 
> there have been several follow-up endeavours to improve some semantic issues. 
>  CASSANDRA-14503 and CASSANDRA-13630 are the latest such efforts, and were 
> combined some months ago into a single overarching refactor of the original 
> work, to address some of the issues that have been discovered.  Given the 
> criticality of this work to the project, we wanted to bring some more eyes to 
> bear to ensure the release goes ahead smoothly.  In doing so, we uncovered a 
> number of issues with messaging, some of which long standing, that we felt 
> needed to be addressed.  This patch widens the scope of CASSANDRA-14503 and 
> CASSANDRA-13630 in an effort to close the book on the messaging service, at 
> least for the foreseeable future.
> The patch includes a number of clarifying refactors that touch outside of the 
> {{net.async}} package, and a number of semantic changes to the {{net.async}} 
> packages itself.  We believe it clarifies the intent and behaviour of the 
> code while improving system stability, which we will outline in comments 
> below.
> https://github.com/belliottsmith/cassandra/tree/messaging-improvements



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to