extras.writeInt(msg.expiration());
String key = msg.key();
short keyLength = (short) key.length();
byte extrasLength = (byte) extras.readableBytes();
FullBinaryMemcacheRequest request = new DefaultFullBinaryMemcacheRequest(key, extras, msg.content());
if (msg instanceof InsertRequest) {
request.setOpcode(OP_INSERT);
} else if (msg instanceof UpsertRequest) {
request.setOpcode(OP_UPSERT);
} else if (msg instanceof ReplaceRequest) {
request.setOpcode(OP_REPLACE);
request.setCAS(((ReplaceRequest) msg).cas());
} else {
throw new IllegalArgumentException("Unknown incoming BinaryStoreRequest type "
+ msg.getClass());
}
request.setKeyLength(keyLength);
request.setTotalBodyLength(keyLength + msg.content().readableBytes() + extrasLength);
request.setExtrasLength(extrasLength);
return request;
}