private void pumpInbound(Buffer buffer) { if (failed) { LOG.trace("Skipping processing of data following transport error: {0}", buffer); return; } // Lets push bytes from vert.x to proton engine. try { ByteBuf data = buffer.getByteBuf(); do { ByteBuffer transportBuffer = transport.tail(); int amount = Math.min(transportBuffer.remaining(), data.readableBytes()); transportBuffer.limit(transportBuffer.position() + amount); data.readBytes(transportBuffer); transport.process(); } while (data.isReadable()); } catch (Exception te) { failed = true; LOG.trace("Exception while processing transport input", te); } }
@Override public void onData(final ByteBuf input) { try { if (isTraceBytes()) { TRACE_BYTES.info("Received: {}", ByteBufUtil.hexDump(input)); } do { ByteBuffer buffer = protonTransport.tail(); int chunkSize = Math.min(buffer.remaining(), input.readableBytes()); buffer.limit(buffer.position() + chunkSize); input.readBytes(buffer); protonTransport.process(); } while (input.isReadable()); // Process the state changes from the latest data and then answer back // any pending updates to the Broker. processUpdates(); pumpToProtonTransport(); } catch (Throwable t) { LOG.warn("Caught problem during data processing: {}", t.getMessage(), t); fireProviderException(t); } }
@Override public void onData(final ByteBuf input) { try { if (isTraceBytes()) { TRACE_BYTES.info("Received: {}", ByteBufUtil.hexDump(input)); } do { ByteBuffer buffer = protonTransport.tail(); int chunkSize = Math.min(buffer.remaining(), input.readableBytes()); buffer.limit(buffer.position() + chunkSize); input.readBytes(buffer); protonTransport.process(); } while (input.isReadable()); // Process the state changes from the latest data and then answer back // any pending updates to the Broker. processUpdates(); pumpToProtonTransport(); } catch (Throwable t) { LOG.warn("Caught problem during data processing: {}", t.getMessage(), t); fireProviderException(t); } }
public void inputBuffer(ByteBuf buffer) { dataReceived = true; lock.lock(); try { while (buffer.readableBytes() > 0) { int capacity = transport.capacity(); if (!receivedFirstPacket) { handleFirstPacket(buffer); // there is a chance that if SASL Handshake has been carried out that the capacity may change. capacity = transport.capacity(); } if (capacity > 0) { ByteBuffer tail = transport.tail(); int min = Math.min(capacity, buffer.readableBytes()); tail.limit(min); buffer.readBytes(tail); flush(); } else { if (capacity == 0) { log.debugf("abandoning: readableBytes=%d", buffer.readableBytes()); } else { log.debugf("transport closed, discarding: readableBytes=%d, capacity=%d", buffer.readableBytes(), transport.capacity()); } break; } } } finally { lock.unlock(); } }
public void inputBuffer(ByteBuf buffer) { requireHandler(); dataReceived = true; while (buffer.readableBytes() > 0) { int capacity = transport.capacity(); if (!receivedFirstPacket) { handleFirstPacket(buffer); // there is a chance that if SASL Handshake has been carried out that the capacity may change. capacity = transport.capacity(); } if (capacity > 0) { ByteBuffer tail = transport.tail(); int min = Math.min(capacity, buffer.readableBytes()); tail.limit(min); buffer.readBytes(tail); flush(); } else { if (capacity == 0) { log.debugf("abandoning: readableBytes=%d", buffer.readableBytes()); } else { log.debugf("transport closed, discarding: readableBytes=%d, capacity=%d", buffer.readableBytes(), transport.capacity()); } break; } } }
ByteBuffer tail = _transport.tail(); int bytesRead = _channel.read(tail); if (bytesRead < 0) {
int bytesRead = _channel.read(_transport.tail()); if (bytesRead < 0) { _transport.close_tail();
ByteBuffer tail = transport.tail(); int min = Math.min(capacity, buffer.readableBytes()); tail.limit(min);
@Override public void run(Selectable selectable) { Reactor reactor = selectable.getReactor(); Transport transport = ((SelectableImpl)selectable).getTransport(); int capacity = transport.capacity(); if (capacity > 0) { SocketChannel socketChannel = (SocketChannel)selectable.getChannel(); try { int n = socketChannel.read(transport.tail()); if (n == -1) { transport.close_tail(); } else { transport.process(); } } catch (IOException | TransportException e) { ErrorCondition condition = new ErrorCondition(); condition.setCondition(Symbol.getSymbol("proton:io")); condition.setDescription(e.getMessage()); transport.setCondition(condition); transport.close_tail(); } } // (Comment from C code:) occasionally transport events aren't // generated when expected, so the following hack ensures we // always update the selector update(selectable); reactor.update(selectable); } };
@Override public void run(Selectable selectable) { Reactor reactor = selectable.getReactor(); Transport transport = ((SelectableImpl)selectable).getTransport(); int capacity = transport.capacity(); if (capacity > 0) { SocketChannel socketChannel = (SocketChannel)selectable.getChannel(); try { int n = socketChannel.read(transport.tail()); if (n == -1) { transport.close_tail(); } else { transport.process(); } } catch (IOException e) { ErrorCondition condition = new ErrorCondition(); condition.setCondition(Symbol.getSymbol("proton:io")); condition.setDescription(e.getMessage()); transport.setCondition(condition); transport.close_tail(); } } // (Comment from C code:) occasionally transport events aren't // generated when expected, so the following hack ensures we // always update the selector update(selectable); reactor.update(selectable); } };
int bytesAvailable; while ((bytesAvailable = dr.buffer.readableBytes()) > 0) { ByteBuffer tail = engineConnection.transport.tail(); if (bytesAvailable > tail.remaining()) { int max = tail.capacity() - tail.position();