From 4fe2f149825acb9bcffa3533d281aeb4d396f415 Mon Sep 17 00:00:00 2001 From: csviri Date: Mon, 19 Sep 2022 13:58:31 +0200 Subject: [PATCH] fix: config service override executor service concurrent reconcilation numbers --- .../config/ConfigurationServiceOverrider.java | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ConfigurationServiceOverrider.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ConfigurationServiceOverrider.java index 0ef1e6a6f4..26e1de7bb1 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ConfigurationServiceOverrider.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ConfigurationServiceOverrider.java @@ -3,6 +3,7 @@ import java.util.Optional; import java.util.Set; import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; import java.util.function.Consumer; import io.fabric8.kubernetes.client.Config; @@ -16,7 +17,8 @@ public class ConfigurationServiceOverrider { private Metrics metrics; private Config clientConfig; private Boolean checkCR; - private Integer threadNumber; + private Integer concurrentReconciliationThreads; + private Integer concurrentWorkflowExecutorThreads; private Cloner cloner; private Integer timeoutSeconds; private Boolean closeClientOnStop; @@ -40,7 +42,12 @@ public ConfigurationServiceOverrider checkingCRDAndValidateLocalModel(boolean ch } public ConfigurationServiceOverrider withConcurrentReconciliationThreads(int threadNumber) { - this.threadNumber = threadNumber; + this.concurrentReconciliationThreads = threadNumber; + return this; + } + + public ConfigurationServiceOverrider withConcurrentWorkflowExecutorThreads(int threadNumber) { + this.concurrentWorkflowExecutorThreads = threadNumber; return this; } @@ -105,7 +112,14 @@ public boolean checkCRDAndValidateLocalModel() { @Override public int concurrentReconciliationThreads() { - return threadNumber != null ? threadNumber : original.concurrentReconciliationThreads(); + return concurrentReconciliationThreads != null ? concurrentReconciliationThreads + : original.concurrentReconciliationThreads(); + } + + @Override + public int concurrentWorkflowExecutorThreads() { + return concurrentWorkflowExecutorThreads != null ? concurrentWorkflowExecutorThreads + : original.concurrentWorkflowExecutorThreads(); } @Override @@ -125,13 +139,14 @@ public boolean closeClientOnStop() { @Override public ExecutorService getExecutorService() { - return executorService != null ? executorService : original.getExecutorService(); + return executorService != null ? executorService + : Executors.newFixedThreadPool(concurrentReconciliationThreads()); } @Override public ExecutorService getWorkflowExecutorService() { return workflowExecutorService != null ? workflowExecutorService - : original.getWorkflowExecutorService(); + : Executors.newFixedThreadPool(concurrentWorkflowExecutorThreads()); } @Override