ARTEMIS-3637 config-delete-diverts not applied properly

The address-setting config-delete-diverts is not being applied correctly
hierarchically because it's not included in the merge() method. It is
also not being persisted to disk either. This commit fixes both issues.
This commit is contained in:
Justin Bertram 2022-01-11 20:32:13 -06:00 committed by clebertsuconic
parent 47b2d4aacd
commit 951c506481
3 changed files with 44 additions and 0 deletions

View File

@ -318,6 +318,7 @@ public class AddressSettings implements Mergeable<AddressSettings>, Serializable
this.autoDeleteAddresses = other.autoDeleteAddresses;
this.autoDeleteAddressesDelay = other.autoDeleteAddressesDelay;
this.configDeleteAddresses = other.configDeleteAddresses;
this.configDeleteDiverts = other.configDeleteDiverts;
this.managementBrowsePageSize = other.managementBrowsePageSize;
this.queuePrefetch = other.queuePrefetch;
this.maxSizeBytesRejectThreshold = other.maxSizeBytesRejectThreshold;
@ -1084,6 +1085,9 @@ public class AddressSettings implements Mergeable<AddressSettings>, Serializable
if (configDeleteAddresses == null) {
configDeleteAddresses = merged.configDeleteAddresses;
}
if (configDeleteDiverts == null) {
configDeleteDiverts = merged.configDeleteDiverts;
}
if (managementBrowsePageSize == null) {
managementBrowsePageSize = merged.managementBrowsePageSize;
}
@ -1398,6 +1402,16 @@ public class AddressSettings implements Mergeable<AddressSettings>, Serializable
if (buffer.readableBytes() > 0) {
enableIngressTimestamp = BufferHelper.readNullableBoolean(buffer);
}
if (buffer.readableBytes() > 0) {
policyStr = tryCompatible ? null : buffer.readNullableSimpleString();
if (policyStr != null) {
configDeleteDiverts = DeletionPolicy.valueOf(policyStr.toString());
} else {
configDeleteDiverts = null;
}
}
}
@Override
@ -1433,6 +1447,7 @@ public class AddressSettings implements Mergeable<AddressSettings>, Serializable
BufferHelper.sizeOfNullableBoolean(autoDeleteQueues) + BufferHelper.sizeOfNullableSimpleString(configDeleteQueues != null ? configDeleteQueues.toString() : null) +
BufferHelper.sizeOfNullableBoolean(autoCreateAddresses) +
BufferHelper.sizeOfNullableBoolean(autoDeleteAddresses) + BufferHelper.sizeOfNullableSimpleString(configDeleteAddresses != null ? configDeleteAddresses.toString() : null) +
BufferHelper.sizeOfNullableSimpleString(configDeleteDiverts != null ? configDeleteDiverts.toString() : null) +
BufferHelper.sizeOfNullableInteger(managementBrowsePageSize) +
BufferHelper.sizeOfNullableLong(maxSizeBytesRejectThreshold) +
BufferHelper.sizeOfNullableInteger(defaultMaxConsumers) +
@ -1596,6 +1611,8 @@ public class AddressSettings implements Mergeable<AddressSettings>, Serializable
BufferHelper.writeNullableInteger(buffer, slowConsumerThresholdMeasurementUnit == null ? null : slowConsumerThresholdMeasurementUnit.getValue());
BufferHelper.writeNullableBoolean(buffer, enableIngressTimestamp);
buffer.writeNullableSimpleString(configDeleteDiverts != null ? new SimpleString(configDeleteDiverts.toString()) : null);
}
/* (non-Javadoc)

View File

@ -20,6 +20,7 @@ import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy;
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
import org.apache.activemq.artemis.core.settings.impl.DeletionPolicy;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.junit.Assert;
import org.junit.Test;
@ -68,6 +69,7 @@ public class AddressSettingsTest extends ActiveMQTestBase {
addressSettingsToMerge.setRedeliveryDelay(1003);
addressSettingsToMerge.setPageSizeBytes(1004);
addressSettingsToMerge.setMaxSizeBytesRejectThreshold(10 * 1024);
addressSettingsToMerge.setConfigDeleteDiverts(DeletionPolicy.FORCE);
addressSettings.merge(addressSettingsToMerge);
Assert.assertEquals(addressSettings.getDeadLetterAddress(), DLQ);
@ -79,6 +81,7 @@ public class AddressSettingsTest extends ActiveMQTestBase {
Assert.assertEquals(addressSettings.getPageSizeBytes(), 1004);
Assert.assertEquals(AddressFullMessagePolicy.DROP, addressSettings.getAddressFullMessagePolicy());
Assert.assertEquals(addressSettings.getMaxSizeBytesRejectThreshold(), 10 * 1024);
Assert.assertEquals(DeletionPolicy.FORCE, addressSettings.getConfigDeleteDiverts());
}
@Test

View File

@ -26,6 +26,7 @@ import org.apache.activemq.artemis.core.persistence.StorageManager;
import org.apache.activemq.artemis.core.persistence.config.PersistedAddressSetting;
import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy;
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
import org.apache.activemq.artemis.core.settings.impl.DeletionPolicy;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -88,6 +89,29 @@ public class AddressSettingsConfigurationStorageTest extends StorageManagerTestB
}
@Test
public void testStoreConfigDeleteSettings() throws Exception {
createStorage();
AddressSettings setting = new AddressSettings()
.setConfigDeleteDiverts(DeletionPolicy.FORCE)
.setConfigDeleteAddresses(DeletionPolicy.FORCE)
.setConfigDeleteQueues(DeletionPolicy.FORCE);
addAddress(journal, "a1", setting);
journal.stop();
createStorage();
checkAddresses(journal);
journal.stop();
journal = null;
}
/**
* @param journal1
* @throws Exception