Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(vertx): configurable worker pool size #1468

Merged
merged 3 commits into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ podman run \
-e CRYOSTAT_ACTIVE_REPORTS_CACHE_EXPIRY_SECONDS="$CRYOSTAT_ACTIVE_REPORTS_CACHE_EXPIRY_SECONDS" \
-e CRYOSTAT_ACTIVE_REPORTS_CACHE_REFRESH_SECONDS="$CRYOSTAT_ACTIVE_REPORTS_CACHE_REFRESH_SECONDS" \
-e CRYOSTAT_PUSH_MAX_FILES="$CRYOSTAT_PUSH_MAX_FILES" \
-e CRYOSTAT_VERTX_POOL_SIZE="$CRYOSTAT_VERTX_POOL_SIZE" \
-e GRAFANA_DATASOURCE_URL="$GRAFANA_DATASOURCE_URL" \
-e GRAFANA_DASHBOARD_URL="$GRAFANA_DASHBOARD_URL" \
-e KEYSTORE_PATH="$KEYSTORE_PATH" \
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/io/cryostat/MainModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,15 @@ public static Function<String, UUID> provideUuidToString() {

@Provides
@Singleton
public static VerticleDeployer provideVerticleDeployer(Vertx vertx, Logger logger) {
return new VerticleDeployer(vertx, logger);
@Named(Variables.VERTX_POOL_SIZE)
public static int provideVertxPoolSize(Environment env) {
return Math.max(1, Integer.parseInt(env.getEnv(Variables.VERTX_POOL_SIZE, "20")));
}

@Provides
@Singleton
public static VerticleDeployer provideVerticleDeployer(
Vertx vertx, @Named(Variables.VERTX_POOL_SIZE) int poolSize, Logger logger) {
return new VerticleDeployer(vertx, poolSize, logger);
}
}
17 changes: 14 additions & 3 deletions src/main/java/io/cryostat/VerticleDeployer.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,31 @@
public class VerticleDeployer {

private final Vertx vertx;
private final int poolSize;
private final Logger logger;

@SuppressFBWarnings(
value = "EI_EXPOSE_REP2",
justification = "vertx is externally mutable and that's fine")
public VerticleDeployer(Vertx vertx, Logger logger) {
public VerticleDeployer(Vertx vertx, int poolSize, Logger logger) {
this.vertx = vertx;
this.poolSize = poolSize;
this.logger = logger;
}

public Future deploy(Verticle verticle, boolean worker) {
String name = verticle.getClass().getName();
logger.info("Deploying {} Verticle", name);
return vertx.deployVerticle(verticle, new DeploymentOptions().setWorker(worker))
DeploymentOptions deploymentOptions = new DeploymentOptions();
deploymentOptions.setWorker(worker);
if (deploymentOptions.isWorker()) {
deploymentOptions.setWorkerPoolName(name + "-worker");
deploymentOptions.setWorkerPoolSize(poolSize);
}
logger.info(
"Deploying {} Verticle with options: {}",
name,
deploymentOptions.toJson().encodePrettily());
return vertx.deployVerticle(verticle, deploymentOptions)
.onSuccess(id -> logger.info("Deployed {} Verticle [{}]", name, id))
andrewazores marked this conversation as resolved.
Show resolved Hide resolved
.onFailure(
t -> {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/io/cryostat/configuration/Variables.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ private Variables() {}
public static final String DISABLE_BUILTIN_DISCOVERY = "CRYOSTAT_DISABLE_BUILTIN_DISCOVERY";
public static final String DISCOVERY_PING_PERIOD_MS = "CRYOSTAT_DISCOVERY_PING_PERIOD";
public static final String K8S_NAMESPACES = "CRYOSTAT_K8S_NAMESPACES";
public static final String VERTX_POOL_SIZE = "CRYOSTAT_VERTX_POOL_SIZE";

// webserver configuration
public static final String WEBSERVER_HOST = "CRYOSTAT_WEB_HOST";
Expand Down