use of com.couchbase.client.core.deps.io.netty.buffer.ByteBuf in project couchbase-jvm-clients by couchbase.
the class GetMetaRequest method encode.
@Override
public ByteBuf encode(ByteBufAllocator alloc, int opaque, KeyValueChannelContext ctx) {
ByteBuf key = null;
ByteBuf extras = null;
try {
extras = alloc.buffer(Byte.BYTES);
extras.writeByte(2);
key = encodedKeyWithCollection(alloc, ctx);
return MemcacheProtocol.request(alloc, MemcacheProtocol.Opcode.GET_META, noDatatype(), partition(), opaque, noCas(), extras, key, noBody());
} finally {
ReferenceCountUtil.release(key);
ReferenceCountUtil.release(extras);
}
}
use of com.couchbase.client.core.deps.io.netty.buffer.ByteBuf in project couchbase-jvm-clients by couchbase.
the class DecrementRequest method encode.
@Override
public ByteBuf encode(ByteBufAllocator alloc, int opaque, KeyValueChannelContext ctx) {
ByteBuf key = null;
ByteBuf extras = null;
ByteBuf flexibleExtras = mutationFlexibleExtras(this, ctx, alloc, syncReplicationType);
try {
key = encodedKeyWithCollection(alloc, ctx);
extras = alloc.buffer((Long.BYTES * 2) + Integer.BYTES);
extras.writeLong(delta);
if (initial.isPresent()) {
extras.writeLong(initial.get());
extras.writeInt((int) expiry);
} else {
// no initial present, will lead to doc not found
extras.writeLong(0);
extras.writeInt(IncrementRequest.COUNTER_NOT_EXISTS_EXPIRY);
}
return MemcacheProtocol.flexibleRequest(alloc, MemcacheProtocol.Opcode.DECREMENT, noDatatype(), partition(), opaque, noCas(), flexibleExtras, extras, key, noBody());
} finally {
ReferenceCountUtil.release(key);
ReferenceCountUtil.release(extras);
ReferenceCountUtil.release(flexibleExtras);
}
}
use of com.couchbase.client.core.deps.io.netty.buffer.ByteBuf in project couchbase-jvm-clients by couchbase.
the class GetAndLockRequest method encode.
@Override
public ByteBuf encode(ByteBufAllocator alloc, int opaque, KeyValueChannelContext ctx) {
ByteBuf key = null;
ByteBuf extras = null;
try {
key = encodedKeyWithCollection(alloc, ctx);
extras = alloc.buffer(Integer.BYTES).writeInt((int) lockFor.getSeconds());
return MemcacheProtocol.request(alloc, Opcode.GET_AND_LOCK, noDatatype(), partition(), opaque, noCas(), extras, key, noBody());
} finally {
ReferenceCountUtil.release(key);
ReferenceCountUtil.release(extras);
}
}
use of com.couchbase.client.core.deps.io.netty.buffer.ByteBuf in project couchbase-jvm-clients by couchbase.
the class GetAndTouchRequest method encode.
@Override
public ByteBuf encode(ByteBufAllocator alloc, int opaque, KeyValueChannelContext ctx) {
ByteBuf key = null;
ByteBuf extras = null;
try {
key = encodedKeyWithCollection(alloc, ctx);
extras = alloc.buffer(Integer.BYTES).writeInt((int) expiration);
return MemcacheProtocol.request(alloc, MemcacheProtocol.Opcode.GET_AND_TOUCH, noDatatype(), partition(), opaque, noCas(), extras, key, noBody());
} finally {
ReferenceCountUtil.release(key);
ReferenceCountUtil.release(extras);
}
}
use of com.couchbase.client.core.deps.io.netty.buffer.ByteBuf in project couchbase-jvm-clients by couchbase.
the class ErrorMapLoadingHandler method buildErrorMapRequest.
/**
* Helper method to build the error map fetch request.
*
* @param ctx the {@link ChannelHandlerContext} for which the channel active operation is made.
* @return the created request as a {@link ByteBuf}.
*/
private ByteBuf buildErrorMapRequest(final ChannelHandlerContext ctx) {
ByteBuf body = ctx.alloc().buffer(Short.BYTES).writeShort(MAP_VERSION);
ByteBuf request = MemcacheProtocol.request(ctx.alloc(), MemcacheProtocol.Opcode.ERROR_MAP, noDatatype(), noPartition(), BaseKeyValueRequest.nextOpaque(), noCas(), noExtras(), noKey(), body);
body.release();
return request;
}
Aggregations