You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2019/10/03 08:06:38 UTC
[camel] 01/02: [CAMEL-14000] Use LRUCache instead of Map when
caching Services (Producers/Consumers) (#3218)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-2.24.x
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 6a6298e33ff2772c7e96d903fc2dbcaa648fb25a
Author: John Poth <po...@gmail.com>
AuthorDate: Thu Oct 3 04:40:58 2019 +0200
[CAMEL-14000] Use LRUCache instead of Map when caching Services (Producers/Consumers) (#3218)
---
.../src/main/java/org/apache/camel/impl/DefaultServicePool.java | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultServicePool.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultServicePool.java
index fdb928e..9d85eea 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultServicePool.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultServicePool.java
@@ -18,13 +18,13 @@ package org.apache.camel.impl;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Map;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
import org.apache.camel.spi.ServicePool;
import org.apache.camel.support.ServiceSupport;
+import org.apache.camel.util.LRUCacheFactory;
import org.apache.camel.util.ServiceHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -37,14 +37,16 @@ import org.slf4j.LoggerFactory;
@Deprecated
public abstract class DefaultServicePool<Key, Service> extends ServiceSupport implements ServicePool<Key, Service> {
protected final Logger log = LoggerFactory.getLogger(getClass());
- protected final ConcurrentMap<Key, BlockingQueue<Service>> pool = new ConcurrentHashMap<>();
+ protected final Map<Key, BlockingQueue<Service>> pool;
protected int capacity = 100;
protected DefaultServicePool() {
+ this.pool = LRUCacheFactory.newLRUCache(capacity);
}
public DefaultServicePool(int capacity) {
this.capacity = capacity;
+ this.pool = LRUCacheFactory.newLRUCache(capacity);
}
public int getCapacity() {