@Test void decodeNotFoundResponse() { ByteBuf response = decodeHexDump(readResource( "get_response_not_found.txt", GetRequestTest.class )); GetRequest request = new GetRequest(null, TIMEOUT, CTX, null, RETRY, null); GetResponse decoded = request.decode(response, null); assertEquals(ResponseStatus.NOT_FOUND, decoded.status()); assertNull(decoded.content()); assertEquals(0, decoded.flags()); }
@Override public GetResponse decode(final ByteBuf response, KeyValueChannelContext ctx) { ResponseStatus status = decodeStatus(response); long cas = cas(response); if (status.success()) { byte[] bytes = bodyAsBytes(response); byte[] content = bytes != null ? tryDecompression(bytes, datatype(response)) : Bytes.EMPTY_BYTE_ARRAY; int flags = extrasAsInt(response, 0, 0); return new GetResponse(status, content, cas, flags); } else { return new GetResponse(status, null, cas, 0); } }
GetRequest extends BaseKeyValueRequest<GetResponse> { @Override public GetResponse decode(final ByteBuf response, KeyValueChannelContext ctx) { ResponseStatus status = decodeStatus(response); long cas = cas(response); if (status.success()) { byte[] bytes = bodyAsBytes(response); byte[] content = bytes != null ? tryDecompression(bytes, datatype(response)) : Bytes.EMPTY_BYTE_ARRAY; int flags = extrasAsInt(response, 0, 0); return new GetResponse(status, content, cas, flags); } else { return new GetResponse(status, null, cas, 0); } } }
GetRequest extends BaseKeyValueRequest<GetResponse> { @Override public GetResponse decode(final ByteBuf response, KeyValueChannelContext ctx) { ResponseStatus status = decodeStatus(response); long cas = cas(response); if (status.success()) { byte[] bytes = bodyAsBytes(response); byte[] content = bytes != null ? tryDecompression(bytes, datatype(response)) : Bytes.EMPTY_BYTE_ARRAY; int flags = extrasAsInt(response, 0, 0); return new GetResponse(status, content, cas, flags); } else { return new GetResponse(status, null, cas, 0); } } GetRequest(final String key, final Duration timeout, final CoreContext ctx,
                    final CollectionIdentifier collectionIdentifier, final RetryStrategy retryStrategy, final InternalSpan span); }
GetRequest extends BaseKeyValueRequest<GetResponse> { @Override public GetResponse decode(final ByteBuf response, KeyValueChannelContext ctx) { ResponseStatus status = decodeStatus(response); long cas = cas(response); if (status.success()) { byte[] bytes = bodyAsBytes(response); byte[] content = bytes != null ? tryDecompression(bytes, datatype(response)) : Bytes.EMPTY_BYTE_ARRAY; int flags = extrasAsInt(response, 0, 0); return new GetResponse(status, content, cas, flags); } else { return new GetResponse(status, null, cas, 0); } } GetRequest(final String key, final Duration timeout, final CoreContext ctx,
                    final CollectionIdentifier collectionIdentifier, final RetryStrategy retryStrategy, final InternalSpan span); @Override ByteBuf encode(ByteBufAllocator alloc, int opaque, KeyValueChannelContext ctx); @Override GetResponse decode(final ByteBuf response, KeyValueChannelContext ctx); @Override boolean idempotent(); }
GetRequest extends BaseKeyValueRequest<GetResponse> { @Override public GetResponse decode(final ByteBuf response, KeyValueChannelContext ctx) { ResponseStatus status = decodeStatus(response); long cas = cas(response); if (status.success()) { byte[] bytes = bodyAsBytes(response); byte[] content = bytes != null ? tryDecompression(bytes, datatype(response)) : Bytes.EMPTY_BYTE_ARRAY; int flags = extrasAsInt(response, 0, 0); return new GetResponse(status, content, cas, flags); } else { return new GetResponse(status, null, cas, 0); } } GetRequest(final String key, final Duration timeout, final CoreContext ctx,
                    final CollectionIdentifier collectionIdentifier, final RetryStrategy retryStrategy, final InternalSpan span); @Override ByteBuf encode(ByteBufAllocator alloc, int opaque, KeyValueChannelContext ctx); @Override GetResponse decode(final ByteBuf response, KeyValueChannelContext ctx); @Override boolean idempotent(); static final String OPERATION_NAME; }