public void sendFlowConditional() { if(_nextIncomingId != null) { UnsignedInteger clientsCredit = _lastSentIncomingLimit.subtract(UnsignedInteger.valueOf(_nextIncomingId.intValue())); // TODO - we should use a better metric here, and/or manage session credit across the whole connection // send a flow if the window is at least half used up if (_incomingWindow.subtract(clientsCredit).compareTo(clientsCredit) >= 0) { sendFlow(); } } }
public void sendFlowConditional() { if(_lastSentCreditLimit != null) { if(_stoppedUpdated) { sendFlow(false); _stoppedUpdated = false; } else { UnsignedInteger clientsCredit = _lastSentCreditLimit.subtract(_deliveryCount.unsignedIntegerValue()); // client has used up over half their credit allowance ? boolean sendFlow = _linkCredit.subtract(clientsCredit).compareTo(clientsCredit) >= 0; if (sendFlow) { sendFlow(false); } else { getSession().sendFlowConditional(); } } } else { sendFlow(false); } }
@Override public boolean allocateCredit(final ServerMessage msg) { ProtocolEngine protocolEngine = getSession().getConnection(); final boolean hasCredit = _linkEndpoint.isAttached() && getEndpoint().hasCreditToSend(); updateNotifyWorkDesired(); if (hasCredit) { _linkEndpoint.setLinkCredit(_linkEndpoint.getLinkCredit().subtract(UnsignedInteger.ONE)); } return hasCredit; }
void transfer(final Transfer xfr, final boolean decrementCredit) { Session_1_0 s = getSession(); xfr.setMessageFormat(UnsignedInteger.ZERO); if(decrementCredit) { setLinkCredit(getLinkCredit().subtract(UnsignedInteger.ONE)); } getDeliveryCount().incr(); xfr.setHandle(getLocalHandle()); s.sendTransfer(xfr, this); }
public void receiveTransfer(final Transfer transfer) { _nextIncomingId.incr(); _remoteOutgoingWindow = _remoteOutgoingWindow.subtract(UnsignedInteger.ONE); UnsignedInteger inputHandle = transfer.getHandle(); LinkEndpoint<? extends BaseSource, ? extends BaseTarget> linkEndpoint = _inputHandleToEndpoint.get(inputHandle); if (linkEndpoint == null) { Error error = new Error(); error.setCondition(SessionError.UNATTACHED_HANDLE); error.setDescription("TRANSFER called on Session for link handle " + inputHandle + " which is not attached."); _connection.close(error); } else if(!(linkEndpoint instanceof AbstractReceivingLinkEndpoint)) { Error error = new Error(); error.setCondition(AmqpError.PRECONDITION_FAILED); error.setDescription("Received TRANSFER for link handle " + inputHandle + " which is a sending link not a receiving link."); _connection.close(error); } else { AbstractReceivingLinkEndpoint endpoint = ((AbstractReceivingLinkEndpoint) linkEndpoint); endpoint.receiveTransfer(transfer); } }
setLinkCredit(getLinkCredit().subtract(UnsignedInteger.ONE)); getDeliveryCount().incr();