Use a concurrent set for registrations 30/98530/1
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 15 Nov 2021 08:54:38 +0000 (09:54 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 15 Nov 2021 08:54:38 +0000 (09:54 +0100)
Rather than copying the entire list, use a concurrent set, which
offers better performance characteristics.

Change-Id: I097eb29fb9ef60d40e1ff457678a52ee3c1d1529
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/state/BGPStateCollector.java

index 2b77720b4f0e2756e27792f47e097c83a94b2096..728f974eeec26573781a41ddb0ecfd1fc5eed461 100644 (file)
@@ -10,7 +10,8 @@ package org.opendaylight.protocol.bgp.rib.impl.state;
 import com.google.common.collect.ImmutableList;
 import java.util.List;
 import java.util.Objects;
-import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
 import javax.inject.Inject;
 import javax.inject.Singleton;
 import org.eclipse.jdt.annotation.NonNull;
@@ -51,8 +52,8 @@ public final class BGPStateCollector implements BGPStateProviderRegistry, BGPSta
         }
     }
 
-    private final List<BGPPeerStateProviderRegistration> bgpPeerStates = new CopyOnWriteArrayList<>();
-    private final List<BGPRibStateProviderRegistration> bgpRibStates = new CopyOnWriteArrayList<>();
+    private final Set<BGPPeerStateProviderRegistration> bgpPeerStates = ConcurrentHashMap.newKeySet();
+    private final Set<BGPRibStateProviderRegistration> bgpRibStates = ConcurrentHashMap.newKeySet();
 
     @Inject
     public BGPStateCollector() {