Search in sources :

Example 1 with TcpDiscoveryStatistics

use of org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryStatistics in project ignite by apache.

the class TcpDiscoverySelfTest method testNoExtraNodeFailedMessage.

/**
     * @throws Exception If failed.
     */
public void testNoExtraNodeFailedMessage() throws Exception {
    try {
        final int NODES = 10;
        startGridsMultiThreaded(NODES);
        int stopIdx = 5;
        Ignite failIgnite = ignite(stopIdx);
        ((TcpDiscoverySpi) failIgnite.configuration().getDiscoverySpi()).simulateNodeFailure();
        for (int i = 0; i < NODES; i++) {
            if (i != stopIdx) {
                final Ignite ignite = ignite(i);
                GridTestUtils.waitForCondition(new PA() {

                    @Override
                    public boolean apply() {
                        return ignite.cluster().topologyVersion() >= NODES + 1;
                    }
                }, 10_000);
                TcpDiscoverySpi spi = (TcpDiscoverySpi) ignite.configuration().getDiscoverySpi();
                TcpDiscoveryStatistics stats = GridTestUtils.getFieldValue(spi, "stats");
                Integer cnt = stats.sentMessages().get(TcpDiscoveryNodeFailedMessage.class.getSimpleName());
                log.info("Count1: " + cnt);
                assertTrue("Invalid message count: " + cnt, cnt == null || cnt <= 2);
                cnt = stats.receivedMessages().get(TcpDiscoveryNodeFailedMessage.class.getSimpleName());
                log.info("Count2: " + cnt);
                assertTrue("Invalid message count: " + cnt, cnt == null || cnt <= 2);
            }
        }
    } finally {
        stopAllGrids();
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) PA(org.apache.ignite.internal.util.typedef.PA) TcpDiscoveryStatistics(org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryStatistics) Ignite(org.apache.ignite.Ignite) TcpDiscoveryNodeFailedMessage(org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryNodeFailedMessage)

Aggregations

AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Ignite (org.apache.ignite.Ignite)1 PA (org.apache.ignite.internal.util.typedef.PA)1 TcpDiscoveryStatistics (org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryStatistics)1 TcpDiscoveryNodeFailedMessage (org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryNodeFailedMessage)1