xds: Synchronize access to test control plane collections (#10012)

Fixes #9938
This commit is contained in:
Terry Wilson 2023-04-04 14:34:11 -07:00 committed by GitHub
parent 4ae7370646
commit 18e274de65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 11 deletions

View File

@ -29,6 +29,7 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -75,25 +76,24 @@ final class XdsTestControlPlaneService extends
"type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment"; "type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment";
private final Map<String, HashMap<String, Message>> xdsResources = new HashMap<>(); private final Map<String, HashMap<String, Message>> xdsResources = new HashMap<>();
private ImmutableMap<String, HashMap<StreamObserver<DiscoveryResponse>, Set<String>>> subscribers private ImmutableMap<String, Map<StreamObserver<DiscoveryResponse>, Set<String>>> subscribers
= ImmutableMap.of( = ImmutableMap.of(
ADS_TYPE_URL_LDS, new HashMap<StreamObserver<DiscoveryResponse>, Set<String>>(), ADS_TYPE_URL_LDS, new ConcurrentHashMap<StreamObserver<DiscoveryResponse>, Set<String>>(),
ADS_TYPE_URL_RDS, new HashMap<StreamObserver<DiscoveryResponse>, Set<String>>(), ADS_TYPE_URL_RDS, new ConcurrentHashMap<StreamObserver<DiscoveryResponse>, Set<String>>(),
ADS_TYPE_URL_CDS, new HashMap<StreamObserver<DiscoveryResponse>, Set<String>>(), ADS_TYPE_URL_CDS, new ConcurrentHashMap<StreamObserver<DiscoveryResponse>, Set<String>>(),
ADS_TYPE_URL_EDS, new HashMap<StreamObserver<DiscoveryResponse>, Set<String>>() ADS_TYPE_URL_EDS, new ConcurrentHashMap<StreamObserver<DiscoveryResponse>, Set<String>>());
);
private final ImmutableMap<String, AtomicInteger> xdsVersions = ImmutableMap.of( private final ImmutableMap<String, AtomicInteger> xdsVersions = ImmutableMap.of(
ADS_TYPE_URL_LDS, new AtomicInteger(1), ADS_TYPE_URL_LDS, new AtomicInteger(1),
ADS_TYPE_URL_RDS, new AtomicInteger(1), ADS_TYPE_URL_RDS, new AtomicInteger(1),
ADS_TYPE_URL_CDS, new AtomicInteger(1), ADS_TYPE_URL_CDS, new AtomicInteger(1),
ADS_TYPE_URL_EDS, new AtomicInteger(1) ADS_TYPE_URL_EDS, new AtomicInteger(1)
); );
private final ImmutableMap<String, HashMap<StreamObserver<DiscoveryResponse>, AtomicInteger>> private final ImmutableMap<String, Map<StreamObserver<DiscoveryResponse>, AtomicInteger>>
xdsNonces = ImmutableMap.of( xdsNonces = ImmutableMap.of(
ADS_TYPE_URL_LDS, new HashMap<StreamObserver<DiscoveryResponse>, AtomicInteger>(), ADS_TYPE_URL_LDS, new ConcurrentHashMap<StreamObserver<DiscoveryResponse>, AtomicInteger>(),
ADS_TYPE_URL_RDS, new HashMap<StreamObserver<DiscoveryResponse>, AtomicInteger>(), ADS_TYPE_URL_RDS, new ConcurrentHashMap<StreamObserver<DiscoveryResponse>, AtomicInteger>(),
ADS_TYPE_URL_CDS, new HashMap<StreamObserver<DiscoveryResponse>, AtomicInteger>(), ADS_TYPE_URL_CDS, new ConcurrentHashMap<StreamObserver<DiscoveryResponse>, AtomicInteger>(),
ADS_TYPE_URL_EDS, new HashMap<StreamObserver<DiscoveryResponse>, AtomicInteger>() ADS_TYPE_URL_EDS, new ConcurrentHashMap<StreamObserver<DiscoveryResponse>, AtomicInteger>()
); );