@@ -94,6 +94,7 @@ public class Main {
9494 private RotatingServiceLinkStore serviceLinkProvider ;
9595 private RotatingCloudEncryptionKeyApiProvider cloudEncryptionKeyProvider ;
9696 private final UidInstanceIdProvider uidInstanceIdProvider ;
97+ private final int requestedServiceInstances ;
9798
9899 public Main (Vertx vertx , JsonObject config ) throws Exception {
99100 this .vertx = vertx ;
@@ -243,6 +244,12 @@ public Main(Vertx vertx, JsonObject config) throws Exception {
243244 }
244245 }
245246 metrics = new OperatorMetrics (getKeyManager (), saltProvider );
247+
248+ Integer svcInstances = config .getInteger (Const .Config .ServiceInstancesProp );
249+ if (svcInstances == null ) {
250+ svcInstances = Runtime .getRuntime ().availableProcessors ();
251+ }
252+ requestedServiceInstances = svcInstances ;
246253 }
247254
248255 private KeyManager getKeyManager () {
@@ -346,8 +353,7 @@ private void run() throws Exception {
346353 };
347354
348355 DeploymentOptions options = new DeploymentOptions ();
349- int svcInstances = this .config .getInteger (Const .Config .ServiceInstancesProp );
350- options .setInstances (svcInstances );
356+ options .setInstances (requestedServiceInstances );
351357
352358 Promise <Void > compositePromise = Promise .promise ();
353359 List <Future > fs = new ArrayList <>();
@@ -564,7 +570,7 @@ public DistributionStatisticConfig configure(Meter.Id id, DistributionStatisticC
564570 }
565571
566572 private void createVertxInstancesMetric () {
567- Gauge .builder ("uid2_vertx_service_instances" , () -> config . getInteger ( "service_instances" ) )
573+ Gauge .builder ("uid2_vertx_service_instances" , () -> requestedServiceInstances )
568574 .description ("gauge for number of vertx service instances requested" )
569575 .register (Metrics .globalRegistry );
570576 }
0 commit comments