Search in sources :

Example 1 with DeliveryRegistry

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);
}
Also used : Disposition(org.apache.qpid.server.protocol.v1_0.type.transport.Disposition) DeliveryRegistry(org.apache.qpid.server.protocol.v1_0.delivery.DeliveryRegistry)

Example 2 with DeliveryRegistry

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);
    }
}
Also used : UnsignedInteger(org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger) DeliveryRegistry(org.apache.qpid.server.protocol.v1_0.delivery.DeliveryRegistry)

Example 3 with DeliveryRegistry

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);
}
Also used : ConnectionScopedRuntimeException(org.apache.qpid.server.util.ConnectionScopedRuntimeException) UnsignedInteger(org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger) DeliveryRegistry(org.apache.qpid.server.protocol.v1_0.delivery.DeliveryRegistry)

Example 4 with DeliveryRegistry

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();
    }
}
Also used : Role(org.apache.qpid.server.protocol.v1_0.type.transport.Role) UnsettledDelivery(org.apache.qpid.server.protocol.v1_0.delivery.UnsettledDelivery) UnsignedInteger(org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger) DeliveryRegistry(org.apache.qpid.server.protocol.v1_0.delivery.DeliveryRegistry)

Aggregations

DeliveryRegistry (org.apache.qpid.server.protocol.v1_0.delivery.DeliveryRegistry)4 UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)3 UnsettledDelivery (org.apache.qpid.server.protocol.v1_0.delivery.UnsettledDelivery)1 Disposition (org.apache.qpid.server.protocol.v1_0.type.transport.Disposition)1 Role (org.apache.qpid.server.protocol.v1_0.type.transport.Role)1 ConnectionScopedRuntimeException (org.apache.qpid.server.util.ConnectionScopedRuntimeException)1