Search in sources :

Example 1 with SlowdownBuildIndexConsumer

use of org.apache.ignite.internal.processors.cache.index.IndexingTestUtils.SlowdownBuildIndexConsumer in project ignite by apache.

the class ResumeCreateIndexTest method testGeneralFlow.

/**
 * Checking the general flow of building a new index.
 *
 * @throws Exception If failed.
 */
@Test
public void testGeneralFlow() 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);
    enableCheckpointsAsync(n, getTestIgniteInstanceName(), true).get(getTestTimeout());
    checkNoStatus(n, cacheName);
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) List(java.util.List) SlowdownBuildIndexConsumer(org.apache.ignite.internal.processors.cache.index.IndexingTestUtils.SlowdownBuildIndexConsumer) Test(org.junit.Test)

Example 2 with SlowdownBuildIndexConsumer

use of org.apache.ignite.internal.processors.cache.index.IndexingTestUtils.SlowdownBuildIndexConsumer 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());
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) List(java.util.List) StopBuildIndexConsumer(org.apache.ignite.internal.processors.cache.index.IndexingTestUtils.StopBuildIndexConsumer) SlowdownBuildIndexConsumer(org.apache.ignite.internal.processors.cache.index.IndexingTestUtils.SlowdownBuildIndexConsumer) QueryIndexKey(org.apache.ignite.internal.processors.query.QueryIndexKey) Test(org.junit.Test)

Example 3 with SlowdownBuildIndexConsumer

use of org.apache.ignite.internal.processors.cache.index.IndexingTestUtils.SlowdownBuildIndexConsumer in project ignite by apache.

the class ResumeCreateIndexTest method testConcurrentBuildNewIndexAndRebuildIndexes1.

/**
 * Checks that building a new index and rebuilding indexes at the same time
 * does not break the {@link IndexBuildStatusHolder}.
 * In this case, rebuilding indexes is completed earlier.
 *
 * @throws Exception If failed.
 */
@Test
public void testConcurrentBuildNewIndexAndRebuildIndexes1() throws Exception {
    String cacheName = DEFAULT_CACHE_NAME;
    IgniteEx n = prepareNodeToCreateNewIndex(cacheName, 100_000, true);
    SlowdownBuildIndexConsumer slowdownRebuildIdxConsumer = addSlowdownRebuildIndexConsumer(n, cacheName, 10);
    assertTrue(forceRebuildIndexes(n, n.cachex(cacheName).context()).isEmpty());
    checkInitStatus(n, cacheName, true, 0);
    slowdownRebuildIdxConsumer.startBuildIdxFut.get(getTestTimeout());
    IgniteInternalFuture<?> idxRebFut = indexRebuildFuture(n, CU.cacheId(cacheName));
    assertNotNull(idxRebFut);
    String idxName = "IDX0";
    SlowdownBuildIndexConsumer slowdownIdxCreateConsumer = addSlowdownIdxCreateConsumer(n, idxName, 100);
    IgniteInternalFuture<List<List<?>>> createIdxFut = createIdxAsync(n.cache(cacheName), idxName);
    slowdownRebuildIdxConsumer.finishBuildIdxFut.onDone();
    slowdownIdxCreateConsumer.startBuildIdxFut.get(getTestTimeout());
    checkInitStatus(n, cacheName, true, 1);
    slowdownIdxCreateConsumer.finishBuildIdxFut.onDone();
    slowdownRebuildIdxConsumer.sleepTime.set(0);
    idxRebFut.get(getTestTimeout());
    checkInitStatus(n, cacheName, false, 1);
    slowdownIdxCreateConsumer.sleepTime.set(0);
    createIdxFut.get(getTestTimeout());
    checkCompletedStatus(n, cacheName);
    enableCheckpointsAsync(n, getTestIgniteInstanceName(), true).get(getTestTimeout());
    checkNoStatus(n, cacheName);
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) List(java.util.List) SlowdownBuildIndexConsumer(org.apache.ignite.internal.processors.cache.index.IndexingTestUtils.SlowdownBuildIndexConsumer) Test(org.junit.Test)

Example 4 with SlowdownBuildIndexConsumer

use of org.apache.ignite.internal.processors.cache.index.IndexingTestUtils.SlowdownBuildIndexConsumer in project ignite by apache.

the class AbstractRebuildIndexTest method addSlowdownRebuildIndexConsumer.

/**
 * Registering a {@link SlowdownBuildIndexConsumer} to {@link IndexesRebuildTaskEx#addCacheRowConsumer}.
 *
 * @param n Node.
 * @param cacheName Cache name.
 * @param sleepTime Sleep time after processing each cache row in milliseconds.
 * @return New instance of {@link SlowdownBuildIndexConsumer}.
 */
protected SlowdownBuildIndexConsumer addSlowdownRebuildIndexConsumer(IgniteEx n, String cacheName, long sleepTime) {
    SlowdownBuildIndexConsumer consumer = new SlowdownBuildIndexConsumer(getTestTimeout(), sleepTime);
    addCacheRowConsumer(nodeName(n), cacheName, consumer);
    return consumer;
}
Also used : SlowdownBuildIndexConsumer(org.apache.ignite.internal.processors.cache.index.IndexingTestUtils.SlowdownBuildIndexConsumer)

Example 5 with SlowdownBuildIndexConsumer

use of org.apache.ignite.internal.processors.cache.index.IndexingTestUtils.SlowdownBuildIndexConsumer in project ignite by apache.

the class AbstractRebuildIndexTest method addSlowdownIdxCreateConsumer.

/**
 * Registering a {@link SlowdownBuildIndexConsumer} to {@link IgniteH2IndexingEx#addIdxCreateCacheRowConsumer}.
 *
 * @param n Node.
 * @param idxName Index name.
 * @param sleepTime Sleep time after processing each cache row in milliseconds.
 * @return New instance of {@link SlowdownBuildIndexConsumer}.
 */
protected SlowdownBuildIndexConsumer addSlowdownIdxCreateConsumer(IgniteEx n, String idxName, long sleepTime) {
    SlowdownBuildIndexConsumer consumer = new SlowdownBuildIndexConsumer(getTestTimeout(), sleepTime);
    addIdxCreateCacheRowConsumer(nodeName(n), idxName, consumer);
    return consumer;
}
Also used : SlowdownBuildIndexConsumer(org.apache.ignite.internal.processors.cache.index.IndexingTestUtils.SlowdownBuildIndexConsumer)

Aggregations

SlowdownBuildIndexConsumer (org.apache.ignite.internal.processors.cache.index.IndexingTestUtils.SlowdownBuildIndexConsumer)7 List (java.util.List)5 IgniteEx (org.apache.ignite.internal.IgniteEx)5 Test (org.junit.Test)5 StopBuildIndexConsumer (org.apache.ignite.internal.processors.cache.index.IndexingTestUtils.StopBuildIndexConsumer)2 QueryIndexKey (org.apache.ignite.internal.processors.query.QueryIndexKey)2