diff --git a/java/google/registry/proxy/ProxyServer.java b/java/google/registry/proxy/ProxyServer.java index 47b5d99ab..db8b10e29 100644 --- a/java/google/registry/proxy/ProxyServer.java +++ b/java/google/registry/proxy/ProxyServer.java @@ -93,6 +93,7 @@ public class ProxyServer implements Runnable { inboundChannel.attr(PROTOCOL_KEY).set(inboundProtocol); inboundChannel.attr(RELAY_BUFFER_KEY).set(new ArrayDeque<>()); addHandlers(inboundChannel.pipeline(), inboundProtocol.handlerProviders()); + logger.atInfo().log("Connection established: %s %s", inboundProtocol.name(), inboundChannel); if (!inboundProtocol.hasBackend()) { // If the frontend has no backend to relay to (health check, web WHOIS redirect, etc), start @@ -146,10 +147,9 @@ public class ProxyServer implements Runnable { .get() .forEach( msg -> { - // TODO (jianglai): do not log the message once retry behavior is - // confirmed. logger.atWarning().log( - "Unfinished relay for connection %s: %s", inboundChannel, msg); + "Unfinished relay for connection %s\nHASH: %s", + inboundChannel, msg.hashCode()); ReferenceCountUtil.release(msg); }); }); @@ -194,14 +194,13 @@ public class ProxyServer implements Runnable { Object[] messages = relayBuffer.toArray(); relayBuffer.clear(); for (Object msg : messages) { - // TODO (jianglai): do not log the message once retry behavior is confirmed. logger.atInfo().log( - "Relay retried: %s <-> %s\nFRONTEND: %s\nBACKEND: %s\nMESSAGE: %s", + "Relay retried: %s <-> %s\nFRONTEND: %s\nBACKEND: %s\nHASH: %s", inboundProtocol.name(), outboundProtocol.name(), inboundChannel, outboundChannel, - msg); + msg.hashCode()); writeToRelayChannel(inboundChannel, outboundChannel, msg, true); } // When this outbound connection is closed, try reconnecting if the inbound connection @@ -220,6 +219,13 @@ public class ProxyServer implements Runnable { outboundChannel); connectOutboundChannel( bootstrap, inboundProtocol, outboundProtocol, inboundChannel); + } else { + logger.atInfo().log( + "Relay terminated: %s <-> %s\nFRONTEND: %s\nBACKEND: %s", + inboundProtocol.name(), + outboundProtocol.name(), + inboundChannel, + outboundChannel); } }); } else { diff --git a/java/google/registry/proxy/handler/BackendMetricsHandler.java b/java/google/registry/proxy/handler/BackendMetricsHandler.java index cb65203df..5371deae1 100644 --- a/java/google/registry/proxy/handler/BackendMetricsHandler.java +++ b/java/google/registry/proxy/handler/BackendMetricsHandler.java @@ -79,7 +79,8 @@ public class BackendMetricsHandler extends ChannelDuplexHandler { @Override public void channelRegistered(ChannelHandlerContext ctx) throws Exception { - // Backend channel is always established after a frontend channel is connected, so this + // Backend channel is always established after a frontend channel is connected, so this call + // should always return a non-null relay channel. relayedChannel = ctx.channel().attr(RELAY_CHANNEL_KEY).get(); checkNotNull(relayedChannel, "No frontend channel found."); relayedProtocolName = relayedChannel.attr(PROTOCOL_KEY).get().name(); diff --git a/java/google/registry/proxy/handler/RelayHandler.java b/java/google/registry/proxy/handler/RelayHandler.java index e71d954e8..61fd6c79d 100644 --- a/java/google/registry/proxy/handler/RelayHandler.java +++ b/java/google/registry/proxy/handler/RelayHandler.java @@ -101,14 +101,13 @@ public class RelayHandler extends SimpleChannelInboundHandler { .addListener( future -> { if (!future.isSuccess()) { - // TODO (jianglai): do not log the message once retry behavior is confirmed. logger.atWarning().withCause(future.cause()).log( - "Relay failed: %s --> %s\nINBOUND: %s\nOUTBOUND: %s\nMESSAGE: %s", + "Relay failed: %s --> %s\nINBOUND: %s\nOUTBOUND: %s\nHASH: %s", channel.attr(PROTOCOL_KEY).get().name(), relayChannel.attr(PROTOCOL_KEY).get().name(), channel, relayChannel, - msg); + msg.hashCode()); // If we cannot write to the relay channel and the originating channel has // a relay buffer (i. e. we tried to relay the frontend to the backend), store // the message in the buffer for retry later. The relay channel (backend) should @@ -129,15 +128,13 @@ public class RelayHandler extends SimpleChannelInboundHandler { ChannelFuture unusedFuture2 = relayChannel.close(); } else { if (retry) { - // TODO (jianglai): do not log the message once retry behavior is confirmed. logger.atInfo().log( - "Relay retry succeeded: %s --> %s\nINBOUND: %s\nOUTBOUND: %s\n" - + "MESSAGE: %s", + "Relay retry succeeded: %s --> %s\nINBOUND: %s\nOUTBOUND: %s\nHASH: %s", channel.attr(PROTOCOL_KEY).get().name(), relayChannel.attr(PROTOCOL_KEY).get().name(), channel, relayChannel, - msg); + msg.hashCode()); } // If the write is successful, we know that no retry is needed. This function // will decrement the reference count if the message is reference counted,