use of org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsFullMessage in project ignite by apache.
the class TxOnCachesStopTest method testOptimisticTxMappedOnPMETopology.
/**
* @throws Exception If failed.
*/
@Test
public void testOptimisticTxMappedOnPMETopology() throws Exception {
Assume.assumeFalse(MvccFeatureChecker.forcedMvcc());
startGridsMultiThreaded(1);
Ignite client = startClientGrid("client");
client.cluster().active(true);
awaitPartitionMapExchange(true, true, null);
final IgniteCache<Integer, byte[]> cache = client.getOrCreateCache(destroyCacheCfg);
final IgniteCache<Integer, byte[]> cache2 = client.getOrCreateCache(surviveCacheCfg);
final TestRecordingCommunicationSpi srvSpi = TestRecordingCommunicationSpi.spi(grid(0));
CountDownLatch destroyLatch = new CountDownLatch(1);
srvSpi.blockMessages((node, msg) -> (msg instanceof GridDhtPartitionsFullMessage));
try (Transaction tx = client.transactions().txStart(OPTIMISTIC, SERIALIZABLE)) {
cache2.put(100, new byte[1024]);
cache.put(100, new byte[1024]);
GridTestUtils.runAsync(() -> {
grid(0).destroyCache(destroyCacheCfg.getName());
destroyLatch.countDown();
});
destroyLatch.await();
IgniteFuture commitFut = tx.commitAsync();
srvSpi.stopBlock();
commitFut.get(10_000);
fail("Transaction should be rolled back.");
} catch (IgniteFutureTimeoutException fte) {
srvSpi.stopBlock();
fail("Partition map exchange hangs [err=" + fte + ']');
} catch (IgniteException e) {
srvSpi.stopBlock();
assertTrue(X.hasCause(e, CacheInvalidStateException.class) || X.hasCause(e, IgniteException.class));
}
}
use of org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsFullMessage in project ignite by apache.
the class IgniteClientCacheStartFailoverTest method testRebalanceState.
/**
* @throws Exception If failed.
*/
@Test
public void testRebalanceState() throws Exception {
final int SRVS = 3;
startGrids(SRVS);
List<String> cacheNames = startCaches(ignite(0), 100);
Ignite c = startClientGrid(SRVS);
assertTrue(c.configuration().isClientMode());
awaitPartitionMapExchange();
TestRecordingCommunicationSpi.spi(ignite(0)).blockMessages(new IgniteBiPredicate<ClusterNode, Message>() {
@Override
public boolean apply(ClusterNode clusterNode, Message msg) {
return msg instanceof GridDhtPartitionsFullMessage && ((GridDhtPartitionsFullMessage) msg).exchangeId() == null;
}
});
startGrid(SRVS + 1);
for (String cacheName : cacheNames) c.cache(cacheName);
// Will switch to ideal topology but some partitions are not evicted yet.
for (int i = 0; i < SRVS + 1; i++) {
AffinityTopologyVersion topVer = new AffinityTopologyVersion(SRVS + 2, 1);
IgniteKernal node = (IgniteKernal) ignite(i);
for (String cacheName : cacheNames) {
GridDhtPartitionTopology top = node.cachex(cacheName).context().topology();
waitForReadyTopology(top, topVer);
assertEquals(topVer, top.readyTopologyVersion());
}
}
TestRecordingCommunicationSpi.spi(ignite(0)).stopBlock();
// Trigger eviction.
awaitPartitionMapExchange();
for (int i = 0; i < SRVS + 1; i++) {
final AffinityTopologyVersion topVer = new AffinityTopologyVersion(SRVS + 2, 1);
final IgniteKernal node = (IgniteKernal) ignite(i);
for (String cacheName : cacheNames) {
final GridDhtPartitionTopology top = node.cachex(cacheName).context().topology();
GridTestUtils.waitForCondition(new GridAbsPredicate() {
@Override
public boolean apply() {
return top.rebalanceFinished(topVer);
}
}, 5000);
assertTrue(top.rebalanceFinished(topVer));
}
}
}
Aggregations