diff --git a/github-bot/src/main/java/io/github/martinwitt/laughing_train/mining/MiningStartup.java b/github-bot/src/main/java/io/github/martinwitt/laughing_train/mining/MiningStartup.java index a91cf0e8d..8edbbb65c 100644 --- a/github-bot/src/main/java/io/github/martinwitt/laughing_train/mining/MiningStartup.java +++ b/github-bot/src/main/java/io/github/martinwitt/laughing_train/mining/MiningStartup.java @@ -1,8 +1,10 @@ package io.github.martinwitt.laughing_train.mining; import io.github.martinwitt.laughing_train.mining.requests.MineNextProject; +import io.quarkus.logging.Log; import io.quarkus.runtime.StartupEvent; import io.vertx.core.DeploymentOptions; +import io.vertx.core.Future; import io.vertx.core.Vertx; import jakarta.enterprise.context.ApplicationScoped; import jakarta.enterprise.event.Observes; @@ -29,14 +31,22 @@ public class MiningStartup { void startup(@Observes StartupEvent event) { DeploymentOptions options = new DeploymentOptions().setWorker(true); - vertx.deployVerticle(qodanaPeriodicMiner, options); - vertx.deployVerticle(spoonPeriodicMiner, options); - vertx.deployVerticle(persistence, options); - vertx.deployVerticle(projectSupplier, options); + Future.join( + vertx.deployVerticle(qodanaPeriodicMiner, options), + vertx.deployVerticle(spoonPeriodicMiner, options), + vertx.deployVerticle(persistence, options), + vertx.deployVerticle(projectSupplier, options)) + .onFailure(Throwable::printStackTrace) + .onComplete(v -> System.out.println("All verticles deployed")) + .onSuccess(v -> startPeriodicMining()); vertx.eventBus().addInboundInterceptor(v -> { System.out.println("Received message: " + v.toString()); v.next(); }); + } + + private void startPeriodicMining() { + Log.info("Starting periodic mining"); vertx.setPeriodic(TimeUnit.MINUTES.toMillis(3), TimeUnit.MINUTES.toMillis(25), v -> vertx.eventBus() .publish("miner", new MineNextProject(QodanaPeriodicMiner.ANALYZER_NAME))); vertx.setPeriodic(TimeUnit.MINUTES.toMillis(2), TimeUnit.MINUTES.toMillis(15), v -> vertx.eventBus() diff --git a/github-bot/src/main/java/io/github/martinwitt/laughing_train/mining/ProjectSupplier.java b/github-bot/src/main/java/io/github/martinwitt/laughing_train/mining/ProjectSupplier.java index 1c0801e63..814bc6718 100644 --- a/github-bot/src/main/java/io/github/martinwitt/laughing_train/mining/ProjectSupplier.java +++ b/github-bot/src/main/java/io/github/martinwitt/laughing_train/mining/ProjectSupplier.java @@ -19,12 +19,11 @@ public class ProjectSupplier extends AbstractVerticle { public static final String SERVICE_NAME = "projectSupplier"; - + private static final Random random = new Random(); final SearchProjectService searchProjectService; final ProjectRepository projectRepository; final ProjectService projectService; final Vertx vertx; - final Random random; @Produces Random random() { @@ -35,13 +34,11 @@ Random random() { SearchProjectService searchProjectService, ProjectRepository projectRepository, ProjectService projectService, - Vertx vertx, - Random random) { + Vertx vertx) { this.searchProjectService = searchProjectService; this.projectRepository = projectRepository; this.projectService = projectService; this.vertx = vertx; - this.random = random; } @Override