Search in sources :

Example 6 with DiscoverySpiTestListener

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

the class CacheLateAffinityAssignmentTest method testDelayAssignmentAffinityChanged.

/**
 * Wait for rebalance, send affinity change message, but affinity already changed (new node joined).
 *
 * @throws Exception If failed.
 */
@Test
public void testDelayAssignmentAffinityChanged() throws Exception {
    Ignite ignite0 = startServer(0, 1);
    for (int i = 0; i < 1024; i++) ignite0.cache(CACHE_NAME1).put(i, i);
    DiscoverySpiTestListener lsnr = new DiscoverySpiTestListener();
    ((IgniteDiscoverySpi) ignite0.configuration().getDiscoverySpi()).setInternalListener(lsnr);
    TestRecordingCommunicationSpi commSpi0 = (TestRecordingCommunicationSpi) ignite0.configuration().getCommunicationSpi();
    startClient(1, 2);
    checkAffinity(2, topVer(2, 0), true);
    lsnr.blockCustomEvent(CacheAffinityChangeMessage.class);
    startServer(2, 3);
    checkAffinity(3, topVer(3, 0), false);
    lsnr.waitCustomEvent();
    blockSupplySend(commSpi0, CACHE_NAME1);
    startServer(3, 4);
    lsnr.stopBlockCustomEvents();
    checkAffinity(4, topVer(4, 0), false);
    checkNoExchange(4, topVer(4, 1));
    commSpi0.stopBlock();
    checkAffinity(4, topVer(4, 1), true);
    awaitPartitionMapExchange(true, true, null, false);
    assertPartitionsSame(idleVerify(grid(0), CACHE_NAME1));
}
Also used : TestRecordingCommunicationSpi(org.apache.ignite.internal.TestRecordingCommunicationSpi) DiscoverySpiTestListener(org.apache.ignite.internal.DiscoverySpiTestListener) Ignite(org.apache.ignite.Ignite) IgniteDiscoverySpi(org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 7 with DiscoverySpiTestListener

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

the class CacheLateAffinityAssignmentTest method testNodeLeaveExchangeWaitAffinityMessage.

/**
 * @throws Exception If failed.
 */
@Test
public void testNodeLeaveExchangeWaitAffinityMessage() throws Exception {
    System.setProperty(IGNITE_EXCHANGE_COMPATIBILITY_VER_1, "true");
    try {
        Ignite ignite0 = startServer(0, 1);
        startServer(1, 2);
        startServer(2, 3);
        checkAffinity(3, topVer(3, 1), true);
        checkOrderCounters(3, topVer(3, 1));
        startClient(3, 4);
        checkAffinity(4, topVer(4, 0), true);
        DiscoverySpiTestListener lsnr = new DiscoverySpiTestListener();
        ((IgniteDiscoverySpi) ignite0.configuration().getDiscoverySpi()).setInternalListener(lsnr);
        lsnr.blockCustomEvent(CacheAffinityChangeMessage.class);
        stopGrid(1);
        List<IgniteInternalFuture<?>> futs = affFutures(3, topVer(5, 0));
        U.sleep(1000);
        for (IgniteInternalFuture<?> fut : futs) assertFalse(fut.isDone());
        lsnr.stopBlockCustomEvents();
        checkAffinity(3, topVer(5, 0), false);
        checkOrderCounters(3, topVer(5, 0));
    } finally {
        System.clearProperty(IGNITE_EXCHANGE_COMPATIBILITY_VER_1);
    }
}
Also used : DiscoverySpiTestListener(org.apache.ignite.internal.DiscoverySpiTestListener) Ignite(org.apache.ignite.Ignite) IgniteDiscoverySpi(org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 8 with DiscoverySpiTestListener

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

the class TcpDiscoveryReconnectUnstableTopologyTest method testReconnectUnstableTopology.

/**
 * @throws Exception If failed.
 */
@Test
public void testReconnectUnstableTopology() throws Exception {
    try {
        List<IgniteEx> nodes = new ArrayList<>();
        nodes.add(startGrid(0));
        nodes.add(startGrid(1));
        nodes.add(startClientGrid("client"));
        nodes.add(startGrid(2));
        nodes.add(startGrid(3));
        for (int i = 0; i < nodes.size(); i++) {
            IgniteEx ex = nodes.get(i);
            assertEquals(i + 1, ex.localNode().order());
        }
        DiscoverySpiTestListener lsnr = new DiscoverySpiTestListener();
        spi(grid("client")).setInternalListener(lsnr);
        lsnr.startBlockReconnect();
        CountDownLatch restartLatch = new CountDownLatch(1);
        IgniteInternalFuture<?> fut = multithreadedAsync(() -> {
            stopGrid(1);
            stopGrid(2);
            stopGrid(3);
            try {
                startGrid(1);
                startGrid(2);
                startGrid(3);
            } catch (Exception e) {
                fail();
            }
            restartLatch.countDown();
        }, 1, "restarter");
        U.awaitQuiet(restartLatch);
        lsnr.stopBlockRestart();
        fut.get();
        // Wait for reconnect.
        doSleep(1500);
        startGrid(4);
    } finally {
        stopAllGrids();
    }
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) ArrayList(java.util.ArrayList) DiscoverySpiTestListener(org.apache.ignite.internal.DiscoverySpiTestListener) CountDownLatch(java.util.concurrent.CountDownLatch) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Aggregations

DiscoverySpiTestListener (org.apache.ignite.internal.DiscoverySpiTestListener)8 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)8 Test (org.junit.Test)8 IgniteDiscoverySpi (org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi)7 Ignite (org.apache.ignite.Ignite)5 TestRecordingCommunicationSpi (org.apache.ignite.internal.TestRecordingCommunicationSpi)3 IOException (java.io.IOException)2 UUID (java.util.UUID)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 IgniteEx (org.apache.ignite.internal.IgniteEx)2 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)2 PA (org.apache.ignite.internal.util.typedef.PA)2 File (java.io.File)1 FilenameFilter (java.io.FilenameFilter)1 ArrayList (java.util.ArrayList)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 IgniteException (org.apache.ignite.IgniteException)1 IgniteLogger (org.apache.ignite.IgniteLogger)1 IgniteMessaging (org.apache.ignite.IgniteMessaging)1