Search in sources :

Example 16 with Person

use of org.apache.ignite.client.Person in project ignite by apache.

the class DropIndexTest method checkDestroyIndexTrees.

/**
 * Checking {@link DurableBackgroundCleanupIndexTreeTaskV2#destroyIndexTrees}.
 *
 * @param persistent Persistent default data region.
 * @param expRes Expected result should not be less than which.
 * @throws Exception If failed.
 */
private void checkDestroyIndexTrees(boolean persistent, long expRes) throws Exception {
    IgniteEx n = startGrid(0, cfg -> {
        cfg.getDataStorageConfiguration().getDefaultDataRegionConfiguration().setPersistenceEnabled(persistent);
    });
    n.cluster().state(ACTIVE);
    IgniteCache<Integer, Person> cache = n.cache(DEFAULT_CACHE_NAME);
    populate(cache, 100);
    String idxName = "IDX0";
    createIdx(cache, idxName);
    GridCacheContext<Integer, Person> cctx = cacheContext(cache);
    Index idx = index(n, cache, idxName);
    SortedIndexDefinition idxDef = indexDefinition(idx);
    String treeName = idxDef.treeName();
    int segments = idxDef.segments();
    Map<Integer, RootPage> rootPages = new HashMap<>();
    if (persistent)
        rootPages.putAll(findIndexRootPages(cctx.group(), cctx.name(), treeName, segments));
    else
        rootPages.putAll(toRootPages(segments(idx)));
    assertFalse(rootPages.isEmpty());
    // Emulating worker cancellation, let's make sure it doesn't cause problems.
    Thread.currentThread().interrupt();
    long pageCnt = 0;
    for (Map.Entry<Integer, RootPage> e : rootPages.entrySet()) pageCnt += destroyIndexTrees(cctx.group(), e.getValue(), cctx.name(), treeName, e.getKey());
    assertTrue(pageCnt >= expRes);
    assertTrue(findIndexRootPages(cctx.group(), cctx.name(), treeName, segments).isEmpty());
}
Also used : HashMap(java.util.HashMap) SortedIndexDefinition(org.apache.ignite.internal.cache.query.index.sorted.SortedIndexDefinition) Index(org.apache.ignite.internal.cache.query.index.Index) IgniteEx(org.apache.ignite.internal.IgniteEx) RootPage(org.apache.ignite.internal.processors.cache.persistence.RootPage) Person(org.apache.ignite.client.Person) HashMap(java.util.HashMap) Map(java.util.Map)

Example 17 with Person

use of org.apache.ignite.client.Person in project ignite by apache.

the class DropIndexTest method testDonotAddTaskOnDeactivateForInMemory.

/**
 * Checks that {@link DurableBackgroundCleanupIndexTreeTaskV2} will not be
 * added when the cluster is deactivated for in-memory caches.
 *
 * @throws Exception If failed.
 */
@Test
public void testDonotAddTaskOnDeactivateForInMemory() throws Exception {
    IgniteEx n = startGrid(0, cfg -> {
        cfg.getDataStorageConfiguration().getDefaultDataRegionConfiguration().setPersistenceEnabled(false);
    });
    n.cluster().state(ACTIVE);
    IgniteCache<Integer, Person> cache = n.cache(DEFAULT_CACHE_NAME);
    populate(cache, 100);
    String idxName = "IDX0";
    createIdx(cache, idxName);
    n.cluster().state(INACTIVE);
    assertTrue(tasks(n).isEmpty());
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) Person(org.apache.ignite.client.Person) Test(org.junit.Test)

Example 18 with Person

use of org.apache.ignite.client.Person in project ignite by apache.

the class DropIndexTest method checkExecuteTaskAfterRestart.

/**
 * Check that after restart / reactivation of the node,
 * the {@link DurableBackgroundCleanupIndexTreeTaskV2} will be completed successfully.
 *
 * @param persistent Persistent default data region.
 * @param expRes Expected result should not be less than which, or {@code null} if there should be no result.
 * @param restartFun Node restart/reactivation function.
 * @throws Exception If failed.
 */
