You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by eo...@apache.org on 2020/09/24 15:51:27 UTC
[bookkeeper] branch branch-4.11 updated: Spammy log when one bookie
of ensemble is down (4.11 porting)
This is an automated email from the ASF dual-hosted git repository.
eolivelli pushed a commit to branch branch-4.11
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git
The following commit(s) were added to refs/heads/branch-4.11 by this push:
new 0979b41 Spammy log when one bookie of ensemble is down (4.11 porting)
0979b41 is described below
commit 0979b41fbba0e50ea27c008f1f9f9a81e3fadd28
Author: Nicolò Boschi <bo...@gmail.com>
AuthorDate: Thu Sep 24 17:51:13 2020 +0200
Spammy log when one bookie of ensemble is down (4.11 porting)
Descriptions of the changes in this PR:
Porting of #2285 PR on 4.11 branch
Reviewers: Enrico Olivelli <eolivelli@apache.org, , Sijie Guo <si...@apache.org>
This closes #2415 from nicoloboschi/fix/2285/port-4.11
---
.../bookkeeper/conf/ClientConfiguration.java | 26 ++++++++++++++++++++++
.../bookkeeper/proto/PerChannelBookieClient.java | 17 ++++++++++----
2 files changed, 39 insertions(+), 4 deletions(-)
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ClientConfiguration.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ClientConfiguration.java
index eddb913..663ad63 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ClientConfiguration.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ClientConfiguration.java
@@ -190,6 +190,10 @@ public class ClientConfiguration extends AbstractConfiguration<ClientConfigurati
// Registration Client
protected static final String REGISTRATION_CLIENT_CLASS = "registrationClientClass";
+ // Logs
+ protected static final String CLIENT_CONNECT_BOOKIE_UNAVAILABLE_LOG_THROTTLING =
+ "clientConnectBookieUnavailableLogThrottling";
+
/**
* Construct a default client-side configuration.
*/
@@ -1927,6 +1931,28 @@ public class ClientConfiguration extends AbstractConfiguration<ClientConfigurati
return getBoolean(STORE_SYSTEMTIME_AS_LEDGER_CREATION_TIME, false);
}
+ /**
+ * Set the log frequency when a bookie is unavailable, in order to limit log filesize.
+ *
+ * @param throttleValue
+ * @param unit
+ * @return client configuration.
+ */
+ public ClientConfiguration setClientConnectBookieUnavailableLogThrottling(
+ int throttleValue, TimeUnit unit) {
+ setProperty(CLIENT_CONNECT_BOOKIE_UNAVAILABLE_LOG_THROTTLING, unit.toMillis(throttleValue));
+ return this;
+ }
+
+ /**
+ * Get the log frequency when a bookie is unavailable, in milliseconds.
+ *
+ * @return log frequency when a bookie is unavailable, in milliseconds.
+ */
+ public long getClientConnectBookieUnavailableLogThrottlingMs() {
+ return getLong(CLIENT_CONNECT_BOOKIE_UNAVAILABLE_LOG_THROTTLING, 5_000L);
+ }
+
@Override
protected ClientConfiguration getThis() {
return this;
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/PerChannelBookieClient.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/PerChannelBookieClient.java
index 94ed865..8e4dd20 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/PerChannelBookieClient.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/PerChannelBookieClient.java
@@ -331,6 +331,7 @@ public class PerChannelBookieClient extends ChannelInboundHandlerAdapter {
private final ExtensionRegistry extRegistry;
private final SecurityHandlerFactory shFactory;
private volatile boolean isWritable = true;
+ private long lastBookieUnavailableLogTimestamp = 0;
public PerChannelBookieClient(OrderedExecutor executor, EventLoopGroup eventLoopGroup,
BookieSocketAddress addr) throws SecurityException {
@@ -2457,12 +2458,12 @@ public class PerChannelBookieClient extends ChannelInboundHandlerAdapter {
Throwable cause = future.cause();
if (cause instanceof UnknownHostException || cause instanceof NativeIoException) {
// Don't log stack trace for common errors
- LOG.warn("Could not connect to bookie: {}/{}, current state {} : {}",
- future.channel(), addr, state, future.cause().getMessage());
+ logBookieUnavailable(() -> LOG.warn("Could not connect to bookie: {}/{}, current state {} : {}",
+ future.channel(), addr, state, future.cause().getMessage()));
} else {
// Regular exceptions, include stack trace
- LOG.error("Could not connect to bookie: {}/{}, current state {} : ",
- future.channel(), addr, state, future.cause());
+ logBookieUnavailable(() -> LOG.error("Could not connect to bookie: {}/{}, current state {} : ",
+ future.channel(), addr, state, future.cause()));
}
rc = BKException.Code.BookieHandleNotAvailableException;
@@ -2488,6 +2489,14 @@ public class PerChannelBookieClient extends ChannelInboundHandlerAdapter {
makeWritable();
}
+
+ private void logBookieUnavailable(Runnable logger) {
+ final long now = System.currentTimeMillis();
+ if ((now - lastBookieUnavailableLogTimestamp) > conf.getClientConnectBookieUnavailableLogThrottlingMs()) {
+ logger.run();
+ lastBookieUnavailableLogTimestamp = now;
+ }
+ }
}
private void initiateTLS() {