use of org.apache.qpid.server.protocol.v1_0.delivery.DeliveryRegistry in project qpid-broker-j by apache.
the class Session_1_0 method updateDisposition.
private void updateDisposition(final Role role, final UnsignedInteger first, final UnsignedInteger last, final DeliveryState state, final boolean settled) {
Disposition disposition = new Disposition();
disposition.setRole(role);
disposition.setFirst(first);
disposition.setLast(last);
disposition.setSettled(settled);
disposition.setState(state);
if (settled) {
final DeliveryRegistry deliveryRegistry = role == Role.RECEIVER ? _incomingDeliveryRegistry : _outgoingDeliveryRegistry;
SequenceNumber pos = new SequenceNumber(first.intValue());
SequenceNumber end = new SequenceNumber(last.intValue());
while (pos.compareTo(end) <= 0) {
deliveryRegistry.removeDelivery(UnsignedInteger.valueOf(pos.intValue()));
pos.incr();
}
}
send(disposition);
}
use of org.apache.qpid.server.protocol.v1_0.delivery.DeliveryRegistry in project qpid-broker-j by apache.
the class Session_1_0 method updateDisposition.
void updateDisposition(final Role role, final Set<Binary> deliveryTags, final DeliveryState state, final boolean settled) {
final DeliveryRegistry deliveryRegistry = role == Role.RECEIVER ? _incomingDeliveryRegistry : _outgoingDeliveryRegistry;
SortedSet<UnsignedInteger> deliveryIds = deliveryTags.stream().map(deliveryRegistry::getDeliveryIdByTag).collect(Collectors.toCollection(TreeSet::new));
final Iterator<UnsignedInteger> iterator = deliveryIds.iterator();
if (iterator.hasNext()) {
UnsignedInteger begin = iterator.next();
UnsignedInteger end = begin;
while (iterator.hasNext()) {
final UnsignedInteger deliveryId = iterator.next();
if (!end.add(UnsignedInteger.ONE).equals(deliveryId)) {
updateDisposition(role, begin, end, state, settled);
begin = deliveryId;
end = begin;
} else {
end = deliveryId;
}
}
updateDisposition(role, begin, end, state, settled);
}
}
use of org.apache.qpid.server.protocol.v1_0.delivery.DeliveryRegistry in project qpid-broker-j by apache.
the class Session_1_0 method updateDisposition.
void updateDisposition(final Role role, final Binary deliveryTag, final DeliveryState state, final boolean settled) {
final DeliveryRegistry deliveryRegistry = role == Role.RECEIVER ? _incomingDeliveryRegistry : _outgoingDeliveryRegistry;
UnsignedInteger deliveryId = deliveryRegistry.getDeliveryIdByTag(deliveryTag);
if (deliveryId == null) {
throw new ConnectionScopedRuntimeException(String.format("Delivery with tag '%s' is not found in unsettled deliveries", deliveryTag));
}
updateDisposition(role, deliveryId, deliveryId, state, settled);
}
use of org.apache.qpid.server.protocol.v1_0.delivery.DeliveryRegistry in project qpid-broker-j by apache.
the class Session_1_0 method receiveDisposition.
public void receiveDisposition(final Disposition disposition) {
Role dispositionRole = disposition.getRole();
DeliveryRegistry unsettledDeliveries;
if (dispositionRole == Role.RECEIVER) {
unsettledDeliveries = _outgoingDeliveryRegistry;
} else {
unsettledDeliveries = _incomingDeliveryRegistry;
}
SequenceNumber deliveryId = new SequenceNumber(disposition.getFirst().intValue());
SequenceNumber last;
if (disposition.getLast() == null) {
last = new SequenceNumber(deliveryId.intValue());
} else {
last = new SequenceNumber(disposition.getLast().intValue());
}
while (deliveryId.compareTo(last) <= 0) {
UnsignedInteger deliveryIdUnsigned = UnsignedInteger.valueOf(deliveryId.intValue());
UnsettledDelivery unsettledDelivery = unsettledDeliveries.getDelivery(deliveryIdUnsigned);
if (unsettledDelivery != null) {
LinkEndpoint<?, ?> linkEndpoint = unsettledDelivery.getLinkEndpoint();
linkEndpoint.receiveDeliveryState(unsettledDelivery.getDeliveryTag(), disposition.getState(), disposition.getSettled());
if (Boolean.TRUE.equals(disposition.getSettled())) {
unsettledDeliveries.removeDelivery(deliveryIdUnsigned);
}
}
deliveryId.incr();
}
}
Aggregations