Skip to content

Commit

Permalink
Revert ErrorCode and OperationStatus changes.
Browse files Browse the repository at this point in the history
This is a squashed revert of two separate commits. After
disabling optimization, I still found failing tests. I had
thought it was related at first, but after doing a bisect
it clearly identified the "Create an ErrorCode class" as
the culprit. In combination with the OperationState
correctly being volatile, it would regularly fail in the
midst of bulk operations.

This commit reverts:
"OperationStatus now has an error code"
 commit cdc26cd and
"Create an ErrorCode class for error codes"
 commit 82ad6cb.

Change-Id: Id6e04ed1787e140c5072a78cece682c45fe06313
Reviewed-on: http://review.couchbase.org/18683
Reviewed-by: Raghavan N. Srinivas <raghavan.srinivas@gmail.com>
Tested-by: Raghavan N. Srinivas <raghavan.srinivas@gmail.com>
  • Loading branch information
ingenthr authored and ragss committed Jul 25, 2012
1 parent 568149b commit b70d1a0
Show file tree
Hide file tree
Showing 26 changed files with 68 additions and 286 deletions.
3 changes: 1 addition & 2 deletions src/main/java/net/spy/memcached/MemcachedClient.java
Expand Up @@ -57,7 +57,6 @@
import net.spy.memcached.ops.CancelledOperationStatus;
import net.spy.memcached.ops.ConcatenationType;
import net.spy.memcached.ops.DeleteOperation;
import net.spy.memcached.ops.ErrorCode;
import net.spy.memcached.ops.GetAndTouchOperation;
import net.spy.memcached.ops.GetOperation;
import net.spy.memcached.ops.GetsOperation;
Expand Down Expand Up @@ -1910,7 +1909,7 @@ public boolean cancel(boolean ign) {
@Override
public Boolean get(long duration, TimeUnit units)
throws InterruptedException, TimeoutException, ExecutionException {
status = new OperationStatus(true, "OK", ErrorCode.SUCCESS);
status = new OperationStatus(true, "OK");
return super.get(duration, units);
}

Expand Down
6 changes: 2 additions & 4 deletions src/main/java/net/spy/memcached/internal/BulkGetFuture.java
Expand Up @@ -35,7 +35,6 @@

import net.spy.memcached.MemcachedConnection;
import net.spy.memcached.compat.log.LoggerFactory;
import net.spy.memcached.ops.ErrorCode;
import net.spy.memcached.ops.Operation;
import net.spy.memcached.ops.OperationState;
import net.spy.memcached.ops.OperationStatus;
Expand Down Expand Up @@ -74,7 +73,7 @@ public boolean cancel(boolean ign) {
v.cancel(ign);
}
cancelled = true;
status = new OperationStatus(false, "Cancelled", ErrorCode.CANCELLED);
status = new OperationStatus(false, "Cancelled");
return rv;
}

