Search in sources :

Example 6 with BaseTarget

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

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

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

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

BaseSource (org.apache.qpid.server.protocol.v1_0.type.BaseSource)5 BaseTarget (org.apache.qpid.server.protocol.v1_0.type.BaseTarget)5 AmqpError (org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError)4 Error (org.apache.qpid.server.protocol.v1_0.type.transport.Error)4 UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)3 LinkError (org.apache.qpid.server.protocol.v1_0.type.transport.LinkError)3 SessionError (org.apache.qpid.server.protocol.v1_0.type.transport.SessionError)3 PreparedStatement (java.sql.PreparedStatement)2 LinkKey (org.apache.qpid.server.protocol.v1_0.LinkKey)2 Source (org.apache.qpid.server.protocol.v1_0.type.messaging.Source)2 StoreException (org.apache.qpid.server.store.StoreException)2 HashSet (java.util.HashSet)1 TokenMgrError (org.apache.qpid.server.filter.selector.TokenMgrError)1 MessageSource (org.apache.qpid.server.message.MessageSource)1 NamedAddressSpace (org.apache.qpid.server.model.NamedAddressSpace)1 LinkStoreUpdaterImpl (org.apache.qpid.server.protocol.v1_0.store.LinkStoreUpdaterImpl)1 AmqpErrorException (org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException)1 Symbol (org.apache.qpid.server.protocol.v1_0.type.Symbol)1 Target (org.apache.qpid.server.protocol.v1_0.type.messaging.Target)1 TransactionError (org.apache.qpid.server.protocol.v1_0.type.transaction.TransactionError)1