Skip to content

Commit

Permalink
fix(vertx): Use a worker pool for mining (#820)
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinWitt authored Jul 10, 2023
1 parent 3b3f843 commit 1026247
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ private Project getKnownProject() {
void mine(@Observes StartupEvent event) {
try {
logger.atInfo().log("Starting Qodana periodic miner");
vertx.setTimer(TimeUnit.MINUTES.toMillis(5), v -> vertx.executeBlocking(it -> mineRandomRepo()));
vertx.exceptionHandler(it -> logger.atWarning().withCause(it).log("Exception in vertx"));
vertx.setTimer(TimeUnit.MINUTES.toMillis(3), v -> vertx.createSharedWorkerExecutor("MINING", 5, 30L)
.executeBlocking(it -> mineRandomRepo()));
} catch (Exception e) {
logger.atWarning().withCause(e).log("Failed to repo with Qodana");
}
Expand Down Expand Up @@ -124,7 +126,8 @@ private void mineRandomRepo() {
} finally {
logger.atInfo().log("Queue size: %s", queue.size());
logger.atInfo().log("Mining next repo in 1 minute");
vertx.setTimer(TimeUnit.MINUTES.toMillis(1), v -> vertx.executeBlocking(it -> mineRandomRepo()));
vertx.setTimer(TimeUnit.MINUTES.toMillis(1), v -> vertx.createSharedWorkerExecutor("MINING", 5, 30L)
.executeBlocking(it -> mineRandomRepo()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ private Project getKnownProject() {
void mine(@Observes StartupEvent event) {
try {
logger.atInfo().log("Start mining with spoon");
vertx.setTimer(TimeUnit.MINUTES.toMillis(5), v -> vertx.executeBlocking(it -> mineRandomRepo()));
vertx.exceptionHandler(it -> logger.atWarning().withCause(it).log("Exception in vertx"));
vertx.setTimer(TimeUnit.MINUTES.toMillis(3), v -> vertx.createSharedWorkerExecutor("MINING", 5, 30L)
.executeBlocking(it -> mineRandomRepo()));
} catch (Exception e) {
logger.atWarning().withCause(e).log("Failed to repo with spoon");
}
Expand Down Expand Up @@ -116,7 +118,8 @@ private void mineRandomRepo() {
} finally {
logger.atInfo().log("Queue size: %s", queue.size());
logger.atInfo().log("Mining next repo in 1 minute");
vertx.setTimer(TimeUnit.MINUTES.toMillis(1), v -> vertx.executeBlocking(it -> mineRandomRepo()));
vertx.setTimer(TimeUnit.MINUTES.toMillis(1), v -> vertx.createSharedWorkerExecutor("MINING", 5, 30L)
.executeBlocking(it -> mineRandomRepo()));
}
}

Expand Down

0 comments on commit 1026247

Please sign in to comment.