use of org.apache.ignite.internal.util.lang.GridCloseableIterator in project ignite by apache.
the class CacheMvccAbstractTest method checkOldVersions.
/**
* Checks if outdated versions were cleaned after the vacuum process.
*
* @param failIfNotCleaned Fail test if not cleaned.
* @return {@code False} if not cleaned.
* @throws IgniteCheckedException If failed.
*/
private boolean checkOldVersions(boolean failIfNotCleaned) throws IgniteCheckedException {
for (Ignite node : G.allGrids()) {
for (IgniteCacheProxy cache : ((IgniteKernal) node).caches()) {
GridCacheContext cctx = cache.context();
if (!cctx.userCache() || !cctx.group().mvccEnabled() || F.isEmpty(cctx.group().caches()) || cctx.shared().closed(cctx))
continue;
try (GridCloseableIterator it = (GridCloseableIterator) cache.withKeepBinary().iterator()) {
while (it.hasNext()) {
IgniteBiTuple entry = (IgniteBiTuple) it.next();
KeyCacheObject key = cctx.toCacheKeyObject(entry.getKey());
List<IgniteBiTuple<Object, MvccVersion>> vers = cctx.offheap().mvccAllVersions(cctx, key).stream().filter(t -> t.get1() != null).collect(Collectors.toList());
if (vers.size() > 1) {
if (failIfNotCleaned)
fail("[key=" + key.value(null, false) + "; vers=" + vers + ']');
else
return false;
}
}
}
}
}
return true;
}
Aggregations