From 611225aa9eb822c23d410e59dec69cf33fa39679 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20M=C3=A9sz=C3=A1ros?= Date: Fri, 20 Jan 2023 16:26:56 +0100 Subject: [PATCH 1/5] chore: fabric8 client v6.3.1 (#1669) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b3fc536ac4..79bca47e26 100644 --- a/pom.xml +++ b/pom.xml @@ -43,7 +43,7 @@ https://sonarcloud.io 5.9.1 - 6.4.1 + 6.3.1 1.7.36 2.19.0 5.2.0 From 69b8737380ec59624da5c5b33df5de5803a898a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20M=C3=A9sz=C3=A1ros?= Date: Wed, 22 Feb 2023 18:34:39 +0100 Subject: [PATCH 2/5] chore: update to fabric8 client 6.4.1 (#1724) Co-authored-by: Chris Laprun --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 79bca47e26..b3fc536ac4 100644 --- a/pom.xml +++ b/pom.xml @@ -43,7 +43,7 @@ https://sonarcloud.io 5.9.1 - 6.3.1 + 6.4.1 1.7.36 2.19.0 5.2.0 From 16cff3aee106aea8f95024d9c9e528efa1681e6b Mon Sep 17 00:00:00 2001 From: csviri Date: Thu, 9 Mar 2023 15:45:05 +0100 Subject: [PATCH 3/5] feat: using dynamic ThreadPoolExecutor for reconcile and workflow executor services --- .../api/config/ConfigurationService.java | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ConfigurationService.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ConfigurationService.java index 53f2ae4176..07370b060d 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ConfigurationService.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ConfigurationService.java @@ -3,8 +3,7 @@ import java.time.Duration; import java.util.Optional; import java.util.Set; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; +import java.util.concurrent.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -75,7 +74,8 @@ default boolean checkCRDAndValidateLocalModel() { return false; } - int DEFAULT_RECONCILIATION_THREADS_NUMBER = 10; + int DEFAULT_RECONCILIATION_THREADS_NUMBER = 200; + int MIN_DEFAULT_RECONCILIATION_THREADS_NUMBER = 10; /** * Retrieves the maximum number of threads the operator can spin out to dispatch reconciliation @@ -87,12 +87,26 @@ default int concurrentReconciliationThreads() { return DEFAULT_RECONCILIATION_THREADS_NUMBER; } + default int minConcurrentReconciliationThreads() { + return MIN_DEFAULT_RECONCILIATION_THREADS_NUMBER; + } + int DEFAULT_WORKFLOW_EXECUTOR_THREAD_NUMBER = DEFAULT_RECONCILIATION_THREADS_NUMBER; + int MIN_DEFAULT_WORKFLOW_EXECUTOR_THREAD_NUMBER = MIN_DEFAULT_RECONCILIATION_THREADS_NUMBER; + /** + * Retrieves the maximum number of threads the operator can spin out to be used in the workflows. + * + * @return the maximum number of concurrent workflow threads + */ default int concurrentWorkflowExecutorThreads() { return DEFAULT_WORKFLOW_EXECUTOR_THREAD_NUMBER; } + default int minConcurrentWorkflowExecutorThreads() { + return MIN_DEFAULT_WORKFLOW_EXECUTOR_THREAD_NUMBER; + } + /** * Used to clone custom resources. It is strongly suggested that implementors override this method * since the default implementation creates a new {@link Cloner} instance each time this method is @@ -136,11 +150,15 @@ default Metrics getMetrics() { } default ExecutorService getExecutorService() { - return Executors.newFixedThreadPool(concurrentReconciliationThreads()); + return new ThreadPoolExecutor(minConcurrentReconciliationThreads(), + concurrentReconciliationThreads(), + 1, TimeUnit.MINUTES, new LinkedBlockingDeque<>()); } default ExecutorService getWorkflowExecutorService() { - return Executors.newFixedThreadPool(concurrentWorkflowExecutorThreads()); + return new ThreadPoolExecutor(minConcurrentWorkflowExecutorThreads(), + concurrentWorkflowExecutorThreads(), + 1, TimeUnit.MINUTES, new LinkedBlockingDeque<>()); } default boolean closeClientOnStop() { From 334f7570e30f0114074b2d841362b02be935cad2 Mon Sep 17 00:00:00 2001 From: csviri Date: Thu, 9 Mar 2023 16:20:11 +0100 Subject: [PATCH 4/5] override --- .../config/ConfigurationServiceOverrider.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) 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 22a4b6e6bd..3cc8dd6078 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 @@ -19,7 +19,9 @@ public class ConfigurationServiceOverrider { private Config clientConfig; private Boolean checkCR; private Integer concurrentReconciliationThreads; + private Integer minConcurrentReconciliationThreads; private Integer concurrentWorkflowExecutorThreads; + private Integer minConcurrentWorkflowExecutorThreads; private Cloner cloner; private Integer timeoutSeconds; private Boolean closeClientOnStop; @@ -56,6 +58,16 @@ public ConfigurationServiceOverrider withConcurrentWorkflowExecutorThreads(int t return this; } + public ConfigurationServiceOverrider withMinConcurrentReconciliationThreads(int threadNumber) { + this.minConcurrentReconciliationThreads = threadNumber; + return this; + } + + public ConfigurationServiceOverrider withMinConcurrentWorkflowExecutorThreads(int threadNumber) { + this.minConcurrentWorkflowExecutorThreads = threadNumber; + return this; + } + public ConfigurationServiceOverrider withResourceCloner(Cloner cloner) { this.cloner = cloner; return this; @@ -149,6 +161,18 @@ public int concurrentWorkflowExecutorThreads() { : original.concurrentWorkflowExecutorThreads(); } + @Override + public int minConcurrentReconciliationThreads() { + return minConcurrentReconciliationThreads != null ? minConcurrentReconciliationThreads + : original.minConcurrentReconciliationThreads(); + } + + @Override + public int minConcurrentWorkflowExecutorThreads() { + return minConcurrentWorkflowExecutorThreads != null ? minConcurrentWorkflowExecutorThreads + : original.minConcurrentWorkflowExecutorThreads(); + } + @Override public int getTerminationTimeoutSeconds() { return timeoutSeconds != null ? timeoutSeconds : original.getTerminationTimeoutSeconds(); From 97ff33c66e6be1f40a338da57e27eaadcd24a1a5 Mon Sep 17 00:00:00 2001 From: csviri Date: Fri, 10 Mar 2023 14:53:19 +0100 Subject: [PATCH 5/5] addded javadocs --- .../operator/api/config/ConfigurationService.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ConfigurationService.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ConfigurationService.java index 07370b060d..d55984fae1 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ConfigurationService.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ConfigurationService.java @@ -78,8 +78,8 @@ default boolean checkCRDAndValidateLocalModel() { int MIN_DEFAULT_RECONCILIATION_THREADS_NUMBER = 10; /** - * Retrieves the maximum number of threads the operator can spin out to dispatch reconciliation - * requests to reconcilers + * The maximum number of threads the operator can spin out to dispatch reconciliation requests to + * reconcilers * * @return the maximum number of concurrent reconciliation threads */ @@ -87,6 +87,11 @@ default int concurrentReconciliationThreads() { return DEFAULT_RECONCILIATION_THREADS_NUMBER; } + /** + * The minimum number of threads the operator starts in the thread pool for reconciliations. + * + * @return the minimum number of concurrent reconciliation threads + */ default int minConcurrentReconciliationThreads() { return MIN_DEFAULT_RECONCILIATION_THREADS_NUMBER; } @@ -103,6 +108,11 @@ default int concurrentWorkflowExecutorThreads() { return DEFAULT_WORKFLOW_EXECUTOR_THREAD_NUMBER; } + /** + * The minimum number of threads the operator starts in the thread pool for workflows. + * + * @return the minimum number of concurrent workflow threads + */ default int minConcurrentWorkflowExecutorThreads() { return MIN_DEFAULT_WORKFLOW_EXECUTOR_THREAD_NUMBER; }