use of org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointHistory in project ignite by apache.
the class ReleaseSegmentOnHistoricalRebalanceTest method testReleaseBeforeRebalanceIterator.
/**
* Checks that if release the segment before {@link IgniteCacheOffheapManagerImpl#rebalanceIterator},
* there will be no errors and the rebalance will be completed.
*
* @throws Exception If failed.
*/
@Test
public void testReleaseBeforeRebalanceIterator() throws Exception {
checkHistoricalRebalance(n -> {
IgniteInternalCache<?, ?> cachex = n.cachex(DEFAULT_CACHE_NAME);
GridCacheOffheapManager spy = spy(offheapManager(cachex));
doAnswer(m -> {
CheckpointHistory cpHist = dbMgr(n).checkpointHistory();
for (Long cp : cpHist.checkpoints()) release(n, entry(cpHist, cp).checkpointMark());
return m.callRealMethod();
}).when(spy).rebalanceIterator(any(), any());
offheapManager(cachex, spy);
});
}
use of org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointHistory in project ignite by apache.
the class ReleaseSegmentOnHistoricalRebalanceTest method testReleaseSegmentAfterSearchAndReserveCheckpoints.
/**
* Checks that if release the segment after {@link CheckpointHistory#searchAndReserveCheckpoints},
* there will be no errors and the rebalance will be completed.
*
* @throws Exception If failed.
*/
@Test
public void testReleaseSegmentAfterSearchAndReserveCheckpoints() throws Exception {
checkHistoricalRebalance(n -> {
CheckpointHistory spy = spy(dbMgr(n).checkpointHistory());
when(spy.searchAndReserveCheckpoints(any())).thenAnswer(m -> {
CheckpointHistoryResult res = (CheckpointHistoryResult) m.callRealMethod();
WALPointer reserved = res.reservedCheckpointMark();
assertNotNull(reserved);
release(n, reserved);
return res;
});
checkpointHistory(n, spy);
});
}
use of org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointHistory in project ignite by apache.
the class LocalWalModeChangeDuringRebalancingSelfTest method doTestSimple.
/**
* @throws Exception If failed.
*/
private void doTestSimple() throws Exception {
Ignite ignite = startGrids(3);
ignite.cluster().baselineAutoAdjustEnabled(false);
ignite.cluster().state(ACTIVE);
IgniteCache<Integer, Integer> cache = ignite.cache(DEFAULT_CACHE_NAME);
IgniteCache<Integer, Integer> cache2 = ignite.cache(REPL_CACHE);
int keysCnt = getKeysCount();
for (int k = 0; k < keysCnt; k++) {
cache.put(k, k);
// Empty cache causes skipped checkpoint.
cache2.put(k, k);
}
IgniteEx newIgnite = startGrid(3);
final CheckpointHistory cpHist = ((GridCacheDatabaseSharedManager) newIgnite.context().cache().context().database()).checkpointHistory();
waitForCondition(new GridAbsPredicate() {
@Override
public boolean apply() {
return !cpHist.checkpoints().isEmpty();
}
}, 10_000);
// To ensure timestamp granularity.
U.sleep(10);
long newIgniteStartedTimestamp = System.currentTimeMillis();
newIgnite.cluster().setBaselineTopology(4);
awaitExchange(newIgnite);
CacheGroupContext grpCtx = newIgnite.cachex(DEFAULT_CACHE_NAME).context().group();
assertEquals(!disableWalDuringRebalancing, grpCtx.walEnabled());
// To ensure timestamp granularity.
U.sleep(10);
long rebalanceStartedTimestamp = System.currentTimeMillis();
for (Ignite g : G.allGrids()) g.cache(DEFAULT_CACHE_NAME).rebalance();
awaitPartitionMapExchange();
assertTrue(grpCtx.walEnabled());
// To ensure timestamp granularity.
U.sleep(10);
long rebalanceFinishedTimestamp = System.currentTimeMillis();
for (Integer k = 0; k < keysCnt; k++) assertEquals("k=" + k, k, cache.get(k));
int checkpointsBeforeNodeStarted = 0;
int checkpointsBeforeRebalance = 0;
int checkpointsAfterRebalance = 0;
for (Long timestamp : cpHist.checkpoints()) {
if (timestamp < newIgniteStartedTimestamp)
checkpointsBeforeNodeStarted++;
else if (timestamp >= newIgniteStartedTimestamp && timestamp < rebalanceStartedTimestamp)
checkpointsBeforeRebalance++;
else if (timestamp >= rebalanceStartedTimestamp && timestamp <= rebalanceFinishedTimestamp)
checkpointsAfterRebalance++;
}
// checkpoint on start
assertEquals(1, checkpointsBeforeNodeStarted);
assertEquals(0, checkpointsBeforeRebalance);
// Expecting a checkpoint for each group.
assertEquals(disableWalDuringRebalancing ? newIgnite.context().cache().cacheGroups().size() : 0, // checkpoint if WAL was re-activated
checkpointsAfterRebalance);
}
use of org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointHistory in project ignite by apache.
the class LocalWalModeChangeDuringRebalancingSelfTest method testWalDisabledDuringRebalancingWithPendingTxTracker.
/**
* @throws Exception If failed.
*/
@Test
public void testWalDisabledDuringRebalancingWithPendingTxTracker() throws Exception {
enablePendingTxTracker = true;
dfltCacheBackupCnt = 2;
Ignite ignite = startGrids(3);
ignite.cluster().baselineAutoAdjustEnabled(false);
ignite.cluster().state(ACTIVE);
ignite.cluster().setBaselineTopology(3);
IgniteCache<Integer, Integer> cache = ignite.cache(DEFAULT_CACHE_NAME);
stopGrid(2);
awaitExchange((IgniteEx) ignite);
// Ensure each partition has received an update.
for (int k = 0; k < RendezvousAffinityFunction.DFLT_PARTITION_COUNT; k++) cache.put(k, k);
IgniteEx newIgnite = startGrid(2);
awaitExchange(newIgnite);
CacheGroupContext grpCtx = newIgnite.cachex(DEFAULT_CACHE_NAME).context().group();
assertFalse(grpCtx.walEnabled());
long rebalanceStartedTs = System.currentTimeMillis();
for (Ignite g : G.allGrids()) g.cache(DEFAULT_CACHE_NAME).rebalance();
awaitPartitionMapExchange();
assertTrue(grpCtx.walEnabled());
long rebalanceFinishedTs = System.currentTimeMillis();
CheckpointHistory cpHist = ((GridCacheDatabaseSharedManager) newIgnite.context().cache().context().database()).checkpointHistory();
assertNotNull(cpHist);
// Ensure there was a checkpoint on WAL re-activation.
assertEquals(1, cpHist.checkpoints().stream().filter(ts -> rebalanceStartedTs <= ts && ts <= rebalanceFinishedTs).count());
}
use of org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointHistory in project ignite by apache.
the class WalDeletionArchiveAbstractTest method testCheckpointHistoryRemovingByTruncate.
/**
* Test for check deprecated removing checkpoint by deprecated walHistorySize parameter
*
* @deprecated Test old removing process depends on WalHistorySize.
*/
@Test
public void testCheckpointHistoryRemovingByTruncate() throws Exception {
Ignite ignite = startGrid(dbCfg -> dbCfg.setMaxWalArchiveSize(2 * 1024 * 1024));
GridCacheDatabaseSharedManager dbMgr = gridDatabase(ignite);
IgniteCache<Integer, Object> cache = ignite.getOrCreateCache(cacheConfiguration());
CheckpointHistory hist = dbMgr.checkpointHistory();
assertNotNull(hist);
int startHistSize = hist.checkpoints().size();
int checkpointCnt = 10;
for (int i = 0; i < checkpointCnt; i++) {
cache.put(i, i);
// and: wait for checkpoint finished
forceCheckpoint();
// Check that the history is growing.
assertEquals(startHistSize + (i + 1), hist.checkpoints().size());
}
// Ensure rollover and wal archive cleaning.
for (int i = 0; i < 6; i++) cache.put(i, new byte[ignite.configuration().getDataStorageConfiguration().getWalSegmentSize() / 2]);
FileWriteAheadLogManager wal = wal(ignite);
assertTrue(waitForCondition(() -> wal.lastTruncatedSegment() >= 0, 10_000));
assertTrue(hist.checkpoints().size() < checkpointCnt + startHistSize);
File[] cpFiles = dbMgr.checkpointDirectory().listFiles();
// starts & ends + node_start
assertTrue(cpFiles.length <= (checkpointCnt * 2 + 1));
}
Aggregations