Permalink
Browse files

Revert ErrorCode and OperationStatus changes.

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...
1 parent 568149b commit b70d1a0c16a0d6da9d57880e558dc87e430253ed @ingenthr ingenthr committed with ragss Jul 23, 2012
Showing with 68 additions and 286 deletions.
  1. +1 −2 src/main/java/net/spy/memcached/MemcachedClient.java
  2. +2 −4 src/main/java/net/spy/memcached/internal/BulkGetFuture.java
  3. +1 −3 src/main/java/net/spy/memcached/internal/OperationFuture.java
  4. +2 −3 src/main/java/net/spy/memcached/ops/CASOperationStatus.java
  5. +1 −1 src/main/java/net/spy/memcached/ops/CancelledOperationStatus.java
  6. +0 −175 src/main/java/net/spy/memcached/ops/ErrorCode.java
  7. +1 −24 src/main/java/net/spy/memcached/ops/OperationStatus.java
  8. +1 −1 src/main/java/net/spy/memcached/ops/TimedOutOperationStatus.java
  9. +1 −2 src/main/java/net/spy/memcached/protocol/BaseOperationImpl.java
  10. +1 −3 src/main/java/net/spy/memcached/protocol/GetCallbackWrapper.java
  11. +3 −5 src/main/java/net/spy/memcached/protocol/ascii/BaseGetOpImpl.java
  12. +1 −2 src/main/java/net/spy/memcached/protocol/ascii/BaseStoreOperationImpl.java
  13. +3 −4 src/main/java/net/spy/memcached/protocol/ascii/CASOperationImpl.java
  14. +2 −3 src/main/java/net/spy/memcached/protocol/ascii/DeleteOperationImpl.java
  15. +1 −3 src/main/java/net/spy/memcached/protocol/ascii/FlushOperationImpl.java
  16. +2 −3 src/main/java/net/spy/memcached/protocol/ascii/MutatorOperationImpl.java
  17. +1 −7 src/main/java/net/spy/memcached/protocol/ascii/OperationImpl.java
  18. +1 −3 src/main/java/net/spy/memcached/protocol/ascii/StatsOperationImpl.java
  19. +2 −3 src/main/java/net/spy/memcached/protocol/ascii/UnlockOperationImpl.java
  20. +2 −3 src/main/java/net/spy/memcached/protocol/ascii/VersionOperationImpl.java
  21. +1 −3 src/main/java/net/spy/memcached/protocol/binary/MutatorOperationImpl.java
  22. +29 −14 src/main/java/net/spy/memcached/protocol/binary/OperationImpl.java
  23. +6 −7 src/main/java/net/spy/memcached/protocol/binary/SASLBaseOperationImpl.java
  24. +1 −3 src/main/java/net/spy/memcached/protocol/binary/SASLMechsOperationImpl.java
  25. +1 −3 src/main/java/net/spy/memcached/protocol/binary/VersionOperationImpl.java
  26. +1 −2 src/test/java/net/spy/memcached/OperationFactoryTestBase.java
