use of org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager in project ignite by apache.
the class GridCacheRebalancingWithAsyncClearingTest method testPartitionClearingNotBlockExchange.
/**
* Test that partition clearing doesn't block partitions map exchange.
*
* @throws Exception If failed.
*/
public void testPartitionClearingNotBlockExchange() throws Exception {
System.setProperty(IgniteSystemProperties.IGNITE_PDS_MAX_CHECKPOINT_MEMORY_HISTORY_SIZE, "1");
IgniteEx ig = (IgniteEx) startGrids(3);
ig.cluster().active(true);
// High number of keys triggers long partition eviction.
final int keysCount = 300_000;
try (IgniteDataStreamer ds = ig.dataStreamer(CACHE_NAME)) {
log.info("Writing initial data...");
ds.allowOverwrite(true);
for (int k = 1; k <= keysCount; k++) {
ds.addData(k, k);
if (k % 50_000 == 0)
log.info("Written " + k + " entities.");
}
log.info("Writing initial data finished.");
}
stopGrid(2);
awaitPartitionMapExchange();
try (IgniteDataStreamer ds = ig.dataStreamer(CACHE_NAME)) {
log.info("Writing external data...");
ds.allowOverwrite(true);
for (int k = 1; k <= keysCount; k++) {
ds.addData(k, 2 * k);
if (k % 50_000 == 0)
log.info("Written " + k + " entities.");
}
log.info("Writing external data finished.");
}
IgniteCache<Integer, Integer> cache = ig.cache(CACHE_NAME);
forceCheckpoint();
GridCachePartitionExchangeManager exchangeManager = ig.cachex(CACHE_NAME).context().shared().exchange();
long topVer = exchangeManager.lastTopologyFuture().topologyVersion().topologyVersion();
startGrid(2);
// Check that exchange future is completed and version is incremented
GridDhtPartitionsExchangeFuture fut1 = exchangeManager.lastTopologyFuture();
fut1.get();
Assert.assertEquals(topVer + 1, fut1.topologyVersion().topologyVersion());
// Check that additional exchange didn't influence on asynchronous partitions eviction.
boolean asyncClearingIsRunning = false;
for (int p = 0; p < PARTITIONS_CNT; p++) {
GridDhtLocalPartition part = grid(2).cachex(CACHE_NAME).context().topology().localPartition(p);
if (part != null && part.state() == GridDhtPartitionState.MOVING && part.isClearing()) {
asyncClearingIsRunning = true;
break;
}
}
Assert.assertTrue("Async clearing is not running at the moment", asyncClearingIsRunning);
// Check that stopping & starting node didn't break rebalance process.
stopGrid(1);
startGrid(1);
// Wait for rebalance on all nodes.
for (Ignite ignite : G.allGrids()) ignite.cache(CACHE_NAME).rebalance().get();
// Check no data loss.
for (int k = 1; k <= keysCount; k++) {
Integer value = cache.get(k);
Assert.assertNotNull("Value for " + k + " is null", value);
Assert.assertEquals("Check failed for " + k + " " + value, 2 * k, (int) value);
}
}
use of org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager in project ignite by apache.
the class IgniteDiagnosticMessage method dumpExchangeInfo.
/**
* @param sb String builder.
* @param ctx Context.
*/
static void dumpExchangeInfo(StringBuilder sb, GridKernalContext ctx) {
GridCachePartitionExchangeManager exchMgr = ctx.cache().context().exchange();
GridDhtTopologyFuture fut = exchMgr.lastTopologyFuture();
sb.append("Partitions exchange info [readyVer=").append(exchMgr.readyAffinityVersion()).append(']').append(U.nl()).append("Last initialized exchange future: ").append(fut);
}
use of org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager in project ignite by apache.
the class CacheExchangeMergeTest method waitForExchangeStart.
/**
* @param node Node.
* @param topVer Exchange version.
* @throws Exception If failed.
*/
private void waitForExchangeStart(final Ignite node, final long topVer) throws Exception {
final GridCachePartitionExchangeManager exch = ((IgniteKernal) node).context().cache().context().exchange();
boolean wait = GridTestUtils.waitForCondition(new PA() {
@Override
public boolean apply() {
return exch.lastTopologyFuture().initialVersion().topologyVersion() >= topVer;
}
}, 15_000);
assertTrue(wait);
}
Aggregations