private void checkExecuteTaskAfterRestart(boolean persistent, @Nullable Long expRes, ThrowableFunction<IgniteEx, IgniteEx, Exception> restartFun) throws Exception {
    IgniteEx n = startGrid(0, cfg -> {
        cfg.getDataStorageConfiguration().getDefaultDataRegionConfiguration().setPersistenceEnabled(persistent);
    });
    n.cluster().state(ACTIVE);
    IgniteCache<Integer, Person> cache = n.cache(DEFAULT_CACHE_NAME);
    populate(cache, 100);
    String idxName = "IDX0";
    createIdx(cache, idxName);
    GridFutureAdapter<Void> startFut = new GridFutureAdapter<>();
    GridFutureAdapter<Void> endFut = new GridFutureAdapter<>();
    idxTreeFactory = taskIndexTreeFactoryEx(startFut, endFut);
    endFut.onDone(new IgniteCheckedException("Stop drop idx"));
    // Removing the index will succeed, but the trees not.
    dropIdx(cache, idxName);
    String taskNamePrefix = taskNamePrefix(cacheContext(cache).name(), idxName);
    assertFalse(taskState(n, taskNamePrefix).outFuture().isDone());
    n = restartFun.apply(n);
    idxTreeFactory = originalTaskIdxTreeFactory;
    GridFutureAdapter<?> taskFut = taskState(n, taskNamePrefix).outFuture();
    assertFalse(taskFut.isDone());
    n.cluster().state(ACTIVE);
    if (expRes == null)
        assertNull(taskFut.get(getTestTimeout()));
    else
        assertTrue((Long) taskFut.get(getTestTimeout()) >= expRes);
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteEx(org.apache.ignite.internal.IgniteEx) GridFutureAdapter(org.apache.ignite.internal.util.future.GridFutureAdapter) Person(org.apache.ignite.client.Person)

Example 19 with Person

use of org.apache.ignite.client.Person in project ignite by apache.

the class DropIndexTest method checkExecuteTask.

/**
 * Check that the {@link DurableBackgroundCleanupIndexTreeTaskV2} will be completed successfully.
 *
 * @param persistent Persistent default data region.
 * @param expRes Expected result should not be less than which.
 * @throws Exception If failed.
 */
private void checkExecuteTask(boolean persistent, long expRes) throws Exception {
    IgniteEx n = startGrid(0, cfg -> {
        cfg.getDataStorageConfiguration().getDefaultDataRegionConfiguration().setPersistenceEnabled(persistent);
    });
    n.cluster().state(ACTIVE);
    IgniteCache<Integer, Person> cache = n.cache(DEFAULT_CACHE_NAME);
    populate(cache, 100);
    String idxName = "IDX0";
    createIdx(cache, idxName);
    GridFutureAdapter<Void> startFut = new GridFutureAdapter<>();
    GridFutureAdapter<Void> endFut = new GridFutureAdapter<>();
    idxTreeFactory = taskIndexTreeFactoryEx(startFut, endFut);
    IgniteInternalFuture<List<List<?>>> dropIdxFut = runAsync(() -> dropIdx(cache, idxName));
    startFut.get(getTestTimeout());
    GridFutureAdapter<?> taskFut = taskState(n, taskNamePrefix(DEFAULT_CACHE_NAME, idxName)).outFuture();
    assertFalse(taskFut.isDone());
    endFut.onDone();
    assertTrue((Long) taskFut.get(getTestTimeout()) >= expRes);
    dropIdxFut.get(getTestTimeout());
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) GridFutureAdapter(org.apache.ignite.internal.util.future.GridFutureAdapter) List(java.util.List) Person(org.apache.ignite.client.Person)

Example 20 with Person

use of org.apache.ignite.client.Person in project ignite by apache.

the class DropIndexTest method testTaskNotExecuteIfAbsentCacheGroupOrRootPages.

/**
 * Check that the {@link DurableBackgroundCleanupIndexTreeTaskV2} will not
 * be executed if the cache group and root pages are not found.
 *
 * @throws Exception If failed.
 */
@Test
public void testTaskNotExecuteIfAbsentCacheGroupOrRootPages() throws Exception {
    IgniteEx n = startGrid(0);
    String fake = UUID.randomUUID().toString();
    GridCacheContext<Integer, Person> cctx = cacheContext(n.cache(DEFAULT_CACHE_NAME));
    List<DurableBackgroundCleanupIndexTreeTaskV2> tasks = F.asList(new DurableBackgroundCleanupIndexTreeTaskV2(fake, fake, fake, fake, fake, 10, null), new DurableBackgroundCleanupIndexTreeTaskV2(cctx.group().name(), cctx.name(), fake, fake, fake, 10, null));
    for (DurableBackgroundCleanupIndexTreeTaskV2 task : tasks) {
        DurableBackgroundTaskResult<Long> res = task.executeAsync(n.context()).get(0);
        assertTrue(res.completed());
        assertNull(res.error());
        assertNull(res.result());
    }
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) Person(org.apache.ignite.client.Person) DurableBackgroundCleanupIndexTreeTaskV2(org.apache.ignite.internal.cache.query.index.sorted.DurableBackgroundCleanupIndexTreeTaskV2) Test(org.junit.Test)

Aggregations

Person (org.apache.ignite.client.Person)21 IgniteEx (org.apache.ignite.internal.IgniteEx)12 Test (org.junit.Test)12 SortedIndexDefinition (org.apache.ignite.internal.cache.query.index.sorted.SortedIndexDefinition)7 RootPage (org.apache.ignite.internal.processors.cache.persistence.RootPage)5 HashMap (java.util.HashMap)3 IgniteClient (org.apache.ignite.client.IgniteClient)3 DurableBackgroundCleanupIndexTreeTaskV2 (org.apache.ignite.internal.cache.query.index.sorted.DurableBackgroundCleanupIndexTreeTaskV2)3 GridFutureAdapter (org.apache.ignite.internal.util.future.GridFutureAdapter)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Map (java.util.Map)2 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)2 Index (org.apache.ignite.internal.cache.query.index.Index)2 FullPageId (org.apache.ignite.internal.pagemem.FullPageId)2 IndexRenameRootPageRecord (org.apache.ignite.internal.pagemem.wal.record.IndexRenameRootPageRecord)2 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1