@@ -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;
@@ -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);
}
@@ -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;
@@ -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;
}
@@ -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;
@@ -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;
@@ -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);
@@ -31,9 +31,8 @@
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;
}
@@ -28,6 +28,6 @@
public class CancelledOperationStatus extends OperationStatus {
public CancelledOperationStatus() {
- super(false, "cancelled", ErrorCode.CANCELLED);
+ super(false, "cancelled");
}
}
@@ -1,175 +0,0 @@
-/**
- * Copyright (C) 2009-2012 Couchbase, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALING
- * IN THE SOFTWARE.
- */
-
-package net.spy.memcached.ops;
-
-/**
- * Contains a list of Memcached and client specific error codes.
- */
-public enum ErrorCode {
-
- /**
- * The operation was successful.
- */
- SUCCESS((short) 0x00),
-
- /**
- * The key was not found on the server.
- */
- ERR_NOT_FOUND((short) 0x01),
-
- /**
- * The key already exists on the server.
- */
- ERR_EXISTS((short) 0x02),
-
- /**
- * The key or value was too big to store on the server.
- */
- ERR_2BIG((short) 0x03),
-
- /**
- * The operation sent was not a valid operation.
- */
- ERR_INVAL((short) 0x04),
-
- /**
- * The value sent in this operation was not stored.
- */
- ERR_NOT_STORED((short) 0x05),
-
- /**
- * The incr/decr value is bad.
- */
- ERR_DELTA_BADVAL((short) 0x06),
-
- /**
- * This operation was sent to the wrong server.
- */
- ERR_NOT_MY_VBUCKET((short) 0x07),
-
- /**
- * An authentication error occurred.
- */
- ERR_AUTH_ERROR((short) 0x20),
-
- /**
- * Authentication can continue.
- */
- ERR_AUTH_CONTINUE((short) 0x21),
- /**
- * The server doesn't recognize this command.
- */
- ERR_UNKNOWN_COMMAND((short) 0x81),
-
- /**
- * The server is completely out of memory.
- */
- ERR_NO_MEM((short) 0x82),
-
- /**
- * This operation is not supported by the server.
- */
- ERR_NOT_SUPPORTED((short) 0x83),
-
- /**
- * An internal error occurred on the server.
- */
- ERR_INTERNAL((short) 0x84),
-
- /**
- * The server is busy and the operation should be tried again later.
- */
- ERR_BUSY((short) 0x85),
-
- /**
- * The server is temporarily out of memory.
- */
- ERR_TEMP_FAIL((short) 0x86),
-
- /**
- * THIS IS A CLIENT SPECIFIC ERROR CODE.
- * The client received an unknown error code from the server.
- */
- UNKNOWN_ERROR((short) 0xF0),
-
- /**
- * THIS IS A CLIENT SPECIFIC ERROR CODE.
- * The operation was canceled by the client.
- */
- CANCELLED((short) 0xF1),
-
- /**
- * THIS IS A CLIENT SPECIFIC ERROR CODE.
- * The operation was timed out in the client.
- */
- TIMED_OUT((short) 0xF2),
-
- /**
- * THIS IS A CLIENT SPECIFIC ERROR CODE.
- * Client threw exception cause operation failure.
- */
- EXCEPTION((short) 0xF3);
-
- private final short error;
-
- ErrorCode(short err) {
- error = err;
- }
-
- public static ErrorCode getErrorCode(short b) {
- if (b == ErrorCode.SUCCESS.error) {
- return ErrorCode.SUCCESS;
- } else if (b == ErrorCode.ERR_NOT_FOUND.error) {
- return ErrorCode.ERR_NOT_FOUND;
- } else if (b == ErrorCode.ERR_EXISTS.error) {
- return ErrorCode.ERR_EXISTS;
- } else if (b == ErrorCode.ERR_2BIG.error) {
- return ErrorCode.ERR_2BIG;
- } else if (b == ErrorCode.ERR_INVAL.error) {
- return ErrorCode.ERR_INVAL;
- } else if (b == ErrorCode.ERR_NOT_STORED.error) {
- return ErrorCode.ERR_NOT_STORED;
- } else if (b == ErrorCode.ERR_DELTA_BADVAL.error) {
- return ErrorCode.ERR_DELTA_BADVAL;
- } else if (b == ErrorCode.ERR_NOT_MY_VBUCKET.error) {
- return ErrorCode.ERR_NOT_MY_VBUCKET;
- } else if (b == ErrorCode.ERR_AUTH_ERROR.error) {
- return ErrorCode.ERR_AUTH_ERROR;
- } else if (b == ErrorCode.ERR_AUTH_CONTINUE.error) {
- return ErrorCode.ERR_AUTH_CONTINUE;
- } else if (b == ErrorCode.ERR_UNKNOWN_COMMAND.error) {
- return ErrorCode.ERR_UNKNOWN_COMMAND;
- } else if (b == ErrorCode.ERR_NO_MEM.error) {
- return ErrorCode.ERR_NO_MEM;
- } else if (b == ErrorCode.ERR_NOT_SUPPORTED.error) {
- return ErrorCode.ERR_NOT_SUPPORTED;
- } else if (b == ErrorCode.ERR_INTERNAL.error) {
- return ErrorCode.ERR_INTERNAL;
- } else if (b == ErrorCode.ERR_BUSY.error) {
- return ErrorCode.ERR_BUSY;
- } else if (b == ErrorCode.ERR_TEMP_FAIL.error) {
- return ErrorCode.ERR_TEMP_FAIL;
- }
- return ErrorCode.UNKNOWN_ERROR;
- }
-}
@@ -29,20 +29,11 @@
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;
}
/**
@@ -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 + "}";
@@ -28,6 +28,6 @@
public class TimedOutOperationStatus extends OperationStatus {
public TimedOutOperationStatus() {
- super(false, "timed out", ErrorCode.TIMED_OUT);
+ super(false, "timed out");
}
}
@@ -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;
@@ -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;
}
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -39,7 +38,7 @@
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;
Oops, something went wrong.

0 comments on commit b70d1a0

Please sign in to comment.