use of org.apache.ignite.internal.processors.query.aware.IndexBuildStatusStorage.KEY_PREFIX in project ignite by apache.
the class ResumeRebuildIndexTest method testNormalFlowIndexRebuildStateStorage.
/**
* Checking normal flow for {@link IndexBuildStatusStorage}.
*
* @throws Exception If failed.
*/
@Test
public void testNormalFlowIndexRebuildStateStorage() throws Exception {
prepareBeforeNodeStart();
IgniteEx n = startGrid(0);
populate(n.cache(DEFAULT_CACHE_NAME), 1_000);
GridCacheContext<?, ?> cacheCtx = n.cachex(DEFAULT_CACHE_NAME).context();
StopBuildIndexConsumer stopRebuildIdxConsumer = addStopRebuildIndexConsumer(n, cacheCtx.name());
dbMgr(n).enableCheckpoints(false).get(getTestTimeout());
assertTrue(forceRebuildIndexes(n, cacheCtx).isEmpty());
IgniteInternalFuture<?> idxRebFut = indexRebuildFuture(n, cacheCtx.cacheId());
assertFalse(indexBuildStatusStorage(n).rebuildCompleted(cacheCtx.name()));
assertNotNull(metaStorageOperation(n, metaStorage -> metaStorage.read(KEY_PREFIX + cacheCtx.name())));
stopRebuildIdxConsumer.startBuildIdxFut.get(getTestTimeout());
stopRebuildIdxConsumer.finishBuildIdxFut.onDone();
idxRebFut.get(getTestTimeout());
assertEquals(1_000, stopRebuildIdxConsumer.visitCnt.get());
assertTrue(indexBuildStatusStorage(n).rebuildCompleted(cacheCtx.name()));
dbMgr(n).enableCheckpoints(true).get(getTestTimeout());
forceCheckpoint();
assertNull(metaStorageOperation(n, metaStorage -> metaStorage.read(KEY_PREFIX + cacheCtx.name())));
}
use of org.apache.ignite.internal.processors.query.aware.IndexBuildStatusStorage.KEY_PREFIX in project ignite by apache.
the class ResumeRebuildIndexTest method testRestartNodeFlowIndexRebuildStateStorage.
/**
* Checking the flow in case of an restart node for {@link IndexBuildStatusStorage}.
*
* @throws Exception If failed.
*/
@Test
public void testRestartNodeFlowIndexRebuildStateStorage() throws Exception {
prepareBeforeNodeStart();
IgniteEx n = startGrid(0);
populate(n.cache(DEFAULT_CACHE_NAME), 1_000);
GridCacheContext<?, ?> cacheCtx = n.cachex(DEFAULT_CACHE_NAME).context();
BreakBuildIndexConsumer breakRebuildIdxConsumer = addBreakRebuildIndexConsumer(n, cacheCtx.name(), 10);
assertTrue(forceRebuildIndexes(n, cacheCtx).isEmpty());
IgniteInternalFuture<?> idxRebFut0 = indexRebuildFuture(n, cacheCtx.cacheId());
breakRebuildIdxConsumer.startBuildIdxFut.get(getTestTimeout());
breakRebuildIdxConsumer.finishBuildIdxFut.onDone();
assertThrows(log, () -> idxRebFut0.get(getTestTimeout()), Throwable.class, null);
forceCheckpoint();
assertFalse(indexBuildStatusStorage(n).rebuildCompleted(cacheCtx.name()));
assertNotNull(metaStorageOperation(n, metaStorage -> metaStorage.read(KEY_PREFIX + cacheCtx.name())));
stopAllGrids();
StopBuildIndexConsumer stopRebuildIdxConsumer = addStopRebuildIndexConsumer(n, cacheCtx.name());
prepareBeforeNodeStart();
n = startGrid(0);
assertFalse(indexBuildStatusStorage(n).rebuildCompleted(cacheCtx.name()));
assertNotNull(metaStorageOperation(n, metaStorage -> metaStorage.read(KEY_PREFIX + cacheCtx.name())));
stopRebuildIdxConsumer.startBuildIdxFut.get(getTestTimeout());
IgniteInternalFuture<?> idxRebFut1 = indexRebuildFuture(n, cacheCtx.cacheId());
dbMgr(n).enableCheckpoints(false).get(getTestTimeout());
stopRebuildIdxConsumer.finishBuildIdxFut.onDone();
idxRebFut1.get(getTestTimeout());
assertEquals(1_000, stopRebuildIdxConsumer.visitCnt.get());
assertTrue(indexBuildStatusStorage(n).rebuildCompleted(cacheCtx.name()));
assertNotNull(metaStorageOperation(n, metaStorage -> metaStorage.read(KEY_PREFIX + cacheCtx.name())));
dbMgr(n).enableCheckpoints(true).get(getTestTimeout());
forceCheckpoint();
assertNull(metaStorageOperation(n, metaStorage -> metaStorage.read(KEY_PREFIX + cacheCtx.name())));
}
use of org.apache.ignite.internal.processors.query.aware.IndexBuildStatusStorage.KEY_PREFIX in project ignite by apache.
the class ResumeRebuildIndexTest method testErrorFlowIndexRebuildStateStorage.
/**
* Checking the flow in case of an error for {@link IndexBuildStatusStorage}.
*
* @throws Exception If failed.
*/
@Test
public void testErrorFlowIndexRebuildStateStorage() throws Exception {
prepareBeforeNodeStart();
IgniteEx n = startGrid(0);
populate(n.cache(DEFAULT_CACHE_NAME), 1_000);
GridCacheContext<?, ?> cacheCtx = n.cachex(DEFAULT_CACHE_NAME).context();
BreakBuildIndexConsumer breakRebuildIdxConsumer = addBreakRebuildIndexConsumer(n, cacheCtx.name(), 10);
assertTrue(forceRebuildIndexes(n, cacheCtx).isEmpty());
IgniteInternalFuture<?> idxRebFut0 = indexRebuildFuture(n, cacheCtx.cacheId());
assertFalse(indexBuildStatusStorage(n).rebuildCompleted(cacheCtx.name()));
assertNotNull(metaStorageOperation(n, metaStorage -> metaStorage.read(KEY_PREFIX + cacheCtx.name())));
breakRebuildIdxConsumer.startBuildIdxFut.get(getTestTimeout());
breakRebuildIdxConsumer.finishBuildIdxFut.onDone();
assertThrows(log, () -> idxRebFut0.get(getTestTimeout()), Throwable.class, null);
assertTrue(breakRebuildIdxConsumer.visitCnt.get() < 1_000);
forceCheckpoint();
assertFalse(indexBuildStatusStorage(n).rebuildCompleted(cacheCtx.name()));
assertNotNull(metaStorageOperation(n, metaStorage -> metaStorage.read(KEY_PREFIX + cacheCtx.name())));
StopBuildIndexConsumer stopRebuildIdxConsumer = addStopRebuildIndexConsumer(n, cacheCtx.name());
dbMgr(n).enableCheckpoints(false).get(getTestTimeout());
assertTrue(forceRebuildIndexes(n, cacheCtx).isEmpty());
IgniteInternalFuture<?> idxRebFut1 = indexRebuildFuture(n, cacheCtx.cacheId());
assertFalse(indexBuildStatusStorage(n).rebuildCompleted(cacheCtx.name()));
assertNotNull(metaStorageOperation(n, metaStorage -> metaStorage.read(KEY_PREFIX + cacheCtx.name())));
stopRebuildIdxConsumer.startBuildIdxFut.get(getTestTimeout());
stopRebuildIdxConsumer.finishBuildIdxFut.onDone();
idxRebFut1.get(getTestTimeout());
assertEquals(1_000, stopRebuildIdxConsumer.visitCnt.get());
assertTrue(indexBuildStatusStorage(n).rebuildCompleted(cacheCtx.name()));
dbMgr(n).enableCheckpoints(true).get(getTestTimeout());
forceCheckpoint();
assertNull(metaStorageOperation(n, metaStorage -> metaStorage.read(KEY_PREFIX + cacheCtx.name())));
}
Aggregations