Search in sources :

Example 1 with BaseSource

use of org.apache.qpid.server.protocol.v1_0.type.BaseSource 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 2 with BaseSource

use of org.apache.qpid.server.protocol.v1_0.type.BaseSource 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 3 with BaseSource

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

the class LinkRegistryImpl method open.

@Override
public void open() {
    Collection<LinkDefinition<Source, Target>> links = _linkStore.openAndLoad(new LinkStoreUpdaterImpl());
    for (LinkDefinition<? extends BaseSource, ? extends BaseTarget> link : links) {
        ConcurrentMap<LinkKey, Link_1_0<? extends BaseSource, ? extends BaseTarget>> linkRegistry = getLinkRegistry(link.getRole());
        linkRegistry.put(new LinkKey(link), new LinkImpl<>(link, this));
    }
}
Also used : LinkStoreUpdaterImpl(org.apache.qpid.server.protocol.v1_0.store.LinkStoreUpdaterImpl) BaseSource(org.apache.qpid.server.protocol.v1_0.type.BaseSource) BaseTarget(org.apache.qpid.server.protocol.v1_0.type.BaseTarget)

Example 4 with BaseSource

use of org.apache.qpid.server.protocol.v1_0.type.BaseSource 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 5 with BaseSource

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

the class SendingLinkEndpoint method recoverLink.

@Override
protected void recoverLink(final Attach attach) throws AmqpErrorException {
    Source source = getSource();
    if (source == null && attach.getDesiredCapabilities() != null) {
        List<Symbol> capabilities = Arrays.asList(attach.getDesiredCapabilities());
        if (capabilities.contains(Session_1_0.GLOBAL_CAPABILITY) && capabilities.contains(Session_1_0.SHARED_CAPABILITY) && getLinkName().endsWith("|global")) {
            NamedAddressSpace namedAddressSpace = getSession().getConnection().getAddressSpace();
            Collection<Link_1_0<? extends BaseSource, ? extends BaseTarget>> links = namedAddressSpace.findSendingLinks(ANY_CONTAINER_ID, Pattern.compile("^" + Pattern.quote(getLinkName()) + "$"));
            for (Link_1_0<? extends BaseSource, ? extends BaseTarget> link : links) {
                BaseSource baseSource = link.getSource();
                if (baseSource instanceof Source) {
                    Source linkSource = (Source) baseSource;
                    source = new Source(linkSource);
                    getLink().setSource(source);
                    break;
                }
            }
        }
    }
    if (source == null) {
        throw new AmqpErrorException(new Error(AmqpError.NOT_FOUND, ""));
    }
    attach.setSource(source);
    receiveAttach(attach);
}
Also used : BaseSource(org.apache.qpid.server.protocol.v1_0.type.BaseSource) Symbol(org.apache.qpid.server.protocol.v1_0.type.Symbol) NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) AmqpErrorException(org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException) TransactionError(org.apache.qpid.server.protocol.v1_0.type.transaction.TransactionError) TokenMgrError(org.apache.qpid.server.filter.selector.TokenMgrError) Error(org.apache.qpid.server.protocol.v1_0.type.transport.Error) AmqpError(org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError) MessageSource(org.apache.qpid.server.message.MessageSource) 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)

Aggregations

BaseSource (org.apache.qpid.server.protocol.v1_0.type.BaseSource)5 BaseTarget (org.apache.qpid.server.protocol.v1_0.type.BaseTarget)5 AmqpError (org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError)4 Error (org.apache.qpid.server.protocol.v1_0.type.transport.Error)4 UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)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 Source (org.apache.qpid.server.protocol.v1_0.type.messaging.Source)2 StoreException (org.apache.qpid.server.store.StoreException)2 HashSet (java.util.HashSet)1 TokenMgrError (org.apache.qpid.server.filter.selector.TokenMgrError)1 MessageSource (org.apache.qpid.server.message.MessageSource)1 NamedAddressSpace (org.apache.qpid.server.model.NamedAddressSpace)1 LinkStoreUpdaterImpl (org.apache.qpid.server.protocol.v1_0.store.LinkStoreUpdaterImpl)1 AmqpErrorException (org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException)1 Symbol (org.apache.qpid.server.protocol.v1_0.type.Symbol)1 Target (org.apache.qpid.server.protocol.v1_0.type.messaging.Target)1 TransactionError (org.apache.qpid.server.protocol.v1_0.type.transaction.TransactionError)1