-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[feat] [broker] PIP-188: Support option to disconnect clients that not support cluster migration feature #20084
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -850,6 +850,17 @@ The delayed message index time step(in seconds) in per bucket snapshot segment, | |
doc = "Enable check for minimum allowed client library version" | ||
) | ||
private boolean clientLibraryVersionCheckEnabled = false; | ||
|
||
@FieldContext( | ||
category = CATEGORY_SERVER, | ||
dynamic = true, | ||
doc = "Minimum client version allowed by broker else broker will reject connection." | ||
+ "(It's useful when client lib doesn't support specific feature and feature " | ||
+ "might be required by broker to apply globally on all topics." | ||
+ "(eg: all clients must be on V20 to perform cloud migration)" | ||
) | ||
private int clientMinVersionAllowed = -1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense to add proto or protocol to the name to disambiguate it from the library version? |
||
|
||
@FieldContext( | ||
category = CATEGORY_SERVER, | ||
doc = "Path for the file used to determine the rotation status for the broker" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -189,6 +189,7 @@ public class ServerCnx extends PulsarHandler implements TransportCnx { | |
private final TopicListService topicListService; | ||
private final BrokerInterceptor brokerInterceptor; | ||
private State state; | ||
private int clientMinVersionAllowed; | ||
private volatile boolean isActive = true; | ||
private String authRole = null; | ||
private volatile AuthenticationDataSource authenticationData; | ||
|
@@ -307,6 +308,7 @@ public ServerCnx(PulsarService pulsar, String listenerName) { | |
this.topicListService = new TopicListService(pulsar, this, | ||
enableSubscriptionPatternEvaluation, maxSubscriptionPatternLength); | ||
this.brokerInterceptor = this.service != null ? this.service.getInterceptor() : null; | ||
this.clientMinVersionAllowed = conf.getClientMinVersionAllowed() > 0 ? conf.getClientMinVersionAllowed() : -1; | ||
} | ||
|
||
@Override | ||
|
@@ -684,6 +686,14 @@ ByteBuf createConsumerStatsResponse(Consumer consumer, long requestId) { | |
|
||
// complete the connect and sent newConnected command | ||
private void completeConnect(int clientProtoVersion, String clientVersion) { | ||
if (clientMinVersionAllowed >= 0 && clientMinVersionAllowed > clientProtoVersion) { | ||
log.info("[{}] client with version {} must be upgraded to {}", remoteAddress, clientProtoVersion, | ||
clientMinVersionAllowed); | ||
final ByteBuf msg = Commands.newError(-1, ServerError.UnsupportedVersionError, | ||
"Upgrade version to " + clientMinVersionAllowed + " or higher"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about 'upgrade your client to a version that supports protocol version ...' |
||
NettyChannelUtil.writeAndFlushWithClosePromise(ctx, msg); | ||
return; | ||
} | ||
if (service.isAuthenticationEnabled()) { | ||
if (service.isAuthorizationEnabled()) { | ||
if (!service.getAuthorizationService() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it's an int, should we just say 20, not V20?