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)));
}
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);
}
}
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;
}
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);
}
}
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);
}
Aggregations