Search in sources :

Example 31 with UnsignedInteger

use of org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger in project qpid-broker-j by apache.

the class Session_1_0 method receiveTransfer.

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);
    }
}
Also used : Error(org.apache.qpid.server.protocol.v1_0.type.transport.Error) AmqpError(org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError) SessionError(org.apache.qpid.server.protocol.v1_0.type.transport.SessionError) LinkError(org.apache.qpid.server.protocol.v1_0.type.transport.LinkError) UnsignedInteger(org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)

Example 32 with UnsignedInteger

use of org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger in project qpid-broker-j by apache.

the class Session_1_0 method receiveAttach.

public void receiveAttach(final Attach attach) {
    receivedComplete();
    if (_sessionState == SessionState.ACTIVE) {
        UnsignedInteger inputHandle = attach.getHandle();
        if (_inputHandleToEndpoint.containsKey(inputHandle)) {
            String errorMessage = String.format("Input Handle '%d' already in use", inputHandle.intValue());
            getConnection().close(new Error(SessionError.HANDLE_IN_USE, errorMessage));
            throw new ConnectionScopedRuntimeException(errorMessage);
        } else {
            final Link_1_0<? extends BaseSource, ? extends BaseTarget> link;
            if (attach.getRole() == Role.RECEIVER) {
                link = getAddressSpace().getSendingLink(getConnection().getRemoteContainerId(), attach.getName());
            } else {
                link = getAddressSpace().getReceivingLink(getConnection().getRemoteContainerId(), attach.getName());
            }
            final ListenableFuture<? extends LinkEndpoint<?, ?>> future = link.attach(this, attach);
            addFutureCallback(future, new EndpointCreationCallback(attach), MoreExecutors.directExecutor());
        }
    }
}
Also used : ConnectionScopedRuntimeException(org.apache.qpid.server.util.ConnectionScopedRuntimeException) Error(org.apache.qpid.server.protocol.v1_0.type.transport.Error) AmqpError(org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError) SessionError(org.apache.qpid.server.protocol.v1_0.type.transport.SessionError) LinkError(org.apache.qpid.server.protocol.v1_0.type.transport.LinkError) UnsignedInteger(org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)

Example 33 with UnsignedInteger

use of org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger 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 34 with UnsignedInteger

use of org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger 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 35 with UnsignedInteger

use of org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger in project qpid-broker-j by apache.

the class Session_1_0 method receiveFlow.

public void receiveFlow(final Flow flow) {
    receivedComplete();
    final SequenceNumber flowNextIncomingId = new SequenceNumber(flow.getNextIncomingId() == null ? _initialOutgoingId.intValue() : flow.getNextIncomingId().intValue());
    if (flowNextIncomingId.compareTo(_nextOutgoingId) > 0) {
        final End end = new End();
        end.setError(new Error(SessionError.WINDOW_VIOLATION, String.format("Next incoming id '%d' exceeds next outgoing id '%d'", flowNextIncomingId.longValue(), _nextOutgoingId.longValue())));
        end(end);
    } else {
        _remoteIncomingWindow = flowNextIncomingId.longValue() + flow.getIncomingWindow().longValue() - _nextOutgoingId.longValue();
        _nextIncomingId = new SequenceNumber(flow.getNextOutgoingId().intValue());
        _remoteOutgoingWindow = flow.getOutgoingWindow();
        UnsignedInteger handle = flow.getHandle();
        if (handle != null) {
            final LinkEndpoint<? extends BaseSource, ? extends BaseTarget> endpoint = _inputHandleToEndpoint.get(handle);
            if (endpoint == null) {
                End end = new End();
                end.setError(new Error(SessionError.UNATTACHED_HANDLE, String.format("Received Flow with unknown handle %d", handle.intValue())));
                end(end);
            } else {
                endpoint.receiveFlow(flow);
            }
        } else {
            final Collection<LinkEndpoint<? extends BaseSource, ? extends BaseTarget>> allLinkEndpoints = _inputHandleToEndpoint.values();
            for (LinkEndpoint<? extends BaseSource, ? extends BaseTarget> le : allLinkEndpoints) {
                le.flowStateChanged();
            }
            if (Boolean.TRUE.equals(flow.getEcho())) {
                sendFlow();
            }
        }
    }
}
Also used : BaseSource(org.apache.qpid.server.protocol.v1_0.type.BaseSource) Error(org.apache.qpid.server.protocol.v1_0.type.transport.Error) AmqpError(org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError) SessionError(org.apache.qpid.server.protocol.v1_0.type.transport.SessionError) LinkError(org.apache.qpid.server.protocol.v1_0.type.transport.LinkError) End(org.apache.qpid.server.protocol.v1_0.type.transport.End) UnsignedInteger(org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger) BaseTarget(org.apache.qpid.server.protocol.v1_0.type.BaseTarget)

Aggregations

UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)57 FrameTransport (org.apache.qpid.tests.protocol.v1_0.FrameTransport)35 Test (org.junit.Test)35 Interaction (org.apache.qpid.tests.protocol.v1_0.Interaction)33 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)29 Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)25 Disposition (org.apache.qpid.server.protocol.v1_0.type.transport.Disposition)20 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)18 Flow (org.apache.qpid.server.protocol.v1_0.type.transport.Flow)17 Open (org.apache.qpid.server.protocol.v1_0.type.transport.Open)14 InteractionTransactionalState (org.apache.qpid.tests.protocol.v1_0.InteractionTransactionalState)13 Error (org.apache.qpid.server.protocol.v1_0.type.transport.Error)12 AmqpError (org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError)11 Begin (org.apache.qpid.server.protocol.v1_0.type.transport.Begin)11 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)9 DeliveryState (org.apache.qpid.server.protocol.v1_0.type.DeliveryState)8 TransactionError (org.apache.qpid.server.protocol.v1_0.type.transaction.TransactionError)7 InetSocketAddress (java.net.InetSocketAddress)6 Detach (org.apache.qpid.server.protocol.v1_0.type.transport.Detach)6 Transfer (org.apache.qpid.server.protocol.v1_0.type.transport.Transfer)6