Search in sources :

Example 1 with LinkEndpoint

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

the class UnsettledDeliveryTest method testNotEqualsWhenLinkEndpointIsDifferent.

@Test
public void testNotEqualsWhenLinkEndpointIsDifferent() {
    final LinkEndpoint<?, ?> linkEndpoint = mock(LinkEndpoint.class);
    assertThat(_unsettledDelivery.equals(new UnsettledDelivery(new Binary(new byte[] { (byte) 32, (byte) 33 }), linkEndpoint)), is(equalTo(false)));
}
Also used : Binary(org.apache.qpid.server.protocol.v1_0.type.Binary) Test(org.junit.Test)

Example 2 with LinkEndpoint

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

the class LinkImpl method attach.

@Override
public final synchronized ListenableFuture<? extends LinkEndpoint<S, T>> attach(final Session_1_0 session, final Attach attach) {
    try {
        if (_role == attach.getRole()) {
            throw new AmqpErrorException(new Error(AmqpError.ILLEGAL_STATE, "Cannot switch SendingLink to ReceivingLink and vice versa"));
        }
        if (_linkEndpoint != null && !session.equals(_linkEndpoint.getSession())) {
            SettableFuture<LinkEndpoint<S, T>> future = SettableFuture.create();
            _thiefQueue.add(new ThiefInformation(session, attach, future));
            startLinkStealingIfNecessary();
            return future;
        } else {
            if (_linkEndpoint == null) {
                _linkEndpoint = createLinkEndpoint(session, attach);
            }
            _linkEndpoint.receiveAttach(attach);
            _linkRegistry.linkChanged(this);
            return Futures.immediateFuture(_linkEndpoint);
        }
    } catch (Exception e) {
        LOGGER.debug("Error attaching link", e);
        return rejectLink(session, e);
    }
}
Also used : AmqpErrorException(org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException) Error(org.apache.qpid.server.protocol.v1_0.type.transport.Error) AmqpError(org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError) LinkError(org.apache.qpid.server.protocol.v1_0.type.transport.LinkError) AmqpErrorException(org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException) ExecutionException(java.util.concurrent.ExecutionException)

Example 3 with LinkEndpoint

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

the class LinkImpl method doStealLink.

private ListenableFuture<LinkEndpoint<S, T>> doStealLink(final Session_1_0 session, final Attach attach) {
    final SettableFuture<LinkEndpoint<S, T>> returnFuture = SettableFuture.create();
    final LinkEndpoint<S, T> linkEndpoint = _linkEndpoint;
    // check whether linkEndpoint has been closed in the mean time
    if (linkEndpoint != null) {
        linkEndpoint.getSession().doOnIOThreadAsync(() -> {
            // check whether linkEndpoint has been closed in the mean time
            LinkEndpoint<S, T> endpoint = _linkEndpoint;
            if (endpoint != null) {
                endpoint.close(new Error(LinkError.STOLEN, String.format("Link is being stolen by connection '%s'", session.getConnection())));
            }
            doLinkStealAndHandleExceptions(session, attach, returnFuture);
        });
    } else {
        doLinkStealAndHandleExceptions(session, attach, returnFuture);
    }
    return returnFuture;
}
Also used : Error(org.apache.qpid.server.protocol.v1_0.type.transport.Error) AmqpError(org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError) LinkError(org.apache.qpid.server.protocol.v1_0.type.transport.LinkError)

Example 4 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 updateDisposition.

void updateDisposition(final LinkEndpoint<?, ?> linkEndpoint, final Set<Binary> deliveryTags, final DeliveryState state, final boolean settled) {
    final Role role = linkEndpoint.getRole();
    final Iterator<UnsignedInteger> iterator = getDeliveryIds(deliveryTags, linkEndpoint).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 : Role(org.apache.qpid.server.protocol.v1_0.type.transport.Role) UnsignedInteger(org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)

Example 5 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 updateDisposition.

void updateDisposition(final LinkEndpoint<?, ?> linkEndpoint, final Binary deliveryTag, final DeliveryState state, final boolean settled) {
    final UnsignedInteger deliveryId = getDeliveryId(deliveryTag, linkEndpoint);
    updateDisposition(linkEndpoint.getRole(), deliveryId, deliveryId, state, settled);
}
Also used : UnsignedInteger(org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)

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