From fe29d6c79027404c65dcc7a4459898d754a1f161 Mon Sep 17 00:00:00 2001 From: amcreynolds Date: Mon, 6 Nov 2017 15:54:02 -0800 Subject: [PATCH] Remove VBucket-specific HashSet from BaseOperationImpl The notMyVbucketNodes HashSet in BaseOperationImpl is only used for Couchbase operations. Given that spymemcached is a memcached client first and foremost, move notMyVbucketNodes to operation implementations that actually need it to relieve memory pressure for high throughput memcached-only applications. --- .../java/net/spy/memcached/protocol/BaseOperationImpl.java | 5 ----- .../spy/memcached/protocol/binary/MultiKeyOperationImpl.java | 4 ++++ .../memcached/protocol/binary/SingleKeyOperationImpl.java | 3 +++ 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/spy/memcached/protocol/BaseOperationImpl.java b/src/main/java/net/spy/memcached/protocol/BaseOperationImpl.java index 24d690899..2e1d89923 100644 --- a/src/main/java/net/spy/memcached/protocol/BaseOperationImpl.java +++ b/src/main/java/net/spy/memcached/protocol/BaseOperationImpl.java @@ -26,12 +26,9 @@ import java.io.IOException; import java.nio.ByteBuffer; import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; -import java.util.HashSet; import java.util.Iterator; import java.util.List; -import java.util.concurrent.atomic.AtomicLong; import net.spy.memcached.MemcachedNode; import net.spy.memcached.compat.SpyObject; @@ -66,8 +63,6 @@ public abstract class BaseOperationImpl extends SpyObject implements Operation { private volatile boolean timedout; private long creationTime; private boolean timedOutUnsent = false; - protected Collection notMyVbucketNodes = - new HashSet(); private long writeCompleteTimestamp; /** diff --git a/src/main/java/net/spy/memcached/protocol/binary/MultiKeyOperationImpl.java b/src/main/java/net/spy/memcached/protocol/binary/MultiKeyOperationImpl.java index 9e8763ea2..2aa06b094 100644 --- a/src/main/java/net/spy/memcached/protocol/binary/MultiKeyOperationImpl.java +++ b/src/main/java/net/spy/memcached/protocol/binary/MultiKeyOperationImpl.java @@ -26,6 +26,7 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; import net.spy.memcached.MemcachedNode; @@ -40,7 +41,10 @@ */ abstract class MultiKeyOperationImpl extends OperationImpl implements VBucketAware, KeyedOperation { + protected final Map vbmap; + protected Collection notMyVbucketNodes = + new HashSet(); protected MultiKeyOperationImpl(byte c, int o, OperationCallback cb) { super(c, o, cb); diff --git a/src/main/java/net/spy/memcached/protocol/binary/SingleKeyOperationImpl.java b/src/main/java/net/spy/memcached/protocol/binary/SingleKeyOperationImpl.java index 71bc2083a..555cd003e 100644 --- a/src/main/java/net/spy/memcached/protocol/binary/SingleKeyOperationImpl.java +++ b/src/main/java/net/spy/memcached/protocol/binary/SingleKeyOperationImpl.java @@ -25,6 +25,7 @@ import java.util.Collection; import java.util.Collections; +import java.util.HashSet; import net.spy.memcached.MemcachedNode; import net.spy.memcached.ops.KeyedOperation; @@ -39,6 +40,8 @@ abstract class SingleKeyOperationImpl extends OperationImpl implements VBucketAware, KeyedOperation { protected final String key; + protected Collection notMyVbucketNodes = + new HashSet(); protected SingleKeyOperationImpl(byte c, int o, String k, OperationCallback cb) {