Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
import org.apache.ignite.spi.IgniteSpiException;
import org.apache.ignite.spi.communication.CommunicationSpi;
import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
import org.apache.ignite.spi.communication.tcp.internal.ConnectionClientPool;
import org.apache.ignite.spi.discovery.DiscoveryDataBag;
import org.apache.ignite.spi.discovery.DiscoveryDataBag.JoiningNodeDiscoveryData;
import org.apache.ignite.spi.discovery.DiscoveryMetricsProvider;
Expand Down Expand Up @@ -186,6 +187,7 @@
import static org.apache.ignite.internal.util.lang.ClusterNodeFunc.eqNodes;
import static org.apache.ignite.internal.util.lang.ClusterNodeFunc.nodeConsistentIds;
import static org.apache.ignite.plugin.segmentation.SegmentationPolicy.NOOP;
import static org.apache.ignite.spi.communication.tcp.internal.ConnectionClientPool.MY_SUPER_QUEUE;

/**
* Discovery SPI manager.
Expand Down Expand Up @@ -559,6 +561,19 @@ private void updateClientNodes(UUID leftNodeId) {

/** {@inheritDoc} */
@Override public IgniteFuture<?> onDiscovery(DiscoveryNotification notification) {
if (notification != null && notification.type() == EVT_NODE_FAILED
|| notification.type() == EVT_NODE_LEFT
|| notification.type() == EVT_CLIENT_NODE_DISCONNECTED
|| notification.type() == EVT_CLIENT_NODE_RECONNECTED
|| notification.type() == EVT_NODE_SEGMENTED
)
MY_SUPER_QUEUE.computeIfAbsent(
ctx.igniteInstanceName(),
k -> new ConnectionClientPool.MySuperData()).add(
"NODE LEFT",
notification.getNode() == null ? null : notification.getNode().id()
);

GridFutureAdapter<?> notificationFut = new GridFutureAdapter<>();

discoNtfWrk.submit(notificationFut, ctx.security().enabled()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,8 @@ private void dumpInfo(StringBuilder sb, UUID dstNodeId) {
stateProvider,
nioSrvWrapper,
getName(),
((IgniteEx)ignite).context().metric()
((IgniteEx)ignite).context().metric(),
ignite.name()
));

this.srvLsnr.setClientPool(clientPool);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@

package org.apache.ignite.spi.communication.tcp.internal;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.net.InetSocketAddress;
import java.util.Arrays;
import java.util.Map;
import java.util.Optional;
import java.util.StringJoiner;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedDeque;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -169,6 +172,9 @@
/** */
private volatile AtomicBoolean asyncMetric;

/** */
private final String igniteInstanceName;

/**
* @param cfg Config.
* @param attrs Attributes.
Expand Down Expand Up @@ -197,8 +203,10 @@
ClusterStateProvider clusterStateProvider,
GridNioServerWrapper nioSrvWrapper,
String igniteInstanceName,
GridMetricManager metricsMgr
GridMetricManager metricsMgr,
String name
) {
this.igniteInstanceName = name;
this.cfg = cfg;
this.attrs = attrs;
this.log = log;
Expand Down Expand Up @@ -655,8 +663,54 @@
}
}

/** */
public static class MySuperData {
/** */
private final ConcurrentLinkedDeque<String> list = new ConcurrentLinkedDeque<>();

/** */
public void add(String op, UUID nodeId) {
list.add(getStackTraceAsString(new Exception(op + " " + nodeId.toString())));
}

/** */
public void stop() {
list.add("@__@ STOP\n");
}

/** {@inheritDoc} */
@Override public String toString() {
StringBuilder b = new StringBuilder();

b.append("\n");

for (String s : list)
b.append(s).append("\n");

return b.toString();
}
}

/** */
public static final ConcurrentHashMap<String, MySuperData> MY_SUPER_QUEUE = new ConcurrentHashMap<>();

Check warning on line 695 in modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/ConnectionClientPool.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make this member "protected".

See more on https://sonarcloud.io/project/issues?id=apache_ignite&issues=AZzIIj_zL5GvtGFBlDF2&open=AZzIIj_zL5GvtGFBlDF2&pullRequest=12869

Check warning on line 695 in modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/ConnectionClientPool.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

The type of "MY_SUPER_QUEUE" should be an interface such as "ConcurrentMap" rather than the implementation "ConcurrentHashMap".

See more on https://sonarcloud.io/project/issues?id=apache_ignite&issues=AZzIIj_zL5GvtGFBlDF1&open=AZzIIj_zL5GvtGFBlDF1&pullRequest=12869

/** */
public static String getStackTraceAsString(Throwable t) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);

t.printStackTrace(pw);

pw.flush();
sw.flush();

return sw.toString();
}

/** */
private void createNodeMetrics(ClusterNode node) {
MY_SUPER_QUEUE.computeIfAbsent(igniteInstanceName, k -> new MySuperData()).add("CREATED", node.id());

MetricRegistryImpl mreg = metricsMgr.registry(nodeMetricsRegName(node.id()));

assert !mreg.iterator().hasNext() : "Node connection pools metrics aren't empty.";
Expand Down Expand Up @@ -836,6 +890,8 @@

/** */
private void removeNodeMetrics(UUID nodeId) {
MY_SUPER_QUEUE.computeIfAbsent(igniteInstanceName, k -> new MySuperData()).add("REMOVED", nodeId);

metricsMgr.remove(nodeMetricsRegName(nodeId));

metrics.remove(nodeId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.cluster.ClusterNode;
Expand Down Expand Up @@ -56,6 +58,7 @@
import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.jetbrains.annotations.Nullable;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
Expand All @@ -67,6 +70,7 @@
import static org.apache.ignite.spi.communication.tcp.internal.ConnectionClientPool.METRIC_NAME_MAX_NET_IDLE_TIME;
import static org.apache.ignite.spi.communication.tcp.internal.ConnectionClientPool.METRIC_NAME_MSG_QUEUE_SIZE;
import static org.apache.ignite.spi.communication.tcp.internal.ConnectionClientPool.METRIC_NAME_REMOVED_CNT;
import static org.apache.ignite.spi.communication.tcp.internal.ConnectionClientPool.MY_SUPER_QUEUE;
import static org.apache.ignite.spi.communication.tcp.internal.ConnectionClientPool.nodeMetricsRegName;
import static org.apache.ignite.testframework.GridTestUtils.waitForCondition;

Expand Down Expand Up @@ -102,13 +106,18 @@
public boolean clientLdr;

/** */
@Parameterized.Parameters(name = "connsPerNode={0}, pairedConns={1}, msgQueueLimit={2}, clientLdr={3}")
@Parameterized.Parameter(4)
public int id;

/** */
@Parameterized.Parameters(name = "connsPerNode={0}, pairedConns={1}, msgQueueLimit={2}, clientLdr={3}, id={4}")
public static Collection<Object[]> params() {
return GridTestUtils.cartesianProduct(
F.asList(1, 4), // Connections per node.
F.asList(false, true), // Paired connections.
F.asList(0, 100), // Message queue limit.
F.asList(true, false) // Use client as a load.
F.asList(true, false), // Use client as a load.
IntStream.range(0, 50).boxed().collect(Collectors.toList())
);
}

Expand Down Expand Up @@ -141,7 +150,8 @@

/** */
@Test
@Ignore
public void testRemovedConnectionMetrics() throws Exception {

Check warning on line 154 in modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/CommunicationConnectionPoolMetricsTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Either add an explanation about why this test is skipped or remove the "@Ignore" annotation.

See more on https://sonarcloud.io/project/issues?id=apache_ignite&issues=AZzIIj5IL5GvtGFBlDFw&open=AZzIIj5IL5GvtGFBlDFw&pullRequest=12869
maxConnIdleTimeout = 500;

// Prevents keeping connections idle by lazy sending of the unacknowledged messages.
Expand Down Expand Up @@ -198,7 +208,8 @@

/** */
@Test
@Ignore
public void testIdleRemovedConnectionMetricsUnderLazyLoad() throws Exception {

Check warning on line 212 in modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/CommunicationConnectionPoolMetricsTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Either add an explanation about why this test is skipped or remove the "@Ignore" annotation.

See more on https://sonarcloud.io/project/issues?id=apache_ignite&issues=AZzIIj5IL5GvtGFBlDFx&open=AZzIIj5IL5GvtGFBlDFx&pullRequest=12869
maxConnIdleTimeout = 10;

Ignite srvr = startGridsMultiThreaded(2);
Expand Down Expand Up @@ -301,7 +312,7 @@
// Current connection implementations are async.
assertEquals(true, mreg0.<BooleanGauge>findMetric(ConnectionClientPool.METRIC_NAME_ASYNC_CONNS).value());

dumpMetrics(ldr);
// dumpMetrics(ldr);

Check warning on line 315 in modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/CommunicationConnectionPoolMetricsTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This block of commented-out lines of code should be removed.

See more on https://sonarcloud.io/project/issues?id=apache_ignite&issues=AZzIIj5IL5GvtGFBlDFy&open=AZzIIj5IL5GvtGFBlDFy&pullRequest=12869

// Stop the loading, free the messages queue to prevent the connection recreation attempts.
runFlag.set(false);
Expand All @@ -327,13 +338,20 @@
return mreg.<IntMetric>findMetric(METRIC_NAME_MSG_QUEUE_SIZE).value() == 0;
}, getTestTimeout(), 100));

MY_SUPER_QUEUE.values().forEach(ConnectionClientPool.MySuperData::stop);

assertTrue(G.stop(node.name(), false));

assertTrue(waitForCondition(() -> {
boolean success = waitForCondition(() -> {
MetricRegistryImpl mreg = ldrMetricsMgr.registry(nodeMetricsRegName(nodeId));

return mreg == null || !mreg.iterator().hasNext();
}, getTestTimeout()));
}, 100000);

if (!success)
log.error(MY_SUPER_QUEUE.get(ldr.name()).toString());

assertTrue(success);
}

// Ensure that all the possible nodes are stopped.
Expand All @@ -342,7 +360,8 @@

/** Simulates delay/concurrency of connections acquire. */
@Test
@Ignore
public void testAcquiringThreadsCntMetric() throws Exception {

Check warning on line 364 in modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/CommunicationConnectionPoolMetricsTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Either add an explanation about why this test is skipped or remove the "@Ignore" annotation.

See more on https://sonarcloud.io/project/issues?id=apache_ignite&issues=AZzIIj5IL5GvtGFBlDFz&open=AZzIIj5IL5GvtGFBlDFz&pullRequest=12869
// Forces quick connection removing and recreating.
maxConnIdleTimeout = 1;
createClientDelay = 50;
Expand Down Expand Up @@ -384,7 +403,8 @@

/** */
@Test
@Ignore
public void testPendingMessagesMetric() throws Exception {

Check warning on line 407 in modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/CommunicationConnectionPoolMetricsTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Either add an explanation about why this test is skipped or remove the "@Ignore" annotation.

See more on https://sonarcloud.io/project/issues?id=apache_ignite&issues=AZzIIj5IL5GvtGFBlDF0&open=AZzIIj5IL5GvtGFBlDF0&pullRequest=12869
int preloadCnt = 500;

Ignite server = startGridsMultiThreaded(2);
Expand Down Expand Up @@ -518,6 +538,8 @@
super.afterTest();

stopAllGrids();

MY_SUPER_QUEUE.clear();
}

/** {@inheritDoc} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,45 +17,7 @@

package org.apache.ignite.testsuites;

import org.apache.ignite.internal.util.nio.TcpCommunicationSpiSslVolatilePayloadTest;
import org.apache.ignite.spi.communication.tcp.ClientExceptionsUtilsTest;
import org.apache.ignite.spi.communication.tcp.CommunicationConnectionPoolMetricsTest;
import org.apache.ignite.spi.communication.tcp.GridCacheDhtLockBackupSelfTest;
import org.apache.ignite.spi.communication.tcp.GridSandboxedClientWithoutNetworkTest;
import org.apache.ignite.spi.communication.tcp.GridTcpCommunicationInverseConnectionEstablishingTest;
import org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiConcurrentConnectSelfTest;
import org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiConcurrentConnectSslSelfTest;
import org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiConfigSelfTest;
import org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiMultithreadedSelfTest;
import org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiRecoveryAckSelfTest;
import org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiRecoveryFailureDetectionSelfTest;
import org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiRecoveryNoPairedConnectionsTest;
import org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiRecoverySelfTest;
import org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiRecoverySslSelfTest;
import org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiSkipWaitHandshakeOnClientTest;
import org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiSslSelfTest;
import org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiSslSmallBuffersSelfTest;
import org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiStartStopSelfTest;
import org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiTcpFailureDetectionSelfTest;
import org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiTcpNoDelayOffSelfTest;
import org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiTcpSelfTest;
import org.apache.ignite.spi.communication.tcp.GridTotallyUnreachableClientTest;
import org.apache.ignite.spi.communication.tcp.IgniteTcpCommunicationConnectOnInitTest;
import org.apache.ignite.spi.communication.tcp.IgniteTcpCommunicationHandshakeWaitSslTest;
import org.apache.ignite.spi.communication.tcp.IgniteTcpCommunicationHandshakeWaitTest;
import org.apache.ignite.spi.communication.tcp.IgniteTcpCommunicationRecoveryAckClosureSelfTest;
import org.apache.ignite.spi.communication.tcp.TcpCommunicationHandshakeTimeoutTest;
import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpiDropNodesTest;
import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpiFaultyClientSslTest;
import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpiFaultyClientTest;
import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpiFreezingClientTest;
import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpiHalfOpenedConnectionTest;
import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpiInverseConnectionLoggingTest;
import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpiMultiJvmTest;
import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpiNodeLeftLoggingTest;
import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpiSkipMessageSendTest;
import org.apache.ignite.spi.communication.tcp.TcpCommunicationStatisticsTest;
import org.apache.ignite.spi.communication.tcp.TooManyOpenFilesTcpCommunicationSpiTest;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;

Expand All @@ -64,64 +26,7 @@
*/
@RunWith(Suite.class)
@Suite.SuiteClasses({
GridTcpCommunicationSpiRecoveryAckSelfTest.class,
IgniteTcpCommunicationRecoveryAckClosureSelfTest.class,
GridTcpCommunicationSpiRecoverySelfTest.class,
GridTcpCommunicationSpiRecoveryNoPairedConnectionsTest.class,
GridTcpCommunicationSpiRecoverySslSelfTest.class,

GridTcpCommunicationSpiConcurrentConnectSelfTest.class,
GridTcpCommunicationSpiConcurrentConnectSslSelfTest.class,

GridTcpCommunicationSpiSslSelfTest.class,
GridTcpCommunicationSpiSslSmallBuffersSelfTest.class,

GridTcpCommunicationSpiTcpSelfTest.class,
GridTcpCommunicationSpiTcpNoDelayOffSelfTest.class,

GridTcpCommunicationSpiStartStopSelfTest.class,

GridTcpCommunicationSpiMultithreadedSelfTest.class,

GridTcpCommunicationSpiRecoveryFailureDetectionSelfTest.class,
GridTcpCommunicationSpiTcpFailureDetectionSelfTest.class,

GridTcpCommunicationSpiConfigSelfTest.class,

TcpCommunicationSpiSkipMessageSendTest.class,

TcpCommunicationSpiFaultyClientTest.class,
TcpCommunicationSpiFaultyClientSslTest.class,

TcpCommunicationSpiFreezingClientTest.class,

TcpCommunicationSpiDropNodesTest.class,
TcpCommunicationSpiHalfOpenedConnectionTest.class,
GridTcpCommunicationSpiSkipWaitHandshakeOnClientTest.class,

TcpCommunicationStatisticsTest.class,

CommunicationConnectionPoolMetricsTest.class,

IgniteTcpCommunicationHandshakeWaitTest.class,
IgniteTcpCommunicationHandshakeWaitSslTest.class,
IgniteTcpCommunicationConnectOnInitTest.class,

TcpCommunicationSpiMultiJvmTest.class,
TooManyOpenFilesTcpCommunicationSpiTest.class,

GridTcpCommunicationInverseConnectionEstablishingTest.class,
GridTotallyUnreachableClientTest.class,
GridSandboxedClientWithoutNetworkTest.class,

GridCacheDhtLockBackupSelfTest.class,
TcpCommunicationHandshakeTimeoutTest.class,

TcpCommunicationSpiNodeLeftLoggingTest.class,
TcpCommunicationSpiInverseConnectionLoggingTest.class,
ClientExceptionsUtilsTest.class,

TcpCommunicationSpiSslVolatilePayloadTest.class,
})
public class IgniteSpiCommunicationSelfTestSuite {
}
Loading
Loading