diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/AddressBindingInfo.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/AddressBindingInfo.java index 83d37bc948..838be122a8 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/AddressBindingInfo.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/AddressBindingInfo.java @@ -25,10 +25,6 @@ public interface AddressBindingInfo { SimpleString getName(); - boolean isAutoCreated(); - - SimpleString getUser(); - AddressInfo.RoutingType getRoutingType(); } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/StorageManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/StorageManager.java index 9675fe9ce5..b45775c3f0 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/StorageManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/StorageManager.java @@ -48,6 +48,7 @@ import org.apache.activemq.artemis.core.server.RouteContextList; import org.apache.activemq.artemis.core.server.ServerMessage; import org.apache.activemq.artemis.core.server.files.FileStoreMonitor; import org.apache.activemq.artemis.core.server.group.impl.GroupBinding; +import org.apache.activemq.artemis.core.server.impl.AddressInfo; import org.apache.activemq.artemis.core.server.impl.JournalLoader; import org.apache.activemq.artemis.core.transaction.ResourceManager; import org.apache.activemq.artemis.core.transaction.Transaction; @@ -301,8 +302,13 @@ public interface StorageManager extends IDGenerator, ActiveMQComponent { void deleteQueueStatus(long recordID) throws Exception; + void addAddressBinding(long tx, AddressInfo addressInfo) throws Exception; + + void deleteAddressBinding(long tx, long addressBindingID) throws Exception; + JournalLoadInformation loadBindingJournal(List queueBindingInfos, - List groupingInfos) throws Exception; + List groupingInfos, + List addressBindingInfos) throws Exception; // grouping related operations void addGrouping(GroupBinding groupBinding) throws Exception; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/AbstractJournalStorageManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/AbstractJournalStorageManager.java index 191a89c55f..af32dda4d3 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/AbstractJournalStorageManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/AbstractJournalStorageManager.java @@ -56,6 +56,7 @@ import org.apache.activemq.artemis.core.paging.cursor.PagePosition; import org.apache.activemq.artemis.core.paging.cursor.PageSubscription; import org.apache.activemq.artemis.core.paging.cursor.PagedReferenceImpl; import org.apache.activemq.artemis.core.paging.impl.PageTransactionInfoImpl; +import org.apache.activemq.artemis.core.persistence.AddressBindingInfo; import org.apache.activemq.artemis.core.persistence.GroupingInfo; import org.apache.activemq.artemis.core.persistence.OperationContext; import org.apache.activemq.artemis.core.persistence.QueueBindingInfo; @@ -77,6 +78,7 @@ import org.apache.activemq.artemis.core.persistence.impl.journal.codec.PageCount import org.apache.activemq.artemis.core.persistence.impl.journal.codec.PageCountRecordInc; import org.apache.activemq.artemis.core.persistence.impl.journal.codec.PageUpdateTXEncoding; import org.apache.activemq.artemis.core.persistence.impl.journal.codec.PendingLargeMessageEncoding; +import org.apache.activemq.artemis.core.persistence.impl.journal.codec.PersistentAddressBindingEncoding; import org.apache.activemq.artemis.core.persistence.impl.journal.codec.PersistentQueueBindingEncoding; import org.apache.activemq.artemis.core.persistence.impl.journal.codec.QueueStatusEncoding; import org.apache.activemq.artemis.core.persistence.impl.journal.codec.RefEncoding; @@ -93,6 +95,7 @@ import org.apache.activemq.artemis.core.server.Queue; import org.apache.activemq.artemis.core.server.RouteContextList; import org.apache.activemq.artemis.core.server.ServerMessage; import org.apache.activemq.artemis.core.server.group.impl.GroupBinding; +import org.apache.activemq.artemis.core.server.impl.AddressInfo; import org.apache.activemq.artemis.core.server.impl.JournalLoader; import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl; import org.apache.activemq.artemis.core.transaction.ResourceManager; @@ -1261,7 +1264,29 @@ public abstract class AbstractJournalStorageManager implements StorageManager { } finally { readUnLock(); } + } + public void addAddressBinding(final long tx, final AddressInfo addressInfo) throws Exception { + PersistentAddressBindingEncoding bindingEncoding = new PersistentAddressBindingEncoding(addressInfo.getName(), addressInfo.getRoutingType()); + + readLock(); + try { + long recordID = idGenerator.generateID(); + bindingEncoding.setId(recordID); + bindingsJournal.appendAddRecordTransactional(tx, recordID, JournalRecordIds.ADDRESS_BINDING_RECORD, bindingEncoding); + } finally { + readUnLock(); + } + } + + @Override + public void deleteAddressBinding(long tx, final long addressBindingID) throws Exception { + readLock(); + try { + bindingsJournal.appendDeleteRecordTransactional(tx, addressBindingID); + } finally { + readUnLock(); + } } @Override @@ -1347,7 +1372,8 @@ public abstract class AbstractJournalStorageManager implements StorageManager { @Override public JournalLoadInformation loadBindingJournal(final List queueBindingInfos, - final List groupingInfos) throws Exception { + final List groupingInfos, + final List addressBindingInfos) throws Exception { List records = new ArrayList<>(); List preparedTransactions = new ArrayList<>(); @@ -1364,12 +1390,15 @@ public abstract class AbstractJournalStorageManager implements StorageManager { byte rec = record.getUserRecordType(); if (rec == JournalRecordIds.QUEUE_BINDING_RECORD) { - PersistentQueueBindingEncoding bindingEncoding = newBindingEncoding(id, buffer); - + PersistentQueueBindingEncoding bindingEncoding = newQueueBindingEncoding(id, buffer); queueBindingInfos.add(bindingEncoding); mapBindings.put(bindingEncoding.getId(), bindingEncoding); } else if (rec == JournalRecordIds.ID_COUNTER_RECORD) { idGenerator.loadState(record.id, buffer); + } else if (rec == JournalRecordIds.ADDRESS_BINDING_RECORD) { + PersistentAddressBindingEncoding bindingEncoding = newAddressBindingEncoding(id, buffer); + ActiveMQServerLogger.LOGGER.info("=== Loading: " + bindingEncoding); + addressBindingInfos.add(bindingEncoding); } else if (rec == JournalRecordIds.GROUP_RECORD) { GroupingEncoding encoding = newGroupEncoding(id, buffer); groupingInfos.add(encoding); @@ -1849,7 +1878,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager { * @param buffer * @return */ - protected static PersistentQueueBindingEncoding newBindingEncoding(long id, ActiveMQBuffer buffer) { + protected static PersistentQueueBindingEncoding newQueueBindingEncoding(long id, ActiveMQBuffer buffer) { PersistentQueueBindingEncoding bindingEncoding = new PersistentQueueBindingEncoding(); bindingEncoding.decode(buffer); @@ -1872,8 +1901,14 @@ public abstract class AbstractJournalStorageManager implements StorageManager { return statusEncoding; } + protected static PersistentAddressBindingEncoding newAddressBindingEncoding(long id, ActiveMQBuffer buffer) { + PersistentAddressBindingEncoding bindingEncoding = new PersistentAddressBindingEncoding(); + bindingEncoding.decode(buffer); + bindingEncoding.setId(id); + return bindingEncoding; + } @Override public boolean addToPage(PagingStore store, diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/DescribeJournal.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/DescribeJournal.java index 58723c6982..a5c1fd7e80 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/DescribeJournal.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/DescribeJournal.java @@ -555,7 +555,7 @@ public final class DescribeJournal { return AbstractJournalStorageManager.newQueueStatusEncoding(id, buffer); case QUEUE_BINDING_RECORD: - return AbstractJournalStorageManager.newBindingEncoding(id, buffer); + return AbstractJournalStorageManager.newQueueBindingEncoding(id, buffer); case ID_COUNTER_RECORD: EncodingSupport idReturn = new IDCounterEncoding(); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/JournalRecordIds.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/JournalRecordIds.java index 0169f38a36..cd1d526448 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/JournalRecordIds.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/JournalRecordIds.java @@ -83,4 +83,6 @@ public final class JournalRecordIds { public static final byte PAGE_CURSOR_COMPLETE = 42; public static final byte PAGE_CURSOR_PENDING_COUNTER = 43; + + public static final byte ADDRESS_BINDING_RECORD = 44; } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/codec/PersistentAddressBindingEncoding.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/codec/PersistentAddressBindingEncoding.java index 9f473624a2..7ef7e4d82f 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/codec/PersistentAddressBindingEncoding.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/codec/PersistentAddressBindingEncoding.java @@ -29,10 +29,6 @@ public class PersistentAddressBindingEncoding implements EncodingSupport, Addres public SimpleString name; - public boolean autoCreated; - - public SimpleString user; - public AddressInfo.RoutingType routingType; public PersistentAddressBindingEncoding() { @@ -43,22 +39,14 @@ public class PersistentAddressBindingEncoding implements EncodingSupport, Addres return "PersistentAddressBindingEncoding [id=" + id + ", name=" + name + - ", user=" + - user + - ", autoCreated=" + - autoCreated + ", routingType=" + routingType + "]"; } public PersistentAddressBindingEncoding(final SimpleString name, - final SimpleString user, - final boolean autoCreated, final AddressInfo.RoutingType routingType) { this.name = name; - this.user = user; - this.autoCreated = autoCreated; this.routingType = routingType; } @@ -76,16 +64,6 @@ public class PersistentAddressBindingEncoding implements EncodingSupport, Addres return name; } - @Override - public SimpleString getUser() { - return user; - } - - @Override - public boolean isAutoCreated() { - return autoCreated; - } - @Override public AddressInfo.RoutingType getRoutingType() { return routingType; @@ -94,42 +72,17 @@ public class PersistentAddressBindingEncoding implements EncodingSupport, Addres @Override public void decode(final ActiveMQBuffer buffer) { name = buffer.readSimpleString(); - - String metadata = buffer.readNullableSimpleString().toString(); - if (metadata != null) { - String[] elements = metadata.split(";"); - for (String element : elements) { - String[] keyValuePair = element.split("="); - if (keyValuePair.length == 2) { - if (keyValuePair[0].equals("user")) { - user = SimpleString.toSimpleString(keyValuePair[1]); - } - } - } - } - - autoCreated = buffer.readBoolean(); routingType = AddressInfo.RoutingType.getType(buffer.readByte()); } @Override public void encode(final ActiveMQBuffer buffer) { buffer.writeSimpleString(name); - buffer.writeNullableSimpleString(createMetadata()); - buffer.writeBoolean(autoCreated); buffer.writeByte(routingType.getType()); } @Override public int getEncodeSize() { - return SimpleString.sizeofString(name) + DataConstants.SIZE_BOOLEAN + - SimpleString.sizeofNullableString(createMetadata()) + - DataConstants.SIZE_BYTE; - } - - private SimpleString createMetadata() { - StringBuilder metadata = new StringBuilder(); - metadata.append("user=").append(user).append(";"); - return SimpleString.toSimpleString(metadata.toString()); + return SimpleString.sizeofString(name) + DataConstants.SIZE_BYTE; } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/nullpm/NullStorageManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/nullpm/NullStorageManager.java index b311888e8e..fac108e40e 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/nullpm/NullStorageManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/nullpm/NullStorageManager.java @@ -38,6 +38,7 @@ import org.apache.activemq.artemis.core.paging.PagedMessage; import org.apache.activemq.artemis.core.paging.PagingManager; import org.apache.activemq.artemis.core.paging.PagingStore; import org.apache.activemq.artemis.core.paging.cursor.PagePosition; +import org.apache.activemq.artemis.core.persistence.AddressBindingInfo; import org.apache.activemq.artemis.core.persistence.GroupingInfo; import org.apache.activemq.artemis.core.persistence.OperationContext; import org.apache.activemq.artemis.core.persistence.QueueBindingInfo; @@ -55,6 +56,7 @@ import org.apache.activemq.artemis.core.server.RouteContextList; import org.apache.activemq.artemis.core.server.ServerMessage; import org.apache.activemq.artemis.core.server.files.FileStoreMonitor; import org.apache.activemq.artemis.core.server.group.impl.GroupBinding; +import org.apache.activemq.artemis.core.server.impl.AddressInfo; import org.apache.activemq.artemis.core.server.impl.JournalLoader; import org.apache.activemq.artemis.core.transaction.ResourceManager; import org.apache.activemq.artemis.core.transaction.Transaction; @@ -154,13 +156,22 @@ public class NullStorageManager implements StorageManager { public void deleteQueueBinding(long tx, final long queueBindingID) throws Exception { } + @Override + public void addAddressBinding(long tx, AddressInfo addressInfo) throws Exception { + } + + @Override + public void deleteAddressBinding(long tx, long addressBindingID) throws Exception { + } + @Override public void commit(final long txID) throws Exception { } @Override public JournalLoadInformation loadBindingJournal(final List queueBindingInfos, - final List groupingInfos) throws Exception { + final List groupingInfos, + final List addressBindingInfos) throws Exception { return new JournalLoadInformation(); } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java index ede8470619..7ad4635694 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java @@ -72,6 +72,7 @@ import org.apache.activemq.artemis.core.paging.PagingManager; import org.apache.activemq.artemis.core.paging.cursor.PageSubscription; import org.apache.activemq.artemis.core.paging.impl.PagingManagerImpl; import org.apache.activemq.artemis.core.paging.impl.PagingStoreFactoryNIO; +import org.apache.activemq.artemis.core.persistence.AddressBindingInfo; import org.apache.activemq.artemis.core.persistence.GroupingInfo; import org.apache.activemq.artemis.core.persistence.OperationContext; import org.apache.activemq.artemis.core.persistence.QueueBindingInfo; @@ -2206,7 +2207,9 @@ public class ActiveMQServerImpl implements ActiveMQServer { List groupingInfos = new ArrayList<>(); - journalInfo[0] = storageManager.loadBindingJournal(queueBindingInfos, groupingInfos); + List addressBindingInfos = new ArrayList<>(); + + journalInfo[0] = storageManager.loadBindingJournal(queueBindingInfos, groupingInfos, addressBindingInfos); recoverStoredConfigs(); @@ -2216,6 +2219,10 @@ public class ActiveMQServerImpl implements ActiveMQServer { journalLoader.handleGroupingBindings(groupingInfos); + Map addressBindingInfosMap = new HashMap<>(); + + journalLoader.initAddresses(addressBindingInfosMap, addressBindingInfos); + Map>> duplicateIDMap = new HashMap<>(); HashSet> pendingLargeMessages = new HashSet<>(); @@ -2314,6 +2321,14 @@ public class ActiveMQServerImpl implements ActiveMQServer { final QueueConfig queueConfig = queueConfigBuilder.filter(filter).pagingManager(pagingManager).user(user).durable(durable).temporary(temporary).autoCreated(autoCreated).build(); final Queue queue = queueFactory.createQueueWith(queueConfig); + boolean addressAlreadyExists = true; + + if (postOffice.getAddressInfo(queue.getAddress()) == null) { + postOffice.addAddressInfo(new AddressInfo(queue.getAddress()) + .setRoutingType(AddressInfo.RoutingType.MULTICAST)); + addressAlreadyExists = false; + } + if (transientQueue) { queue.setConsumersRefCount(new TransientQueueManagerImpl(this, queue.getName())); } else if (queue.isAutoCreated()) { @@ -2324,6 +2339,9 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (queue.isDurable()) { storageManager.addQueueBinding(txID, localQueueBinding); + if (!addressAlreadyExists) { + storageManager.addAddressBinding(txID, getAddressInfo(queue.getAddress())); + } } try { diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AddressInfo.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AddressInfo.java index 1449107201..4e982c419b 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AddressInfo.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AddressInfo.java @@ -36,24 +36,27 @@ public class AddressInfo { return routingType; } - public void setRoutingType(RoutingType routingType) { + public AddressInfo setRoutingType(RoutingType routingType) { this.routingType = routingType; + return this; } public boolean isDefaultDeleteOnNoConsumers() { return defaultDeleteOnNoConsumers; } - public void setDefaultDeleteOnNoConsumers(boolean defaultDeleteOnNoConsumers) { + public AddressInfo setDefaultDeleteOnNoConsumers(boolean defaultDeleteOnNoConsumers) { this.defaultDeleteOnNoConsumers = defaultDeleteOnNoConsumers; + return this; } public int getDefaultMaxConsumers() { return defaultMaxConsumers; } - public void setDefaultMaxConsumers(int defaultMaxConsumers) { + public AddressInfo setDefaultMaxConsumers(int defaultMaxConsumers) { this.defaultMaxConsumers = defaultMaxConsumers; + return this; } public SimpleString getName() { diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/JournalLoader.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/JournalLoader.java index 6f36ff54ca..40cef5091a 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/JournalLoader.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/JournalLoader.java @@ -23,6 +23,7 @@ import java.util.Map; import org.apache.activemq.artemis.api.core.Pair; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.core.journal.Journal; +import org.apache.activemq.artemis.core.persistence.AddressBindingInfo; import org.apache.activemq.artemis.core.persistence.GroupingInfo; import org.apache.activemq.artemis.core.persistence.QueueBindingInfo; import org.apache.activemq.artemis.core.persistence.impl.PageCountPending; @@ -37,6 +38,9 @@ public interface JournalLoader { void initQueues(Map queueBindingInfosMap, List queueBindingInfos) throws Exception; + void initAddresses(Map addressBindingInfosMap, + List addressBindingInfo) throws Exception; + void handleAddMessage(Map> queueMap) throws Exception; void handleNoMessageReferences(Map messages); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/PostOfficeJournalLoader.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/PostOfficeJournalLoader.java index 71c5b2bd83..4e89e8a4c8 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/PostOfficeJournalLoader.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/PostOfficeJournalLoader.java @@ -37,6 +37,7 @@ import org.apache.activemq.artemis.core.paging.PagingManager; import org.apache.activemq.artemis.core.paging.PagingStore; import org.apache.activemq.artemis.core.paging.cursor.PageSubscriptionCounter; import org.apache.activemq.artemis.core.paging.impl.Page; +import org.apache.activemq.artemis.core.persistence.AddressBindingInfo; import org.apache.activemq.artemis.core.persistence.GroupingInfo; import org.apache.activemq.artemis.core.persistence.QueueBindingInfo; import org.apache.activemq.artemis.core.persistence.QueueStatus; @@ -165,6 +166,21 @@ public class PostOfficeJournalLoader implements JournalLoader { } } + @Override + public void initAddresses(Map addressBindingInfosMap, + List addressBindingInfos) throws Exception { + for (AddressBindingInfo addressBindingInfo : addressBindingInfos) { + addressBindingInfosMap.put(addressBindingInfo.getId(), addressBindingInfo); + + // TODO: figure out what else to set here + AddressInfo addressInfo = new AddressInfo(addressBindingInfo.getName()) + .setRoutingType(addressBindingInfo.getRoutingType()); + + postOffice.addAddressInfo(addressInfo); + managementService.registerAddress(addressInfo.getName()); + } + } + @Override public void handleAddMessage(Map> queueMap) throws Exception { for (Map.Entry> entry : queueMap.entrySet()) { diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/transaction/impl/TransactionImplTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/transaction/impl/TransactionImplTest.java index 9b06fbea12..ee800542e3 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/transaction/impl/TransactionImplTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/transaction/impl/TransactionImplTest.java @@ -38,6 +38,7 @@ import org.apache.activemq.artemis.core.paging.PagedMessage; import org.apache.activemq.artemis.core.paging.PagingManager; import org.apache.activemq.artemis.core.paging.PagingStore; import org.apache.activemq.artemis.core.paging.cursor.PagePosition; +import org.apache.activemq.artemis.core.persistence.AddressBindingInfo; import org.apache.activemq.artemis.core.persistence.GroupingInfo; import org.apache.activemq.artemis.core.persistence.OperationContext; import org.apache.activemq.artemis.core.persistence.QueueBindingInfo; @@ -55,6 +56,7 @@ import org.apache.activemq.artemis.core.server.RouteContextList; import org.apache.activemq.artemis.core.server.ServerMessage; import org.apache.activemq.artemis.core.server.files.FileStoreMonitor; import org.apache.activemq.artemis.core.server.group.impl.GroupBinding; +import org.apache.activemq.artemis.core.server.impl.AddressInfo; import org.apache.activemq.artemis.core.server.impl.JournalLoader; import org.apache.activemq.artemis.core.transaction.ResourceManager; import org.apache.activemq.artemis.core.transaction.Transaction; @@ -528,9 +530,20 @@ public class TransactionImplTest extends ActiveMQTestBase { } + @Override + public void addAddressBinding(long tx, AddressInfo addressInfo) throws Exception { + + } + + @Override + public void deleteAddressBinding(long tx, long addressBindingID) throws Exception { + + } + @Override public JournalLoadInformation loadBindingJournal(List queueBindingInfos, - List groupingInfos) throws Exception { + List groupingInfos, + List addressBindingInfos) throws Exception { return null; } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/addressing/AddressConfigTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/addressing/AddressConfigTest.java new file mode 100644 index 0000000000..f3a0bebf1e --- /dev/null +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/addressing/AddressConfigTest.java @@ -0,0 +1,50 @@ +/* + * 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.activemq.artemis.tests.integration.addressing; + +import org.apache.activemq.artemis.api.core.SimpleString; +import org.apache.activemq.artemis.core.config.Configuration; +import org.apache.activemq.artemis.core.server.ActiveMQServer; +import org.apache.activemq.artemis.core.server.impl.AddressInfo; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.junit.Before; +import org.junit.Test; + +public class AddressConfigTest extends ActiveMQTestBase { + + protected ActiveMQServer server; + + @Override + @Before + public void setUp() throws Exception { + super.setUp(); + Configuration configuration = createDefaultInVMConfig(); + server = createServer(true, configuration); + server.start(); + } + + @Test + public void persistAddressConfigTest() throws Exception { + server.createQueue(SimpleString.toSimpleString("myAddress"), SimpleString.toSimpleString("myQueue"), null, true, false); + server.stop(); + server.start(); + AddressInfo addressInfo = server.getAddressInfo(SimpleString.toSimpleString("myAddress")); + assertNotNull(addressInfo); + assertEquals(AddressInfo.RoutingType.MULTICAST, addressInfo.getRoutingType()); + } +} diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/DeleteMessagesOnStartupTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/DeleteMessagesOnStartupTest.java index 7d515d89f3..90f7c5f2d4 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/DeleteMessagesOnStartupTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/DeleteMessagesOnStartupTest.java @@ -24,6 +24,7 @@ import java.util.HashMap; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.config.StoreConfiguration; +import org.apache.activemq.artemis.core.persistence.AddressBindingInfo; import org.apache.activemq.artemis.core.persistence.GroupingInfo; import org.apache.activemq.artemis.core.persistence.QueueBindingInfo; import org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager; @@ -76,7 +77,7 @@ public class DeleteMessagesOnStartupTest extends StorageManagerTestBase { journal.start(); - journal.loadBindingJournal(new ArrayList(), new ArrayList()); + journal.loadBindingJournal(new ArrayList(), new ArrayList(), new ArrayList()); FakePostOffice postOffice = new FakePostOffice(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/RestartSMTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/RestartSMTest.java index 49d3a1214a..2ee879f8af 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/RestartSMTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/RestartSMTest.java @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.ExecutorService; +import org.apache.activemq.artemis.core.persistence.AddressBindingInfo; import org.apache.activemq.artemis.core.persistence.GroupingInfo; import org.apache.activemq.artemis.core.persistence.QueueBindingInfo; import org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager; @@ -73,7 +74,7 @@ public class RestartSMTest extends ActiveMQTestBase { List queueBindingInfos = new ArrayList<>(); - journal.loadBindingJournal(queueBindingInfos, new ArrayList()); + journal.loadBindingJournal(queueBindingInfos, new ArrayList(), new ArrayList()); journal.loadMessageJournal(postOffice, null, null, null, null, null, null, new FakeJournalLoader()); @@ -87,7 +88,7 @@ public class RestartSMTest extends ActiveMQTestBase { queueBindingInfos = new ArrayList<>(); - journal.loadBindingJournal(queueBindingInfos, new ArrayList()); + journal.loadBindingJournal(queueBindingInfos, new ArrayList(), new ArrayList()); journal.start(); } finally { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/StorageManagerTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/StorageManagerTestBase.java index a1043638c9..508f23bf3a 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/StorageManagerTestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/StorageManagerTestBase.java @@ -25,6 +25,7 @@ import java.util.concurrent.ScheduledThreadPoolExecutor; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.config.StoreConfiguration; +import org.apache.activemq.artemis.core.persistence.AddressBindingInfo; import org.apache.activemq.artemis.core.persistence.GroupingInfo; import org.apache.activemq.artemis.core.persistence.QueueBindingInfo; import org.apache.activemq.artemis.core.persistence.StorageManager; @@ -128,7 +129,7 @@ public abstract class StorageManagerTestBase extends ActiveMQTestBase { journal.start(); - journal.loadBindingJournal(new ArrayList(), new ArrayList()); + journal.loadBindingJournal(new ArrayList(), new ArrayList(), new ArrayList()); journal.loadMessageJournal(new FakePostOffice(), null, null, null, null, null, null, new FakeJournalLoader()); } diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/DuplicateDetectionUnitTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/DuplicateDetectionUnitTest.java index 96fa35c951..58c5c4f45a 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/DuplicateDetectionUnitTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/DuplicateDetectionUnitTest.java @@ -27,6 +27,7 @@ import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; import org.apache.activemq.artemis.api.core.Pair; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.core.config.Configuration; +import org.apache.activemq.artemis.core.persistence.AddressBindingInfo; import org.apache.activemq.artemis.core.persistence.GroupingInfo; import org.apache.activemq.artemis.core.persistence.QueueBindingInfo; import org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager; @@ -95,7 +96,7 @@ public class DuplicateDetectionUnitTest extends ActiveMQTestBase { journal = new JournalStorageManager(configuration, factory, factory); journal.start(); - journal.loadBindingJournal(new ArrayList(), new ArrayList()); + journal.loadBindingJournal(new ArrayList(), new ArrayList(), new ArrayList()); HashMap>> mapDups = new HashMap<>(); @@ -114,7 +115,7 @@ public class DuplicateDetectionUnitTest extends ActiveMQTestBase { journal = new JournalStorageManager(configuration, factory, factory); journal.start(); - journal.loadBindingJournal(new ArrayList(), new ArrayList()); + journal.loadBindingJournal(new ArrayList(), new ArrayList(), new ArrayList()); journal.loadMessageJournal(postOffice, pagingManager, new ResourceManagerImpl(0, 0, scheduledThreadPool), null, mapDups, null, null, new PostOfficeJournalLoader(postOffice, pagingManager, null, null, null, null, null, null)); @@ -137,7 +138,7 @@ public class DuplicateDetectionUnitTest extends ActiveMQTestBase { journal = new JournalStorageManager(configuration, factory, factory); journal.start(); - journal.loadBindingJournal(new ArrayList(), new ArrayList()); + journal.loadBindingJournal(new ArrayList(), new ArrayList(), new ArrayList()); journal.loadMessageJournal(postOffice, pagingManager, new ResourceManagerImpl(0, 0, scheduledThreadPool), null, mapDups, null, null, new PostOfficeJournalLoader(postOffice, pagingManager, null, null, null, null, null, null)); diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/fakes/FakeJournalLoader.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/fakes/FakeJournalLoader.java index 32ad718299..547d669eb7 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/fakes/FakeJournalLoader.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/fakes/FakeJournalLoader.java @@ -23,6 +23,7 @@ import java.util.Map; import org.apache.activemq.artemis.api.core.Pair; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.core.journal.Journal; +import org.apache.activemq.artemis.core.persistence.AddressBindingInfo; import org.apache.activemq.artemis.core.persistence.GroupingInfo; import org.apache.activemq.artemis.core.persistence.QueueBindingInfo; import org.apache.activemq.artemis.core.persistence.impl.PageCountPending; @@ -48,6 +49,11 @@ public class FakeJournalLoader implements JournalLoader { List queueBindingInfos) throws Exception { } + @Override + public void initAddresses(Map addressBindingInfosMap, + List addressBindingInfo) throws Exception { + } + @Override public void handleGroupingBindings(List groupingInfos) { }