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