gemmellr commented on code in PR #5128:
URL: https://github.com/apache/activemq-artemis/pull/5128#discussion_r1705323890
##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java:
##########
@@ -228,11 +228,34 @@ private void configureSizeMetric() {
size.setMax(maxSize, maxSize, maxMessages, maxMessages);
}
+ private boolean validateNewSettings(final AddressSettings addressSettings) {
+
+ Long newPageLimitBytes = addressSettings.getPageLimitBytes();
+
+ if (newPageLimitBytes != null && newPageLimitBytes.longValue() < 0) {
Review Comment:
The .longValue() call seems redundant
##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java:
##########
@@ -228,11 +228,34 @@ private void configureSizeMetric() {
size.setMax(maxSize, maxSize, maxMessages, maxMessages);
}
+ private boolean validateNewSettings(final AddressSettings addressSettings) {
+
+ Long newPageLimitBytes = addressSettings.getPageLimitBytes();
+
+ if (newPageLimitBytes != null && newPageLimitBytes.longValue() < 0) {
+ newPageLimitBytes = null;
+ }
+ int newPageSize =
storageManager.getAllowedPageSize(addressSettings.getPageSizeBytes());
+ if (newPageLimitBytes != null && newPageSize > 0) {
+ long newEstimatedMaxPages = newPageLimitBytes / newPageSize;
+ if (this.numberOfPages > newEstimatedMaxPages) {
+ ActiveMQServerLogger.LOGGER.pageSettingsFailedApply(storeName,
addressSettings, "estimated max pages " + newEstimatedMaxPages + " is less than
current number of pages " + this.numberOfPages);
Review Comment:
"estimated max pages \<foo\> is less than current number of pages \<bar\>"
doesnt do a great job of conveying it is the configured page size and page
limit bytes that are responsible for the 'estimated max pages'.
Perhaps add an indicator that the estimate is calculated from them, e.g
"estimated max pages \<foo\> (page limit / page size) is less than current
number of pages \<bar\>" ?
##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java:
##########
@@ -228,11 +228,34 @@ private void configureSizeMetric() {
size.setMax(maxSize, maxSize, maxMessages, maxMessages);
}
+ private boolean validateNewSettings(final AddressSettings addressSettings) {
+
+ Long newPageLimitBytes = addressSettings.getPageLimitBytes();
+
+ if (newPageLimitBytes != null && newPageLimitBytes.longValue() < 0) {
+ newPageLimitBytes = null;
+ }
+ int newPageSize =
storageManager.getAllowedPageSize(addressSettings.getPageSizeBytes());
+ if (newPageLimitBytes != null && newPageSize > 0) {
+ long newEstimatedMaxPages = newPageLimitBytes / newPageSize;
+ if (this.numberOfPages > newEstimatedMaxPages) {
+ ActiveMQServerLogger.LOGGER.pageSettingsFailedApply(storeName,
addressSettings, "estimated max pages " + newEstimatedMaxPages + " is less than
current number of pages " + this.numberOfPages);
+ return false;
+ }
+ }
+ return true;
+ }
+
/**
* @param addressSettings
*/
@Override
public void applySetting(final AddressSettings addressSettings) {
+
+ if (!validateNewSettings(addressSettings)) {
+ return;
+ }
Review Comment:
The containing applySetting method is also called from the constructor, but
this could make it 'silently' (not counting the logging, which is out of band)
abort and yet successfully return without apply _any_ of the settings, and so
perhaps just continue on with entirely the wrong settings. That feels off.
##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java:
##########
@@ -228,11 +228,34 @@ private void configureSizeMetric() {
size.setMax(maxSize, maxSize, maxMessages, maxMessages);
}
+ private boolean validateNewSettings(final AddressSettings addressSettings) {
+
+ Long newPageLimitBytes = addressSettings.getPageLimitBytes();
+
Review Comment:
If we can manage 2 newline spacers here, seems like we could manage some
below here in the actual logic for improved readability.
##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQMessageBundle.java:
##########
@@ -559,4 +560,6 @@ IllegalStateException invalidRoutingTypeUpdate(String
queueName,
@Message(id = 229255, value = "Bridge {} cannot be {}. Current state: {}")
ActiveMQIllegalStateException bridgeOperationCannotBeExecuted(String
bridgeName, String failedOp, BridgeImpl.State currentState);
+ @Message(id = 229256, value = "Invalid address settings {} for page store
{}. Details: {}")
+ ActiveMQException invalidPageSettings(String pageStoreName, AddressSettings
addressSettings, String details);
Review Comment:
This new exception doesnt appear to be getting thrown anywhere
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact