@Override public ByteBuf clear() { buf.clear(); return this; }
@Override public final ByteBuf clear() { buf.clear(); return this; }
@Override public final ByteBuf clear() { buf.clear(); return this; }
@Override public ByteBuf clear() { buf.clear(); return this; }
/** * Push a config chunk into the streaming observable. */ private void maybePushConfigChunk() { String currentChunk = responseContent.toString(CHARSET); int separatorIndex = currentChunk.indexOf("\n\n\n\n"); if (separatorIndex > 0) { String content = currentChunk.substring(0, separatorIndex); streamingConfigObservable.onNext(content.trim()); responseContent.clear(); responseContent.writeBytes(currentChunk.substring(separatorIndex + 4).getBytes(CHARSET)); } }
/** * Push a config chunk into the streaming observable. */ private void maybePushConfigChunk() { String currentChunk = responseContent.toString(CHARSET); int separatorIndex = currentChunk.indexOf("\n\n\n\n"); if (separatorIndex > 0) { String content = currentChunk.substring(0, separatorIndex); streamingConfigObservable.onNext(content.trim()); responseContent.clear(); responseContent.writeBytes(currentChunk.substring(separatorIndex + 4).getBytes(CHARSET)); } }
/** * Helper method to decode and analyze the chunk. * * @param chunk the chunk to analyze. */ private void decodeChunk(InetSocketAddress address, final ByteBuf chunk) { responseContent.writeBytes(chunk); String currentChunk = responseContent.toString(CharsetUtil.UTF_8); int separatorIndex = currentChunk.indexOf("\n\n\n\n"); if (separatorIndex > 0) { String rawConfig = currentChunk .substring(0, separatorIndex) .trim() .replace("$HOST", address.getAddress().getHostAddress()); NetworkAddress origin = NetworkAddress.create(address.getAddress().getHostAddress()); CouchbaseBucketConfig config = (CouchbaseBucketConfig) BucketConfigParser.parse(rawConfig, environment, origin); synchronized (currentBucketConfigRev) { if (config.rev() > currentBucketConfigRev.get()) { currentBucketConfigRev.set(config.rev()); configStream.onNext(config); } else { LOGGER.trace("Ignoring config, since rev has not changed."); } } responseContent.clear(); responseContent.writeBytes(currentChunk.substring(separatorIndex + 4).getBytes(CharsetUtil.UTF_8)); } }
private void generateNextDocument() { byteBuff.retain(); // reset the string strBuilder.setLength(0); strBuilder.append("{\"id\":" + (counter + upsertCounter) + ",\"name\":\"" + names[(counter + upsertCounter) % names.length] + "\""); switch (counter % 3) { case 0: // Missing break; case 1: strBuilder.append(",\"exp\":null"); break; case 2: strBuilder.append(",\"exp\":" + ((counter + upsertCounter) * 3)); break; default: break; } strBuilder.append("}"); byteBuff.clear(); byteBuff.writeBytes(strBuilder.toString().getBytes(StandardCharsets.UTF_8)); }
private void process(String input) throws IOException { value.reset(); nettyBuffer.clear(); nettyBuffer.writeBytes(input.getBytes(StandardCharsets.UTF_8)); DCPMessageToRecordConverter.set(nettyBuffer, decoder, bytes, chars, value); Assert.assertEquals(input, value.toString()); } }
responseContent.clear(); } else { responseContent = ctx.alloc().buffer(); responseContent.clear(); responseContent.discardReadBytes(); } else if (request instanceof PingRequest) { if (msg instanceof LastHttpContent) { response = new PingResponse(ResponseStatusConverter.fromHttp(responseHeader.getStatus().code()), request); responseContent.clear(); responseContent.discardReadBytes(); finishedDecoding();
responseHeader = (HttpResponse) msg; if (responseContent != null) { responseContent.clear(); } else { responseContent = ctx.alloc().buffer(); if (msg instanceof LastHttpContent) { response = new KeepAliveResponse(ResponseStatusConverter.fromHttp(responseHeader.getStatus().code()), currentRequest()); responseContent.clear(); responseContent.discardReadBytes(); finishedDecoding(); if (msg instanceof LastHttpContent) { response = new PingResponse(ResponseStatusConverter.fromHttp(responseHeader.getStatus().code()), currentRequest()); responseContent.clear(); responseContent.discardReadBytes(); finishedDecoding();
responseHeader = (HttpResponse) msg; if (responseContent != null) { responseContent.clear(); } else { responseContent = ctx.alloc().buffer(); if (msg instanceof LastHttpContent) { response = new KeepAliveResponse(ResponseStatusConverter.fromHttp(responseHeader.getStatus().code()), currentRequest()); responseContent.clear(); responseContent.discardReadBytes(); finishedDecoding(); if (msg instanceof LastHttpContent) { response = new PingResponse(ResponseStatusConverter.fromHttp(responseHeader.getStatus().code()), currentRequest()); responseContent.clear(); responseContent.discardReadBytes(); finishedDecoding();
responseHeader = (HttpResponse) msg; if (responseContent != null) { responseContent.clear(); } else { responseContent = ctx.alloc().buffer(); if (msg instanceof LastHttpContent) { response = new KeepAliveResponse(ResponseStatusConverter.fromHttp(responseHeader.getStatus().code()), currentRequest()); responseContent.clear(); responseContent.discardReadBytes(); finishedDecoding(); if (msg instanceof LastHttpContent) { response = new PingResponse(ResponseStatusConverter.fromHttp(responseHeader.getStatus().code()), currentRequest()); responseContent.clear(); responseContent.discardReadBytes(); finishedDecoding();
responseHeader = (HttpResponse) msg; if (responseContent != null) { responseContent.clear(); } else { responseContent = ctx.alloc().buffer(); if (msg instanceof LastHttpContent) { response = new KeepAliveResponse(ResponseStatusConverter.fromHttp(responseHeader.getStatus().code()), currentRequest()); responseContent.clear(); responseContent.discardReadBytes(); finishedDecoding(); if (msg instanceof LastHttpContent) { response = new PingResponse(ResponseStatusConverter.fromHttp(responseHeader.getStatus().code()), currentRequest()); responseContent.clear(); responseContent.discardReadBytes(); finishedDecoding();
responseContent.clear(); } else { responseContent = ctx.alloc().buffer(); responseContent.clear(); responseContent.discardReadBytes(); } else if (request instanceof PingRequest) { if (msg instanceof LastHttpContent) { response = new PingResponse(ResponseStatusConverter.fromHttp(responseHeader.getStatus().code()), request); responseContent.clear(); responseContent.discardReadBytes(); finishedDecoding();
responseHeader = (HttpResponse) msg; if (responseContent != null) { responseContent.clear(); } else { responseContent = ctx.alloc().buffer(); if (msg instanceof LastHttpContent) { response = new KeepAliveResponse(ResponseStatusConverter.fromHttp(responseHeader.getStatus().code()), currentRequest()); responseContent.clear(); responseContent.discardReadBytes(); finishedDecoding(); if (msg instanceof LastHttpContent) { response = new PingResponse(ResponseStatusConverter.fromHttp(responseHeader.getStatus().code()), currentRequest()); responseContent.clear(); responseContent.discardReadBytes(); finishedDecoding();
responseHeader = (HttpResponse) msg; if (responseContent != null) { responseContent.clear(); } else { responseContent = ctx.alloc().buffer(); if (msg instanceof LastHttpContent) { response = new KeepAliveResponse(ResponseStatusConverter.fromHttp(responseHeader.getStatus().code()), currentRequest()); responseContent.clear(); responseContent.discardReadBytes(); finishedDecoding(); if (msg instanceof LastHttpContent) { response = new PingResponse(ResponseStatusConverter.fromHttp(responseHeader.getStatus().code()), currentRequest()); responseContent.clear(); responseContent.discardReadBytes(); finishedDecoding();
responseContent.clear(); } else { responseContent = ctx.alloc().buffer(); if (msg instanceof LastHttpContent) { response = new KeepAliveResponse(ResponseStatusConverter.fromHttp(responseHeader.getStatus().code()), currentRequest()); responseContent.clear(); responseContent.discardReadBytes(); finishedDecoding(); if (msg instanceof LastHttpContent) { response = new PingResponse(ResponseStatusConverter.fromHttp(responseHeader.getStatus().code()), currentRequest()); responseContent.clear(); responseContent.discardReadBytes(); finishedDecoding();
byte[] compressed = compress(encoded.copy().array()); if (compressed.length < encoded.array().length) { encoded.clear().writeBytes(compressed); flags |= COMPRESSED;
responseContent.clear(); } else { responseContent = ctx.alloc().buffer(); if (msg instanceof LastHttpContent) { response = new KeepAliveResponse(ResponseStatusConverter.fromHttp(responseHeader.getStatus().code()), currentRequest()); responseContent.clear(); responseContent.discardReadBytes(); finishedDecoding(); if (msg instanceof LastHttpContent) { response = new PingResponse(ResponseStatusConverter.fromHttp(responseHeader.getStatus().code()), currentRequest()); responseContent.clear(); responseContent.discardReadBytes(); finishedDecoding();