Permalink
Browse files

Fixed issues with the Observe Method(s)

Change-Id: Id2a1483bc1c75268f579b3df88ae4e8d488b6f46
Reviewed-on: http://review.couchbase.org/19919
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Tested-by: Matt Ingenthron <matt@couchbase.com>
  • Loading branch information...
1 parent 52c767d commit b1a7ece3f8b6ea3982599cf4eb89c297c1001a99 @ragsns ragsns committed with ingenthr Aug 21, 2012
@@ -52,13 +52,29 @@
* Response indicating the key was not found and not
* persisted, as in the case of deletes - a logical delete.
*/
- NOT_FOUND_NOT_PERSISTED((byte) 0x11);
+ NOT_FOUND_NOT_PERSISTED((byte) 0x81);
private final byte value;
-
ObserveResponse(byte b) {
value = b;
}
+ public static ObserveResponse valueOf(byte b) {
+ switch (b) {
+ case (byte) 0x00:
+ return ObserveResponse.FOUND_NOT_PERSISTED;
+ case (byte) 0x01:
+ return ObserveResponse.FOUND_PERSISTED;
+ case (byte) 0x80:
+ return ObserveResponse.NOT_FOUND_PERSISTED;
+ case (byte) 0x81:
+ return ObserveResponse.NOT_FOUND_NOT_PERSISTED;
+ case (byte) 0xfe:
+ return ObserveResponse.MODIFIED;
+ default:
+ return ObserveResponse.UNINITIALIZED;
+ }
+ }
+
}
@@ -34,7 +34,6 @@
private static final byte CMD = (byte) 0x92;
private final long cas;
- private final String key;
private final int index;
private byte keystate = (byte)0xff;
private long retCas = 0;
@@ -43,7 +42,6 @@ public ObserveOperationImpl(String k, long c, int i,
OperationCallback cb) {
super(CMD, generateOpaque(), k, cb);
cas = c;
- key = k;
index = i;
}
@@ -63,9 +61,7 @@ protected void decodePayload(byte[] pl) {
final short keylen = (short) decodeShort(pl, 2);
keystate = (byte) decodeByte(pl, keylen+4);
retCas = (long) decodeLong(pl, keylen+5);
-
- ObserveResponse r = ObserveResponse.values()[keystate];
-
+ ObserveResponse r = ObserveResponse.valueOf(keystate);
((ObserveOperation.Callback) getCallback()).gotData(key, retCas, r);
getCallback().receivedStatus(STATUS_OK);
}

0 comments on commit b1a7ece

Please sign in to comment.