Search in sources :

Example 1 with PollingMonitor

use of org.jboss.pnc.common.monitor.PollingMonitor in project pnc by project-ncl.

the class DefaultBuildCoordinator method monitorCancellation.

private void monitorCancellation(BuildTask buildTask) {
    int cancellationTimeout = 30;
    PollingMonitor monitor = new PollingMonitor();
    Runnable invokeCancelInternal = () -> {
        if (!getSubmittedBuildTasks().contains(buildTask)) {
            log.debug("Task {} cancellation already completed.", buildTask.getId());
            return;
        }
        log.warn("Cancellation did not complete in {} seconds.", cancellationTimeout);
        cancelInternal(buildTask);
    };
    ScheduledFuture<?> timer = monitor.timer(invokeCancelInternal, cancellationTimeout, TimeUnit.SECONDS);
// TODO optimization: cancel the timer when the task is canceled
// timer.cancel(false);
}
Also used : PollingMonitor(org.jboss.pnc.common.monitor.PollingMonitor)

Aggregations

PollingMonitor (org.jboss.pnc.common.monitor.PollingMonitor)1