Search in sources :

Example 11 with End

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

the class Session_1_0 method receiveEnd.

public void receiveEnd(final End end) {
    receivedComplete();
    switch(_sessionState) {
        case END_SENT:
            remoteEnd(end);
            _sessionState = SessionState.ENDED;
            break;
        case ACTIVE:
            _sessionState = SessionState.END_RECVD;
            detachLinks();
            remoteEnd(end);
            _connection.sendEnd(_sendingChannel, new End(), true);
            _sessionState = SessionState.ENDED;
            break;
        default:
            End reply = new End();
            Error error = new Error();
            error.setCondition(AmqpError.ILLEGAL_STATE);
            error.setDescription("END called on Session which has not been opened");
            reply.setError(error);
            _connection.sendEnd(_sendingChannel, reply, true);
            break;
    }
}
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) End(org.apache.qpid.server.protocol.v1_0.type.transport.End)

Example 12 with End

use of org.apache.qpid.server.protocol.v1_0.type.transport.End 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 13 with End

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

the class Session_1_0 method remoteEnd.

void remoteEnd(End end) {
    Set<LinkEndpoint<? extends BaseSource, ? extends BaseTarget>> associatedLinkEndpoints = new HashSet<>(_associatedLinkEndpoints);
    for (LinkEndpoint<? extends BaseSource, ? extends BaseTarget> linkEndpoint : associatedLinkEndpoints) {
        linkEndpoint.remoteDetached(new Detach());
        linkEndpoint.destroy();
    }
    _associatedLinkEndpoints.clear();
    _connection.sessionEnded(this);
    performCloseTasks();
}
Also used : BaseSource(org.apache.qpid.server.protocol.v1_0.type.BaseSource) Detach(org.apache.qpid.server.protocol.v1_0.type.transport.Detach) BaseTarget(org.apache.qpid.server.protocol.v1_0.type.BaseTarget) HashSet(java.util.HashSet)

Example 14 with End

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

the class Session_1_0 method close.

public void close(ErrorCondition condition, String message) {
    performCloseTasks();
    final End end = new End();
    final Error theError = new Error();
    theError.setDescription(message);
    theError.setCondition(condition);
    end.setError(theError);
    end(end);
}
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) End(org.apache.qpid.server.protocol.v1_0.type.transport.End)

Example 15 with End

use of org.apache.qpid.server.protocol.v1_0.type.transport.End 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

End (org.apache.qpid.server.protocol.v1_0.type.transport.End)15 Error (org.apache.qpid.server.protocol.v1_0.type.transport.Error)11 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)8 Test (org.junit.Test)8 AmqpError (org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError)7 Open (org.apache.qpid.server.protocol.v1_0.type.transport.Open)6 FrameTransport (org.apache.qpid.tests.protocol.v1_0.FrameTransport)6 Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)5 Begin (org.apache.qpid.server.protocol.v1_0.type.transport.Begin)5 Detach (org.apache.qpid.server.protocol.v1_0.type.transport.Detach)5 LinkError (org.apache.qpid.server.protocol.v1_0.type.transport.LinkError)5 SessionError (org.apache.qpid.server.protocol.v1_0.type.transport.SessionError)5 Close (org.apache.qpid.server.protocol.v1_0.type.transport.Close)4 Interaction (org.apache.qpid.tests.protocol.v1_0.Interaction)4 InetSocketAddress (java.net.InetSocketAddress)3 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)3 UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 DeliveryRegistry (org.apache.qpid.server.protocol.v1_0.delivery.DeliveryRegistry)2