use of org.apache.activemq.artemis.core.persistence.config.PersistedAddressSetting in project activemq-artemis by apache.
the class ActiveMQServerImpl method recoverStoredConfigs.
/**
* @throws Exception
*/
private void recoverStoredConfigs() throws Exception {
List<PersistedAddressSetting> adsettings = storageManager.recoverAddressSettings();
for (PersistedAddressSetting set : adsettings) {
addressSettingsRepository.addMatch(set.getAddressMatch().toString(), set.getSetting());
}
List<PersistedRoles> roles = storageManager.recoverPersistedRoles();
for (PersistedRoles roleItem : roles) {
Set<Role> setRoles = SecurityFormatter.createSecurity(roleItem.getSendRoles(), roleItem.getConsumeRoles(), roleItem.getCreateDurableQueueRoles(), roleItem.getDeleteDurableQueueRoles(), roleItem.getCreateNonDurableQueueRoles(), roleItem.getDeleteNonDurableQueueRoles(), roleItem.getManageRoles(), roleItem.getBrowseRoles(), roleItem.getCreateAddressRoles(), roleItem.getDeleteAddressRoles());
securityRepository.addMatch(roleItem.getAddressMatch().toString(), setRoles);
}
}
use of org.apache.activemq.artemis.core.persistence.config.PersistedAddressSetting in project activemq-artemis by apache.
the class AbstractJournalStorageManager method newAddressEncoding.
/**
* @param id
* @param buffer
* @return
*/
static PersistedAddressSetting newAddressEncoding(long id, ActiveMQBuffer buffer) {
PersistedAddressSetting setting = new PersistedAddressSetting();
setting.decode(buffer);
setting.setStoreId(id);
return setting;
}
use of org.apache.activemq.artemis.core.persistence.config.PersistedAddressSetting in project activemq-artemis by apache.
the class AbstractJournalStorageManager method loadBindingJournal.
@Override
public JournalLoadInformation loadBindingJournal(final List<QueueBindingInfo> queueBindingInfos, final List<GroupingInfo> groupingInfos, final List<AddressBindingInfo> addressBindingInfos) throws Exception {
List<RecordInfo> records = new ArrayList<>();
List<PreparedTransactionInfo> preparedTransactions = new ArrayList<>();
JournalLoadInformation bindingsInfo = bindingsJournal.load(records, preparedTransactions, null);
HashMap<Long, PersistentQueueBindingEncoding> mapBindings = new HashMap<>();
for (RecordInfo record : records) {
long id = record.id;
ActiveMQBuffer buffer = ActiveMQBuffers.wrappedBuffer(record.data);
byte rec = record.getUserRecordType();
if (rec == JournalRecordIds.QUEUE_BINDING_RECORD) {
PersistentQueueBindingEncoding bindingEncoding = newQueueBindingEncoding(id, buffer);
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);
addressBindingInfos.add(bindingEncoding);
} else if (rec == JournalRecordIds.GROUP_RECORD) {
GroupingEncoding encoding = newGroupEncoding(id, buffer);
groupingInfos.add(encoding);
} else if (rec == JournalRecordIds.ADDRESS_SETTING_RECORD) {
PersistedAddressSetting setting = newAddressEncoding(id, buffer);
mapPersistedAddressSettings.put(setting.getAddressMatch(), setting);
} else if (rec == JournalRecordIds.SECURITY_RECORD) {
PersistedRoles roles = newSecurityRecord(id, buffer);
mapPersistedRoles.put(roles.getAddressMatch(), roles);
} else if (rec == JournalRecordIds.QUEUE_STATUS_RECORD) {
QueueStatusEncoding statusEncoding = newQueueStatusEncoding(id, buffer);
PersistentQueueBindingEncoding queueBindingEncoding = mapBindings.get(statusEncoding.queueID);
if (queueBindingEncoding != null) {
queueBindingEncoding.addQueueStatusEncoding(statusEncoding);
} else {
// unlikely to happen, so I didn't bother about the Logger method
ActiveMQServerLogger.LOGGER.infoNoQueueWithID(statusEncoding.queueID, statusEncoding.getId());
this.deleteQueueStatus(statusEncoding.getId());
}
} else {
// unlikely to happen
ActiveMQServerLogger.LOGGER.invalidRecordType(rec, new Exception("invalid record type " + rec));
}
}
for (PersistentQueueBindingEncoding queue : mapBindings.values()) {
queueBindingInfos.add(queue);
}
// just to give a hand to GC
mapBindings.clear();
// This will instruct the IDGenerator to beforeStop old records
idGenerator.cleanup();
return bindingsInfo;
}
use of org.apache.activemq.artemis.core.persistence.config.PersistedAddressSetting in project activemq-artemis by apache.
the class ActiveMQServerControlImpl method addAddressSettings.
@Override
public void addAddressSettings(final String address, final String DLA, final String expiryAddress, final long expiryDelay, final boolean lastValueQueue, final int deliveryAttempts, final long maxSizeBytes, final int pageSizeBytes, final int pageMaxCacheSize, final long redeliveryDelay, final double redeliveryMultiplier, final long maxRedeliveryDelay, final long redistributionDelay, final boolean sendToDLAOnNoRoute, final String addressFullMessagePolicy, final long slowConsumerThreshold, final long slowConsumerCheckPeriod, final String slowConsumerPolicy, final boolean autoCreateJmsQueues, final boolean autoDeleteJmsQueues, final boolean autoCreateJmsTopics, final boolean autoDeleteJmsTopics, final boolean autoCreateQueues, final boolean autoDeleteQueues, final boolean autoCreateAddresses, final boolean autoDeleteAddresses) throws Exception {
checkStarted();
// JBPAPP-6334 requested this to be pageSizeBytes > maxSizeBytes
if (pageSizeBytes > maxSizeBytes && maxSizeBytes > 0) {
throw new IllegalStateException("pageSize has to be lower than maxSizeBytes. Invalid argument (" + pageSizeBytes + " < " + maxSizeBytes + ")");
}
if (maxSizeBytes < -1) {
throw new IllegalStateException("Invalid argument on maxSizeBytes");
}
AddressSettings addressSettings = new AddressSettings();
addressSettings.setDeadLetterAddress(DLA == null ? null : new SimpleString(DLA));
addressSettings.setExpiryAddress(expiryAddress == null ? null : new SimpleString(expiryAddress));
addressSettings.setExpiryDelay(expiryDelay);
addressSettings.setDefaultLastValueQueue(lastValueQueue);
addressSettings.setMaxDeliveryAttempts(deliveryAttempts);
addressSettings.setPageCacheMaxSize(pageMaxCacheSize);
addressSettings.setMaxSizeBytes(maxSizeBytes);
addressSettings.setPageSizeBytes(pageSizeBytes);
addressSettings.setRedeliveryDelay(redeliveryDelay);
addressSettings.setRedeliveryMultiplier(redeliveryMultiplier);
addressSettings.setMaxRedeliveryDelay(maxRedeliveryDelay);
addressSettings.setRedistributionDelay(redistributionDelay);
addressSettings.setSendToDLAOnNoRoute(sendToDLAOnNoRoute);
if (addressFullMessagePolicy == null) {
addressSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE);
} else if (addressFullMessagePolicy.equalsIgnoreCase("PAGE")) {
addressSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE);
} else if (addressFullMessagePolicy.equalsIgnoreCase("DROP")) {
addressSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.DROP);
} else if (addressFullMessagePolicy.equalsIgnoreCase("BLOCK")) {
addressSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.BLOCK);
} else if (addressFullMessagePolicy.equalsIgnoreCase("FAIL")) {
addressSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.FAIL);
}
addressSettings.setSlowConsumerThreshold(slowConsumerThreshold);
addressSettings.setSlowConsumerCheckPeriod(slowConsumerCheckPeriod);
if (slowConsumerPolicy == null) {
addressSettings.setSlowConsumerPolicy(SlowConsumerPolicy.NOTIFY);
} else if (slowConsumerPolicy.equalsIgnoreCase("NOTIFY")) {
addressSettings.setSlowConsumerPolicy(SlowConsumerPolicy.NOTIFY);
} else if (slowConsumerPolicy.equalsIgnoreCase("KILL")) {
addressSettings.setSlowConsumerPolicy(SlowConsumerPolicy.KILL);
}
addressSettings.setAutoCreateJmsQueues(autoCreateJmsQueues);
addressSettings.setAutoDeleteJmsQueues(autoDeleteJmsQueues);
addressSettings.setAutoCreateJmsTopics(autoCreateJmsTopics);
addressSettings.setAutoDeleteJmsTopics(autoDeleteJmsTopics);
addressSettings.setAutoCreateQueues(autoCreateQueues);
addressSettings.setAutoDeleteQueues(autoDeleteQueues);
addressSettings.setAutoCreateAddresses(autoCreateAddresses);
addressSettings.setAutoDeleteAddresses(autoDeleteAddresses);
server.getAddressSettingsRepository().addMatch(address, addressSettings);
storageManager.storeAddressSetting(new PersistedAddressSetting(new SimpleString(address), addressSettings));
}
use of org.apache.activemq.artemis.core.persistence.config.PersistedAddressSetting in project activemq-artemis by apache.
the class AddressSettingsConfigurationStorageTest method checkAddresses.
/**
* @param journal1
* @throws Exception
*/
private void checkAddresses(StorageManager journal1) throws Exception {
List<PersistedAddressSetting> listSetting = journal1.recoverAddressSettings();
assertEquals(mapExpectedAddresses.size(), listSetting.size());
for (PersistedAddressSetting el : listSetting) {
PersistedAddressSetting el2 = mapExpectedAddresses.get(el.getAddressMatch());
assertEquals(el.getAddressMatch(), el2.getAddressMatch());
assertEquals(el.getSetting(), el2.getSetting());
}
}
Aggregations