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