Skip to content

THRIFT-5030: Seqid verification Alternative - Added TMessageValidatorProtocol#1952

Closed
ptsneves wants to merge 1 commit intoapache:masterfrom
ptsneves:tmessage_validator_protocol
Closed

THRIFT-5030: Seqid verification Alternative - Added TMessageValidatorProtocol#1952
ptsneves wants to merge 1 commit intoapache:masterfrom
ptsneves:tmessage_validator_protocol

Conversation

@ptsneves
Copy link
Copy Markdown
Contributor

Client: python, netstd

TMessageValidatorProtocol is a protocol-independent concrete decorator
that allows a Thrift client to communicate with a Server and validate
that the messaged received is matching the sent seqid. If it does not
match we keep reading the buffer or throw an exception. This Protocol
Decorator provides the most advantage with a framed transport. By
default Thrift processors only provide an incrementing seqid that always
starts in 0, which can lead to collisions when 2 protocols are started
at the same time over the same transport. To mitigate that this
protocol also overrides the seqid normally generated by the processor,
because it uses a random seq id to avoid shared channel seqid
collisions.

Client: python, netstd

TMessageValidatorProtocol is a protocol-independent concrete decorator
that allows a Thrift client to communicate with a Server and validate
that the messaged received is matching the sent seqid. If it does not
match we keep reading the buffer or throw an exception.  This Protocol
Decorator provides the most advantage with a framed transport.  By
default Thrift processors only provide an incrementing seqid that always
starts in 0, which can lead to collisions when 2 protocols are started
at the same time over the same transport.  To mitigate that this
protocol also overrides the seqid normally generated by the processor,
because it uses a random seq id to avoid shared channel seqid
collisions.
@ptsneves ptsneves force-pushed the tmessage_validator_protocol branch from acb12d5 to aa6f8e3 Compare November 26, 2019 20:38
@Jens-G Jens-G self-requested a review November 27, 2019 00:45
@@ -0,0 +1,100 @@
using System;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ASF header missing

else if (ValidationMode == ValidationModeEnum.THROW_EXCEPTION)
throw new TApplicationException(TApplicationException.ExceptionType.MissingResult, "Received SeqID and sent one do not match.");
else
throw new InvalidProgramException("This is an unreachable situation");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love these kind of errors.

@@ -0,0 +1,60 @@
class TMessageValidatorProtocolFactory(object):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ASF header

using Thrift.Protocol;
using Thrift.Protocol.Entities;
using Thrift;
namespace DroHub.Helpers.Thrift
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Namespace needs to be fixed.

@ptsneves ptsneves closed this Dec 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants