allow to set which queue implementation to use

expert setting, but still would be great to be able to control it
This commit is contained in:
Shay Banon 2013-02-21 20:07:40 +01:00
parent 5cce40fa5e
commit 4753ffdf1e
1 changed files with 7 additions and 2 deletions

View File

@ -26,6 +26,7 @@ import java.util.Queue;
import java.util.Set; import java.util.Set;
import java.util.concurrent.BlockingQueue; import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentMap;
/** /**
@ -33,7 +34,8 @@ import java.util.concurrent.ConcurrentMap;
*/ */
public abstract class ConcurrentCollections { public abstract class ConcurrentCollections {
private final static boolean useNonBlockingMap = Boolean.parseBoolean(System.getProperty("elasticsearch.useNonBlockingMap", "false")); private final static boolean useNonBlockingMap = Boolean.parseBoolean(System.getProperty("es.useNonBlockingMap", "false"));
private final static boolean useLinkedTransferQueue = Boolean.parseBoolean(System.getProperty("es.useLinkedTransferQueue", "false"));
public static <K, V> ConcurrentMap<K, V> newConcurrentMap() { public static <K, V> ConcurrentMap<K, V> newConcurrentMap() {
// if (useNonBlockingMap) { // if (useNonBlockingMap) {
@ -57,7 +59,10 @@ public abstract class ConcurrentCollections {
} }
public static <T> Queue<T> newQueue() { public static <T> Queue<T> newQueue() {
return new LinkedTransferQueue<T>(); if (useLinkedTransferQueue) {
return new LinkedTransferQueue<T>();
}
return new ConcurrentLinkedQueue<T>();
} }
public static <T> BlockingQueue<T> newBlockingQueue() { public static <T> BlockingQueue<T> newBlockingQueue() {