Skip to content
Merged
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
12 changes: 9 additions & 3 deletions src/main/java/com/uid2/operator/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public class Main {
private RotatingServiceLinkStore serviceLinkProvider;
private RotatingCloudEncryptionKeyApiProvider cloudEncryptionKeyProvider;
private final UidInstanceIdProvider uidInstanceIdProvider;
private final int requestedServiceInstances;

public Main(Vertx vertx, JsonObject config) throws Exception {
this.vertx = vertx;
Expand Down Expand Up @@ -243,6 +244,12 @@ public Main(Vertx vertx, JsonObject config) throws Exception {
}
}
metrics = new OperatorMetrics(getKeyManager(), saltProvider);

Integer svcInstances = config.getInteger(Const.Config.ServiceInstancesProp);
if (svcInstances == null) {
svcInstances = Runtime.getRuntime().availableProcessors();
}
requestedServiceInstances = svcInstances;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Can we dorequestedServiceInstances = config.getInteger(Const.Config.ServiceInstancesProp, Runtime.getRuntime().availableProcessors());

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't because if we have "service_instance": null, then this will still pick up the value as null :(
The default value is only used if the key doesn't exist

}

private KeyManager getKeyManager() {
Expand Down Expand Up @@ -346,8 +353,7 @@ private void run() throws Exception {
};

DeploymentOptions options = new DeploymentOptions();
int svcInstances = this.config.getInteger(Const.Config.ServiceInstancesProp);
options.setInstances(svcInstances);
options.setInstances(requestedServiceInstances);

Promise<Void> compositePromise = Promise.promise();
List<Future> fs = new ArrayList<>();
Expand Down Expand Up @@ -564,7 +570,7 @@ public DistributionStatisticConfig configure(Meter.Id id, DistributionStatisticC
}

private void createVertxInstancesMetric() {
Gauge.builder("uid2_vertx_service_instances", () -> config.getInteger("service_instances"))
Gauge.builder("uid2_vertx_service_instances", () -> requestedServiceInstances)
.description("gauge for number of vertx service instances requested")
.register(Metrics.globalRegistry);
}
Expand Down
Loading