-
Notifications
You must be signed in to change notification settings - Fork 415
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The issue here was that we were combinding multiple types of get operations in the same class, but each operation would have a different Callback type. When we would go to optimize get operations it would optimize get, getl, gat, and gets operations and since they have different callback types we would throw an exception. Each operation now has its own class. Change-Id: I4ca0da4f9638f7fe3a69bbe55dfb3edf30ae13cc Reviewed-on: http://review.couchbase.org/7877 Reviewed-by: Matt Ingenthron <matt@couchbase.com> Tested-by: Matt Ingenthron <matt@couchbase.com>
- Loading branch information
Mike Wiederhold
authored and
Michael Wiederhold
committed
Jul 11, 2011
1 parent
e50ec2d
commit 5f01535
Showing
5 changed files
with
114 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/main/java/net/spy/memcached/protocol/binary/GetAndTouchOperationImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package net.spy.memcached.protocol.binary; | ||
|
||
import net.spy.memcached.ops.GetAndTouchOperation; | ||
|
||
public class GetAndTouchOperationImpl extends SingleKeyOperationImpl | ||
implements GetAndTouchOperation { | ||
|
||
static final int GAT_CMD=0x1d; | ||
|
||
/** | ||
* Length of the extra header stuff for a GET response. | ||
*/ | ||
static final int EXTRA_HDR_LEN=4; | ||
|
||
private final int exp; | ||
|
||
public GetAndTouchOperationImpl(String k, int e, GetAndTouchOperation.Callback cb) { | ||
super(GAT_CMD, generateOpaque(), k, cb); | ||
exp=e; | ||
} | ||
|
||
@Override | ||
public void initialize() { | ||
prepareBuffer(key, 0, EMPTY_BYTES, exp); | ||
} | ||
|
||
@Override | ||
protected void decodePayload(byte[] pl) { | ||
final int flags=decodeInt(pl, 0); | ||
final byte[] data=new byte[pl.length - EXTRA_HDR_LEN]; | ||
System.arraycopy(pl, EXTRA_HDR_LEN, data, 0, pl.length-EXTRA_HDR_LEN); | ||
GetAndTouchOperation.Callback gcb=(GetAndTouchOperation.Callback)getCallback(); | ||
gcb.gotData(key, flags, responseCas, data); | ||
getCallback().receivedStatus(STATUS_OK); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/java/net/spy/memcached/protocol/binary/GetlOperationImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package net.spy.memcached.protocol.binary; | ||
|
||
import net.spy.memcached.ops.GetlOperation; | ||
|
||
public class GetlOperationImpl extends SingleKeyOperationImpl | ||
implements GetlOperation { | ||
|
||
static final int GETL_CMD=0x94; | ||
|
||
/** | ||
* Length of the extra header stuff for a GET response. | ||
*/ | ||
static final int EXTRA_HDR_LEN=4; | ||
|
||
private final int exp; | ||
|
||
public GetlOperationImpl(String k, int e, GetlOperation.Callback cb) { | ||
super(GETL_CMD, generateOpaque(), k, cb); | ||
exp=e; | ||
} | ||
|
||
@Override | ||
public void initialize() { | ||
prepareBuffer(key, 0, EMPTY_BYTES, exp); | ||
} | ||
|
||
@Override | ||
protected void decodePayload(byte[] pl) { | ||
final int flags=decodeInt(pl, 0); | ||
final byte[] data=new byte[pl.length - EXTRA_HDR_LEN]; | ||
System.arraycopy(pl, EXTRA_HDR_LEN, data, 0, pl.length-EXTRA_HDR_LEN); | ||
GetlOperation.Callback gcb=(GetlOperation.Callback)getCallback(); | ||
gcb.gotData(key, flags, responseCas, data); | ||
getCallback().receivedStatus(STATUS_OK); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/net/spy/memcached/protocol/binary/GetsOperationImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package net.spy.memcached.protocol.binary; | ||
|
||
import net.spy.memcached.ops.GetsOperation; | ||
|
||
public class GetsOperationImpl extends SingleKeyOperationImpl | ||
implements GetsOperation { | ||
|
||
static final int GET_CMD=0x00; | ||
|
||
/** | ||
* Length of the extra header stuff for a GET response. | ||
*/ | ||
static final int EXTRA_HDR_LEN=4; | ||
|
||
public GetsOperationImpl(String k, GetsOperation.Callback cb) { | ||
super(GET_CMD, generateOpaque(), k, cb); | ||
} | ||
|
||
@Override | ||
public void initialize() { | ||
prepareBuffer(key, 0, EMPTY_BYTES); | ||
} | ||
|
||
@Override | ||
protected void decodePayload(byte[] pl) { | ||
final int flags=decodeInt(pl, 0); | ||
final byte[] data=new byte[pl.length - EXTRA_HDR_LEN]; | ||
System.arraycopy(pl, EXTRA_HDR_LEN, data, 0, pl.length-EXTRA_HDR_LEN); | ||
GetsOperation.Callback gcb=(GetsOperation.Callback)getCallback(); | ||
gcb.gotData(key, flags, responseCas, data); | ||
getCallback().receivedStatus(STATUS_OK); | ||
} | ||
|
||
} |