funky-eyes commented on code in PR #8020:
URL: https://github.com/apache/incubator-seata/pull/8020#discussion_r3019314388
##########
core/src/main/java/org/apache/seata/core/rpc/netty/RmNettyRemotingClient.java:
##########
@@ -292,6 +300,59 @@ public void sendRegisterMessage(String serverAddress,
Channel channel, String re
}
}
+ public void unregisterResource(String resourceGroupId, String resourceId) {
+ if (StringUtils.isBlank(transactionServiceGroup) ||
StringUtils.isBlank(resourceId)) {
+ return;
+ }
+ sendUnregisterToServers(resourceId);
+ }
+
+ private static final long UNREGISTER_FLUSH_TIMEOUT_MS = 1000;
+
+ private List<ChannelFuture> sendUnregisterToServers(String resourceIds) {
+ List<ChannelFuture> futures = new ArrayList<>();
+ try {
+ for (Map.Entry<String, Channel> entry :
+ getClientChannelManager().getChannels().entrySet()) {
+ String serverAddress = entry.getKey();
+ Channel channel = entry.getValue();
+ if (!channel.isActive()) {
+ continue;
+ }
+ String serverVersion =
getClientChannelManager().getServerVersion(serverAddress);
+ if (serverVersion == null ||
!Version.isAboveOrEqualVersion260(serverVersion)) {
+ LOGGER.warn(
+ "Server {} does not support UnregisterRMRequest
(version: {})",
+ serverAddress,
+ serverVersion);
+ continue;
+ }
+ UnregisterRMRequest message = new
UnregisterRMRequest(applicationId, transactionServiceGroup);
+ message.setResourceIds(resourceIds);
+ try {
+ if (!channel.isWritable()) {
+ throw new FrameworkException(
+ "msg:" + message.toString(),
FrameworkErrorCode.ChannelIsNotWritable);
+ }
+ RpcMessage rpcMessage = buildRequestMessage(message,
ProtocolConstants.MSGTYPE_RESQUEST_ONEWAY);
+ futures.add(channel.writeAndFlush(rpcMessage));
Review Comment:
@WangzJi PTAL
--
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]