mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +02:00
Remove some unnecessary loggings from the proxy
We confirmed that the retry is working. Instead of logging the messages them selves, we only need to log the message hash to ensure that the same message is retried. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=208883712
This commit is contained in:
parent
3dba385213
commit
301301cafe
3 changed files with 18 additions and 14 deletions
|
@ -93,6 +93,7 @@ public class ProxyServer implements Runnable {
|
||||||
inboundChannel.attr(PROTOCOL_KEY).set(inboundProtocol);
|
inboundChannel.attr(PROTOCOL_KEY).set(inboundProtocol);
|
||||||
inboundChannel.attr(RELAY_BUFFER_KEY).set(new ArrayDeque<>());
|
inboundChannel.attr(RELAY_BUFFER_KEY).set(new ArrayDeque<>());
|
||||||
addHandlers(inboundChannel.pipeline(), inboundProtocol.handlerProviders());
|
addHandlers(inboundChannel.pipeline(), inboundProtocol.handlerProviders());
|
||||||
|
logger.atInfo().log("Connection established: %s %s", inboundProtocol.name(), inboundChannel);
|
||||||
|
|
||||||
if (!inboundProtocol.hasBackend()) {
|
if (!inboundProtocol.hasBackend()) {
|
||||||
// If the frontend has no backend to relay to (health check, web WHOIS redirect, etc), start
|
// 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()
|
.get()
|
||||||
.forEach(
|
.forEach(
|
||||||
msg -> {
|
msg -> {
|
||||||
// TODO (jianglai): do not log the message once retry behavior is
|
|
||||||
// confirmed.
|
|
||||||
logger.atWarning().log(
|
logger.atWarning().log(
|
||||||
"Unfinished relay for connection %s: %s", inboundChannel, msg);
|
"Unfinished relay for connection %s\nHASH: %s",
|
||||||
|
inboundChannel, msg.hashCode());
|
||||||
ReferenceCountUtil.release(msg);
|
ReferenceCountUtil.release(msg);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -194,14 +194,13 @@ public class ProxyServer implements Runnable {
|
||||||
Object[] messages = relayBuffer.toArray();
|
Object[] messages = relayBuffer.toArray();
|
||||||
relayBuffer.clear();
|
relayBuffer.clear();
|
||||||
for (Object msg : messages) {
|
for (Object msg : messages) {
|
||||||
// TODO (jianglai): do not log the message once retry behavior is confirmed.
|
|
||||||
logger.atInfo().log(
|
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(),
|
inboundProtocol.name(),
|
||||||
outboundProtocol.name(),
|
outboundProtocol.name(),
|
||||||
inboundChannel,
|
inboundChannel,
|
||||||
outboundChannel,
|
outboundChannel,
|
||||||
msg);
|
msg.hashCode());
|
||||||
writeToRelayChannel(inboundChannel, outboundChannel, msg, true);
|
writeToRelayChannel(inboundChannel, outboundChannel, msg, true);
|
||||||
}
|
}
|
||||||
// When this outbound connection is closed, try reconnecting if the inbound connection
|
// When this outbound connection is closed, try reconnecting if the inbound connection
|
||||||
|
@ -220,6 +219,13 @@ public class ProxyServer implements Runnable {
|
||||||
outboundChannel);
|
outboundChannel);
|
||||||
connectOutboundChannel(
|
connectOutboundChannel(
|
||||||
bootstrap, inboundProtocol, outboundProtocol, inboundChannel);
|
bootstrap, inboundProtocol, outboundProtocol, inboundChannel);
|
||||||
|
} else {
|
||||||
|
logger.atInfo().log(
|
||||||
|
"Relay terminated: %s <-> %s\nFRONTEND: %s\nBACKEND: %s",
|
||||||
|
inboundProtocol.name(),
|
||||||
|
outboundProtocol.name(),
|
||||||
|
inboundChannel,
|
||||||
|
outboundChannel);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -79,7 +79,8 @@ public class BackendMetricsHandler extends ChannelDuplexHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void channelRegistered(ChannelHandlerContext ctx) throws Exception {
|
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();
|
relayedChannel = ctx.channel().attr(RELAY_CHANNEL_KEY).get();
|
||||||
checkNotNull(relayedChannel, "No frontend channel found.");
|
checkNotNull(relayedChannel, "No frontend channel found.");
|
||||||
relayedProtocolName = relayedChannel.attr(PROTOCOL_KEY).get().name();
|
relayedProtocolName = relayedChannel.attr(PROTOCOL_KEY).get().name();
|
||||||
|
|
|
@ -101,14 +101,13 @@ public class RelayHandler<I> extends SimpleChannelInboundHandler<I> {
|
||||||
.addListener(
|
.addListener(
|
||||||
future -> {
|
future -> {
|
||||||
if (!future.isSuccess()) {
|
if (!future.isSuccess()) {
|
||||||
// TODO (jianglai): do not log the message once retry behavior is confirmed.
|
|
||||||
logger.atWarning().withCause(future.cause()).log(
|
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(),
|
channel.attr(PROTOCOL_KEY).get().name(),
|
||||||
relayChannel.attr(PROTOCOL_KEY).get().name(),
|
relayChannel.attr(PROTOCOL_KEY).get().name(),
|
||||||
channel,
|
channel,
|
||||||
relayChannel,
|
relayChannel,
|
||||||
msg);
|
msg.hashCode());
|
||||||
// If we cannot write to the relay channel and the originating channel has
|
// 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
|
// 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
|
// the message in the buffer for retry later. The relay channel (backend) should
|
||||||
|
@ -129,15 +128,13 @@ public class RelayHandler<I> extends SimpleChannelInboundHandler<I> {
|
||||||
ChannelFuture unusedFuture2 = relayChannel.close();
|
ChannelFuture unusedFuture2 = relayChannel.close();
|
||||||
} else {
|
} else {
|
||||||
if (retry) {
|
if (retry) {
|
||||||
// TODO (jianglai): do not log the message once retry behavior is confirmed.
|
|
||||||
logger.atInfo().log(
|
logger.atInfo().log(
|
||||||
"Relay retry succeeded: %s --> %s\nINBOUND: %s\nOUTBOUND: %s\n"
|
"Relay retry succeeded: %s --> %s\nINBOUND: %s\nOUTBOUND: %s\nHASH: %s",
|
||||||
+ "MESSAGE: %s",
|
|
||||||
channel.attr(PROTOCOL_KEY).get().name(),
|
channel.attr(PROTOCOL_KEY).get().name(),
|
||||||
relayChannel.attr(PROTOCOL_KEY).get().name(),
|
relayChannel.attr(PROTOCOL_KEY).get().name(),
|
||||||
channel,
|
channel,
|
||||||
relayChannel,
|
relayChannel,
|
||||||
msg);
|
msg.hashCode());
|
||||||
}
|
}
|
||||||
// If the write is successful, we know that no retry is needed. This function
|
// 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,
|
// will decrement the reference count if the message is reference counted,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue