Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions src/main/java/net/spy/memcached/MemcachedConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ public class MemcachedConnection extends SpyThread {
private static final int DEFAULT_RETRY_QUEUE_SIZE = -1;

/**
* If an operation gets cloned more than this ceiling, cancel it for
* safety reasons.
* The default number of times an operation will be cloned before it
* is cancelled for safety reasons.
*/
private static final int MAX_CLONE_COUNT = 100;
private static final int DEFAULT_MAX_CLONE_COUNT = 100;

private static final String RECON_QUEUE_METRIC =
"[MEM] Reconnecting Nodes (ReconnectQueue)";
Expand Down Expand Up @@ -251,6 +251,12 @@ public class MemcachedConnection extends SpyThread {
*/
private final int retryQueueSize;

/**
* The number of times an operation will be cloned before it is
* cancelled for safety reasons.
*/
private final int maxCloneCount;

/**
* Construct a {@link MemcachedConnection}.
*
Expand Down Expand Up @@ -294,6 +300,9 @@ public MemcachedConnection(final int bufSize, final ConnectionFactory f,
Integer.toString(DEFAULT_RETRY_QUEUE_SIZE)));
getLogger().info("Setting retryQueueSize to " + retryQueueSize);

maxCloneCount = Integer.parseInt(System.getProperty("net.spy.maxCloneCount",
Integer.toString(DEFAULT_MAX_CLONE_COUNT)));

List<MemcachedNode> connections = createConnections(a);
locator = f.createLocator(connections);

Expand Down Expand Up @@ -1048,9 +1057,9 @@ public void redistributeOperation(Operation op) {
return;
}

if (op.getCloneCount() >= MAX_CLONE_COUNT) {
if (op.getCloneCount() >= maxCloneCount) {
getLogger().warn("Cancelling operation " + op + "because it has been "
+ "retried (cloned) more than " + MAX_CLONE_COUNT + "times.");
+ "retried (cloned) more than " + maxCloneCount + "times.");
op.cancel();
return;
}
Expand Down