use of org.apache.ignite.internal.util.GridCountDownCallback in project ignite by apache.
the class GridCacheDatabaseSharedManager method rebuildIndexes.
/**
* Rebuilding indexes for caches.
*
* @param contexts Collection of cache contexts for which indexes should be rebuilt.
* @param rebuildCond Condition that should be met for indexes to be rebuilt for specific cache.
* @param force Force rebuild indexes.
* @return Cache contexts that did not pass by {@code rebuildCond}.
*/
private Collection<GridCacheContext> rebuildIndexes(Collection<GridCacheContext> contexts, Predicate<GridCacheContext> rebuildCond, boolean force) {
GridQueryProcessor qryProc = cctx.kernalContext().query();
if (!qryProc.moduleEnabled())
return emptyList();
GridCountDownCallback rebuildIndexesCompleteCntr = new GridCountDownCallback(contexts.size(), () -> {
if (log.isInfoEnabled())
log.info("Indexes rebuilding completed for all caches.");
}, // need at least 1 index rebuilded to print message about rebuilding completion
1);
Collection<GridCacheContext> rejected = null;
for (GridCacheContext cacheCtx : contexts) {
if (rebuildCond.test(cacheCtx)) {
IgniteInternalFuture<?> rebuildFut = qryProc.rebuildIndexesFromHash(cacheCtx, force || !qryProc.rebuildIndexesCompleted(cacheCtx));
if (rebuildFut != null)
rebuildFut.listen(fut -> rebuildIndexesCompleteCntr.countDown(true));
else
rebuildIndexesCompleteCntr.countDown(false);
} else {
if (rejected == null)
rejected = new ArrayList<>();
rejected.add(cacheCtx);
}
}
return rejected == null ? emptyList() : rejected;
}
Aggregations