use of org.apache.ignite.internal.processors.query.QueryIndexKey in project ignite by apache.
the class ResumeCreateIndexTest method testPartialCheckpointNewIndexRows.
/**
* Checks that if a checkpoint fails after building a new index and the
* node restarts, then the indexes will be rebuilt.
*
* @throws Exception If failed.
*/
@Test
public void testPartialCheckpointNewIndexRows() throws Exception {
String cacheName = DEFAULT_CACHE_NAME;
IgniteEx n = prepareNodeToCreateNewIndex(cacheName, 100_000, false);
String idxName = "IDX0";
SlowdownBuildIndexConsumer slowdownIdxCreateConsumer = addSlowdownIdxCreateConsumer(n, idxName, 10);
IgniteInternalFuture<List<List<?>>> createIdxFut = createIdxAsync(n.cache(cacheName), idxName);
slowdownIdxCreateConsumer.startBuildIdxFut.get(getTestTimeout());
checkInitStatus(n, cacheName, false, 1);
String reason = getTestIgniteInstanceName();
IgniteInternalFuture<Void> awaitBeforeCpBeginFut = awaitBeforeCheckpointBeginAsync(n, reason);
IgniteInternalFuture<Void> disableCpFut = enableCheckpointsAsync(n, reason, false);
awaitBeforeCpBeginFut.get(getTestTimeout());
slowdownIdxCreateConsumer.finishBuildIdxFut.onDone();
disableCpFut.get(getTestTimeout());
slowdownIdxCreateConsumer.sleepTime.set(0);
createIdxFut.get(getTestTimeout());
checkCompletedStatus(n, cacheName);
stopGrid(0);
IndexesRebuildTaskEx.prepareBeforeNodeStart();
StopBuildIndexConsumer stopRebuildIdxConsumer = addStopRebuildIndexConsumer(n, cacheName);
n = startGrid(0);
stopRebuildIdxConsumer.startBuildIdxFut.get(getTestTimeout());
IgniteInternalFuture<?> rebIdxFut = indexRebuildFuture(n, CU.cacheId(cacheName));
assertNotNull(rebIdxFut);
checkInitStatus(n, cacheName, true, 0);
assertTrue(allIndexes(n).containsKey(new QueryIndexKey(cacheName, idxName)));
stopRebuildIdxConsumer.finishBuildIdxFut.onDone();
rebIdxFut.get(getTestTimeout());
forceCheckpoint();
checkNoStatus(n, cacheName);
assertEquals(100_000, selectPersonByName(n.cache(cacheName)).size());
}
use of org.apache.ignite.internal.processors.query.QueryIndexKey in project ignite by apache.
the class ResumeCreateIndexTest method testNoCheckpointAfterIndexCreation.
/**
* Checks that if there is no checkpoint after the index is created and the
* node is restarted, the indexes will be rebuilt.
*
* @throws Exception If failed.
*/
@Test
public void testNoCheckpointAfterIndexCreation() throws Exception {
String cacheName = DEFAULT_CACHE_NAME;
IgniteEx n = prepareNodeToCreateNewIndex(cacheName, 10, true);
String idxName = "IDX0";
SlowdownBuildIndexConsumer slowdownIdxCreateConsumer = addSlowdownIdxCreateConsumer(n, idxName, 0);
IgniteInternalFuture<List<List<?>>> createIdxFut = createIdxAsync(n.cache(cacheName), idxName);
slowdownIdxCreateConsumer.startBuildIdxFut.get(getTestTimeout());
checkInitStatus(n, cacheName, false, 1);
slowdownIdxCreateConsumer.finishBuildIdxFut.onDone();
createIdxFut.get(getTestTimeout());
checkCompletedStatus(n, cacheName);
stopGrid(0);
IndexesRebuildTaskEx.prepareBeforeNodeStart();
StopBuildIndexConsumer stopRebuildIdxConsumer = addStopRebuildIndexConsumer(n, cacheName);
n = startGrid(0);
stopRebuildIdxConsumer.startBuildIdxFut.get(getTestTimeout());
IgniteInternalFuture<?> idxRebFut = indexRebuildFuture(n, CU.cacheId(cacheName));
assertNotNull(idxRebFut);
checkInitStatus(n, cacheName, true, 0);
assertTrue(allIndexes(n).containsKey(new QueryIndexKey(cacheName, idxName)));
stopRebuildIdxConsumer.finishBuildIdxFut.onDone();
idxRebFut.get(getTestTimeout());
forceCheckpoint();
checkNoStatus(n, cacheName);
assertEquals(10, selectPersonByName(n.cache(cacheName)).size());
}
Aggregations