Skip to content

Commit 0283051

Browse files
daschlMichael Nitschinger
authored andcommitted
SPY-181: GetAndLock needs to be cloneable like any other keyed op.
Motivation ---------- In case a getAndLock operation needs to be rescheduled, it needs to be cloneable (like any other keyed operation). Modifications ------------- Apply the same clone logic as with any other keyed operation. Also added getter methods to the operations so that the expiration time can be extracted on cloning. Result ------ Correct behavior when a getAndLock op needs to be cloned. Change-Id: I7f4fdad62af71a42cc203b2a4b7e72f2002a286d Reviewed-on: http://review.couchbase.org/45129 Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com> Reviewed-by: Simon Baslé <simon@couchbase.com>
1 parent f896fd5 commit 0283051

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,11 @@ public Collection<Operation> clone(KeyedOperation op) {
9292
} else if(op instanceof GetAndTouchOperation) {
9393
GetAndTouchOperation gt = (GetAndTouchOperation) op;
9494
rv.add(getAndTouch(first(gt.getKeys()), gt.getExpiration(),
95-
(GetAndTouchOperation.Callback) gt.getCallback()));
95+
(GetAndTouchOperation.Callback) gt.getCallback()));
96+
} else if (op instanceof GetlOperation) {
97+
GetlOperation gl = (GetlOperation) op;
98+
rv.add(getl(first(gl.getKeys()), gl.getExpiration(),
99+
(GetlOperation.Callback) gl.getCallback()));
96100
} else if (op instanceof ObserveOperation) {
97101
ObserveOperation oo = (ObserveOperation) op;
98102
rv.add(observe(first(oo.getKeys()), oo.getCasValue(), oo.getIndex(),

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,7 @@ interface Callback extends OperationCallback {
4040
*/
4141
void gotData(String key, int flags, long cas, byte[] data);
4242
}
43+
44+
int getExpiration();
45+
4346
}

src/main/java/net/spy/memcached/protocol/ascii/GetlOperationImpl.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,15 @@ class GetlOperationImpl extends BaseGetOpImpl implements GetlOperation {
3131

3232
private static final String CMD = "getl";
3333

34+
private final int exp;
35+
3436
public GetlOperationImpl(String key, int exp, GetlOperation.Callback c) {
3537
super(CMD, exp, c, key);
38+
this.exp = exp;
39+
}
40+
41+
@Override
42+
public int getExpiration() {
43+
return exp;
3644
}
3745
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,10 @@ protected void decodePayload(byte[] pl) {
6464
public String toString() {
6565
return super.toString() + " Exp: " + exp;
6666
}
67+
68+
@Override
69+
public int getExpiration() {
70+
return exp;
71+
}
72+
6773
}

0 commit comments

Comments
 (0)