Expand Down Expand Up @@ -168,8 +167,7 @@ public OperationStatus getStatus() {
try {
get();
} catch (InterruptedException e) {
status = new OperationStatus(false, "Interrupted",
ErrorCode.EXCEPTION);
status = new OperationStatus(false, "Interrupted");
Thread.currentThread().interrupt();
} catch (ExecutionException e) {
return status;
Expand Down
Expand Up @@ -32,7 +32,6 @@

import net.spy.memcached.MemcachedConnection;
import net.spy.memcached.compat.SpyObject;
import net.spy.memcached.ops.ErrorCode;
import net.spy.memcached.ops.Operation;
import net.spy.memcached.ops.OperationState;
import net.spy.memcached.ops.OperationStatus;
Expand Down Expand Up @@ -199,8 +198,7 @@ public OperationStatus getStatus() {
try {
get();
} catch (InterruptedException e) {
status = new OperationStatus(false, "Interrupted",
ErrorCode.EXCEPTION);
status = new OperationStatus(false, "Interrupted");
Thread.currentThread().isInterrupted();
} catch (ExecutionException e) {
getLogger().warn("Error getting status of operation", e);
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/net/spy/memcached/ops/CASOperationStatus.java
Expand Up @@ -31,9 +31,8 @@ public class CASOperationStatus extends OperationStatus {

private final CASResponse casResponse;

public CASOperationStatus(boolean success, String msg, ErrorCode ec,
CASResponse cres) {
super(success, msg, ec);
public CASOperationStatus(boolean success, String msg, CASResponse cres) {
super(success, msg);
casResponse = cres;
}

Expand Down
Expand Up @@ -28,6 +28,6 @@
public class CancelledOperationStatus extends OperationStatus {

public CancelledOperationStatus() {
super(false, "cancelled", ErrorCode.CANCELLED);
super(false, "cancelled");
}
}
175 changes: 0 additions & 175 deletions src/main/java/net/spy/memcached/ops/ErrorCode.java

This file was deleted.

25 changes: 1 addition & 24 deletions src/main/java/net/spy/memcached/ops/OperationStatus.java
Expand Up @@ -29,20 +29,11 @@ public class OperationStatus {

private final boolean isSuccess;
private final String message;
private final ErrorCode errorCode;
private final Throwable throwable;

public OperationStatus(boolean success, String msg, ErrorCode ec) {
this(success, msg, ec, null);
}

public OperationStatus(boolean success, String msg, ErrorCode ec,
Throwable t) {
public OperationStatus(boolean success, String msg) {
super();
isSuccess = success;
message = msg;
errorCode = ec;
throwable = null;
}

/**
Expand All @@ -59,20 +50,6 @@ public String getMessage() {
return message;
}

/**
* Get the error code associated with this request.
*/
public ErrorCode getErrorCode() {
return errorCode;
}

/**
* Get the throwable if one exists for this operation.
*/
public Throwable getThrowable() {
return throwable;
}

@Override
public String toString() {
return "{OperationStatus success=" + isSuccess + ": " + message + "}";
Expand Down
Expand Up @@ -28,6 +28,6 @@
public class TimedOutOperationStatus extends OperationStatus {

public TimedOutOperationStatus() {
super(false, "timed out", ErrorCode.TIMED_OUT);
super(false, "timed out");
}
}
Expand Up @@ -31,7 +31,6 @@
import net.spy.memcached.MemcachedNode;
import net.spy.memcached.compat.SpyObject;
import net.spy.memcached.ops.CancelledOperationStatus;
import net.spy.memcached.ops.ErrorCode;
import net.spy.memcached.ops.Operation;
import net.spy.memcached.ops.OperationCallback;
import net.spy.memcached.ops.OperationErrorType;
Expand Down Expand Up @@ -171,7 +170,7 @@ protected void handleError(OperationErrorType eType, String line)
assert false;
}
callback.receivedStatus(new OperationStatus(false,
exception.getMessage(), ErrorCode.EXCEPTION, exception));
exception.getMessage()));
transitionState(OperationState.COMPLETE);
throw exception;
}
Expand Down
Expand Up @@ -22,7 +22,6 @@

package net.spy.memcached.protocol;

import net.spy.memcached.ops.ErrorCode;
import net.spy.memcached.ops.GetOperation;
import net.spy.memcached.ops.OperationStatus;

Expand All @@ -31,8 +30,7 @@
*/
public class GetCallbackWrapper implements GetOperation.Callback {

private static final OperationStatus END = new OperationStatus(true, "END",
ErrorCode.SUCCESS);
private static final OperationStatus END = new OperationStatus(true, "END");

private boolean completed = false;
private int remainingKeys = 0;
Expand Down
Expand Up @@ -28,7 +28,6 @@
import java.util.Collections;

import net.spy.memcached.KeyUtil;
import net.spy.memcached.ops.ErrorCode;
import net.spy.memcached.ops.GetAndTouchOperation;
import net.spy.memcached.ops.GetOperation;
import net.spy.memcached.ops.GetlOperation;
Expand All @@ -43,12 +42,11 @@
*/
abstract class BaseGetOpImpl extends OperationImpl {

private static final OperationStatus END = new OperationStatus(true, "END",
ErrorCode.SUCCESS);
private static final OperationStatus END = new OperationStatus(true, "END");
private static final OperationStatus NOT_FOUND = new OperationStatus(false,
"NOT_FOUND", ErrorCode.ERR_NOT_FOUND);
"NOT_FOUND");
private static final OperationStatus LOCK_ERROR = new OperationStatus(false,
"LOCK_ERROR", ErrorCode.ERR_EXISTS);
"LOCK_ERROR");
private static final byte[] RN_BYTES = "\r\n".getBytes();
private final String cmd;
private final Collection<String> keys;
Expand Down
Expand Up @@ -27,7 +27,6 @@
import java.util.Collections;

import net.spy.memcached.KeyUtil;
import net.spy.memcached.ops.ErrorCode;
import net.spy.memcached.ops.OperationCallback;
import net.spy.memcached.ops.OperationState;
import net.spy.memcached.ops.OperationStatus;
Expand All @@ -39,7 +38,7 @@ abstract class BaseStoreOperationImpl extends OperationImpl {

private static final int OVERHEAD = 32;
private static final OperationStatus STORED = new OperationStatus(true,
"STORED", ErrorCode.SUCCESS);
"STORED");
protected final String type;
protected final String key;
protected final int flags;
Expand Down

0 comments on commit b70d1a0

Please sign in to comment.