funky-eyes commented on code in PR #7095:
URL: https://github.com/apache/incubator-seata/pull/7095#discussion_r1972722402
##########
core/src/main/java/org/apache/seata/core/rpc/netty/AbstractNettyRemotingClient.java:
##########
@@ -501,4 +513,59 @@ public void close(ChannelHandlerContext ctx,
ChannelPromise future) throws Excep
}
}
+ /**
+ * Iterates over futures and marks all MessageFutures associated with the
specified Channel as failed.
+ *
+ * @param channel The Channel that has been disconnected or encountered an
exception.
+ * @param cause The reason for the failure.
+ */
+ private void failFuturesForChannel(Channel channel, Throwable cause) {
+ Set<Integer> requestIds = channelToRequestIds.remove(channel);
+ if (requestIds != null) {
+ for (Integer requestId : requestIds) {
+ MessageFuture future = futures.remove(requestId);
+ if (future != null) {
+ future.setResultMessage(cause);
+ }
+ }
+ }
+ }
+
+ /**
+ * Removes the association between the specified Channel and requestId
from the channelToRequestIds mapping.
+ * If the Channel no longer has any associated requestId, the Channel will
be removed from the mapping.
+ *
+ * @param channel The Channel that has been disconnected or encountered
an exception.
+ * @param requestId The requestId to be removed.
+ */
+ private void removeRequestIdFromChannel(Channel channel, Integer
requestId) {
+ if (channel == null) {
+ if (requestId != null) {
+ LOGGER.warn("Attempted to remove requestId {} from a null
channel.", requestId);
+ } else {
+ LOGGER.warn("Attempted to remove a null requestId from a null
channel.");
+ }
+ return;
+ }
+
+ if (requestId == null) {
+ LOGGER.warn("Attempted to remove a null requestId from channel
{}.", channel);
+ return;
+ }
+
+ channelToRequestIds.computeIfPresent(channel, (ch, requestIds) -> {
+ boolean removed = requestIds.remove(requestId);
+ if (removed) {
+ LOGGER.debug("Removed requestId {} from channel {}.",
requestId, ch);
Review Comment:
You need to determine whether the current log level is debug level or not.
##########
core/src/main/java/org/apache/seata/core/rpc/netty/AbstractNettyRemotingClient.java:
##########
@@ -501,4 +513,59 @@ public void close(ChannelHandlerContext ctx,
ChannelPromise future) throws Excep
}
}
+ /**
+ * Iterates over futures and marks all MessageFutures associated with the
specified Channel as failed.
+ *
+ * @param channel The Channel that has been disconnected or encountered an
exception.
+ * @param cause The reason for the failure.
+ */
+ private void failFuturesForChannel(Channel channel, Throwable cause) {
+ Set<Integer> requestIds = channelToRequestIds.remove(channel);
+ if (requestIds != null) {
+ for (Integer requestId : requestIds) {
+ MessageFuture future = futures.remove(requestId);
+ if (future != null) {
+ future.setResultMessage(cause);
+ }
+ }
+ }
+ }
+
+ /**
+ * Removes the association between the specified Channel and requestId
from the channelToRequestIds mapping.
+ * If the Channel no longer has any associated requestId, the Channel will
be removed from the mapping.
+ *
+ * @param channel The Channel that has been disconnected or encountered
an exception.
+ * @param requestId The requestId to be removed.
+ */
+ private void removeRequestIdFromChannel(Channel channel, Integer
requestId) {
+ if (channel == null) {
+ if (requestId != null) {
+ LOGGER.warn("Attempted to remove requestId {} from a null
channel.", requestId);
+ } else {
+ LOGGER.warn("Attempted to remove a null requestId from a null
channel.");
+ }
+ return;
+ }
+
+ if (requestId == null) {
+ LOGGER.warn("Attempted to remove a null requestId from channel
{}.", channel);
+ return;
+ }
+
+ channelToRequestIds.computeIfPresent(channel, (ch, requestIds) -> {
+ boolean removed = requestIds.remove(requestId);
+ if (removed) {
+ LOGGER.debug("Removed requestId {} from channel {}.",
requestId, ch);
+ } else {
+ LOGGER.warn("Attempted to remove non-existing requestId {}
from channel {}.", requestId, ch);
+ }
+
+ if (requestIds.isEmpty()) {
+ LOGGER.debug("No more requestIds associated with channel {}.
Channel removed from mapping.", ch);
Review Comment:
You need to determine whether the current log level is debug level or not.
--
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]