Search in sources :

Example 1 with AbortableRunnableExecutorFactory

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;
}
Also used : DelegatingRunnableExecutorFactory(com.datastax.fallout.runner.DelegatingRunnableExecutorFactory) AbortableRunnableExecutorFactory(com.datastax.fallout.runner.AbortableRunnableExecutorFactory) CompletableFuture(java.util.concurrent.CompletableFuture) DelegatingExecutorFactory(com.datastax.fallout.runner.DelegatingExecutorFactory) ArrayList(java.util.ArrayList) WebTarget(javax.ws.rs.client.WebTarget)

Aggregations

AbortableRunnableExecutorFactory (com.datastax.fallout.runner.AbortableRunnableExecutorFactory)1 DelegatingExecutorFactory (com.datastax.fallout.runner.DelegatingExecutorFactory)1 DelegatingRunnableExecutorFactory (com.datastax.fallout.runner.DelegatingRunnableExecutorFactory)1 ArrayList (java.util.ArrayList)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 WebTarget (javax.ws.rs.client.WebTarget)1