gtully commented on code in PR #6240:
URL: https://github.com/apache/artemis/pull/6240#discussion_r2823383061
##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/server/routing/ConnectionRouterManager.java:
##########
@@ -46,52 +46,108 @@
import java.lang.invoke.MethodHandles;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+import java.util.function.Function;
+import java.util.stream.Collectors;
public final class ConnectionRouterManager implements ActiveMQComponent {
+
private static final Logger logger =
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
public static final String CACHE_ID_PREFIX = "$.BC.";
-
- private final Configuration config;
-
private final ActiveMQServer server;
private final ScheduledExecutorService scheduledExecutor;
private volatile boolean started = false;
- private Map<String, ConnectionRouter> connectionRouters = new HashMap<>();
+ private final ReentrantReadWriteLock stateLock = new
ReentrantReadWriteLock();
+ private Map<String, ConnectionRouterConfiguration> configurations = new
HashMap<>();
+ private Map<String, ConnectionRouter> connectionRouters = new HashMap<>();
@Override
public boolean isStarted() {
return started;
}
-
- public ConnectionRouterManager(final Configuration config, final
ActiveMQServer server, ScheduledExecutorService scheduledExecutor) {
- this.config = config;
+ public ConnectionRouterManager(final ActiveMQServer server,
ScheduledExecutorService scheduledExecutor) {
this.server = server;
this.scheduledExecutor = scheduledExecutor;
}
- public void deploy() throws Exception {
- for (ConnectionRouterConfiguration connectionRouterConfig :
config.getConnectionRouters()) {
- deployConnectionRouter(connectionRouterConfig);
+ public void deploy(Configuration config) throws Exception {
+ stateLock.writeLock().lock();
+ try {
+ for (ConnectionRouterConfiguration connectionRouterConfig :
config.getConnectionRouters()) {
+ deployConnectionRouter(connectionRouterConfig);
+ }
+ } finally {
+ stateLock.writeLock().unlock();
+ }
+ }
+
+ public void update(Configuration config) throws Exception {
+ stateLock.writeLock().lock();
+ try {
+ final List<ConnectionRouterConfiguration> activeConfiguration =
Objects.requireNonNullElse(config.getConnectionRouters(),
Collections.emptyList());
+
+ // Find any updated configurations and stop them, we will deploy at
the end all new and updated configurations
Review Comment:
I think this comment is not accurate, updated and new are deployed in the
next loop.
--
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]