Skip to content

Commit 2fa095a

Browse files
daschlMichael Nitschinger
authored andcommitted
SPY-169: Also clone observe calls on redistribute.
Motivation ---------- Observe calls also need to be cloned when redistributed, for example if a socket gets closed or the op stil waits for an auth latch. Modifications ------------- The observe operation now gets cloned similar to get, gets and so on. Result ------ No assert error is raised if an observe needs to be cloned. Change-Id: I6269a1d7fb756855f94caa2fe0495133fe1a83b0 Reviewed-on: http://review.couchbase.org/36698 Reviewed-by: Matt Ingenthron <matt@couchbase.com> Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
1 parent fde7a94 commit 2fa095a

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

src/main/java/net/spy/memcached/ops/BaseOperationFactory.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323

2424
package net.spy.memcached.ops;
2525

26-
import java.util.ArrayList;
27-
import java.util.Collection;
28-
2926
import net.spy.memcached.MemcachedNode;
3027
import net.spy.memcached.OperationFactory;
3128

29+
import java.util.ArrayList;
30+
import java.util.Collection;
31+
3232
/**
3333
* Base class for operation factories.
3434
*
@@ -93,6 +93,10 @@ public Collection<Operation> clone(KeyedOperation op) {
9393
GetAndTouchOperation gt = (GetAndTouchOperation) op;
9494
rv.add(getAndTouch(first(gt.getKeys()), gt.getExpiration(),
9595
(GetAndTouchOperation.Callback) gt.getCallback()));
96+
} else if (op instanceof ObserveOperation) {
97+
ObserveOperation oo = (ObserveOperation) op;
98+
rv.add(observe(first(oo.getKeys()), oo.getCasValue(), oo.getIndex(),
99+
(ObserveOperation.Callback) oo.getCallback()));
96100
} else {
97101
assert false : "Unhandled operation type: " + op.getClass();
98102
}

src/main/java/net/spy/memcached/ops/ObserveOperation.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@
2929
* Observe operation.
3030
*/
3131
public interface ObserveOperation extends KeyedOperation {
32+
33+
/**
34+
* Get the CAS value advised for this operation.
35+
*/
36+
long getCasValue();
37+
38+
/**
39+
* Get the index advised for this operation.
40+
*/
41+
int getIndex();
42+
3243
/**
3344
* Operation callback for the Observe request.
3445
*/

src/main/java/net/spy/memcached/protocol/binary/ObserveOperationImpl.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,14 @@ protected void decodePayload(byte[] pl) {
6767
getHandlingNode(), r);
6868
getCallback().receivedStatus(STATUS_OK);
6969
}
70+
71+
@Override
72+
public long getCasValue() {
73+
return cas;
74+
}
75+
76+
@Override
77+
public int getIndex() {
78+
return index;
79+
}
7080
}

0 commit comments

Comments
 (0)