From 0dad05d5c06a3271411fffc295e39422824d8c64 Mon Sep 17 00:00:00 2001 From: Dmitry Spikhalskiy Date: Wed, 5 Oct 2016 00:08:15 +0300 Subject: [PATCH] Fix ignoring opQueueMaxBlockTime in KetamaConnectionFactory --- .../spy/memcached/KetamaConnectionFactory.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/spy/memcached/KetamaConnectionFactory.java b/src/main/java/net/spy/memcached/KetamaConnectionFactory.java index 0308eb674..8ed945de4 100644 --- a/src/main/java/net/spy/memcached/KetamaConnectionFactory.java +++ b/src/main/java/net/spy/memcached/KetamaConnectionFactory.java @@ -44,7 +44,8 @@ public class KetamaConnectionFactory extends DefaultConnectionFactory { private final KetamaNodeKeyFormatter.Format ketamaNodeKeyFormat; - private Map weights; + private final Map weights; + private final long opQueueMaxBlockTime; /** * Create a KetamaConnectionFactory with the given maximum operation @@ -53,7 +54,7 @@ public class KetamaConnectionFactory extends DefaultConnectionFactory { * @param opQueueMaxBlockTime the maximum time to block waiting for op * queue operations to complete, in milliseconds */ - public KetamaConnectionFactory(int qLen, int bufSize, + public KetamaConnectionFactory(int qLen, int bufSize, long opQueueMaxBlockTime) { this(qLen, bufSize, opQueueMaxBlockTime, DefaultHashAlgorithm.KETAMA_HASH, @@ -77,6 +78,7 @@ public KetamaConnectionFactory( super(qLen, bufSize, hash); this.ketamaNodeKeyFormat = nodeKeyFormat; this.weights = weights; + this.opQueueMaxBlockTime = opQueueMaxBlockTime; } /** @@ -96,9 +98,14 @@ public KetamaConnectionFactory() { public NodeLocator createLocator(List nodes) { return new KetamaNodeLocator(nodes, getHashAlg(), getKetamaNodeKeyFormat(), getWeights()); - } + } - /** + @Override + public long getOpQueueMaxBlockTime() { + return opQueueMaxBlockTime; + } + + /** * @return the ketamaNodeKeyFormat */ public KetamaNodeKeyFormatter.Format getKetamaNodeKeyFormat() {