Search in sources :

Example 36 with TestRecordingCommunicationSpi

use of org.apache.ignite.internal.TestRecordingCommunicationSpi in project ignite by apache.

the class IgniteDiagnosticMessagesTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);
    ((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(ipFinder);
    if (testSpi)
        cfg.setCommunicationSpi(new TestRecordingCommunicationSpi());
    if (connectionsPerNode != null)
        ((TcpCommunicationSpi) cfg.getCommunicationSpi()).setConnectionsPerNode(connectionsPerNode);
    cfg.setClientMode(client);
    if (strLog != null) {
        cfg.setGridLogger(strLog);
        strLog = null;
    }
    return cfg;
}
Also used : TestRecordingCommunicationSpi(org.apache.ignite.internal.TestRecordingCommunicationSpi) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 37 with TestRecordingCommunicationSpi

use of org.apache.ignite.internal.TestRecordingCommunicationSpi in project ignite by apache.

the class CacheLateAffinityAssignmentTest method testDelayAssignmentClientLeave.

/**
 * Wait for rebalance, client node leaves.
 *
 * @throws Exception If failed.
 */
public void testDelayAssignmentClientLeave() throws Exception {
    Ignite ignite0 = startServer(0, 1);
    startClient(1, 2);
    checkAffinity(2, topVer(2, 0), true);
    TestRecordingCommunicationSpi spi = (TestRecordingCommunicationSpi) ignite0.configuration().getCommunicationSpi();
    blockSupplySend(spi, CACHE_NAME1);
    startServer(2, 3);
    checkAffinity(3, topVer(3, 0), false);
    stopNode(1, 4);
    checkAffinity(2, topVer(4, 0), false);
    spi.stopBlock();
    checkAffinity(2, topVer(4, 1), true);
}
Also used : TestRecordingCommunicationSpi(org.apache.ignite.internal.TestRecordingCommunicationSpi) Ignite(org.apache.ignite.Ignite)

Example 38 with TestRecordingCommunicationSpi

use of org.apache.ignite.internal.TestRecordingCommunicationSpi in project ignite by apache.

the class CacheLateAffinityAssignmentTest method nodeLeftExchangeCoordinatorLeave.

/**
 * @param nodes Number of nodes.
 * @throws Exception If failed.
 */
private void nodeLeftExchangeCoordinatorLeave(int nodes) throws Exception {
    System.setProperty(IGNITE_EXCHANGE_COMPATIBILITY_VER_1, "true");
    try {
        assert nodes > 2 : nodes;
        long topVer = 0;
        for (int i = 0; i < nodes; i++) startServer(i, ++topVer);
        Ignite ignite1 = grid(1);
        checkAffinity(nodes, topVer(nodes, 1), true);
        TestRecordingCommunicationSpi spi1 = (TestRecordingCommunicationSpi) ignite1.configuration().getCommunicationSpi();
        // Prevent exchange finish while node0 is coordinator.
        spi1.blockMessages(GridDhtPartitionsSingleMessage.class, ignite(0).name());
        // New exchange started.
        stopNode(2, ++topVer);
        // Stop coordinator while exchange in progress.
        stopGrid(0);
        Map<String, List<List<ClusterNode>>> aff = checkAffinity(nodes - 2, topVer(topVer, 0), false);
        topVer++;
        boolean primaryChanged = calculateAffinity(nodes + 2, false, aff);
        checkAffinity(nodes - 2, topVer(topVer, 0), !primaryChanged);
        if (primaryChanged)
            checkAffinity(nodes - 2, topVer(topVer, 1), true);
        awaitPartitionMapExchange();
    } finally {
        System.clearProperty(IGNITE_EXCHANGE_COMPATIBILITY_VER_1);
    }
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) TestRecordingCommunicationSpi(org.apache.ignite.internal.TestRecordingCommunicationSpi) Ignite(org.apache.ignite.Ignite) List(java.util.List) ArrayList(java.util.ArrayList)

Example 39 with TestRecordingCommunicationSpi

use of org.apache.ignite.internal.TestRecordingCommunicationSpi in project ignite by apache.

the class CacheLateAffinityAssignmentTest method testDelayAssignmentCoordinatorLeave2.

/**
 * Wait for rebalance, coordinator leaves, 3 nodes.
 *
 * @throws Exception If failed.
 */
public void testDelayAssignmentCoordinatorLeave2() throws Exception {
    Ignite ignite0 = startServer(0, 1);
    Ignite ignite1 = startServer(1, 2);
    checkAffinity(2, topVer(2, 1), true);
    TestRecordingCommunicationSpi spi0 = (TestRecordingCommunicationSpi) ignite0.configuration().getCommunicationSpi();
    TestRecordingCommunicationSpi spi1 = (TestRecordingCommunicationSpi) ignite1.configuration().getCommunicationSpi();
    blockSupplySend(spi0, CACHE_NAME1);
    blockSupplySend(spi1, CACHE_NAME1);
    startServer(2, 3);
    stopNode(0, 4);
    checkAffinity(2, topVer(4, 0), false);
    spi1.stopBlock();
    checkAffinity(2, topVer(4, 1), true);
}
Also used : TestRecordingCommunicationSpi(org.apache.ignite.internal.TestRecordingCommunicationSpi) Ignite(org.apache.ignite.Ignite)

Example 40 with TestRecordingCommunicationSpi

use of org.apache.ignite.internal.TestRecordingCommunicationSpi in project ignite by apache.

the class CacheLateAffinityAssignmentTest method delayAssignmentMultipleJoin.

/**
 * @param joinCnt Number of joining nodes.
 * @throws Exception If failed.
 */
private void delayAssignmentMultipleJoin(int joinCnt) throws Exception {
    Ignite ignite0 = startServer(0, 1);
    TestRecordingCommunicationSpi spi = (TestRecordingCommunicationSpi) ignite0.configuration().getCommunicationSpi();
    blockSupplySend(spi, CACHE_NAME1);
    int majorVer = 1;
    for (int i = 0; i < joinCnt; i++) {
        majorVer++;
        startServer(i + 1, majorVer);
        checkAffinity(majorVer, topVer(majorVer, 0), false);
    }
    List<IgniteInternalFuture<?>> futs = affFutures(majorVer, topVer(majorVer, 1));
    U.sleep(1000);
    for (IgniteInternalFuture<?> fut : futs) assertFalse(fut.isDone());
    spi.stopBlock();
    checkAffinity(majorVer, topVer(majorVer, 1), true);
    for (IgniteInternalFuture<?> fut : futs) assertTrue(fut.isDone());
    awaitPartitionMapExchange();
}
Also used : TestRecordingCommunicationSpi(org.apache.ignite.internal.TestRecordingCommunicationSpi) Ignite(org.apache.ignite.Ignite) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture)

Aggregations

TestRecordingCommunicationSpi (org.apache.ignite.internal.TestRecordingCommunicationSpi)61 Ignite (org.apache.ignite.Ignite)33 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)20 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)18 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)11 ClusterNode (org.apache.ignite.cluster.ClusterNode)10 Message (org.apache.ignite.plugin.extensions.communication.Message)9 ArrayList (java.util.ArrayList)6 GridDhtPartitionsFullMessage (org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsFullMessage)6 GridDhtPartitionsSingleMessage (org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsSingleMessage)6 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)5 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)5 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)4 GridDhtPartitionSupplyMessage (org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessage)4 IgniteException (org.apache.ignite.IgniteException)3 ClusterTopologyServerNotFoundException (org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException)3 DiscoveryCustomMessage (org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage)3 CacheAffinityChangeMessage (org.apache.ignite.internal.processors.cache.CacheAffinityChangeMessage)3 Transaction (org.apache.ignite.transactions.Transaction)3 IOException (java.io.IOException)2