[ 
https://issues.apache.org/jira/browse/ARTEMIS-5609?focusedWorklogId=977715&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-977715
 ]

ASF GitHub Bot logged work on ARTEMIS-5609:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 05/Aug/25 14:03
            Start Date: 05/Aug/25 14:03
    Worklog Time Spent: 10m 
      Work Description: 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.





Issue Time Tracking
-------------------

    Worklog Id:     (was: 977715)
    Time Spent: 40m  (was: 0.5h)

> Add support for (add/remove/update) of acceptors via config reload
> ------------------------------------------------------------------
>
>                 Key: ARTEMIS-5609
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-5609
>             Project: ActiveMQ Artemis
>          Issue Type: New Feature
>          Components: Broker
>    Affects Versions: 2.42.0
>            Reporter: Timothy A. Bish
>            Priority: Minor
>              Labels: pull-request-available
>             Fix For: 2.43.0
>
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> Acceptors are not part of config reload at the moment. 
> [https://activemq.apache.org/components/artemis/documentation/latest/config-reload.html]
> In support of an multi-tenant deployment, having the ability to onboard a new 
> acceptor to a running broker is needed.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to