use of org.apache.ignite.internal.TestRecordingCommunicationSpi in project ignite by apache.
the class IgniteCacheClientMultiNodeUpdateTopologyLockTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
cfg.setConsistentId(gridName);
((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(ipFinder);
TestRecordingCommunicationSpi commSpi = new TestRecordingCommunicationSpi();
cfg.setCommunicationSpi(commSpi);
cfg.setClientMode(client);
return cfg;
}
use of org.apache.ignite.internal.TestRecordingCommunicationSpi in project ignite by apache.
the class IgniteCacheNearLockValueSelfTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
cfg.setDiscoverySpi(new TcpDiscoverySpi().setForceServerMode(true).setIpFinder(IP_FINDER));
if (getTestIgniteInstanceName(0).equals(igniteInstanceName))
cfg.setClientMode(true);
TestRecordingCommunicationSpi commSpi = new TestRecordingCommunicationSpi();
commSpi.record(GridNearLockRequest.class);
cfg.setCommunicationSpi(commSpi);
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 IgniteTxCachePrimarySyncTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(ipFinder);
cfg.setClientMode(clientMode);
TestRecordingCommunicationSpi commSpi = new TestRecordingCommunicationSpi();
commSpi.setSharedMemoryPort(-1);
cfg.setCommunicationSpi(commSpi);
return cfg;
}
use of org.apache.ignite.internal.TestRecordingCommunicationSpi in project ignite by apache.
the class IgniteTxCachePrimarySyncTest method singleKeyPrimaryNodeLeft.
/**
* @param client Node executing cache operation.
* @param ccfg Cache configuration.
* @param c Cache update closure.
* @throws Exception If failed.
*/
private void singleKeyPrimaryNodeLeft(Ignite client, final CacheConfiguration<Object, Object> ccfg, final IgniteBiInClosure<Integer, IgniteCache<Object, Object>> c) throws Exception {
Ignite ignite = startGrid(NODES);
awaitPartitionMapExchange();
final TestRecordingCommunicationSpi commSpiClient = (TestRecordingCommunicationSpi) client.configuration().getCommunicationSpi();
IgniteCache<Object, Object> cache = ignite.cache(ccfg.getName());
final Integer key = primaryKey(cache);
cache.remove(key);
waitKeyRemoved(ccfg.getName(), key);
commSpiClient.blockMessages(GridNearTxFinishRequest.class, ignite.name());
final IgniteCache<Object, Object> clientCache = client.cache(ccfg.getName());
IgniteInternalFuture<?> fut = GridTestUtils.runAsync(new Callable<Void>() {
@Override
public Void call() throws Exception {
c.apply(key, clientCache);
return null;
}
});
boolean waitMsgSnd = GridTestUtils.waitForCondition(new GridAbsPredicate() {
@Override
public boolean apply() {
return commSpiClient.hasBlockedMessages();
}
}, 5000);
assertTrue(waitMsgSnd);
ignite.close();
commSpiClient.stopBlock(false);
fut.get();
awaitPartitionMapExchange();
waitKeyUpdated(client, ccfg.getBackups() + 1, ccfg.getName(), key);
clientCache.remove(key);
waitKeyRemoved(ccfg.getName(), key);
c.apply(key, clientCache);
waitKeyUpdated(client, ccfg.getBackups() + 1, ccfg.getName(), key);
}
Aggregations