Java Code Examples for com.couchbase.client.core.message.ResponseStatus#isSuccess()
The following examples show how to use
com.couchbase.client.core.message.ResponseStatus#isSuccess() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConfigHandler.java From couchbase-jvm-core with Apache License 2.0 | 6 votes |
/** * Decodes a {@link BucketStreamingResponse}. * * @param ctx the handler context. * @param header the received header. * @return a initialized {@link CouchbaseResponse}. */ private CouchbaseResponse handleBucketStreamingResponse(final ChannelHandlerContext ctx, final HttpResponse header) { SocketAddress addr = ctx.channel().remoteAddress(); String host = addr instanceof InetSocketAddress ? ((InetSocketAddress) addr).getAddress().getHostAddress() : addr.toString(); ResponseStatus status = ResponseStatusConverter.fromHttp(header.getStatus().code()); Observable<String> scheduledObservable = null; if (status.isSuccess()) { streamingConfigObservable = BehaviorSubject.create(); scheduledObservable = streamingConfigObservable.onBackpressureBuffer().observeOn(env().scheduler()); } return new BucketStreamingResponse( scheduledObservable, host, status, currentRequest() ); }
Example 2
Source File: KeyValueFeatureHandler.java From couchbase-jvm-core with Apache License 2.0 | 6 votes |
@Override protected void channelRead0(ChannelHandlerContext ctx, FullBinaryMemcacheResponse msg) throws Exception { List<ServerFeatures> supported = new ArrayList<ServerFeatures>(); ResponseStatus responseStatus = ResponseStatusConverter.fromBinary(msg.getStatus()); if (responseStatus.isSuccess()) { while (msg.content().isReadable()) { supported.add(ServerFeatures.fromValue(msg.content().readShort())); } } else { LOGGER.debug("HELLO Negotiation did not succeed ({}).", responseStatus); } LOGGER.debug("Negotiated supported features: {}", supported); ctx.fireUserEventTriggered(new ServerFeaturesEvent(supported)); originalPromise.setSuccess(); ctx.pipeline().remove(this); ctx.fireChannelActive(); }
Example 3
Source File: KeyValueHandler.java From couchbase-jvm-core with Apache License 2.0 | 5 votes |
/** * Helper method to decode all multi lookup response messages. * * @param request the current request. * @param msg the current response message. * @param ctx the handler context. * @param status the response status code. * @return the decoded response or null if it wasn't a subdocument multi lookup. */ private static CouchbaseResponse handleSubdocumentMultiLookupResponseMessages(BinaryRequest request, FullBinaryMemcacheResponse msg, ChannelHandlerContext ctx, ResponseStatus status) { if (!(request instanceof BinarySubdocMultiLookupRequest)) return null; BinarySubdocMultiLookupRequest subdocRequest = (BinarySubdocMultiLookupRequest) request; short statusCode = msg.getStatus(); long cas = msg.getCAS(); String bucket = request.bucket(); ByteBuf body = msg.content(); List<MultiResult<Lookup>> responses; if (status.isSuccess() || ResponseStatus.SUBDOC_MULTI_PATH_FAILURE.equals(status)) { long bodyLength = body.readableBytes(); List<LookupCommand> commands = subdocRequest.commands(); responses = new ArrayList<MultiResult<Lookup>>(commands.size()); for (LookupCommand cmd : commands) { if (msg.content().readableBytes() < 6) { body.release(); throw new IllegalStateException("Expected " + commands.size() + " lookup responses, only got " + responses.size() + ", total of " + bodyLength + " bytes"); } short cmdStatus = body.readShort(); int valueLength = body.readInt(); ByteBuf value = ctx.alloc().buffer(valueLength, valueLength); value.writeBytes(body, valueLength); responses.add(MultiResult.create(cmdStatus, ResponseStatusConverter.fromBinary(cmdStatus), cmd.path(), cmd.lookup(), value)); } } else { responses = Collections.emptyList(); } body.release(); return new MultiLookupResponse(status, statusCode, bucket, responses, subdocRequest, cas); }