use of com.datastax.fallout.runner.AbortableRunnableExecutorFactory in project fallout by datastax.
the class FalloutServiceBase method createQueueTestRunExecutorFactory.
private AbortableRunnableExecutorFactory createQueueTestRunExecutorFactory(FC conf, LifecycleManager m, UserMessenger mailer, TestDAO testDAO, TestRunDAO testRunDAO, ActiveTestRunFactory activeTestRunFactory) {
final WebTarget delegateRunnerTarget = httpClient.target(conf.getDelegateURI().toString());
final AbortableRunnableExecutorFactory abortableTestRunExecutorFactory = new AbortableRunnableExecutorFactory(m.manage(new DelegatingRunnableExecutorFactory(delegateRunnerTarget, testRunDAO::get)));
final List<CompletableFuture<Void>> allExistingTestRunsKnown = new ArrayList<>();
conf.getExistingRunnerURIsExcludingDelegate().forEach(uri -> {
final var existingRunnerTestRunExecutorFactory = m.manage(new DelegatingExecutorFactory(httpClient.target(uri), testRunDAO::get, abortableTestRunExecutorFactory::addExecutorIfNotExists));
allExistingTestRunsKnown.add(existingRunnerTestRunExecutorFactory.waitUntilAllExistingTestRunsKnownAsync());
});
m.manage(new StaleTestRunAborter(testRunDAO, abortableTestRunExecutorFactory::activeTestRuns) {
@Override
public void start() throws Exception {
logger.withScopedInfo("Waiting for all existing test runs to register").run(() -> CompletableFuture.allOf(allExistingTestRunsKnown.toArray(new CompletableFuture[] {})).join());
super.start();
}
});
return abortableTestRunExecutorFactory;
}
Aggregations