Added: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/NullLinkStoreFactory.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/NullLinkStoreFactory.java?rev=1787994&view=auto ============================================================================== --- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/NullLinkStoreFactory.java (added) +++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/NullLinkStoreFactory.java Tue Mar 21 15:30:44 2017 @@ -0,0 +1,94 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +package org.apache.qpid.server.protocol.v1_0; + +import java.util.Collection; +import java.util.Collections; + +import org.apache.qpid.server.model.NamedAddressSpace; +import org.apache.qpid.server.plugin.PluggableService; +import org.apache.qpid.server.protocol.v1_0.store.LinkStore; +import org.apache.qpid.server.protocol.v1_0.store.LinkStoreFactory; +import org.apache.qpid.server.protocol.v1_0.store.LinkStoreUpdater; +import org.apache.qpid.server.protocol.v1_0.type.messaging.TerminusDurability; +import org.apache.qpid.server.store.StoreException; + +@PluggableService +public class NullLinkStoreFactory implements LinkStoreFactory +{ + @Override + public String getType() + { + return "NULL"; + } + + @Override + public LinkStore create(final NamedAddressSpace addressSpace) + { + return new LinkStore() + { + @Override + public Collection<LinkDefinition> openAndLoad(final LinkStoreUpdater updater) + throws StoreException, StoreException + { + return Collections.emptyList(); + } + + @Override + public void close() + { + } + + @Override + public void saveLink(final LinkDefinition link) + { + } + + @Override + public void deleteLink(final LinkDefinition link) + { + } + + @Override + public void delete() + { + } + + @Override + public TerminusDurability getHighestSupportedTerminusDurability() + { + return TerminusDurability.NONE; + } + }; + } + + @Override + public boolean supports(final NamedAddressSpace addressSpace) + { + return true; + } + + @Override + public int getPriority() + { + return Integer.MIN_VALUE; + } +}
Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLinkEndpoint.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLinkEndpoint.java?rev=1787994&r1=1787993&r2=1787994&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLinkEndpoint.java (original) +++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLinkEndpoint.java Tue Mar 21 15:30:44 2017 @@ -62,6 +62,7 @@ import org.apache.qpid.server.protocol.v import org.apache.qpid.server.protocol.v1_0.type.messaging.StdDistMode; import org.apache.qpid.server.protocol.v1_0.type.messaging.Target; import org.apache.qpid.server.protocol.v1_0.type.messaging.TerminusDurability; +import org.apache.qpid.server.protocol.v1_0.type.messaging.TerminusExpiryPolicy; import org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError; import org.apache.qpid.server.protocol.v1_0.type.transport.Attach; import org.apache.qpid.server.protocol.v1_0.type.transport.Detach; @@ -503,11 +504,12 @@ public class SendingLinkEndpoint extends protected void remoteDetachedPerformDetach(final Detach detach) { getConsumerTarget().close(); - //TODO - // if not durable or close + + TerminusExpiryPolicy expiryPolicy = ((Source) getSource()).getExpiryPolicy(); if (Boolean.TRUE.equals(detach.getClosed()) - || !(TerminusDurability.UNSETTLED_STATE.equals(getTerminusDurability()) - || TerminusDurability.CONFIGURATION.equals(getTerminusDurability()))) + || TerminusExpiryPolicy.LINK_DETACH.equals(expiryPolicy) + || (TerminusExpiryPolicy.SESSION_END.equals(expiryPolicy) && getSession().isClosing()) + || (TerminusExpiryPolicy.CONNECTION_CLOSE.equals(expiryPolicy) && getSession().getConnection().isClosing())) { Modified state = new Modified(); @@ -520,15 +522,11 @@ public class SendingLinkEndpoint extends _unsettledActionMap.clear(); if (getDestination() instanceof ExchangeDestination - && (getTerminusDurability() == TerminusDurability.CONFIGURATION - || getTerminusDurability() == TerminusDurability.UNSETTLED_STATE)) + && getSession().getConnection().getAddressSpace() instanceof QueueManagingVirtualHost) { try { - if (getSession().getConnection().getAddressSpace() instanceof QueueManagingVirtualHost) - { - ((QueueManagingVirtualHost) getSession().getConnection().getAddressSpace()).removeSubscriptionQueue(((ExchangeDestination) getDestination()).getQueue().getName()); - } + ((QueueManagingVirtualHost) getSession().getConnection().getAddressSpace()).removeSubscriptionQueue(((ExchangeDestination) getDestination()).getQueue().getName()); } catch (AccessControlException e) { @@ -641,13 +639,15 @@ public class SendingLinkEndpoint extends source = new Source(); Source attachSource = (Source) attach.getSource(); - final SendingDestination destination = getSession().getSendingDestination(attach.getName(), attachSource); source.setAddress(attachSource.getAddress()); source.setDynamic(attachSource.getDynamic()); - source.setDurable(attachSource.getDurable()); + source.setDurable(TerminusDurability.min(attachSource.getDurable(), + getLink().getHighestSupportedTerminusDurability())); source.setExpiryPolicy(attachSource.getExpiryPolicy()); source.setDistributionMode(attachSource.getDistributionMode()); source.setFilter(attachSource.getFilter()); + source.setCapabilities(attachSource.getCapabilities()); + final SendingDestination destination = getSession().getSendingDestination(attach.getName(), source); source.setCapabilities(destination.getCapabilities()); if (destination instanceof ExchangeDestination) { Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/Session_1_0.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/Session_1_0.java?rev=1787994&r1=1787993&r2=1787994&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/Session_1_0.java (original) +++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/Session_1_0.java Tue Mar 21 15:30:44 2017 @@ -361,6 +361,7 @@ public class Session_1_0 extends Abstrac _sessionState = SessionState.ENDED; break; case ACTIVE: + _sessionState = SessionState.END_RECVD; detachLinks(); remoteEnd(end); _connection.sendEnd(_sendingChannel, new End(), true); @@ -833,7 +834,7 @@ public class Session_1_0 extends Abstrac if (!Boolean.TRUE.equals(source.getDynamic())) { final Map<String, Object> attributes = new HashMap<>(); - boolean isDurable = source.getDurable() != TerminusDurability.NONE; + boolean isDurable = source.getExpiryPolicy() == TerminusExpiryPolicy.NEVER; boolean isShared = hasCapability(source.getCapabilities(), SHARED_CAPABILITY); boolean isGlobal = hasCapability(source.getCapabilities(), ExchangeDestination.GLOBAL_CAPABILITY); @@ -1107,7 +1108,8 @@ public class Session_1_0 extends Abstrac void remoteEnd(End end) { - for (LinkEndpoint linkEndpoint : _associatedLinkEndpoints) + Set<LinkEndpoint> associatedLinkEndpoints = new HashSet<>(_associatedLinkEndpoints); + for (LinkEndpoint linkEndpoint : associatedLinkEndpoints) { linkEndpoint.remoteDetached(new Detach()); linkEndpoint.destroy(); Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/StandardReceivingLinkEndpoint.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/StandardReceivingLinkEndpoint.java?rev=1787994&r1=1787993&r2=1787994&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/StandardReceivingLinkEndpoint.java (original) +++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/StandardReceivingLinkEndpoint.java Tue Mar 21 15:30:44 2017 @@ -468,6 +468,8 @@ public class StandardReceivingLinkEndpoi target.setAddress(attachTarget.getAddress()); target.setDynamic(attachTarget.getDynamic()); target.setCapabilities(destination.getCapabilities()); + target.setDurable(TerminusDurability.min(attachTarget.getDurable(), + getLink().getHighestSupportedTerminusDurability())); setCapabilities(Arrays.asList(destination.getCapabilities())); setDestination(destination); Added: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/store/LinkStore.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/store/LinkStore.java?rev=1787994&view=auto ============================================================================== --- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/store/LinkStore.java (added) +++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/store/LinkStore.java Tue Mar 21 15:30:44 2017 @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.qpid.server.protocol.v1_0.store; + +import java.util.Collection; + +import org.apache.qpid.server.protocol.v1_0.LinkDefinition; +import org.apache.qpid.server.protocol.v1_0.type.messaging.TerminusDurability; +import org.apache.qpid.server.store.StoreException; + + +public interface LinkStore +{ + Collection<LinkDefinition> openAndLoad(LinkStoreUpdater updater) throws StoreException; + + void close() throws StoreException; + + void saveLink(LinkDefinition link) throws StoreException; + + void deleteLink(LinkDefinition link) throws StoreException; + + void delete(); + + TerminusDurability getHighestSupportedTerminusDurability(); +} Added: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/store/LinkStoreFactory.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/store/LinkStoreFactory.java?rev=1787994&view=auto ============================================================================== --- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/store/LinkStoreFactory.java (added) +++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/store/LinkStoreFactory.java Tue Mar 21 15:30:44 2017 @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.qpid.server.protocol.v1_0.store; + + +import org.apache.qpid.server.model.NamedAddressSpace; +import org.apache.qpid.server.plugin.Pluggable; + +public interface LinkStoreFactory extends Pluggable +{ + LinkStore create(NamedAddressSpace addressSpace); + boolean supports(NamedAddressSpace addressSpace); + int getPriority(); +} Added: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/store/LinkStoreUpdater.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/store/LinkStoreUpdater.java?rev=1787994&view=auto ============================================================================== --- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/store/LinkStoreUpdater.java (added) +++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/store/LinkStoreUpdater.java Tue Mar 21 15:30:44 2017 @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.qpid.server.protocol.v1_0.store; + + +import java.util.Collection; + +import org.apache.qpid.server.protocol.v1_0.LinkDefinition; + +public interface LinkStoreUpdater +{ + Collection<LinkDefinition> update(String currentVersion, Collection<LinkDefinition> linkDefinitions); +} Copied: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/store/LinkStoreUpdaterImpl.java (from r1787932, qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/virtualhost/LinkRegistry.java) URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/store/LinkStoreUpdaterImpl.java?p2=qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/store/LinkStoreUpdaterImpl.java&p1=qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/virtualhost/LinkRegistry.java&r1=1787932&r2=1787994&rev=1787994&view=diff ============================================================================== --- qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/virtualhost/LinkRegistry.java (original) +++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/store/LinkStoreUpdaterImpl.java Tue Mar 21 15:30:44 2017 @@ -1,5 +1,4 @@ /* - * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -18,12 +17,19 @@ * under the License. * */ -package org.apache.qpid.server.virtualhost; -import org.apache.qpid.server.protocol.LinkModel; +package org.apache.qpid.server.protocol.v1_0.store; + +import java.util.Collection; + +import org.apache.qpid.server.protocol.v1_0.LinkDefinition; -public interface LinkRegistry +public class LinkStoreUpdaterImpl implements LinkStoreUpdater { - <T extends LinkModel> T getSendingLink(String remoteContainerId, String linkName); - <T extends LinkModel> T getReceivingLink(String remoteContainerId, String linkName); + @Override + public Collection<LinkDefinition> update(final String currentVersion, + final Collection<LinkDefinition> linkDefinitions) + { + return linkDefinitions; + } } Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/Header.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/Header.java?rev=1787994&r1=1787993&r2=1787994&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/Header.java (original) +++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/Header.java Tue Mar 21 15:30:44 2017 @@ -115,7 +115,7 @@ public class Header implements NonEncodi { builder.append(','); } - builder.append("priority=").append(_priority); + builder.append("getPriority=").append(_priority); } if (_ttl != null) Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/Source.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/Source.java?rev=1787994&r1=1787993&r2=1787994&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/Source.java (original) +++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/Source.java Tue Mar 21 15:30:44 2017 @@ -276,5 +276,102 @@ public class Source implements BaseSourc return builder.toString(); } + @Override + public boolean equals(final Object o) + { + if (this == o) + { + return true; + } + if (o == null || getClass() != o.getClass()) + { + return false; + } + final Source source = (Source) o; + + if (_address != null ? !_address.equals(source._address) : source._address != null) + { + return false; + } + if (_durable != null ? !_durable.equals(source._durable) : source._durable != null) + { + return false; + } + if (_expiryPolicy != null ? !_expiryPolicy.equals(source._expiryPolicy) : source._expiryPolicy != null) + { + return false; + } + if (_timeout != null ? !_timeout.equals(source._timeout) : source._timeout != null) + { + return false; + } + if (_dynamic != null ? !_dynamic.equals(source._dynamic) : source._dynamic != null) + { + return false; + } + if (_dynamicNodeProperties != null + ? !_dynamicNodeProperties.equals(source._dynamicNodeProperties) + : source._dynamicNodeProperties != null) + { + return false; + } + if (_distributionMode != null + ? !_distributionMode.equals(source._distributionMode) + : source._distributionMode != null) + { + return false; + } + if (_filter != null ? !_filter.equals(source._filter) : source._filter != null) + { + return false; + } + if (_defaultOutcome != null) + { + if (source._defaultOutcome == null) + { + return false; + } + + if (_defaultOutcome.getSymbol() != null) + { + if (source._defaultOutcome.getSymbol() == null) + { + return false; + } + + if (!_defaultOutcome.getSymbol().equals(source._defaultOutcome.getSymbol())) + { + return false; + } + } + else if (source._defaultOutcome.getSymbol() != null) + { + return false; + } + } + else if (source._defaultOutcome != null) + { + return false; + } + + return Arrays.equals(_outcomes, source._outcomes) && Arrays.equals(_capabilities, source._capabilities); + } + + @Override + public int hashCode() + { + int result = _address != null ? _address.hashCode() : 0; + result = 31 * result + (_durable != null ? _durable.hashCode() : 0); + result = 31 * result + (_expiryPolicy != null ? _expiryPolicy.hashCode() : 0); + result = 31 * result + (_timeout != null ? _timeout.hashCode() : 0); + result = 31 * result + (_dynamic != null ? _dynamic.hashCode() : 0); + result = 31 * result + (_dynamicNodeProperties != null ? _dynamicNodeProperties.hashCode() : 0); + result = 31 * result + (_distributionMode != null ? _distributionMode.hashCode() : 0); + result = 31 * result + (_filter != null ? _filter.hashCode() : 0); + result = 31 * result + (_defaultOutcome != null ? _defaultOutcome.hashCode() : 0); + result = 31 * result + Arrays.hashCode(_outcomes); + result = 31 * result + Arrays.hashCode(_capabilities); + return result; + } } Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/Target.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/Target.java?rev=1787994&r1=1787993&r2=1787994&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/Target.java (original) +++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/Target.java Tue Mar 21 15:30:44 2017 @@ -121,6 +121,64 @@ public class Target } @Override + public boolean equals(final Object o) + { + if (this == o) + { + return true; + } + + if (o == null || getClass() != o.getClass()) + { + return false; + } + + final Target target = (Target) o; + + if (_address != null ? !_address.equals(target._address) : target._address != null) + { + return false; + } + if (_durable != null ? !_durable.equals(target._durable) : target._durable != null) + { + return false; + } + if (_expiryPolicy != null ? !_expiryPolicy.equals(target._expiryPolicy) : target._expiryPolicy != null) + { + return false; + } + if (_timeout != null ? !_timeout.equals(target._timeout) : target._timeout != null) + { + return false; + } + if (_dynamic != null ? !_dynamic.equals(target._dynamic) : target._dynamic != null) + { + return false; + } + if (_dynamicNodeProperties != null + ? !_dynamicNodeProperties.equals(target._dynamicNodeProperties) + : target._dynamicNodeProperties != null) + { + return false; + } + + return Arrays.equals(_capabilities, target._capabilities); + } + + @Override + public int hashCode() + { + int result = _address != null ? _address.hashCode() : 0; + result = 31 * result + (_durable != null ? _durable.hashCode() : 0); + result = 31 * result + (_expiryPolicy != null ? _expiryPolicy.hashCode() : 0); + result = 31 * result + (_timeout != null ? _timeout.hashCode() : 0); + result = 31 * result + (_dynamic != null ? _dynamic.hashCode() : 0); + result = 31 * result + (_dynamicNodeProperties != null ? _dynamicNodeProperties.hashCode() : 0); + result = 31 * result + Arrays.hashCode(_capabilities); + return result; + } + + @Override public String toString() { StringBuilder builder = new StringBuilder("Target{"); Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/TerminusDurability.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/TerminusDurability.java?rev=1787994&r1=1787993&r2=1787994&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/TerminusDurability.java (original) +++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/TerminusDurability.java Tue Mar 21 15:30:44 2017 @@ -102,6 +102,11 @@ public class TerminusDurability return null; } - + public static TerminusDurability min(TerminusDurability durabilityA, TerminusDurability durabilityB) + { + int durabilitAValue = durabilityA != null ? durabilityA._val.intValue() : 0; + int durabilityBValue = durabilityB != null ? durabilityB._val.intValue() : 0; + return TerminusDurability.valueOf(new UnsignedInteger(Math.min(durabilitAValue, durabilityBValue))); + } } Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/test/java/org/apache/qpid/server/protocol/v1_0/LinkRegistryTest.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/test/java/org/apache/qpid/server/protocol/v1_0/LinkRegistryTest.java?rev=1787994&r1=1787993&r2=1787994&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/test/java/org/apache/qpid/server/protocol/v1_0/LinkRegistryTest.java (original) +++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/test/java/org/apache/qpid/server/protocol/v1_0/LinkRegistryTest.java Tue Mar 21 15:30:44 2017 @@ -43,10 +43,10 @@ public class LinkRegistryTest extends Qp String remoteContainerId = "testRemoteContainerId"; String linkName = "testLinkName"; LinkModel link = _linkRegistry.getSendingLink(remoteContainerId, linkName); - assertNotNull("LinkRegistry#getSendingLink should always return an object", link); + assertNotNull("LinkRegistryModel#getSendingLink should always return an object", link); LinkModel link2 = _linkRegistry.getSendingLink(remoteContainerId, linkName); - assertNotNull("LinkRegistry#getSendingLink should always return an object", link2); - assertSame("Two calls to LinkRegistry#getSendingLink should return the same object", link, link2); + assertNotNull("LinkRegistryModel#getSendingLink should always return an object", link2); + assertSame("Two calls to LinkRegistryModel#getSendingLink should return the same object", link, link2); } public void testGetReceivingLink() throws Exception @@ -54,9 +54,9 @@ public class LinkRegistryTest extends Qp String remoteContainerId = "testRemoteContainerId"; String linkName = "testLinkName"; LinkModel link = _linkRegistry.getReceivingLink(remoteContainerId, linkName); - assertNotNull("LinkRegistry#getReceivingLink should always return an object", link); + assertNotNull("LinkRegistryModel#getReceivingLink should always return an object", link); LinkModel link2 = _linkRegistry.getReceivingLink(remoteContainerId, linkName); - assertNotNull("LinkRegistry#getReceivingLink should always return an object", link2); - assertSame("Two calls to LinkRegistry#getReceivingLink should return the same object", link, link2); + assertNotNull("LinkRegistryModel#getReceivingLink should always return an object", link2); + assertSame("Two calls to LinkRegistryModel#getReceivingLink should return the same object", link, link2); } } Added: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/test/java/org/apache/qpid/server/protocol/v1_0/TestLinkStoreFactory.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/test/java/org/apache/qpid/server/protocol/v1_0/TestLinkStoreFactory.java?rev=1787994&view=auto ============================================================================== --- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/test/java/org/apache/qpid/server/protocol/v1_0/TestLinkStoreFactory.java (added) +++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/test/java/org/apache/qpid/server/protocol/v1_0/TestLinkStoreFactory.java Tue Mar 21 15:30:44 2017 @@ -0,0 +1,99 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +package org.apache.qpid.server.protocol.v1_0; + +import java.util.Collection; +import java.util.Collections; + +import org.apache.qpid.server.model.NamedAddressSpace; +import org.apache.qpid.server.plugin.PluggableService; +import org.apache.qpid.server.protocol.v1_0.store.LinkStore; +import org.apache.qpid.server.protocol.v1_0.store.LinkStoreFactory; +import org.apache.qpid.server.protocol.v1_0.store.LinkStoreUpdater; +import org.apache.qpid.server.protocol.v1_0.type.messaging.TerminusDurability; +import org.apache.qpid.server.store.StoreException; +import org.apache.qpid.server.virtualhost.TestMemoryVirtualHost; + +@SuppressWarnings("unused") +@PluggableService +public class TestLinkStoreFactory implements LinkStoreFactory +{ + @Override + public String getType() + { + return "test"; + } + + @Override + public LinkStore create(final NamedAddressSpace addressSpace) + { + return new LinkStore() + { + @Override + public Collection<LinkDefinition> openAndLoad(final LinkStoreUpdater updater) throws StoreException + { + return Collections.emptyList(); + } + + @Override + public void close() throws StoreException + { + + } + + @Override + public void saveLink(final LinkDefinition link) throws StoreException + { + + } + + @Override + public void deleteLink(final LinkDefinition link) throws StoreException + { + + } + + @Override + public void delete() + { + + } + + @Override + public TerminusDurability getHighestSupportedTerminusDurability() + { + return TerminusDurability.CONFIGURATION; + } + }; + } + + @Override + public boolean supports(final NamedAddressSpace addressSpace) + { + return (addressSpace instanceof TestMemoryVirtualHost); + } + + @Override + public int getPriority() + { + return Integer.MIN_VALUE + 1; + } +} Added: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/test/java/org/apache/qpid/server/protocol/v1_0/store/LinkStoreTestCase.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/test/java/org/apache/qpid/server/protocol/v1_0/store/LinkStoreTestCase.java?rev=1787994&view=auto ============================================================================== --- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/test/java/org/apache/qpid/server/protocol/v1_0/store/LinkStoreTestCase.java (added) +++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/test/java/org/apache/qpid/server/protocol/v1_0/store/LinkStoreTestCase.java Tue Mar 21 15:30:44 2017 @@ -0,0 +1,188 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +package org.apache.qpid.server.protocol.v1_0.store; + +import java.util.Collection; +import java.util.Collections; + +import org.apache.qpid.server.protocol.v1_0.LinkDefinition; +import org.apache.qpid.server.protocol.v1_0.LinkDefinitionImpl; +import org.apache.qpid.server.protocol.v1_0.type.Symbol; +import org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger; +import org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted; +import org.apache.qpid.server.protocol.v1_0.type.messaging.NoLocalFilter; +import org.apache.qpid.server.protocol.v1_0.type.messaging.Rejected; +import org.apache.qpid.server.protocol.v1_0.type.messaging.Source; +import org.apache.qpid.server.protocol.v1_0.type.messaging.StdDistMode; +import org.apache.qpid.server.protocol.v1_0.type.messaging.Target; +import org.apache.qpid.server.protocol.v1_0.type.messaging.TerminusDurability; +import org.apache.qpid.server.protocol.v1_0.type.messaging.TerminusExpiryPolicy; +import org.apache.qpid.server.protocol.v1_0.type.transport.Role; +import org.apache.qpid.server.store.StoreException; +import org.apache.qpid.test.utils.QpidTestCase; + +public abstract class LinkStoreTestCase extends QpidTestCase +{ + private static final String ADDRESS = "amqp.direct/test"; + private static final String CAPABILITY = "test.capability"; + + private LinkStore _linkStore; + private Source _source; + private Target _target; + + @Override + public void setUp() throws Exception + { + super.setUp(); + _linkStore = createLinkStore(); + + _source = new Source(); + _target = new Target(); + + _source.setAddress(ADDRESS); + _source.setCapabilities(new Symbol[]{Symbol.getSymbol(CAPABILITY)}); + _source.setDefaultOutcome(new Rejected()); + _source.setDistributionMode(StdDistMode.COPY); + _source.setDurable(TerminusDurability.UNSETTLED_STATE); + _source.setDynamic(Boolean.TRUE); + _source.setExpiryPolicy(TerminusExpiryPolicy.CONNECTION_CLOSE); + _source.setFilter(Collections.singletonMap("foo", NoLocalFilter.INSTANCE)); + _source.setOutcomes(new Accepted().getSymbol()); + _source.setDynamicNodeProperties(Collections.singletonMap("dynamicProperty", "dynamicPropertyValue")); + _source.setTimeout(new UnsignedInteger(1)); + + _target.setTimeout(new UnsignedInteger(2)); + _target.setDynamicNodeProperties(Collections.singletonMap("targetDynamicProperty", "targetDynamicPropertyValue")); + _target.setDynamic(Boolean.TRUE); + _target.setExpiryPolicy(TerminusExpiryPolicy.LINK_DETACH); + _target.setAddress("bar"); + _target.setCapabilities(new Symbol[]{Symbol.getSymbol(CAPABILITY)}); + _target.setDurable(TerminusDurability.CONFIGURATION); + } + + @Override + public void tearDown() throws Exception + { + super.tearDown(); + deleteLinkStore(); + } + + public void testOpenAndLoad() throws Exception + { + Collection<LinkDefinition> links = _linkStore.openAndLoad(new LinkStoreUpdaterImpl()); + assertTrue("Unexpected links", links.isEmpty()); + + LinkDefinition linkDefinition = createLinkDefinition("1", "test"); + _linkStore.saveLink(linkDefinition); + _linkStore.close(); + + links = _linkStore.openAndLoad(new LinkStoreUpdaterImpl()); + assertEquals("Unexpected link number", 1, links.size()); + } + + + + public void testClose() throws Exception + { + _linkStore.openAndLoad(new LinkStoreUpdaterImpl()); + + _linkStore.close(); + try + { + LinkDefinition linkDefinition = createLinkDefinition("1", "test"); + _linkStore.saveLink(linkDefinition); + fail("Saving link with close store should fail"); + } + catch(StoreException e) + { + // pass + } + } + + public void testSaveLink() throws Exception + { + _linkStore.openAndLoad(new LinkStoreUpdaterImpl()); + LinkDefinition linkDefinition = createLinkDefinition("1", "test"); + _linkStore.saveLink(linkDefinition); + _linkStore.close(); + + Collection<LinkDefinition> links = _linkStore.openAndLoad(new LinkStoreUpdaterImpl()); + assertEquals("Unexpected link number", 1, links.size()); + + LinkDefinition recoveredLink = links.iterator().next(); + + assertEquals("Unexpected link name", linkDefinition.getName(), recoveredLink.getName()); + assertEquals("Unexpected container id", linkDefinition.getRemoteContainerId(), recoveredLink.getRemoteContainerId()); + assertEquals("Unexpected role", linkDefinition.getRole(), recoveredLink.getRole()); + assertEquals("Unexpected source", linkDefinition.getSource(), recoveredLink.getSource()); + assertEquals("Unexpected target", linkDefinition.getTarget(), recoveredLink.getTarget()); + } + + public void testDeleteLink() throws Exception + { + _linkStore.openAndLoad(new LinkStoreUpdaterImpl()); + + LinkDefinition linkDefinition = createLinkDefinition("1", "test"); + _linkStore.saveLink(linkDefinition); + + LinkDefinition linkDefinition2 = createLinkDefinition("2", "test2"); + _linkStore.saveLink(linkDefinition2); + + _linkStore.deleteLink(linkDefinition2); + _linkStore.close(); + + Collection<LinkDefinition> links = _linkStore.openAndLoad(new LinkStoreUpdaterImpl()); + assertEquals("Unexpected link number", 1, links.size()); + + LinkDefinition recoveredLink = links.iterator().next(); + + assertEquals("Unexpected link name", linkDefinition.getName(), recoveredLink.getName()); + assertEquals("Unexpected container id", linkDefinition.getRemoteContainerId(), recoveredLink.getRemoteContainerId()); + assertEquals("Unexpected role", linkDefinition.getRole(), recoveredLink.getRole()); + assertEquals("Unexpected source", linkDefinition.getSource(), recoveredLink.getSource()); + assertEquals("Unexpected target", linkDefinition.getTarget(), recoveredLink.getTarget()); + } + + public void testDelete() throws Exception + { + _linkStore.openAndLoad(new LinkStoreUpdaterImpl()); + + LinkDefinition linkDefinition = createLinkDefinition("1", "test"); + _linkStore.saveLink(linkDefinition); + + LinkDefinition linkDefinition2 = createLinkDefinition("2", "test2"); + _linkStore.saveLink(linkDefinition2); + + _linkStore.delete(); + + Collection<LinkDefinition> links = _linkStore.openAndLoad(new LinkStoreUpdaterImpl()); + assertEquals("Unexpected link number", 0, links.size()); + } + + protected abstract LinkStore createLinkStore(); + + protected abstract void deleteLinkStore(); + + private LinkDefinitionImpl createLinkDefinition(final String remoteContainerId, final String linkName) + { + return new LinkDefinitionImpl(remoteContainerId, linkName, Role.RECEIVER, _source, _target); + } +} Modified: qpid/java/trunk/broker-plugins/management-amqp/src/main/java/org/apache/qpid/server/management/amqp/ManagementAddressSpace.java URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-amqp/src/main/java/org/apache/qpid/server/management/amqp/ManagementAddressSpace.java?rev=1787994&r1=1787993&r2=1787994&view=diff ============================================================================== --- qpid/java/trunk/broker-plugins/management-amqp/src/main/java/org/apache/qpid/server/management/amqp/ManagementAddressSpace.java (original) +++ qpid/java/trunk/broker-plugins/management-amqp/src/main/java/org/apache/qpid/server/management/amqp/ManagementAddressSpace.java Tue Mar 21 15:30:44 2017 @@ -66,7 +66,7 @@ import org.apache.qpid.server.transport. import org.apache.qpid.server.txn.DtxNotSupportedException; import org.apache.qpid.server.txn.DtxRegistry; import org.apache.qpid.server.util.Action; -import org.apache.qpid.server.virtualhost.LinkRegistry; +import org.apache.qpid.server.virtualhost.LinkRegistryModel; import org.apache.qpid.server.virtualhost.LinkRegistryFactory; import org.apache.qpid.server.virtualhost.VirtualHostPropertiesNode; @@ -89,7 +89,7 @@ public class ManagementAddressSpace impl private final Principal _principal; private final UUID _id; private final ConcurrentMap<Object, ConcurrentMap<String, ProxyMessageSource>> _connectionSpecificDestinations = new ConcurrentHashMap<>(); - private final LinkRegistry _linkRegistry; + private final LinkRegistryModel _linkRegistry; public ManagementAddressSpace(final SystemAddressSpaceCreator.AddressSpaceRegistry addressSpaceRegistry) { @@ -118,6 +118,7 @@ public class ManagementAddressSpace impl throw new RuntimeException("Found multiple implementations of LinkRegistry"); } _linkRegistry = linkRegistryFactory.create(this); + _linkRegistry.open(); } else { Modified: qpid/java/trunk/broker/pom.xml URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker/pom.xml?rev=1787994&r1=1787993&r2=1787994&view=diff ============================================================================== --- qpid/java/trunk/broker/pom.xml (original) +++ qpid/java/trunk/broker/pom.xml Tue Mar 21 15:30:44 2017 @@ -162,6 +162,14 @@ <optional>true</optional> </dependency> + <dependency> + <groupId>org.apache.qpid</groupId> + <artifactId>qpid-broker-plugins-amqp-1-0-protocol-bdb-store</artifactId> + <version>${project.version}</version> + <scope>runtime</scope> + <optional>true</optional> + </dependency> + <!-- test dependencies --> <dependency> <groupId>org.apache.qpid</groupId> Modified: qpid/java/trunk/pom.xml URL: http://svn.apache.org/viewvc/qpid/java/trunk/pom.xml?rev=1787994&r1=1787993&r2=1787994&view=diff ============================================================================== --- qpid/java/trunk/pom.xml (original) +++ qpid/java/trunk/pom.xml Tue Mar 21 15:30:44 2017 @@ -179,7 +179,7 @@ <module>broker-plugins/management-http</module> <module>broker-plugins/memory-store</module> <module>broker-plugins/websocket</module> - + <module>broker-plugins/amqp-1-0-bdb-store</module> <module>tools</module> <module>qpid-systests-parent</module> Modified: qpid/java/trunk/systests/pom.xml URL: http://svn.apache.org/viewvc/qpid/java/trunk/systests/pom.xml?rev=1787994&r1=1787993&r2=1787994&view=diff ============================================================================== --- qpid/java/trunk/systests/pom.xml (original) +++ qpid/java/trunk/systests/pom.xml Tue Mar 21 15:30:44 2017 @@ -154,6 +154,12 @@ <dependency> <groupId>org.apache.qpid</groupId> + <artifactId>qpid-broker-plugins-amqp-1-0-protocol-bdb-store</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>org.apache.qpid</groupId> <artifactId>qpid-bdbstore</artifactId> <version>${project.version}</version> <scope>test</scope> Modified: qpid/java/trunk/systests/qpid-systests-jms_2.0/pom.xml URL: http://svn.apache.org/viewvc/qpid/java/trunk/systests/qpid-systests-jms_2.0/pom.xml?rev=1787994&r1=1787993&r2=1787994&view=diff ============================================================================== --- qpid/java/trunk/systests/qpid-systests-jms_2.0/pom.xml (original) +++ qpid/java/trunk/systests/qpid-systests-jms_2.0/pom.xml Tue Mar 21 15:30:44 2017 @@ -72,6 +72,13 @@ <groupId>org.apache.geronimo.specs</groupId> <artifactId>geronimo-jms_2.0_spec</artifactId> </dependency> + + <dependency> + <groupId>org.apache.qpid</groupId> + <artifactId>qpid-broker-plugins-amqp-1-0-protocol-bdb-store</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> <profiles> Modified: qpid/java/trunk/test-profiles/JavaBDBExcludes URL: http://svn.apache.org/viewvc/qpid/java/trunk/test-profiles/JavaBDBExcludes?rev=1787994&r1=1787993&r2=1787994&view=diff ============================================================================== --- qpid/java/trunk/test-profiles/JavaBDBExcludes (original) +++ qpid/java/trunk/test-profiles/JavaBDBExcludes Tue Mar 21 15:30:44 2017 @@ -17,8 +17,3 @@ // under the License. // - - -// Links are currently not persisted so when the broker is restarted this test fails -// When Link persistance is implemented (QPID-7663) this test should be included again -org.apache.qpid.systests.jms_2_0.subscription.SharedSubscriptionTest#testUnsubscribe --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org