Search in sources :

Example 6 with LinkEndpoint

use of org.apache.qpid.server.protocol.v1_0.LinkEndpoint 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)

Example 7 with LinkEndpoint

use of org.apache.qpid.server.protocol.v1_0.LinkEndpoint 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 8 with LinkEndpoint

use of org.apache.qpid.server.protocol.v1_0.LinkEndpoint 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 9 with LinkEndpoint

use of org.apache.qpid.server.protocol.v1_0.LinkEndpoint 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 10 with LinkEndpoint

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

the class Session_1_0 method updateSourceForSubscription.

public boolean updateSourceForSubscription(final SendingLinkEndpoint linkEndpoint, final Source newSource, final SendingDestination newDestination) {
    SendingDestination oldDestination = linkEndpoint.getDestination();
    if (oldDestination instanceof ExchangeSendingDestination) {
        ExchangeSendingDestination oldExchangeDestination = (ExchangeSendingDestination) oldDestination;
        String newAddress = newSource.getAddress();
        if (newDestination instanceof ExchangeSendingDestination) {
            ExchangeSendingDestination newExchangeDestination = (ExchangeSendingDestination) newDestination;
            if (oldExchangeDestination.getQueue() != newExchangeDestination.getQueue()) {
                Source oldSource = linkEndpoint.getSource();
                oldSource.setAddress(newAddress);
                oldSource.setFilter(newSource.getFilter());
                return true;
            }
        }
    }
    return false;
}
Also used : MessageSource(org.apache.qpid.server.message.MessageSource) BaseSource(org.apache.qpid.server.protocol.v1_0.type.BaseSource) Source(org.apache.qpid.server.protocol.v1_0.type.messaging.Source)

Aggregations

UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)6 AmqpError (org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError)5 Error (org.apache.qpid.server.protocol.v1_0.type.transport.Error)5 LinkError (org.apache.qpid.server.protocol.v1_0.type.transport.LinkError)5 BaseSource (org.apache.qpid.server.protocol.v1_0.type.BaseSource)3 SessionError (org.apache.qpid.server.protocol.v1_0.type.transport.SessionError)3 BaseTarget (org.apache.qpid.server.protocol.v1_0.type.BaseTarget)2 Source (org.apache.qpid.server.protocol.v1_0.type.messaging.Source)2 Role (org.apache.qpid.server.protocol.v1_0.type.transport.Role)2 HashSet (java.util.HashSet)1 ExecutionException (java.util.concurrent.ExecutionException)1 MessageSource (org.apache.qpid.server.message.MessageSource)1 DeliveryRegistry (org.apache.qpid.server.protocol.v1_0.delivery.DeliveryRegistry)1 UnsettledDelivery (org.apache.qpid.server.protocol.v1_0.delivery.UnsettledDelivery)1 AmqpErrorException (org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException)1 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)1 Coordinator (org.apache.qpid.server.protocol.v1_0.type.transaction.Coordinator)1 Detach (org.apache.qpid.server.protocol.v1_0.type.transport.Detach)1 End (org.apache.qpid.server.protocol.v1_0.type.transport.End)1 ConnectionScopedRuntimeException (org.apache.qpid.server.util.ConnectionScopedRuntimeException)1