@Override public void run() { ByteBuffer source = incoming.nioBuffer(); LOG.trace("Client Received from Broker {} bytes:", source.remaining()); if (protonTransport.isClosed()) { LOG.debug("Ignoring incoming data because transport is closed"); return; } do { ByteBuffer buffer = protonTransport.getInputBuffer(); int limit = Math.min(buffer.remaining(), source.remaining()); ByteBuffer duplicate = source.duplicate(); duplicate.limit(source.position() + limit); buffer.put(duplicate); protonTransport.processInput(); source.position(source.position() + limit); } while (source.hasRemaining()); ReferenceCountUtil.release(incoming); // Process the state changes from the latest data and then answer back // any pending updates to the Broker. processUpdates(); pumpToProtonTransport(); } });
@Override public void run() { boolean checkScheduled = false; if (connection.getLocalState() == EndpointState.ACTIVE) { // Using nano time since it is not related to the wall clock, which may change long now = TimeUnit.NANOSECONDS.toMillis(System.nanoTime()); long deadline = protonTransport.tick(now); boolean pumpSucceeded = pumpToProtonTransport(); if (protonTransport.isClosed()) { LOG.info("IdleTimeoutCheck closed the transport due to the peer exceeding our requested idle-timeout."); if (pumpSucceeded) { fireProviderException(new IOException("Transport closed due to the peer exceeding our requested idle-timeout")); } } else { if (deadline != 0) { long delay = deadline - now; checkScheduled = true; LOG.trace("IdleTimeoutCheck rescheduling with delay: {}", delay); nextIdleTimeoutCheck = serializer.schedule(this, delay, TimeUnit.MILLISECONDS); } } } else { LOG.trace("IdleTimeoutCheck skipping check, connection is not active."); } if (!checkScheduled) { nextIdleTimeoutCheck = null; LOG.trace("IdleTimeoutCheck exiting"); } } }
@Override public void run() { boolean checkScheduled = false; if (connection.getLocalState() == EndpointState.ACTIVE) { // Using nano time since it is not related to the wall clock, which may change long now = TimeUnit.NANOSECONDS.toMillis(System.nanoTime()); long deadline = protonTransport.tick(now); boolean pumpSucceeded = pumpToProtonTransport(); if (protonTransport.isClosed()) { LOG.info("IdleTimeoutCheck closed the transport due to the peer exceeding our requested idle-timeout."); if (pumpSucceeded) { fireProviderException(new IOException("Transport closed due to the peer exceeding our requested idle-timeout")); } } else { if (deadline != 0) { long delay = deadline - now; checkScheduled = true; LOG.trace("IdleTimeoutCheck rescheduling with delay: {}", delay); nextIdleTimeoutCheck = serializer.schedule(this, delay, TimeUnit.MILLISECONDS); } } } else { LOG.trace("IdleTimeoutCheck skipping check, connection is not active."); } if (!checkScheduled) { nextIdleTimeoutCheck = null; LOG.trace("IdleTimeoutCheck exiting"); } } }
private static int pending(Selectable selectable) { Transport transport = ((SelectableImpl)selectable).getTransport(); int pending = transport.pending(); if (pending < 0) { if (transport.isClosed()) { selectable.terminate(); } } return pending; }
@Override public long tick(boolean firstTick) { if (!firstTick) { try { if (connection.getLocalState() != EndpointState.CLOSED) { long rescheduleAt = transport.tick(TimeUnit.NANOSECONDS.toMillis(System.nanoTime())); if (transport.isClosed()) { throw new IllegalStateException("Channel was inactive for to long"); } return rescheduleAt; } } catch (Exception e) { transport.close(); connection.setCondition(new ErrorCondition()); } return 0; } return transport.tick(TimeUnit.NANOSECONDS.toMillis(System.nanoTime())); }
private static int capacity(Selectable selectable) { Transport transport = ((SelectableImpl)selectable).getTransport(); int capacity = transport.capacity(); if (capacity < 0) { if (transport.isClosed()) { selectable.terminate(); } } return capacity; }
private static int pending(Selectable selectable) { Transport transport = ((SelectableImpl)selectable).getTransport(); int pending = transport.pending(); if (pending < 0) { if (transport.isClosed()) { selectable.terminate(); } } return pending; }
@Override public long keepAlive() throws IOException { long rescheduleAt = 0l; LOG.trace("Performing connection:{} keep-alive processing", amqpTransport.getRemoteAddress()); if (protonConnection.getLocalState() != EndpointState.CLOSED) { // Using nano time since it is not related to the wall clock, which may change long now = TimeUnit.NANOSECONDS.toMillis(System.nanoTime()); long deadline = protonTransport.tick(now); pumpProtonToSocket(); if (protonTransport.isClosed()) { LOG.debug("Transport closed after inactivity check."); throw new InactivityIOException("Channel was inactive for too long"); } else { if(deadline != 0) { // caller treats 0 as no-work, ensure value is at least 1 as there was a deadline rescheduleAt = Math.max(deadline - now, 1); } } } LOG.trace("Connection:{} keep alive processing done, next update in {} milliseconds.", amqpTransport.getRemoteAddress(), rescheduleAt); return rescheduleAt; }
private static int capacity(Selectable selectable) { Transport transport = ((SelectableImpl)selectable).getTransport(); int capacity = transport.capacity(); if (capacity < 0) { if (transport.isClosed()) { selectable.terminate(); } } return capacity; }
if (connection.getLocalState() != EndpointState.CLOSED) { long rescheduleAt = transport.tick(TimeUnit.NANOSECONDS.toMillis(System.nanoTime())); if (transport.isClosed()) { throw new IllegalStateException("Channel was inactive for to long");
@Override public long keepAlive() throws IOException { long rescheduleAt = 0l; LOG.trace("Performing connection:{} keep-alive processing", amqpTransport.getRemoteAddress()); if (protonConnection.getLocalState() != EndpointState.CLOSED) { // Using nano time since it is not related to the wall clock, which may change long now = TimeUnit.NANOSECONDS.toMillis(System.nanoTime()); long deadline = protonTransport.tick(now); pumpProtonToSocket(); if (protonTransport.isClosed()) { LOG.debug("Transport closed after inactivity check."); throw new InactivityIOException("Channel was inactive for too long"); } else { if(deadline != 0) { // caller treats 0 as no-work, ensure value is at least 1 as there was a deadline rescheduleAt = Math.max(deadline - now, 1); } } } LOG.trace("Connection:{} keep alive processing done, next update in {} milliseconds.", amqpTransport.getRemoteAddress(), rescheduleAt); return rescheduleAt; }
public Long tick(boolean firstTick) { requireHandler(); if (!firstTick) { try { if (connection.getLocalState() != EndpointState.CLOSED) { long rescheduleAt = transport.tick(TimeUnit.NANOSECONDS.toMillis(System.nanoTime())); if (transport.isClosed()) { throw new IllegalStateException("Channel was inactive for to long"); } return rescheduleAt; } } catch (Exception e) { log.warn(e.getMessage(), e); transport.close(); connection.setCondition(new ErrorCondition()); } finally { flush(); } return 0L; } return transport.tick(TimeUnit.NANOSECONDS.toMillis(System.nanoTime())); }
@Override public void run() { try { if (getEndpoint().getLocalState() != EndpointState.CLOSED) { LOG.debug("Client performing next idle check"); // Using nano time since it is not related to the wall clock, which may change long now = TimeUnit.NANOSECONDS.toMillis(System.nanoTime()); long deadline = protonTransport.tick(now); pumpToProtonTransport(); if (protonTransport.isClosed()) { LOG.debug("Transport closed after inactivity check."); throw new InactivityIOException("Channel was inactive for too long"); } else { if (deadline != 0) { getScheduler().schedule(this, deadline - now, TimeUnit.MILLISECONDS); } } } } catch (Exception e) { try { transport.close(); } catch (IOException e1) { } fireClientException(e); } } }, initialKeepAliveDeadline - initialNow, TimeUnit.MILLISECONDS);
@Override public void handle(Long event) { boolean checkScheduled = false; if (connection.getLocalState() == EndpointState.ACTIVE) { // Using nano time since it is not related to the wall clock, which may change long now = TimeUnit.NANOSECONDS.toMillis(System.nanoTime()); long deadline = transport.tick(now); flush(); if (transport.isClosed()) { LOG.info("IdleTimeoutCheck closed the transport due to the peer exceeding our requested idle-timeout."); disconnect(); } else { if (deadline != 0) { // timer treats 0 as error, ensure value is at least 1 as there was a deadline long delay = Math.max(deadline - now, 1); checkScheduled = true; LOG.trace("IdleTimeoutCheck rescheduling with delay: {0}", delay); idleTimeoutCheckTimerId = vertx.setTimer(delay, this); } } } else { LOG.trace("IdleTimeoutCheck skipping check, connection is not active."); } if (!checkScheduled) { idleTimeoutCheckTimerId = null; LOG.trace("IdleTimeoutCheck exiting"); } } }
if (protonTransport.isClosed()) { LOG.debug("Ignoring incoming AMQP data, transport is closed."); return;
if (protonTransport.isClosed()) { LOG.debug("Ignoring incoming AMQP data, transport is closed."); return;
try { EngineConnection engineConnection = (EngineConnection) dr.channel.getContext(); if (!engineConnection.closed && !engineConnection.transport.isClosed()) { int bytesAvailable; while ((bytesAvailable = dr.buffer.readableBytes()) > 0) {