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));
}
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);
}
}
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();
}
}
Aggregations