use of org.apache.ignite.internal.TestRecordingCommunicationSpi in project ignite by apache.
the class IgniteCacheReadFromBackupTest method getConfiguration.
/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
TestRecordingCommunicationSpi commSpi = new TestRecordingCommunicationSpi();
cfg.setCommunicationSpi(commSpi);
((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(ipFinder);
return cfg;
}
use of org.apache.ignite.internal.TestRecordingCommunicationSpi in project ignite by apache.
the class GridCacheDhtPreloadMessageCountTest method testAutomaticPreload.
/**
* @throws Exception If failed.
*/
public void testAutomaticPreload() throws Exception {
Ignite g0 = startGrid(0);
int cnt = KEY_CNT;
IgniteCache<String, Integer> c0 = g0.cache(DEFAULT_CACHE_NAME);
for (int i = 0; i < cnt; i++) c0.put(Integer.toString(i), i);
Ignite g1 = startGrid(1);
Ignite g2 = startGrid(2);
U.sleep(1000);
IgniteCache<String, Integer> c1 = g1.cache(DEFAULT_CACHE_NAME);
IgniteCache<String, Integer> c2 = g2.cache(DEFAULT_CACHE_NAME);
TestRecordingCommunicationSpi spi0 = (TestRecordingCommunicationSpi) g0.configuration().getCommunicationSpi();
TestRecordingCommunicationSpi spi1 = (TestRecordingCommunicationSpi) g1.configuration().getCommunicationSpi();
TestRecordingCommunicationSpi spi2 = (TestRecordingCommunicationSpi) g2.configuration().getCommunicationSpi();
info(spi0.recordedMessages(false).size() + " " + spi1.recordedMessages(false).size() + " " + spi2.recordedMessages(false).size());
checkCache(c0, cnt);
checkCache(c1, cnt);
checkCache(c2, cnt);
}
use of org.apache.ignite.internal.TestRecordingCommunicationSpi in project ignite by apache.
the class CacheExchangeMessageDuplicatedStateTest method checkFullMessages.
/**
* @param crdIdx Coordinator node index.
*/
private void checkFullMessages(int crdIdx) {
TestRecordingCommunicationSpi commSpi0 = (TestRecordingCommunicationSpi) ignite(crdIdx).configuration().getCommunicationSpi();
List<Object> msgs = commSpi0.recordedMessages(false);
assertTrue(msgs.size() > 0);
for (Object msg : msgs) {
assertTrue("Unexpected messages: " + msg, msg instanceof GridDhtPartitionsFullMessage);
checkFullMessage((GridDhtPartitionsFullMessage) msg);
}
}
use of org.apache.ignite.internal.TestRecordingCommunicationSpi in project ignite by apache.
the class CacheLateAffinityAssignmentTest method testJoinExchangeBecomeCoordinator.
/**
* @throws Exception If failed.
*/
public void testJoinExchangeBecomeCoordinator() throws Exception {
long topVer = 0;
final int NODES = 3;
for (int i = 0; i < NODES; i++) startServer(i, ++topVer);
checkAffinity(NODES, topVer(topVer, 1), true);
for (int i = 0; i < NODES; i++) {
TestRecordingCommunicationSpi spi = (TestRecordingCommunicationSpi) ignite(i).configuration().getCommunicationSpi();
spi.blockMessages(new IgniteBiPredicate<ClusterNode, Message>() {
@Override
public boolean apply(ClusterNode node, Message msg) {
return msg.getClass().equals(GridDhtPartitionsSingleMessage.class) || msg.getClass().equals(GridDhtPartitionsFullMessage.class);
}
});
}
final CountDownLatch latch = new CountDownLatch(1);
IgniteInternalFuture<?> stopFut = GridTestUtils.runAsync(new Callable<Void>() {
@Override
public Void call() throws Exception {
latch.await();
U.sleep(5000);
for (int i = 0; i < NODES; i++) stopGrid(getTestIgniteInstanceName(i), false, false);
return null;
}
}, "stop-thread");
latch.countDown();
Ignite node = startGrid(NODES);
assertEquals(NODES + 1, node.cluster().localNode().order());
stopFut.get();
for (int i = 0; i < NODES + 1; i++) calculateAffinity(++topVer);
checkAffinity(1, topVer(topVer, 0), true);
for (int i = 0; i < NODES; i++) startServer(i, ++topVer);
checkAffinity(NODES + 1, topVer(topVer, 1), true);
}
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();
}
Aggregations