use of org.apache.ignite.internal.util.future.GridCompoundIdentityFuture in project ignite by apache.
the class CacheMvccAbstractTest method runVacuumSync.
/**
* Runs vacuum on all nodes and waits for its completion.
*
* @throws IgniteCheckedException If failed.
*/
private void runVacuumSync() throws IgniteCheckedException {
GridCompoundIdentityFuture<VacuumMetrics> fut = new GridCompoundIdentityFuture<>();
// Run vacuum manually.
for (Ignite node : G.allGrids()) {
if (!node.configuration().isClientMode()) {
MvccProcessorImpl crd = mvccProcessor(node);
if (!crd.mvccEnabled() || GridTestUtils.getFieldValue(crd, "vacuumWorkers") == null)
continue;
assert GridTestUtils.getFieldValue(crd, "txLog") != null;
fut.add(crd.runVacuum());
}
}
fut.markInitialized();
// Wait vacuum finished.
fut.get(getTestTimeout());
}
use of org.apache.ignite.internal.util.future.GridCompoundIdentityFuture in project ignite by apache.
the class MvccProcessorImpl method continueRunVacuum.
/**
* @param res Result.
* @param snapshot Snapshot.
*/
private void continueRunVacuum(GridFutureAdapter<VacuumMetrics> res, MvccSnapshot snapshot) {
ackTxCommit(snapshot).listen(new IgniteInClosure<IgniteInternalFuture>() {
@Override
public void apply(IgniteInternalFuture fut) {
Throwable err;
if ((err = fut.error()) != null) {
U.error(log, "Vacuum error.", err);
res.onDone(err);
} else if (snapshot.cleanupVersion() <= MVCC_COUNTER_NA)
res.onDone(new VacuumMetrics());
else {
try {
if (log.isDebugEnabled())
log.debug("Started vacuum with cleanup version=" + snapshot.cleanupVersion() + '.');
synchronized (mux) {
if (cleanupQueue == null) {
res.onDone(vacuumCancelledException());
return;
}
GridCompoundIdentityFuture<VacuumMetrics> res0 = new GridCompoundIdentityFuture<VacuumMetrics>(new VacuumMetricsReducer()) {
/**
* {@inheritDoc}
*/
@Override
protected void logError(IgniteLogger log, String msg, Throwable e) {
// no-op
}
/**
* {@inheritDoc}
*/
@Override
protected void logDebug(IgniteLogger log, String msg) {
// no-op
}
};
for (CacheGroupContext grp : ctx.cache().cacheGroups()) {
if (grp.mvccEnabled()) {
grp.topology().readLock();
try {
for (GridDhtLocalPartition part : grp.topology().localPartitions()) {
VacuumTask task = new VacuumTask(snapshot, part);
cleanupQueue.offer(task);
res0.add(task);
}
} finally {
grp.topology().readUnlock();
}
}
}
res0.markInitialized();
res0.listen(future -> {
VacuumMetrics metrics = null;
Throwable ex = null;
try {
metrics = future.get();
txLog.removeUntil(snapshot.coordinatorVersion(), snapshot.cleanupVersion());
if (log.isDebugEnabled())
log.debug("Vacuum completed. " + metrics);
} catch (Throwable e) {
if (X.hasCause(e, NodeStoppingException.class)) {
if (log.isDebugEnabled())
log.debug("Cannot complete vacuum (node is stopping).");
metrics = new VacuumMetrics();
} else
ex = new GridClosureException(e);
}
res.onDone(metrics, ex);
});
}
} catch (Throwable e) {
completeWithException(res, e);
}
}
}
});
}
Aggregations