Search in sources :

Example 1 with BaseTarget

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

the class JDBCLinkStore method insert.

private void insert(final Connection connection, final String linkKey, final LinkDefinition<? extends BaseSource, ? extends BaseTarget> linkDefinition) throws SQLException {
    try (PreparedStatement statement = connection.prepareStatement(String.format("INSERT INTO %s (link_key, remote_container_id, link_name, link_role, source, target) VALUES (?,?,?,?,?,?)", getLinksTableName()))) {
        statement.setString(1, linkKey);
        saveStringAsBlob(statement, 2, linkDefinition.getRemoteContainerId());
        saveStringAsBlob(statement, 3, linkDefinition.getName());
        statement.setInt(4, linkDefinition.getRole().getValue() ? 1 : 0);
        saveObjectAsBlob(statement, 5, linkDefinition.getSource());
        saveObjectAsBlob(statement, 6, linkDefinition.getTarget());
        if (statement.executeUpdate() != 1) {
            throw new StoreException(String.format("Cannot save link %s", new LinkKey(linkDefinition)));
        }
    }
}
Also used : LinkKey(org.apache.qpid.server.protocol.v1_0.LinkKey) PreparedStatement(java.sql.PreparedStatement) StoreException(org.apache.qpid.server.store.StoreException)

Example 2 with BaseTarget

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

the class Interaction method copyAttach.

private Attach copyAttach(final Attach attach) {
    final Attach attachCopy = new Attach();
    attachCopy.setName(attach.getName());
    attachCopy.setHandle(attach.getHandle());
    attachCopy.setRole(attach.getRole());
    attachCopy.setSndSettleMode(attach.getSndSettleMode());
    attachCopy.setRcvSettleMode(attach.getRcvSettleMode());
    final BaseSource baseSource = attach.getSource();
    if (baseSource != null && baseSource instanceof Source) {
        final Source source = (Source) baseSource;
        final Source sourceCopy = new Source();
        sourceCopy.setAddress(source.getAddress());
        sourceCopy.setDurable(source.getDurable());
        sourceCopy.setExpiryPolicy(source.getExpiryPolicy());
        sourceCopy.setTimeout(source.getTimeout());
        sourceCopy.setDynamic(source.getDynamic());
        if (source.getDynamicNodeProperties() != null) {
            sourceCopy.setDynamicNodeProperties(new LinkedHashMap<>(source.getDynamicNodeProperties()));
        }
        sourceCopy.setFilter(source.getFilter());
        sourceCopy.setDefaultOutcome(source.getDefaultOutcome());
        sourceCopy.setOutcomes(source.getOutcomes());
        sourceCopy.setCapabilities(source.getCapabilities());
        attachCopy.setSource(sourceCopy);
    } else {
        attachCopy.setSource(baseSource);
    }
    final BaseTarget baseTarget = attach.getTarget();
    if (baseTarget != null && baseTarget instanceof Target) {
        final Target target = (Target) baseTarget;
        final Target targetCopy = new Target();
        targetCopy.setAddress(target.getAddress());
        targetCopy.setDurable(target.getDurable());
        targetCopy.setExpiryPolicy(target.getExpiryPolicy());
        targetCopy.setTimeout(target.getTimeout());
        targetCopy.setDynamic(target.getDynamic());
        if (target.getDynamicNodeProperties() != null) {
            targetCopy.setDynamicNodeProperties(new LinkedHashMap<>(target.getDynamicNodeProperties()));
        }
        targetCopy.setCapabilities(target.getCapabilities());
        attachCopy.setTarget(targetCopy);
    } else {
        attachCopy.setTarget(baseTarget);
    }
    if (attach.getUnsettled() != null) {
        attachCopy.setUnsettled(new LinkedHashMap<>(attach.getUnsettled()));
    }
    attachCopy.setIncompleteUnsettled(attach.getIncompleteUnsettled());
    attachCopy.setInitialDeliveryCount(attach.getInitialDeliveryCount());
    attachCopy.setMaxMessageSize(attach.getMaxMessageSize());
    attachCopy.setOfferedCapabilities(attach.getOfferedCapabilities());
    attachCopy.setDesiredCapabilities(attach.getDesiredCapabilities());
    if (attach.getProperties() != null) {
        attachCopy.setProperties(new LinkedHashMap<>(attach.getProperties()));
    }
    return attachCopy;
}
Also used : BaseTarget(org.apache.qpid.server.protocol.v1_0.type.BaseTarget) Target(org.apache.qpid.server.protocol.v1_0.type.messaging.Target) BaseSource(org.apache.qpid.server.protocol.v1_0.type.BaseSource) Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) BaseSource(org.apache.qpid.server.protocol.v1_0.type.BaseSource) Source(org.apache.qpid.server.protocol.v1_0.type.messaging.Source) BaseTarget(org.apache.qpid.server.protocol.v1_0.type.BaseTarget)

Example 3 with BaseTarget

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

the class JDBCLinkStore method update.

private void update(final Connection connection, final String linkKey, final LinkDefinition<? extends BaseSource, ? extends BaseTarget> linkDefinition) throws SQLException {
    try (PreparedStatement statement = connection.prepareStatement(String.format("UPDATE %s SET source = ?, target = ? WHERE link_key = ?", getLinksTableName()))) {
        saveObjectAsBlob(statement, 1, linkDefinition.getSource());
        saveObjectAsBlob(statement, 2, linkDefinition.getTarget());
        statement.setString(3, linkKey);
        if (statement.executeUpdate() != 1) {
            throw new StoreException(String.format("Cannot save link %s", new LinkKey(linkDefinition)));
        }
    }
}
Also used : LinkKey(org.apache.qpid.server.protocol.v1_0.LinkKey) PreparedStatement(java.sql.PreparedStatement) StoreException(org.apache.qpid.server.store.StoreException)

Example 4 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)

Example 5 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)

Aggregations

BaseSource (org.apache.qpid.server.protocol.v1_0.type.BaseSource)3 BaseTarget (org.apache.qpid.server.protocol.v1_0.type.BaseTarget)3 UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)3 AmqpError (org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError)3 Error (org.apache.qpid.server.protocol.v1_0.type.transport.Error)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 StoreException (org.apache.qpid.server.store.StoreException)2 HashSet (java.util.HashSet)1 Source (org.apache.qpid.server.protocol.v1_0.type.messaging.Source)1 Target (org.apache.qpid.server.protocol.v1_0.type.messaging.Target)1 Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)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