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());
}
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());
}
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);
}
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());
}
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());
}
}
Aggregations