adelapena commented on code in PR #2506:
URL: https://github.com/apache/cassandra/pull/2506#discussion_r1273367738
##########
src/java/org/apache/cassandra/net/OutboundConnectionInitiator.java:
##########
@@ -350,68 +350,35 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf
in, List<Object> out)
FrameEncoder frameEncoder = null;
Result<SuccessType> result;
- if (useMessagingVersion > 0)
+ assert useMessagingVersion > 0;
+
+ if (useMessagingVersion < settings.acceptVersions.min ||
useMessagingVersion > settings.acceptVersions.max)
{
- if (useMessagingVersion < settings.acceptVersions.min ||
useMessagingVersion > settings.acceptVersions.max)
- {
- result = incompatible(useMessagingVersion,
peerMessagingVersion);
- }
- else
- {
- // This is a bit ugly
- if (type.isMessaging())
- {
- switch (settings.framing)
- {
- case LZ4:
- frameEncoder =
FrameEncoderLZ4.fastInstance;
- break;
- case CRC:
- frameEncoder = FrameEncoderCrc.instance;
- break;
- case UNPROTECTED:
- frameEncoder =
FrameEncoderUnprotected.instance;
- break;
- }
-
- result = (Result<SuccessType>)
messagingSuccess(ctx.channel(), useMessagingVersion, frameEncoder.allocator());
- }
- else
- {
- result = (Result<SuccessType>)
streamingSuccess(ctx.channel(), useMessagingVersion);
- }
- }
+ result = incompatible(useMessagingVersion,
peerMessagingVersion);
}
else
{
- assert type.isMessaging();
-
- // pre40 handshake responses only (can be a post40 node)
- if (peerMessagingVersion == requestMessagingVersion
- || peerMessagingVersion > settings.acceptVersions.max)
// this clause is for impersonating 3.0 node in testing only
+ // This is a bit ugly
+ if (type.isMessaging())
{
switch (settings.framing)
{
+ case LZ4:
+ frameEncoder = FrameEncoderLZ4.fastInstance;
+ break;
case CRC:
- case UNPROTECTED:
- frameEncoder = FrameEncoderLegacy.instance;
+ frameEncoder = FrameEncoderCrc.instance;
break;
- case LZ4:
- frameEncoder = FrameEncoderLegacyLZ4.instance;
+ case UNPROTECTED:
+ frameEncoder =
FrameEncoderUnprotected.instance;
break;
}
- result = (Result<SuccessType>)
messagingSuccess(ctx.channel(), requestMessagingVersion,
frameEncoder.allocator());
+ result = (Result<SuccessType>)
messagingSuccess(ctx.channel(), useMessagingVersion, frameEncoder.allocator());
}
- else if (peerMessagingVersion <
settings.acceptVersions.min)
- result = incompatible(-1, peerMessagingVersion);
else
- result = retry(peerMessagingVersion);
-
- if (result.isSuccess())
{
- ConfirmOutboundPre40 message = new
ConfirmOutboundPre40(settings.acceptVersions.max, settings.from);
- AsyncChannelPromise.writeAndFlush(ctx,
message.encode());
+ result = (Result<SuccessType>)
streamingSuccess(ctx.channel(), useMessagingVersion);
Review Comment:
I think `OutboundConnectionSettings.maybeWithSecurePort`, at the end of this
method, can be simplified now that the min MS version is 4.0.
--
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]