use of com.datastax.fallout.runner.RunnableExecutorFactory in project fallout by datastax.
the class FalloutServiceBase method createThreadedTestRunExecutorFactoryWithFinishedCallbacks.
/**
* Create the {@link RunnableExecutorFactory} that will actually create the {@link ActiveTestRun}s via the specified
* {@link ActiveTestRunFactory} and run them; used in {@link ServerMode#STANDALONE} and {@link ServerMode#RUNNER}.
* Finished callbacks are processed by this executor, because if we try to process them in {@link ServerMode#QUEUE}
* they could be lost due to missed updates while {@link ServerMode#QUEUE} is offline during a redeploy
*/
private RunnableExecutorFactory createThreadedTestRunExecutorFactoryWithFinishedCallbacks(FC conf, LifecycleManager m, UserMessenger mailer, TestDAO testDAO, TestRunDAO testRunDAO, ActiveTestRunFactory activeTestRunFactory) {
JobLoggersFactory fileLoggersFactory = new JobLoggersFactory(Paths.get(conf.getArtifactPath()), conf.logTestRunsToConsole());
final var threadedTestRunExecutorFactory = new ThreadedRunnableExecutorFactory(fileLoggersFactory, testRunDAO::update, activeTestRunFactory, conf);
final var userNotifier = new FinishedTestRunUserNotifier(conf.getExternalUrl(), mailer, SlackUserMessenger.create(conf.getSlackToken(), m.manage(FalloutClientBuilder.forComponent(SlackUserMessenger.class).build(), Client::close)));
return new RunnableExecutorFactory() {
@Override
public RunnableExecutor create(TestRun testRun, UserCredentials userCredentials) {
final var executor = threadedTestRunExecutorFactory.create(testRun, userCredentials);
executor.getTestRunStatus().addFinishedCallback(() -> {
testDAO.increaseSizeOnDiskBytesByTestRunSize(testRun);
userNotifier.notify(testRun);
});
return executor;
}
@Override
public void close() {
threadedTestRunExecutorFactory.close();
}
};
}
Aggregations