Permalink
Browse files
Merge pull request #12249 from pferraro/singleton
WFLY-12022 Concurrent singleton service installation can cause service to run simultaneously on 2 members
- Loading branch information
|
|
@@ -81,7 +81,7 @@ |
|
|
* all of which share the same {@link Cache} instance. |
|
|
* @author Paul Ferraro |
|
|
*/ |
|
|
@org.infinispan.notifications.Listener(sync = false) |
|
|
@org.infinispan.notifications.Listener |
|
|
public class CacheServiceProviderRegistry<T> implements ServiceProviderRegistry<T>, GroupListener, AutoCloseable { |
|
|
|
|
|
private static ThreadFactory createThreadFactory(Class<?> targetClass) { |
|
|
|
|
|
@@ -98,7 +98,7 @@ public void stop(StopContext context) { |
|
|
} |
|
|
|
|
|
@Override |
|
|
public void providersChanged(Set<Node> nodes) { |
|
|
public synchronized void providersChanged(Set<Node> nodes) { |
|
|
Group group = this.registry.get().getGroup(); |
|
|
List<Node> candidates = new ArrayList<>(group.getMembership().getMembers()); |
|
|
candidates.retainAll(nodes); |
|
|
@@ -159,15 +159,15 @@ public void providersChanged(Set<Node> nodes) { |
|
|
} |
|
|
|
|
|
@Override |
|
|
public void start() { |
|
|
public synchronized void start() { |
|
|
// If we were not already the primary node |
|
|
if (this.primary.compareAndSet(false, true)) { |
|
|
this.primaryLifecycle.start(); |
|
|
} |
|
|
} |
|
|
|
|
|
@Override |
|
|
public void stop() { |
|
|
public synchronized void stop() { |
|
|
// If we were the previous the primary node |
|
|
if (this.primary.compareAndSet(true, false)) { |
|
|
this.primaryLifecycle.stop(); |
|
|
|