mirror of https://github.com/apache/druid.git
allow disabling of memcached op-queue limit, default to disabled
This commit is contained in:
parent
04f3d0a13a
commit
b5d9876b77
|
@ -32,6 +32,8 @@ import net.spy.memcached.FailureMode;
|
||||||
import net.spy.memcached.MemcachedClient;
|
import net.spy.memcached.MemcachedClient;
|
||||||
import net.spy.memcached.MemcachedClientIF;
|
import net.spy.memcached.MemcachedClientIF;
|
||||||
import net.spy.memcached.internal.BulkFuture;
|
import net.spy.memcached.internal.BulkFuture;
|
||||||
|
import net.spy.memcached.ops.LinkedOperationQueueFactory;
|
||||||
|
import net.spy.memcached.ops.OperationQueueFactory;
|
||||||
import org.apache.commons.codec.digest.DigestUtils;
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
@ -56,7 +58,15 @@ public class MemcachedCache implements Cache
|
||||||
|
|
||||||
// always use compression
|
// always use compression
|
||||||
transcoder.setCompressionThreshold(0);
|
transcoder.setCompressionThreshold(0);
|
||||||
MemcachedOperationQueueFactory queueFactory = new MemcachedOperationQueueFactory(config.getMaxOperationQueueSize());
|
|
||||||
|
OperationQueueFactory opQueueFactory;
|
||||||
|
long maxQueueBytes = config.getMaxOperationQueueSize();
|
||||||
|
if(maxQueueBytes > 0) {
|
||||||
|
opQueueFactory = new MemcachedOperationQueueFactory(maxQueueBytes);
|
||||||
|
} else {
|
||||||
|
opQueueFactory = new LinkedOperationQueueFactory();
|
||||||
|
}
|
||||||
|
|
||||||
return new MemcachedCache(
|
return new MemcachedCache(
|
||||||
new MemcachedClient(
|
new MemcachedClient(
|
||||||
new ConnectionFactoryBuilder().setProtocol(ConnectionFactoryBuilder.Protocol.BINARY)
|
new ConnectionFactoryBuilder().setProtocol(ConnectionFactoryBuilder.Protocol.BINARY)
|
||||||
|
@ -68,7 +78,7 @@ public class MemcachedCache implements Cache
|
||||||
.setShouldOptimize(true)
|
.setShouldOptimize(true)
|
||||||
.setOpQueueMaxBlockTime(config.getTimeout())
|
.setOpQueueMaxBlockTime(config.getTimeout())
|
||||||
.setOpTimeout(config.getTimeout())
|
.setOpTimeout(config.getTimeout())
|
||||||
.setOpQueueFactory(queueFactory)
|
.setOpQueueFactory(opQueueFactory)
|
||||||
.build(),
|
.build(),
|
||||||
AddrUtil.getAddresses(config.getHosts())
|
AddrUtil.getAddresses(config.getHosts())
|
||||||
),
|
),
|
||||||
|
|
|
@ -36,8 +36,10 @@ public class MemcachedCacheConfig
|
||||||
private int maxObjectSize = 50 * 1024 * 1024;
|
private int maxObjectSize = 50 * 1024 * 1024;
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
private String memcachedPrefix = "druid";
|
private String memcachedPrefix = "druid";
|
||||||
|
|
||||||
|
// maximum size in bytes of memcached client operation queue. 0 means unlimited
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
private long maxOperationQueueSize = 256 * 1024 * 1024L; // 256 MB
|
private long maxOperationQueueSize = 0;
|
||||||
|
|
||||||
public int getExpiration()
|
public int getExpiration()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue