Java Code Examples for com.couchbase.client.deps.io.netty.buffer.ByteBuf#release()
The following examples show how to use
com.couchbase.client.deps.io.netty.buffer.ByteBuf#release() .
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: CouchbaseReader.java From components with Apache License 2.0 | 6 votes |
@Override public boolean advance() throws IOException { while (true) { ByteBuf event; try { event = resultsQueue.poll(1, TimeUnit.SECONDS); } catch (InterruptedException e) { LOG.error("Failed to poll event from the results queue", e); return false; } if (event != null) { currentRecord = converter.convertToAvro(event); connection.acknowledge(event); event.release(); recordCount++; return true; } if (!connection.isStreaming() && resultsQueue.isEmpty()) { break; } } return false; }
Example 2
Source File: CouchbaseStreamingConnection.java From components with Apache License 2.0 | 6 votes |
@Override public void onEvent(ChannelFlowController controller, ByteBuf event) { if (controller != null) { this.classController = controller; } if (resultsQueue != null) { try { resultsQueue.put(event); } catch (InterruptedException e) { LOG.error("Unable to put DCP request into the results queue"); } } else { controller.ack(event); event.release(); } }
Example 3
Source File: CouchbaseStreamingConnection.java From components with Apache License 2.0 | 5 votes |
public void stopStreaming() { if (resultsQueue != null) { client.stopStreaming(partitionsToStream()).await(); BlockingQueue<ByteBuf> queue = resultsQueue; resultsQueue = null; List<ByteBuf> drained = new ArrayList<ByteBuf>(); queue.drainTo(drained); for (ByteBuf byteBuf : drained) { byteBuf.release(); } client.disconnect(); } }
Example 4
Source File: CouchbaseUtils.java From nifi with Apache License 2.0 | 5 votes |
public static String getStringContent(Object content) { if (content instanceof String) { return (String) content; } else if (content instanceof byte[]) { return new String((byte[]) content, StandardCharsets.UTF_8); } else if (content instanceof ByteBuf) { final ByteBuf byteBuf = (ByteBuf) content; byte[] bytes = new byte[byteBuf.readableBytes()]; byteBuf.readBytes(bytes); byteBuf.release(); return new String(bytes, StandardCharsets.UTF_8); } return content.toString(); }
Example 5
Source File: CouchbaseMapCacheClient.java From nifi with Apache License 2.0 | 5 votes |
private <V> V deserialize(BinaryDocument doc, Deserializer<V> valueDeserializer) throws IOException { if (doc == null) { return null; } final ByteBuf byteBuf = doc.content(); final byte[] bytes = new byte[byteBuf.readableBytes()]; byteBuf.readBytes(bytes); byteBuf.release(); return valueDeserializer.deserialize(bytes); }