You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by GitBox <gi...@apache.org> on 2022/12/06 06:51:26 UTC
[GitHub] [rocketmq] xdkxlk commented on a diff in pull request #5575: [ISSUE #5392] [RIP-55] Support remoting protocol in rocketmq proxy module
xdkxlk commented on code in PR #5575:
URL: https://github.com/apache/rocketmq/pull/5575#discussion_r1040564992
##########
proxy/src/main/java/org/apache/rocketmq/proxy/grpc/v2/client/ClientActivity.java:
##########
@@ -413,14 +417,48 @@ protected class ConsumerIdsChangeListenerImpl implements ConsumerIdsChangeListen
@Override
public void handle(ConsumerGroupEvent event, String group, Object... args) {
- if (event == ConsumerGroupEvent.CLIENT_UNREGISTER) {
- if (args == null || args.length < 1) {
+ switch (event) {
+ case CLIENT_UNREGISTER:
+ processClientUnregister(group, args);
+ break;
+ case REGISTER:
+ processClientRegister(group, args);
+ break;
+ default:
+ break;
+ }
+ }
+
+ protected void processClientUnregister(String group, Object... args) {
+ if (args == null || args.length < 1) {
+ return;
+ }
+ if (args[0] instanceof ClientChannelInfo) {
+ ClientChannelInfo clientChannelInfo = (ClientChannelInfo) args[0];
+ if (ChannelHelper.isRemote(clientChannelInfo.getChannel())) {
return;
}
- if (args[0] instanceof ClientChannelInfo) {
- ClientChannelInfo clientChannelInfo = (ClientChannelInfo) args[0];
- grpcChannelManager.removeChannel(clientChannelInfo.getClientId());
- grpcClientSettingsManager.removeClientSettings(clientChannelInfo.getClientId());
+ GrpcClientChannel removedChannel = grpcChannelManager.removeChannel(clientChannelInfo.getClientId());
+ log.info("remove grpc channel when client unregister. group:{}, clientChannelInfo:{}, removed:{}",
+ group, clientChannelInfo, removedChannel != null);
+ }
+ }
+
+ protected void processClientRegister(String group, Object... args) {
+ if (args == null || args.length < 2) {
+ return;
+ }
+ if (args[1] instanceof ClientChannelInfo) {
+ ClientChannelInfo clientChannelInfo = (ClientChannelInfo) args[1];
+ Channel channel = clientChannelInfo.getChannel();
+ if (ChannelHelper.isRemote(channel)) {
+ // save settings from channel sync from other proxy
+ Settings settings = GrpcClientChannel.parseChannelExtendAttribute(channel);
Review Comment:
The purpose is different. The parseChannelExtendAttribute method of GrpcClientChannel is a tool method to try to convert the attribute to the Settings. And the grpcClientSettingsManager is passed to channel in order to get extendAttribute of this channel in real time.
--
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: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org