You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by pt...@apache.org on 2022/10/20 05:27:05 UTC
[ignite] branch master updated: IGNITE-17351 Java thin: Add logging (#10331)
This is an automated email from the ASF dual-hosted git repository.
ptupitsyn pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new 2a1f7a4ea8d IGNITE-17351 Java thin: Add logging (#10331)
2a1f7a4ea8d is described below
commit 2a1f7a4ea8d656072b69df7ea36559f705b8e861
Author: Pavel Tupitsyn <pt...@apache.org>
AuthorDate: Thu Oct 20 08:26:55 2022 +0300
IGNITE-17351 Java thin: Add logging (#10331)
* Add `ClientConfiguration.logger`
* Log connection attempts, configuration adjustments, errors
---
.../ignite/configuration/ClientConfiguration.java | 26 +++++++++++
.../client/thin/ClientBinaryMarshaller.java | 2 +-
.../client/thin/ClientChannelConfiguration.java | 13 ++++++
.../thin/ClientInternalBinaryConfiguration.java | 6 +++
.../internal/client/thin/ReliableChannel.java | 50 ++++++++++++++++------
.../internal/client/thin/TcpClientChannel.java | 46 ++++++++++++++++++--
.../internal/client/thin/TcpIgniteClient.java | 15 ++++++-
.../java/org/apache/ignite/logger/NullLogger.java | 11 +++++
.../ignite/client/BinaryConfigurationTest.java | 24 +++++++++--
.../client/thin/AbstractThinClientTest.java | 9 +++-
10 files changed, 180 insertions(+), 22 deletions(-)
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/ClientConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/ClientConfiguration.java
index f3eb294965c..84b680d0bea 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/ClientConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/ClientConfiguration.java
@@ -24,6 +24,8 @@ import java.util.concurrent.Executor;
import java.util.concurrent.ForkJoinPool;
import javax.cache.configuration.Factory;
import javax.net.ssl.SSLContext;
+
+import org.apache.ignite.IgniteLogger;
import org.apache.ignite.client.ClientAddressFinder;
import org.apache.ignite.client.ClientPartitionAwarenessMapper;
import org.apache.ignite.client.ClientPartitionAwarenessMapperFactory;
@@ -150,6 +152,9 @@ public final class ClientConfiguration implements Serializable {
*/
private boolean autoBinaryConfigurationEnabled = true;
+ /** Logger. */
+ private IgniteLogger logger;
+
/**
* @return Host addresses.
*/
@@ -814,4 +819,25 @@ public final class ClientConfiguration implements Serializable {
public ClientPartitionAwarenessMapperFactory getPartitionAwarenessMapperFactory() {
return partitionAwarenessMapperFactory;
}
+
+ /**
+ * Sets the logger.
+ *
+ * @param logger Logger.
+ * @return {@code this} for chaining.
+ */
+ public ClientConfiguration setLogger(IgniteLogger logger) {
+ this.logger = logger;
+
+ return this;
+ }
+
+ /**
+ * Gets the logger.
+ *
+ * @return Logger.
+ */
+ public IgniteLogger getLogger() {
+ return logger;
+ }
}
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientBinaryMarshaller.java b/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientBinaryMarshaller.java
index a8b5ba54abd..f886d46d3f9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientBinaryMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientBinaryMarshaller.java
@@ -107,7 +107,7 @@ class ClientBinaryMarshaller {
igniteCfg.setBinaryConfiguration(binCfg);
- BinaryContext ctx = new BinaryContext(metaHnd, igniteCfg, new NullLogger());
+ BinaryContext ctx = new BinaryContext(metaHnd, igniteCfg, NullLogger.INSTANCE);
BinaryMarshaller marsh = new BinaryMarshaller();
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientChannelConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientChannelConfiguration.java
index a23d2226614..e81dc9204c8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientChannelConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientChannelConfiguration.java
@@ -22,6 +22,8 @@ import java.util.Map;
import java.util.concurrent.Executor;
import javax.cache.configuration.Factory;
import javax.net.ssl.SSLContext;
+
+import org.apache.ignite.IgniteLogger;
import org.apache.ignite.client.SslMode;
import org.apache.ignite.client.SslProtocol;
import org.apache.ignite.configuration.ClientConfiguration;
@@ -105,6 +107,9 @@ final class ClientChannelConfiguration {
/** Automatic binary configuration. */
private final boolean autoBinaryConfigurationEnabled;
+ /** */
+ private final IgniteLogger logger;
+
/**
* Constructor.
*/
@@ -135,6 +140,7 @@ final class ClientChannelConfiguration {
this.heartbeatEnabled = cfg.isHeartbeatEnabled();
this.heartbeatInterval = cfg.getHeartbeatInterval();
this.autoBinaryConfigurationEnabled = cfg.isAutoBinaryConfigurationEnabled();
+ this.logger = cfg.getLogger();
}
/**
@@ -312,4 +318,11 @@ final class ClientChannelConfiguration {
public boolean isAutoBinaryConfigurationEnabled() {
return autoBinaryConfigurationEnabled;
}
+
+ /**
+ * @return Logger.
+ */
+ public IgniteLogger getLogger() {
+ return logger;
+ }
}
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientInternalBinaryConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientInternalBinaryConfiguration.java
index da8cb03f737..b9c5d308b1a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientInternalBinaryConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientInternalBinaryConfiguration.java
@@ -18,6 +18,7 @@
package org.apache.ignite.internal.client.thin;
import org.apache.ignite.internal.binary.streams.BinaryInputStream;
+import org.apache.ignite.internal.util.typedef.internal.S;
/**
* Cluster binary configuration.
@@ -52,4 +53,9 @@ class ClientInternalBinaryConfiguration {
public BinaryNameMapperMode binaryNameMapperMode() {
return binaryNameMapperMode;
}
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(ClientInternalBinaryConfiguration.class, this);
+ }
}
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java b/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
index e030979f0b1..d7e0b63d550 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
@@ -40,6 +40,7 @@ import java.util.stream.Collectors;
import java.util.stream.IntStream;
import org.apache.ignite.IgniteBinary;
import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteLogger;
import org.apache.ignite.client.ClientAuthenticationException;
import org.apache.ignite.client.ClientAuthorizationException;
import org.apache.ignite.client.ClientConnectionException;
@@ -56,6 +57,7 @@ import org.apache.ignite.internal.client.thin.io.gridnioserver.GridNioClientConn
import org.apache.ignite.internal.util.HostAndPortRange;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.logger.NullLogger;
/**
* Communication channel with failover and partition awareness.
@@ -82,6 +84,9 @@ final class ReliableChannel implements AutoCloseable {
/** Client configuration. */
private final ClientConfiguration clientCfg;
+ /** Logger. */
+ private final IgniteLogger log;
+
/** Node channels. */
private final Map<UUID, ClientChannelHolder> nodeChannels = new ConcurrentHashMap<>();
@@ -128,6 +133,7 @@ final class ReliableChannel implements AutoCloseable {
this.clientCfg = clientCfg;
this.chFactory = chFactory;
+ log = NullLogger.whenNull(clientCfg.getLogger());
partitionAwarenessEnabled = clientCfg.isPartitionAwarenessEnabled();
@@ -135,10 +141,16 @@ final class ReliableChannel implements AutoCloseable {
connMgr = new GridNioClientConnectionMultiplexer(clientCfg);
connMgr.start();
+
+ if (log.isDebugEnabled())
+ log.debug("ReliableChannel created");
}
/** {@inheritDoc} */
@Override public synchronized void close() {
+ if (log.isDebugEnabled())
+ log.debug("ReliableChannel stopping");
+
closed = true;
connMgr.stop();
@@ -149,6 +161,9 @@ final class ReliableChannel implements AutoCloseable {
for (ClientChannelHolder hld: holders)
hld.close();
}
+
+ if (log.isDebugEnabled())
+ log.debug("ReliableChannel stopped");
}
/**
@@ -228,7 +243,7 @@ final class ReliableChannel implements AutoCloseable {
if (err instanceof ClientConnectionException) {
try {
// Will try to reinit channels if topology changed.
- onChannelFailure(ch);
+ onChannelFailure(ch, err);
}
catch (Throwable ex) {
fut.completeExceptionally(ex);
@@ -369,7 +384,7 @@ final class ReliableChannel implements AutoCloseable {
try {
// Will try to reinit channels if topology changed.
- onChannelFailure(channel);
+ onChannelFailure(channel, err);
}
catch (Throwable ex) {
fut.completeExceptionally(ex);
@@ -529,17 +544,19 @@ final class ReliableChannel implements AutoCloseable {
/**
* On current channel failure.
*/
- private void onChannelFailure(ClientChannel ch) {
+ private void onChannelFailure(ClientChannel ch, Throwable t) {
// There is nothing wrong if curChIdx was concurrently changed, since channel was closed by another thread
// when current index was changed and no other wrong channel will be closed by current thread because
// onChannelFailure checks channel binded to the holder before closing it.
- onChannelFailure(channels.get(curChIdx), ch);
+ onChannelFailure(channels.get(curChIdx), ch, t);
}
/**
* On channel of the specified holder failure.
*/
- private void onChannelFailure(ClientChannelHolder hld, ClientChannel ch) {
+ private void onChannelFailure(ClientChannelHolder hld, ClientChannel ch, Throwable t) {
+ log.warning("Channel failure [address=" + hld.chCfg.getAddress() + ", err=" + t.getMessage() + ']', t);
+
if (ch != null && ch == hld.ch)
hld.closeChannel();
@@ -579,8 +596,8 @@ final class ReliableChannel implements AutoCloseable {
try {
hld.getOrCreateChannel(true);
}
- catch (Exception ignore) {
- // No-op.
+ catch (Exception e) {
+ log.warning("Failed to initialize channel [address=" + hld.chCfg.getAddress() + ", err=" + e.getMessage() + ']', e);
}
}
}
@@ -755,7 +772,7 @@ final class ReliableChannel implements AutoCloseable {
return function.apply(channel);
}
catch (ClientConnectionException e) {
- onChannelFailure(hld, channel);
+ onChannelFailure(hld, channel, e);
}
return null;
@@ -806,7 +823,7 @@ final class ReliableChannel implements AutoCloseable {
else
failure.addSuppressed(e);
- onChannelFailure(hld, c);
+ onChannelFailure(hld, c, e);
if (op != null && !shouldRetry(op, attempt, e))
break;
@@ -836,7 +853,7 @@ final class ReliableChannel implements AutoCloseable {
}
catch (ClientConnectionException e) {
- onChannelFailure(hld, channel);
+ onChannelFailure(hld, channel, e);
retryLimit -= 1;
@@ -864,8 +881,12 @@ final class ReliableChannel implements AutoCloseable {
private boolean shouldRetry(ClientOperation op, int iteration, ClientConnectionException exception) {
ClientOperationType opType = op.toPublicOperationType();
- if (opType == null)
+ if (opType == null) {
+ if (log.isDebugEnabled())
+ log.debug("Retrying system operation [op=" + op + ", iteration=" + iteration + ']');
+
return true; // System operation.
+ }
ClientRetryPolicy plc = clientCfg.getRetryPolicy();
@@ -875,7 +896,12 @@ final class ReliableChannel implements AutoCloseable {
ClientRetryPolicyContext ctx = new ClientRetryPolicyContextImpl(clientCfg, opType, iteration, exception);
try {
- return plc.shouldRetry(ctx);
+ boolean res = plc.shouldRetry(ctx);
+
+ if (log.isDebugEnabled())
+ log.debug("Retry policy returned " + res + " [op=" + op + ", iteration=" + iteration + ']');
+
+ return res;
}
catch (Throwable t) {
exception.addSuppressed(t);
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/TcpClientChannel.java b/modules/core/src/main/java/org/apache/ignite/internal/client/thin/TcpClientChannel.java
index 74408192db5..a97298bfe7d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/TcpClientChannel.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/client/thin/TcpClientChannel.java
@@ -41,6 +41,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.function.Consumer;
import java.util.function.Function;
import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteLogger;
import org.apache.ignite.client.ClientAuthenticationException;
import org.apache.ignite.client.ClientAuthorizationException;
import org.apache.ignite.client.ClientConnectionException;
@@ -70,6 +71,7 @@ import org.apache.ignite.internal.util.future.GridFutureAdapter;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.T2;
import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.logger.NullLogger;
import org.jetbrains.annotations.Nullable;
import static org.apache.ignite.internal.client.thin.ProtocolBitmaskFeature.HEARTBEAT;
@@ -157,6 +159,9 @@ class TcpClientChannel implements ClientChannel, ClientMessageHandler, ClientCon
/** Heartbeat timer. */
private final Timer heartbeatTimer;
+ /** Log. */
+ private final IgniteLogger log;
+
/** Last send operation timestamp. */
private volatile long lastSendMillis;
@@ -165,6 +170,8 @@ class TcpClientChannel implements ClientChannel, ClientMessageHandler, ClientCon
throws ClientConnectionException, ClientAuthenticationException, ClientProtocolError {
validateConfiguration(cfg);
+ log = NullLogger.whenNull(cfg.getLogger());
+
for (ClientNotificationType type : ClientNotificationType.values()) {
if (type.keepNotificationsWithoutListener())
pendingNotifications[type.ordinal()] = new ConcurrentHashMap<>();
@@ -177,6 +184,9 @@ class TcpClientChannel implements ClientChannel, ClientMessageHandler, ClientCon
sock = connMgr.open(cfg.getAddress(), this, this);
+ if (log.isDebugEnabled())
+ log.debug("Connection establised: " + cfg.getAddress());
+
handshake(DEFAULT_VERSION, cfg.getUserName(), cfg.getUserPassword(), cfg.getUserAttributes());
heartbeatTimer = protocolCtx.isFeatureSupported(HEARTBEAT) && cfg.getHeartbeatEnabled()
@@ -196,6 +206,11 @@ class TcpClientChannel implements ClientChannel, ClientMessageHandler, ClientCon
/** {@inheritDoc} */
@Override public void onDisconnected(@Nullable Exception e) {
+ if (e == null)
+ log.info("Client disconnected");
+ else
+ log.warning("Client disconnected: " + e.getMessage(), e);
+
close(e);
}
@@ -316,6 +331,8 @@ class TcpClientChannel implements ClientChannel, ClientMessageHandler, ClientCon
return payloadReader.apply(new PayloadInputChannel(this, payload));
}
catch (IgniteCheckedException e) {
+ log.warning("Failed to process response: " + e.getMessage(), e);
+
throw convertException(e);
}
}
@@ -342,6 +359,8 @@ class TcpClientChannel implements ClientChannel, ClientMessageHandler, ClientCon
}
}
catch (Throwable t) {
+ log.warning("Failed to process response: " + t.getMessage(), t);
+
fut.completeExceptionally(convertException(t));
}
}));
@@ -666,6 +685,9 @@ class TcpClientChannel implements ClientChannel, ClientMessageHandler, ClientCon
// Reading server UUID
srvNodeId = reader.readUuid();
}
+
+ if (log.isDebugEnabled())
+ log.debug("Handshake succeeded [protocolVersion=" + protocolCtx.version() + ", srvNodeId=" + srvNodeId + ']');
}
else {
ProtocolVersion srvVer = new ProtocolVersion(res.readShort(), res.readShort(), res.readShort());
@@ -676,6 +698,9 @@ class TcpClientChannel implements ClientChannel, ClientMessageHandler, ClientCon
if (res.remaining() > 0)
errCode = reader.readInt();
+ if (log.isDebugEnabled())
+ log.debug("Handshake failed [protocolVersion=" + srvVer + ", err=" + err + ", errCode=" + errCode + ']');
+
if (errCode == ClientStatus.AUTH_FAILED)
throw new ClientAuthenticationException(err);
else if (proposedVer.equals(srvVer))
@@ -690,7 +715,11 @@ class TcpClientChannel implements ClientChannel, ClientMessageHandler, ClientCon
srvVer,
err
));
- else { // Retry with server version.
+ else {
+ // Retry with server version.
+ if (log.isDebugEnabled())
+ log.debug("Retrying handshake with server version [protocolVersion=" + srvVer + ']');
+
handshake(srvVer, user, pwd, userAttrs);
}
}
@@ -753,15 +782,26 @@ class TcpClientChannel implements ClientChannel, ClientMessageHandler, ClientCon
private long getHeartbeatInterval(long configuredInterval) {
long serverIdleTimeoutMs = service(ClientOperation.GET_IDLE_TIMEOUT, null, in -> in.in().readLong());
- if (serverIdleTimeoutMs <= 0)
+ if (serverIdleTimeoutMs <= 0) {
+ if (log.isInfoEnabled())
+ log.info("Server-side IdleTimeout is not set, using configured ClientConfiguration.heartbeatInterval: " +
+ configuredInterval);
+
return configuredInterval;
+ }
long recommendedHeartbeatInterval = serverIdleTimeoutMs / 3;
if (recommendedHeartbeatInterval < MIN_RECOMMENDED_HEARTBEAT_INTERVAL)
recommendedHeartbeatInterval = MIN_RECOMMENDED_HEARTBEAT_INTERVAL;
- return Math.min(configuredInterval, recommendedHeartbeatInterval);
+ long res = Math.min(configuredInterval, recommendedHeartbeatInterval);
+
+ if (log.isInfoEnabled())
+ log.info("Using heartbeat interval: " + res + " (configured: " + configuredInterval +
+ ", recommended: " + recommendedHeartbeatInterval + ", server-side IdleTimeout: " + serverIdleTimeoutMs + ")");
+
+ return res;
}
/**
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/TcpIgniteClient.java b/modules/core/src/main/java/org/apache/ignite/internal/client/thin/TcpIgniteClient.java
index 82e7bb04ca2..f15293089fb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/TcpIgniteClient.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/client/thin/TcpIgniteClient.java
@@ -29,6 +29,7 @@ import java.util.function.BiFunction;
import java.util.function.Consumer;
import org.apache.ignite.IgniteBinary;
import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteLogger;
import org.apache.ignite.binary.BinaryBasicNameMapper;
import org.apache.ignite.binary.BinaryObjectException;
import org.apache.ignite.binary.BinaryType;
@@ -69,6 +70,7 @@ import org.apache.ignite.internal.processors.platform.client.IgniteClientExcepti
import org.apache.ignite.internal.util.GridArgumentCheck;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.logger.NullLogger;
import org.apache.ignite.marshaller.MarshallerContext;
import org.apache.ignite.marshaller.MarshallerUtils;
import org.apache.ignite.marshaller.jdk.JdkMarshaller;
@@ -473,12 +475,23 @@ public class TcpIgniteClient implements IgniteClient {
if (clusterCfg == null)
return;
+ IgniteLogger log = NullLogger.whenNull(cfg.getLogger());
+
+ if (log.isDebugEnabled())
+ log.debug("Cluster binary configuration retrieved: " + clusterCfg);
+
BinaryConfiguration resCfg = cfg.getBinaryConfiguration();
if (resCfg == null)
resCfg = new BinaryConfiguration();
- resCfg.setCompactFooter(clusterCfg.compactFooter());
+ if (resCfg.isCompactFooter() != clusterCfg.compactFooter()) {
+ if (log.isInfoEnabled())
+ log.info("Overriding compact footer setting according to cluster configuration: " +
+ resCfg.isCompactFooter() + " -> " + clusterCfg.compactFooter());
+
+ resCfg.setCompactFooter(clusterCfg.compactFooter());
+ }
switch (clusterCfg.binaryNameMapperMode()) {
case BASIC_FULL:
diff --git a/modules/core/src/main/java/org/apache/ignite/logger/NullLogger.java b/modules/core/src/main/java/org/apache/ignite/logger/NullLogger.java
index 64924835e1a..3b0b9edebfa 100644
--- a/modules/core/src/main/java/org/apache/ignite/logger/NullLogger.java
+++ b/modules/core/src/main/java/org/apache/ignite/logger/NullLogger.java
@@ -25,6 +25,17 @@ import org.jetbrains.annotations.Nullable;
* Logger which does not output anything.
*/
public class NullLogger implements IgniteLogger {
+ /** Singleton instance. */
+ public static final NullLogger INSTANCE = new NullLogger();
+
+ /**
+ * @param log Logger.
+ * @return Specified logger if it is not {@code null}, {@code NullLogger} otherwise.
+ */
+ public static IgniteLogger whenNull(IgniteLogger log) {
+ return log == null ? INSTANCE : log;
+ }
+
/** {@inheritDoc} */
@Override public IgniteLogger getLogger(Object ctgr) {
return this;
diff --git a/modules/core/src/test/java/org/apache/ignite/client/BinaryConfigurationTest.java b/modules/core/src/test/java/org/apache/ignite/client/BinaryConfigurationTest.java
index b09efe4601f..52779e8ccba 100644
--- a/modules/core/src/test/java/org/apache/ignite/client/BinaryConfigurationTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/client/BinaryConfigurationTest.java
@@ -27,6 +27,8 @@ import org.apache.ignite.internal.binary.BinaryObjectImpl;
import org.apache.ignite.internal.client.thin.AbstractThinClientTest;
import org.apache.ignite.internal.processors.platform.client.IgniteClientException;
import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.ListeningTestLogger;
+import org.apache.ignite.testframework.LogListener;
import org.junit.Test;
import static org.apache.ignite.internal.binary.BinaryUtils.FLAG_COMPACT_FOOTER;
@@ -68,8 +70,13 @@ public class BinaryConfigurationTest extends AbstractThinClientTest {
.setCompactFooter(false)
.setNameMapper(new BinaryBasicNameMapper().setSimpleName(true));
- ClientConfiguration clientCfg = getClientConfiguration(server)
- .setBinaryConfiguration(binaryCfg);
+ LogListener listener = LogListener.matches(
+ "Overriding compact footer setting according to cluster configuration: false -> true").build();
+
+ ClientConfiguration baseCfg = getClientConfiguration(server);
+ ClientConfiguration clientCfg = baseCfg
+ .setBinaryConfiguration(binaryCfg)
+ .setLogger(new ListeningTestLogger(baseCfg.getLogger(), listener));
try (IgniteClient client = Ignition.startClient(clientCfg)) {
BinaryObjectImpl res = getClientBinaryObjectFromServer(server, client);
@@ -77,6 +84,8 @@ public class BinaryConfigurationTest extends AbstractThinClientTest {
// Server-side defaults are compact footers and full name mapper.
assertTrue(res.isFlagSet(FLAG_COMPACT_FOOTER));
assertEquals("org.apache.ignite.client.Person", res.type().typeName());
+
+ assertTrue(listener.check());
}
}
@@ -134,14 +143,21 @@ public class BinaryConfigurationTest extends AbstractThinClientTest {
Ignite server = startGrid("0", cfg -> cfg.setBinaryConfiguration(binaryCfg));
- ClientConfiguration clientCfg = getClientConfiguration(server)
- .setBinaryConfiguration(binaryCfg);
+ LogListener listener = LogListener.matches(
+ "Cluster binary configuration retrieved: ClientInternalBinaryConfiguration " +
+ "[compactFooter=true, binaryNameMapperMode=CUSTOM]").build();
+
+ ClientConfiguration baseCfg = getClientConfiguration(server);
+ ClientConfiguration clientCfg = baseCfg
+ .setBinaryConfiguration(binaryCfg)
+ .setLogger(new ListeningTestLogger(baseCfg.getLogger(), listener));
try (IgniteClient client = Ignition.startClient(clientCfg)) {
BinaryObjectImpl res = getClientBinaryObjectFromServer(server, client);
assertTrue(res.isFlagSet(FLAG_COMPACT_FOOTER));
assertEquals("org.apache.ignite.client.Person_", res.type().typeName());
+ assertTrue(listener.check());
}
}
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/client/thin/AbstractThinClientTest.java b/modules/core/src/test/java/org/apache/ignite/internal/client/thin/AbstractThinClientTest.java
index ecf394d1a33..e9ac0e6d984 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/client/thin/AbstractThinClientTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/client/thin/AbstractThinClientTest.java
@@ -28,6 +28,8 @@ import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.G;
import org.apache.ignite.mxbean.ClientProcessorMXBean;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.testframework.junits.logger.GridTestLog4jLogger;
+import org.apache.logging.log4j.Level;
/**
* Abstract thin client test.
@@ -37,7 +39,12 @@ public abstract class AbstractThinClientTest extends GridCommonAbstractTest {
* Gets default client configuration.
*/
protected ClientConfiguration getClientConfiguration() {
- return new ClientConfiguration().setPartitionAwarenessEnabled(false);
+ GridTestLog4jLogger log = new GridTestLog4jLogger();
+ log.setLevel(Level.ALL);
+
+ return new ClientConfiguration()
+ .setPartitionAwarenessEnabled(false)
+ .setLogger(log);
}
/**