You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@activemq.apache.org by "tabish121 (via GitHub)" <gi...@apache.org> on 2025/08/04 17:59:28 UTC
[PR] ARTEMIS-5609 Add support for acceptor updates on config reload [activemq-artemis]
tabish121 opened a new pull request, #5854:
URL: https://github.com/apache/activemq-artemis/pull/5854
Allows acceptors to be added, updated and removed from configuation and that change is handled via the reload manager. Removed or updated acceptors have all connections under them closed as a consequence of that action.
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-5609 Add support for acceptor updates on config reload [activemq-artemis]
Posted by "tabish121 (via GitHub)" <gi...@apache.org>.
tabish121 commented on code in PR #5854:
URL: https://github.com/apache/activemq-artemis/pull/5854#discussion_r2254576757
##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java:
##########
@@ -571,11 +610,110 @@ public void loadProtocolServices(List<ActiveMQComponent> protocolServices) {
@Override
public void updateProtocolServices(List<ActiveMQComponent> protocolServices) throws Exception {
+ updateAcceptors();
+
for (ProtocolManagerFactory protocolManagerFactory : protocolMap.values()) {
protocolManagerFactory.updateProtocolServices(this.server, protocolServices);
}
}
+ private void updateAcceptors() throws Exception {
+ final Set<TransportConfiguration> updatedConfigurationSet = Objects.requireNonNullElse(server.getConfiguration().getAcceptorConfigurations(), Collections.emptySet());
+ final Map<String, TransportConfiguration> updatedConfiguration =
+ updatedConfigurationSet.stream()
+ .collect(Collectors.toMap(c -> c.getName(), Function.identity()));
+
+ final Set<TransportConfiguration> acceptorsToStop = new HashSet<>();
+ final Set<TransportConfiguration> acceptorsToCreate = new HashSet<>();
+
+ for (TransportConfiguration candidateConfiguration : updatedConfiguration.values()) {
+ final TransportConfiguration previous = acceptorsConfig.get(candidateConfiguration.getName());
+
+ if (previous == null) {
+ // New configuration that was added during the update
+ acceptorsToCreate.add(candidateConfiguration);
+ } else if (!previous.equals(candidateConfiguration)) {
+ // Updated configuration that needs to be stopped and restarted.
+ acceptorsToCreate.add(candidateConfiguration);
+ acceptorsToStop.add(candidateConfiguration);
+ }
+ }
+
+ for (TransportConfiguration currentConfiguration : acceptorsConfig.values()) {
+ if (!updatedConfiguration.containsKey(currentConfiguration.getName())) {
+ // Acceptor that was removed from the configuration which needs stopped and removed.
+ acceptorsToStop.add(currentConfiguration);
+ }
+ }
+
+ // Replace old configuration map with new configurations ahead of the stop and restart phase.
+ acceptorsConfig.clear();
+ acceptorsConfig.putAll(updatedConfiguration);
+
+ final CountDownLatch acceptorsStoppedLatch = new CountDownLatch(acceptorsToStop.size());
+
+ for (TransportConfiguration acceptorToStop : acceptorsToStop) {
+ final Acceptor acceptor = acceptors.remove(acceptorToStop.getName());
+
+ if (acceptor == null) {
+ continue;
+ }
+
+ final Map<String, Object> acceptorToStopParams = acceptorToStop.getCombinedParams();
+
+ removeAcceptorStoreReloadCallback(acceptorToStop.getName(),
+ fileUrlFrom(acceptorToStopParams.get(KEYSTORE_PATH_PROP_NAME)),
+ storeTypeFrom(acceptorToStopParams.get(KEYSTORE_TYPE_PROP_NAME)));
+
+ removeAcceptorStoreReloadCallback(acceptorToStop.getName(),
+ fileUrlFrom(acceptorToStopParams.get(TRUSTSTORE_PATH_PROP_NAME)),
+ storeTypeFrom(acceptorToStopParams.get(TRUSTSTORE_TYPE_PROP_NAME)));
+
+ try {
+ managementService.unregisterAcceptor(acceptor.getName());
+ } catch (Throwable t) {
+ ActiveMQServerLogger.LOGGER.errorStoppingAcceptor(acceptor.getName());
+ }
+
+ try {
+ acceptor.notifyStop();
+ } catch (Throwable t) {
+ ActiveMQServerLogger.LOGGER.errorStoppingAcceptor(acceptor.getName());
+ }
+
+ try {
+ acceptor.pause();
+ } catch (Throwable t) {
+ ActiveMQServerLogger.LOGGER.errorStoppingAcceptor(acceptor.getName());
+ }
+
+ try {
+ acceptor.asyncStop(acceptorsStoppedLatch::countDown);
+ } catch (Throwable t) {
+ ActiveMQServerLogger.LOGGER.errorStoppingAcceptor(acceptor.getName());
+ }
+ }
+
+ // In some cases an acceptor stopping could be locked ie NettyAcceptor stopping could be locked by a network failure.
+ if (!acceptorsStoppedLatch.await(UPDATE_ACCEPTORS_STOP_TIMEOUT, TimeUnit.MILLISECONDS)) {
+ logger.warn("Timed out waiting on removed or updated acceptors stopping.");
+ }
+
+ // Add all the new or updated acceptors now that removed or updated acceptors have been stopped.
+ for (TransportConfiguration candidateConfiguration : acceptorsToCreate) {
+ final Acceptor acceptor = createAcceptor(candidateConfiguration);
+
+ if (isStarted() && acceptor instanceof NettyAcceptor startable && startable.isAutoStart()) {
+ try {
+ startable.start();
+ } catch (Throwable t) {
+ ActiveMQServerLogger.LOGGER.errorStartingAcceptor(acceptor.getName(), acceptor.getConfiguration());
+ throw t;
+ }
+ }
+ }
Review Comment:
Pushed change to start after all creates are done and only report error after trying to start the batch.
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-5609 Add support for acceptor updates on config reload [activemq-artemis]
Posted by "gemmellr (via GitHub)" <gi...@apache.org>.
gemmellr merged PR #5854:
URL: https://github.com/apache/activemq-artemis/pull/5854
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-5609 Add support for acceptor updates on config reload [activemq-artemis]
Posted by "gemmellr (via GitHub)" <gi...@apache.org>.
gemmellr commented on code in PR #5854:
URL: https://github.com/apache/activemq-artemis/pull/5854#discussion_r2254459932
##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java:
##########
@@ -140,7 +159,12 @@ public RemotingServiceImpl(final ClusterManager clusterManager,
final ServiceRegistry serviceRegistry) {
this.serviceRegistry = serviceRegistry;
- acceptorsConfig = config.getAcceptorConfigurations();
+ if (config.getAcceptorConfigurations() != null && !config.getAcceptorConfigurations().isEmpty()) {
+ acceptorsConfig = config.getAcceptorConfigurations().stream()
+ .collect(Collectors.toMap(c -> c.getName(), Function.identity()));
+ } else {
+ acceptorsConfig = Collections.emptyMap();
Review Comment:
Good catch. I guess that was the point initially, but you are correct that if none were present initially, but then some were attempted to be added, it would try to do a putAll on this map.
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-5609 Add support for acceptor updates on config reload [activemq-artemis]
Posted by "gemmellr (via GitHub)" <gi...@apache.org>.
gemmellr commented on code in PR #5854:
URL: https://github.com/apache/activemq-artemis/pull/5854#discussion_r2254496560
##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java:
##########
@@ -571,11 +610,110 @@ public void loadProtocolServices(List<ActiveMQComponent> protocolServices) {
@Override
public void updateProtocolServices(List<ActiveMQComponent> protocolServices) throws Exception {
+ updateAcceptors();
+
for (ProtocolManagerFactory protocolManagerFactory : protocolMap.values()) {
protocolManagerFactory.updateProtocolServices(this.server, protocolServices);
}
}
+ private void updateAcceptors() throws Exception {
+ final Set<TransportConfiguration> updatedConfigurationSet = Objects.requireNonNullElse(server.getConfiguration().getAcceptorConfigurations(), Collections.emptySet());
+ final Map<String, TransportConfiguration> updatedConfiguration =
+ updatedConfigurationSet.stream()
+ .collect(Collectors.toMap(c -> c.getName(), Function.identity()));
+
+ final Set<TransportConfiguration> acceptorsToStop = new HashSet<>();
+ final Set<TransportConfiguration> acceptorsToCreate = new HashSet<>();
+
+ for (TransportConfiguration candidateConfiguration : updatedConfiguration.values()) {
+ final TransportConfiguration previous = acceptorsConfig.get(candidateConfiguration.getName());
+
+ if (previous == null) {
+ // New configuration that was added during the update
+ acceptorsToCreate.add(candidateConfiguration);
+ } else if (!previous.equals(candidateConfiguration)) {
+ // Updated configuration that needs to be stopped and restarted.
+ acceptorsToCreate.add(candidateConfiguration);
+ acceptorsToStop.add(candidateConfiguration);
+ }
+ }
+
+ for (TransportConfiguration currentConfiguration : acceptorsConfig.values()) {
+ if (!updatedConfiguration.containsKey(currentConfiguration.getName())) {
+ // Acceptor that was removed from the configuration which needs stopped and removed.
+ acceptorsToStop.add(currentConfiguration);
+ }
+ }
+
+ // Replace old configuration map with new configurations ahead of the stop and restart phase.
+ acceptorsConfig.clear();
+ acceptorsConfig.putAll(updatedConfiguration);
+
+ final CountDownLatch acceptorsStoppedLatch = new CountDownLatch(acceptorsToStop.size());
+
+ for (TransportConfiguration acceptorToStop : acceptorsToStop) {
+ final Acceptor acceptor = acceptors.remove(acceptorToStop.getName());
+
+ if (acceptor == null) {
+ continue;
+ }
+
+ final Map<String, Object> acceptorToStopParams = acceptorToStop.getCombinedParams();
+
+ removeAcceptorStoreReloadCallback(acceptorToStop.getName(),
+ fileUrlFrom(acceptorToStopParams.get(KEYSTORE_PATH_PROP_NAME)),
+ storeTypeFrom(acceptorToStopParams.get(KEYSTORE_TYPE_PROP_NAME)));
+
+ removeAcceptorStoreReloadCallback(acceptorToStop.getName(),
+ fileUrlFrom(acceptorToStopParams.get(TRUSTSTORE_PATH_PROP_NAME)),
+ storeTypeFrom(acceptorToStopParams.get(TRUSTSTORE_TYPE_PROP_NAME)));
+
+ try {
+ managementService.unregisterAcceptor(acceptor.getName());
+ } catch (Throwable t) {
+ ActiveMQServerLogger.LOGGER.errorStoppingAcceptor(acceptor.getName());
+ }
+
+ try {
+ acceptor.notifyStop();
+ } catch (Throwable t) {
+ ActiveMQServerLogger.LOGGER.errorStoppingAcceptor(acceptor.getName());
+ }
+
+ try {
+ acceptor.pause();
+ } catch (Throwable t) {
+ ActiveMQServerLogger.LOGGER.errorStoppingAcceptor(acceptor.getName());
+ }
+
+ try {
+ acceptor.asyncStop(acceptorsStoppedLatch::countDown);
+ } catch (Throwable t) {
+ ActiveMQServerLogger.LOGGER.errorStoppingAcceptor(acceptor.getName());
+ }
+ }
+
+ // In some cases an acceptor stopping could be locked ie NettyAcceptor stopping could be locked by a network failure.
+ if (!acceptorsStoppedLatch.await(UPDATE_ACCEPTORS_STOP_TIMEOUT, TimeUnit.MILLISECONDS)) {
+ logger.warn("Timed out waiting on removed or updated acceptors stopping.");
+ }
+
+ // Add all the new or updated acceptors now that removed or updated acceptors have been stopped.
+ for (TransportConfiguration candidateConfiguration : acceptorsToCreate) {
+ final Acceptor acceptor = createAcceptor(candidateConfiguration);
+
+ if (isStarted() && acceptor instanceof NettyAcceptor startable && startable.isAutoStart()) {
+ try {
+ startable.start();
+ } catch (Throwable t) {
+ ActiveMQServerLogger.LOGGER.errorStartingAcceptor(acceptor.getName(), acceptor.getConfiguration());
+ throw t;
+ }
+ }
+ }
Review Comment:
Not sure it matters, but I spotted a difference in sequence between normal startup and the reload. At normal startup, all the acceptors are created (which catches exceptions) but not started, then started in sequence at the end. Here, they are both created and started together, one at a time. If start throws, any later acceptor wouldnt be created. I wondered if the two points should be made consistent?
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-5609 Add support for acceptor updates on config reload [activemq-artemis]
Posted by "tabish121 (via GitHub)" <gi...@apache.org>.
tabish121 commented on code in PR #5854:
URL: https://github.com/apache/activemq-artemis/pull/5854#discussion_r2254499604
##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java:
##########
@@ -140,7 +159,12 @@ public RemotingServiceImpl(final ClusterManager clusterManager,
final ServiceRegistry serviceRegistry) {
this.serviceRegistry = serviceRegistry;
- acceptorsConfig = config.getAcceptorConfigurations();
+ if (config.getAcceptorConfigurations() != null && !config.getAcceptorConfigurations().isEmpty()) {
+ acceptorsConfig = config.getAcceptorConfigurations().stream()
+ .collect(Collectors.toMap(c -> c.getName(), Function.identity()));
+ } else {
+ acceptorsConfig = Collections.emptyMap();
Review Comment:
Fixed
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-5609 Add support for acceptor updates on config reload [activemq-artemis]
Posted by "brusdev (via GitHub)" <gi...@apache.org>.
brusdev commented on code in PR #5854:
URL: https://github.com/apache/activemq-artemis/pull/5854#discussion_r2253171932
##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java:
##########
@@ -571,11 +609,110 @@ public void loadProtocolServices(List<ActiveMQComponent> protocolServices) {
@Override
public void updateProtocolServices(List<ActiveMQComponent> protocolServices) throws Exception {
+ updateAcceptors();
+
for (ProtocolManagerFactory protocolManagerFactory : protocolMap.values()) {
protocolManagerFactory.updateProtocolServices(this.server, protocolServices);
}
}
+ private void updateAcceptors() throws Exception {
+ final Set<TransportConfiguration> updatedConfigurationSet = Objects.requireNonNullElse(server.getConfiguration().getAcceptorConfigurations(), Collections.emptySet());
+ final Map<String, TransportConfiguration> updatedConfiguration =
+ updatedConfigurationSet.stream()
+ .collect(Collectors.toMap(c -> c.getName(), Function.identity()));
+
+ final Set<TransportConfiguration> acceptorsToStop = new HashSet<>();
+ final Set<TransportConfiguration> acceptorsToCreate = new HashSet<>();
+
+ for (TransportConfiguration candidateConfiguration : updatedConfiguration.values()) {
+ final TransportConfiguration previous = acceptorsConfig.get(candidateConfiguration.getName());
+
+ if (previous == null) {
+ // New configuration that was added during the update
+ acceptorsToCreate.add(candidateConfiguration);
+ } else if (!previous.equals(candidateConfiguration)) {
+ // Updated configuration that needs to be stopped and restarted.
+ acceptorsToCreate.add(candidateConfiguration);
+ acceptorsToStop.add(candidateConfiguration);
+ }
+ }
+
+ for (TransportConfiguration currentConfiguration : acceptorsConfig.values()) {
+ if (!updatedConfiguration.containsKey(currentConfiguration.getName())) {
+ // Acceptor that was removed from the configuration which needs stopped and removed.
+ acceptorsToStop.add(currentConfiguration);
+ }
+ }
+
+ // Replace old configuration map with new configurations ahead of the stop and restart phase.
+ acceptorsConfig.clear();
+ acceptorsConfig.putAll(updatedConfiguration);
+
+ final CountDownLatch acceptorsStoppedLatch = new CountDownLatch(acceptorsToStop.size());
+
+ for (TransportConfiguration acceptorToStop : acceptorsToStop) {
+ final Acceptor acceptor = acceptors.remove(acceptorToStop.getName());
+
+ if (acceptor == null) {
+ continue;
+ }
+
+ final Map<String, Object> acceptorToStopParams = acceptorToStop.getCombinedParams();
+
+ removeAcceptorStoreReloadCallback(acceptorToStop.getName(),
+ fileUrlFrom(acceptorToStopParams.get(KEYSTORE_PATH_PROP_NAME)),
+ storeTypeFrom(acceptorToStopParams.get(KEYSTORE_TYPE_PROP_NAME)));
+
+ removeAcceptorStoreReloadCallback(acceptorToStop.getName(),
+ fileUrlFrom(acceptorToStopParams.get(TRUSTSTORE_PATH_PROP_NAME)),
+ storeTypeFrom(acceptorToStopParams.get(TRUSTSTORE_TYPE_PROP_NAME)));
+
+ try {
+ managementService.unregisterAcceptor(acceptor.getName());
+ } catch (Throwable t) {
+ ActiveMQServerLogger.LOGGER.errorStoppingAcceptor(acceptor.getName());
+ }
+
+ try {
+ acceptor.notifyStop();
+ } catch (Throwable t) {
+ ActiveMQServerLogger.LOGGER.errorStoppingAcceptor(acceptor.getName());
+ }
+
+ try {
+ acceptor.pause();
+ } catch (Throwable t) {
+ ActiveMQServerLogger.LOGGER.errorStoppingAcceptor(acceptor.getName());
+ }
+
+ try {
+ acceptor.asyncStop(acceptorsStoppedLatch::countDown);
+ } catch (Throwable t) {
+ ActiveMQServerLogger.LOGGER.errorStoppingAcceptor(acceptor.getName());
+ }
+ }
+
+ // In some cases an acceptor stopping could be locked ie NettyAcceptor stopping could be locked by a network failure.
+ if (!acceptorsStoppedLatch.await(ACCEPTOR_STOP_TIMEOUT, TimeUnit.MILLISECONDS)) {
+ logger.debug("Timed out waiting on removed or updated acceptors stopping.");
Review Comment:
Should a zombie acceptor deserve a waning?
##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java:
##########
@@ -140,7 +159,12 @@ public RemotingServiceImpl(final ClusterManager clusterManager,
final ServiceRegistry serviceRegistry) {
this.serviceRegistry = serviceRegistry;
- acceptorsConfig = config.getAcceptorConfigurations();
+ if (config.getAcceptorConfigurations() != null && !config.getAcceptorConfigurations().isEmpty()) {
+ acceptorsConfig = config.getAcceptorConfigurations().stream()
+ .collect(Collectors.toMap(c -> c.getName(), Function.identity()));
+ } else {
+ acceptorsConfig = Collections.emptyMap();
Review Comment:
Collections.emptyMap doesn't support put operations.
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-5609 Add support for acceptor updates on config reload [activemq-artemis]
Posted by "tabish121 (via GitHub)" <gi...@apache.org>.
tabish121 commented on PR #5854:
URL: https://github.com/apache/activemq-artemis/pull/5854#issuecomment-3155674928
Reran CI with all current changes, no new failures reported.
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-5609 Add support for acceptor updates on config reload [activemq-artemis]
Posted by "gemmellr (via GitHub)" <gi...@apache.org>.
gemmellr commented on code in PR #5854:
URL: https://github.com/apache/activemq-artemis/pull/5854#discussion_r2254462876
##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java:
##########
@@ -571,11 +609,110 @@ public void loadProtocolServices(List<ActiveMQComponent> protocolServices) {
@Override
public void updateProtocolServices(List<ActiveMQComponent> protocolServices) throws Exception {
+ updateAcceptors();
+
for (ProtocolManagerFactory protocolManagerFactory : protocolMap.values()) {
protocolManagerFactory.updateProtocolServices(this.server, protocolServices);
}
}
+ private void updateAcceptors() throws Exception {
+ final Set<TransportConfiguration> updatedConfigurationSet = Objects.requireNonNullElse(server.getConfiguration().getAcceptorConfigurations(), Collections.emptySet());
+ final Map<String, TransportConfiguration> updatedConfiguration =
+ updatedConfigurationSet.stream()
+ .collect(Collectors.toMap(c -> c.getName(), Function.identity()));
+
+ final Set<TransportConfiguration> acceptorsToStop = new HashSet<>();
+ final Set<TransportConfiguration> acceptorsToCreate = new HashSet<>();
+
+ for (TransportConfiguration candidateConfiguration : updatedConfiguration.values()) {
+ final TransportConfiguration previous = acceptorsConfig.get(candidateConfiguration.getName());
+
+ if (previous == null) {
+ // New configuration that was added during the update
+ acceptorsToCreate.add(candidateConfiguration);
+ } else if (!previous.equals(candidateConfiguration)) {
+ // Updated configuration that needs to be stopped and restarted.
+ acceptorsToCreate.add(candidateConfiguration);
+ acceptorsToStop.add(candidateConfiguration);
+ }
+ }
+
+ for (TransportConfiguration currentConfiguration : acceptorsConfig.values()) {
+ if (!updatedConfiguration.containsKey(currentConfiguration.getName())) {
+ // Acceptor that was removed from the configuration which needs stopped and removed.
+ acceptorsToStop.add(currentConfiguration);
+ }
+ }
+
+ // Replace old configuration map with new configurations ahead of the stop and restart phase.
+ acceptorsConfig.clear();
+ acceptorsConfig.putAll(updatedConfiguration);
+
+ final CountDownLatch acceptorsStoppedLatch = new CountDownLatch(acceptorsToStop.size());
+
+ for (TransportConfiguration acceptorToStop : acceptorsToStop) {
+ final Acceptor acceptor = acceptors.remove(acceptorToStop.getName());
+
+ if (acceptor == null) {
+ continue;
+ }
+
+ final Map<String, Object> acceptorToStopParams = acceptorToStop.getCombinedParams();
+
+ removeAcceptorStoreReloadCallback(acceptorToStop.getName(),
+ fileUrlFrom(acceptorToStopParams.get(KEYSTORE_PATH_PROP_NAME)),
+ storeTypeFrom(acceptorToStopParams.get(KEYSTORE_TYPE_PROP_NAME)));
+
+ removeAcceptorStoreReloadCallback(acceptorToStop.getName(),
+ fileUrlFrom(acceptorToStopParams.get(TRUSTSTORE_PATH_PROP_NAME)),
+ storeTypeFrom(acceptorToStopParams.get(TRUSTSTORE_TYPE_PROP_NAME)));
+
+ try {
+ managementService.unregisterAcceptor(acceptor.getName());
+ } catch (Throwable t) {
+ ActiveMQServerLogger.LOGGER.errorStoppingAcceptor(acceptor.getName());
+ }
+
+ try {
+ acceptor.notifyStop();
+ } catch (Throwable t) {
+ ActiveMQServerLogger.LOGGER.errorStoppingAcceptor(acceptor.getName());
+ }
+
+ try {
+ acceptor.pause();
+ } catch (Throwable t) {
+ ActiveMQServerLogger.LOGGER.errorStoppingAcceptor(acceptor.getName());
+ }
+
+ try {
+ acceptor.asyncStop(acceptorsStoppedLatch::countDown);
+ } catch (Throwable t) {
+ ActiveMQServerLogger.LOGGER.errorStoppingAcceptor(acceptor.getName());
+ }
+ }
+
+ // In some cases an acceptor stopping could be locked ie NettyAcceptor stopping could be locked by a network failure.
+ if (!acceptorsStoppedLatch.await(ACCEPTOR_STOP_TIMEOUT, TimeUnit.MILLISECONDS)) {
+ logger.debug("Timed out waiting on removed or updated acceptors stopping.");
Review Comment:
I can see that argument too. I believe this is inspired by the stop method, which itself doesnt even check the await. However that is only used on shutdown, whilst this one would only happen during continued running. Would perhaps need a larger timeout if changing it to a warning, but should perhaps have one anyway given subsequent attempt to start an updated one matching one that didnt stop yet could lead to barfing.
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-5609 Add support for acceptor updates on config reload [activemq-artemis]
Posted by "tabish121 (via GitHub)" <gi...@apache.org>.
tabish121 commented on code in PR #5854:
URL: https://github.com/apache/activemq-artemis/pull/5854#discussion_r2254498469
##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java:
##########
@@ -571,11 +609,110 @@ public void loadProtocolServices(List<ActiveMQComponent> protocolServices) {
@Override
public void updateProtocolServices(List<ActiveMQComponent> protocolServices) throws Exception {
+ updateAcceptors();
+
for (ProtocolManagerFactory protocolManagerFactory : protocolMap.values()) {
protocolManagerFactory.updateProtocolServices(this.server, protocolServices);
}
}
+ private void updateAcceptors() throws Exception {
+ final Set<TransportConfiguration> updatedConfigurationSet = Objects.requireNonNullElse(server.getConfiguration().getAcceptorConfigurations(), Collections.emptySet());
+ final Map<String, TransportConfiguration> updatedConfiguration =
+ updatedConfigurationSet.stream()
+ .collect(Collectors.toMap(c -> c.getName(), Function.identity()));
+
+ final Set<TransportConfiguration> acceptorsToStop = new HashSet<>();
+ final Set<TransportConfiguration> acceptorsToCreate = new HashSet<>();
+
+ for (TransportConfiguration candidateConfiguration : updatedConfiguration.values()) {
+ final TransportConfiguration previous = acceptorsConfig.get(candidateConfiguration.getName());
+
+ if (previous == null) {
+ // New configuration that was added during the update
+ acceptorsToCreate.add(candidateConfiguration);
+ } else if (!previous.equals(candidateConfiguration)) {
+ // Updated configuration that needs to be stopped and restarted.
+ acceptorsToCreate.add(candidateConfiguration);
+ acceptorsToStop.add(candidateConfiguration);
+ }
+ }
+
+ for (TransportConfiguration currentConfiguration : acceptorsConfig.values()) {
+ if (!updatedConfiguration.containsKey(currentConfiguration.getName())) {
+ // Acceptor that was removed from the configuration which needs stopped and removed.
+ acceptorsToStop.add(currentConfiguration);
+ }
+ }
+
+ // Replace old configuration map with new configurations ahead of the stop and restart phase.
+ acceptorsConfig.clear();
+ acceptorsConfig.putAll(updatedConfiguration);
+
+ final CountDownLatch acceptorsStoppedLatch = new CountDownLatch(acceptorsToStop.size());
+
+ for (TransportConfiguration acceptorToStop : acceptorsToStop) {
+ final Acceptor acceptor = acceptors.remove(acceptorToStop.getName());
+
+ if (acceptor == null) {
+ continue;
+ }
+
+ final Map<String, Object> acceptorToStopParams = acceptorToStop.getCombinedParams();
+
+ removeAcceptorStoreReloadCallback(acceptorToStop.getName(),
+ fileUrlFrom(acceptorToStopParams.get(KEYSTORE_PATH_PROP_NAME)),
+ storeTypeFrom(acceptorToStopParams.get(KEYSTORE_TYPE_PROP_NAME)));
+
+ removeAcceptorStoreReloadCallback(acceptorToStop.getName(),
+ fileUrlFrom(acceptorToStopParams.get(TRUSTSTORE_PATH_PROP_NAME)),
+ storeTypeFrom(acceptorToStopParams.get(TRUSTSTORE_TYPE_PROP_NAME)));
+
+ try {
+ managementService.unregisterAcceptor(acceptor.getName());
+ } catch (Throwable t) {
+ ActiveMQServerLogger.LOGGER.errorStoppingAcceptor(acceptor.getName());
+ }
+
+ try {
+ acceptor.notifyStop();
+ } catch (Throwable t) {
+ ActiveMQServerLogger.LOGGER.errorStoppingAcceptor(acceptor.getName());
+ }
+
+ try {
+ acceptor.pause();
+ } catch (Throwable t) {
+ ActiveMQServerLogger.LOGGER.errorStoppingAcceptor(acceptor.getName());
+ }
+
+ try {
+ acceptor.asyncStop(acceptorsStoppedLatch::countDown);
+ } catch (Throwable t) {
+ ActiveMQServerLogger.LOGGER.errorStoppingAcceptor(acceptor.getName());
+ }
+ }
+
+ // In some cases an acceptor stopping could be locked ie NettyAcceptor stopping could be locked by a network failure.
+ if (!acceptorsStoppedLatch.await(ACCEPTOR_STOP_TIMEOUT, TimeUnit.MILLISECONDS)) {
+ logger.debug("Timed out waiting on removed or updated acceptors stopping.");
Review Comment:
I've changed it to warn and added a slightly longer timeout for that particular wait
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-5609 Add support for acceptor updates on config reload [activemq-artemis]
Posted by "tabish121 (via GitHub)" <gi...@apache.org>.
tabish121 commented on code in PR #5854:
URL: https://github.com/apache/activemq-artemis/pull/5854#discussion_r2254513482
##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java:
##########
@@ -571,11 +610,110 @@ public void loadProtocolServices(List<ActiveMQComponent> protocolServices) {
@Override
public void updateProtocolServices(List<ActiveMQComponent> protocolServices) throws Exception {
+ updateAcceptors();
+
for (ProtocolManagerFactory protocolManagerFactory : protocolMap.values()) {
protocolManagerFactory.updateProtocolServices(this.server, protocolServices);
}
}
+ private void updateAcceptors() throws Exception {
+ final Set<TransportConfiguration> updatedConfigurationSet = Objects.requireNonNullElse(server.getConfiguration().getAcceptorConfigurations(), Collections.emptySet());
+ final Map<String, TransportConfiguration> updatedConfiguration =
+ updatedConfigurationSet.stream()
+ .collect(Collectors.toMap(c -> c.getName(), Function.identity()));
+
+ final Set<TransportConfiguration> acceptorsToStop = new HashSet<>();
+ final Set<TransportConfiguration> acceptorsToCreate = new HashSet<>();
+
+ for (TransportConfiguration candidateConfiguration : updatedConfiguration.values()) {
+ final TransportConfiguration previous = acceptorsConfig.get(candidateConfiguration.getName());
+
+ if (previous == null) {
+ // New configuration that was added during the update
+ acceptorsToCreate.add(candidateConfiguration);
+ } else if (!previous.equals(candidateConfiguration)) {
+ // Updated configuration that needs to be stopped and restarted.
+ acceptorsToCreate.add(candidateConfiguration);
+ acceptorsToStop.add(candidateConfiguration);
+ }
+ }
+
+ for (TransportConfiguration currentConfiguration : acceptorsConfig.values()) {
+ if (!updatedConfiguration.containsKey(currentConfiguration.getName())) {
+ // Acceptor that was removed from the configuration which needs stopped and removed.
+ acceptorsToStop.add(currentConfiguration);
+ }
+ }
+
+ // Replace old configuration map with new configurations ahead of the stop and restart phase.
+ acceptorsConfig.clear();
+ acceptorsConfig.putAll(updatedConfiguration);
+
+ final CountDownLatch acceptorsStoppedLatch = new CountDownLatch(acceptorsToStop.size());
+
+ for (TransportConfiguration acceptorToStop : acceptorsToStop) {
+ final Acceptor acceptor = acceptors.remove(acceptorToStop.getName());
+
+ if (acceptor == null) {
+ continue;
+ }
+
+ final Map<String, Object> acceptorToStopParams = acceptorToStop.getCombinedParams();
+
+ removeAcceptorStoreReloadCallback(acceptorToStop.getName(),
+ fileUrlFrom(acceptorToStopParams.get(KEYSTORE_PATH_PROP_NAME)),
+ storeTypeFrom(acceptorToStopParams.get(KEYSTORE_TYPE_PROP_NAME)));
+
+ removeAcceptorStoreReloadCallback(acceptorToStop.getName(),
+ fileUrlFrom(acceptorToStopParams.get(TRUSTSTORE_PATH_PROP_NAME)),
+ storeTypeFrom(acceptorToStopParams.get(TRUSTSTORE_TYPE_PROP_NAME)));
+
+ try {
+ managementService.unregisterAcceptor(acceptor.getName());
+ } catch (Throwable t) {
+ ActiveMQServerLogger.LOGGER.errorStoppingAcceptor(acceptor.getName());
+ }
+
+ try {
+ acceptor.notifyStop();
+ } catch (Throwable t) {
+ ActiveMQServerLogger.LOGGER.errorStoppingAcceptor(acceptor.getName());
+ }
+
+ try {
+ acceptor.pause();
+ } catch (Throwable t) {
+ ActiveMQServerLogger.LOGGER.errorStoppingAcceptor(acceptor.getName());
+ }
+
+ try {
+ acceptor.asyncStop(acceptorsStoppedLatch::countDown);
+ } catch (Throwable t) {
+ ActiveMQServerLogger.LOGGER.errorStoppingAcceptor(acceptor.getName());
+ }
+ }
+
+ // In some cases an acceptor stopping could be locked ie NettyAcceptor stopping could be locked by a network failure.
+ if (!acceptorsStoppedLatch.await(UPDATE_ACCEPTORS_STOP_TIMEOUT, TimeUnit.MILLISECONDS)) {
+ logger.warn("Timed out waiting on removed or updated acceptors stopping.");
+ }
+
+ // Add all the new or updated acceptors now that removed or updated acceptors have been stopped.
+ for (TransportConfiguration candidateConfiguration : acceptorsToCreate) {
+ final Acceptor acceptor = createAcceptor(candidateConfiguration);
+
+ if (isStarted() && acceptor instanceof NettyAcceptor startable && startable.isAutoStart()) {
+ try {
+ startable.start();
+ } catch (Throwable t) {
+ ActiveMQServerLogger.LOGGER.errorStartingAcceptor(acceptor.getName(), acceptor.getConfiguration());
+ throw t;
+ }
+ }
+ }
Review Comment:
Since the update is likely to be small and there would still be existing acceptors that are started likely it seems you still just end up with some active and some not, so it feels like rearranging deck chairs on the Hindenburg. You likely need to stop the broker at that point if you added or updated acceptors with invalid configuration.
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact