diff --git a/xds/src/main/java/io/grpc/xds/ClientXdsClient.java b/xds/src/main/java/io/grpc/xds/ClientXdsClient.java index 202bfedcca..95b3bbfcfd 100644 --- a/xds/src/main/java/io/grpc/xds/ClientXdsClient.java +++ b/xds/src/main/java/io/grpc/xds/ClientXdsClient.java @@ -111,7 +111,6 @@ import java.net.InetSocketAddress; import java.net.URI; import java.net.UnknownHostException; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.EnumSet; @@ -398,7 +397,7 @@ final class ClientXdsClient extends XdsClient implements XdsResponseHandler, Res } } - List filterChains = new ArrayList<>(); + ImmutableList.Builder filterChains = ImmutableList.builder(); Set uniqueSet = new HashSet<>(); for (io.envoyproxy.envoy.config.listener.v3.FilterChain fc : proto.getFilterChainsList()) { filterChains.add( @@ -412,8 +411,8 @@ final class ClientXdsClient extends XdsClient implements XdsResponseHandler, Res null, certProviderInstances, parseHttpFilter); } - return new EnvoyServerProtoData.Listener( - proto.getName(), address, Collections.unmodifiableList(filterChains), defaultFilterChain); + return EnvoyServerProtoData.Listener.create( + proto.getName(), address, filterChains.build(), defaultFilterChain); } @VisibleForTesting @@ -470,7 +469,7 @@ final class ClientXdsClient extends XdsClient implements XdsResponseHandler, Res FilterChainMatch filterChainMatch = parseFilterChainMatch(proto.getFilterChainMatch()); checkForUniqueness(uniqueSet, filterChainMatch); - return new FilterChain( + return FilterChain.create( proto.getName(), filterChainMatch, httpConnectionManager, @@ -673,18 +672,18 @@ final class ClientXdsClient extends XdsClient implements XdsResponseHandler, Res private static List expandOnPrefixRange(FilterChainMatch filterChainMatch) { ArrayList expandedList = new ArrayList<>(); - if (filterChainMatch.getPrefixRanges().isEmpty()) { + if (filterChainMatch.prefixRanges().isEmpty()) { expandedList.add(filterChainMatch); } else { - for (EnvoyServerProtoData.CidrRange cidrRange : filterChainMatch.getPrefixRanges()) { - expandedList.add(new FilterChainMatch(filterChainMatch.getDestinationPort(), - Arrays.asList(cidrRange), - Collections.unmodifiableList(filterChainMatch.getApplicationProtocols()), - Collections.unmodifiableList(filterChainMatch.getSourcePrefixRanges()), - filterChainMatch.getConnectionSourceType(), - Collections.unmodifiableList(filterChainMatch.getSourcePorts()), - Collections.unmodifiableList(filterChainMatch.getServerNames()), - filterChainMatch.getTransportProtocol())); + for (EnvoyServerProtoData.CidrRange cidrRange : filterChainMatch.prefixRanges()) { + expandedList.add(FilterChainMatch.create(filterChainMatch.destinationPort(), + ImmutableList.of(cidrRange), + filterChainMatch.applicationProtocols(), + filterChainMatch.sourcePrefixRanges(), + filterChainMatch.connectionSourceType(), + filterChainMatch.sourcePorts(), + filterChainMatch.serverNames(), + filterChainMatch.transportProtocol())); } } return expandedList; @@ -694,18 +693,18 @@ final class ClientXdsClient extends XdsClient implements XdsResponseHandler, Res Collection set) { ArrayList expandedList = new ArrayList<>(); for (FilterChainMatch filterChainMatch : set) { - if (filterChainMatch.getApplicationProtocols().isEmpty()) { + if (filterChainMatch.applicationProtocols().isEmpty()) { expandedList.add(filterChainMatch); } else { - for (String applicationProtocol : filterChainMatch.getApplicationProtocols()) { - expandedList.add(new FilterChainMatch(filterChainMatch.getDestinationPort(), - Collections.unmodifiableList(filterChainMatch.getPrefixRanges()), - Arrays.asList(applicationProtocol), - Collections.unmodifiableList(filterChainMatch.getSourcePrefixRanges()), - filterChainMatch.getConnectionSourceType(), - Collections.unmodifiableList(filterChainMatch.getSourcePorts()), - Collections.unmodifiableList(filterChainMatch.getServerNames()), - filterChainMatch.getTransportProtocol())); + for (String applicationProtocol : filterChainMatch.applicationProtocols()) { + expandedList.add(FilterChainMatch.create(filterChainMatch.destinationPort(), + filterChainMatch.prefixRanges(), + ImmutableList.of(applicationProtocol), + filterChainMatch.sourcePrefixRanges(), + filterChainMatch.connectionSourceType(), + filterChainMatch.sourcePorts(), + filterChainMatch.serverNames(), + filterChainMatch.transportProtocol())); } } } @@ -716,18 +715,18 @@ final class ClientXdsClient extends XdsClient implements XdsResponseHandler, Res Collection set) { ArrayList expandedList = new ArrayList<>(); for (FilterChainMatch filterChainMatch : set) { - if (filterChainMatch.getSourcePrefixRanges().isEmpty()) { + if (filterChainMatch.sourcePrefixRanges().isEmpty()) { expandedList.add(filterChainMatch); } else { - for (EnvoyServerProtoData.CidrRange cidrRange : filterChainMatch.getSourcePrefixRanges()) { - expandedList.add(new FilterChainMatch(filterChainMatch.getDestinationPort(), - Collections.unmodifiableList(filterChainMatch.getPrefixRanges()), - Collections.unmodifiableList(filterChainMatch.getApplicationProtocols()), - Arrays.asList(cidrRange), - filterChainMatch.getConnectionSourceType(), - Collections.unmodifiableList(filterChainMatch.getSourcePorts()), - Collections.unmodifiableList(filterChainMatch.getServerNames()), - filterChainMatch.getTransportProtocol())); + for (EnvoyServerProtoData.CidrRange cidrRange : filterChainMatch.sourcePrefixRanges()) { + expandedList.add(FilterChainMatch.create(filterChainMatch.destinationPort(), + filterChainMatch.prefixRanges(), + filterChainMatch.applicationProtocols(), + ImmutableList.of(cidrRange), + filterChainMatch.connectionSourceType(), + filterChainMatch.sourcePorts(), + filterChainMatch.serverNames(), + filterChainMatch.transportProtocol())); } } } @@ -737,18 +736,18 @@ final class ClientXdsClient extends XdsClient implements XdsResponseHandler, Res private static List expandOnSourcePorts(Collection set) { ArrayList expandedList = new ArrayList<>(); for (FilterChainMatch filterChainMatch : set) { - if (filterChainMatch.getSourcePorts().isEmpty()) { + if (filterChainMatch.sourcePorts().isEmpty()) { expandedList.add(filterChainMatch); } else { - for (Integer sourcePort : filterChainMatch.getSourcePorts()) { - expandedList.add(new FilterChainMatch(filterChainMatch.getDestinationPort(), - Collections.unmodifiableList(filterChainMatch.getPrefixRanges()), - Collections.unmodifiableList(filterChainMatch.getApplicationProtocols()), - Collections.unmodifiableList(filterChainMatch.getSourcePrefixRanges()), - filterChainMatch.getConnectionSourceType(), - Arrays.asList(sourcePort), - Collections.unmodifiableList(filterChainMatch.getServerNames()), - filterChainMatch.getTransportProtocol())); + for (Integer sourcePort : filterChainMatch.sourcePorts()) { + expandedList.add(FilterChainMatch.create(filterChainMatch.destinationPort(), + filterChainMatch.prefixRanges(), + filterChainMatch.applicationProtocols(), + filterChainMatch.sourcePrefixRanges(), + filterChainMatch.connectionSourceType(), + ImmutableList.of(sourcePort), + filterChainMatch.serverNames(), + filterChainMatch.transportProtocol())); } } } @@ -758,18 +757,18 @@ final class ClientXdsClient extends XdsClient implements XdsResponseHandler, Res private static List expandOnServerNames(Collection set) { ArrayList expandedList = new ArrayList<>(); for (FilterChainMatch filterChainMatch : set) { - if (filterChainMatch.getServerNames().isEmpty()) { + if (filterChainMatch.serverNames().isEmpty()) { expandedList.add(filterChainMatch); } else { - for (String serverName : filterChainMatch.getServerNames()) { - expandedList.add(new FilterChainMatch(filterChainMatch.getDestinationPort(), - Collections.unmodifiableList(filterChainMatch.getPrefixRanges()), - Collections.unmodifiableList(filterChainMatch.getApplicationProtocols()), - Collections.unmodifiableList(filterChainMatch.getSourcePrefixRanges()), - filterChainMatch.getConnectionSourceType(), - Collections.unmodifiableList(filterChainMatch.getSourcePorts()), - Arrays.asList(serverName), - filterChainMatch.getTransportProtocol())); + for (String serverName : filterChainMatch.serverNames()) { + expandedList.add(FilterChainMatch.create(filterChainMatch.destinationPort(), + filterChainMatch.prefixRanges(), + filterChainMatch.applicationProtocols(), + filterChainMatch.sourcePrefixRanges(), + filterChainMatch.connectionSourceType(), + filterChainMatch.sourcePorts(), + ImmutableList.of(serverName), + filterChainMatch.transportProtocol())); } } } @@ -779,16 +778,17 @@ final class ClientXdsClient extends XdsClient implements XdsResponseHandler, Res private static FilterChainMatch parseFilterChainMatch( io.envoyproxy.envoy.config.listener.v3.FilterChainMatch proto) throws ResourceInvalidException { - List prefixRanges = new ArrayList<>(); - List sourcePrefixRanges = new ArrayList<>(); + ImmutableList.Builder prefixRanges = ImmutableList.builder(); + ImmutableList.Builder sourcePrefixRanges = ImmutableList.builder(); try { for (io.envoyproxy.envoy.config.core.v3.CidrRange range : proto.getPrefixRangesList()) { - prefixRanges.add(new CidrRange(range.getAddressPrefix(), range.getPrefixLen().getValue())); + prefixRanges.add( + CidrRange.create(range.getAddressPrefix(), range.getPrefixLen().getValue())); } for (io.envoyproxy.envoy.config.core.v3.CidrRange range : proto.getSourcePrefixRangesList()) { sourcePrefixRanges.add( - new CidrRange(range.getAddressPrefix(), range.getPrefixLen().getValue())); + CidrRange.create(range.getAddressPrefix(), range.getPrefixLen().getValue())); } } catch (UnknownHostException e) { throw new ResourceInvalidException("Failed to create CidrRange", e); @@ -807,14 +807,14 @@ final class ClientXdsClient extends XdsClient implements XdsResponseHandler, Res default: throw new ResourceInvalidException("Unknown source-type: " + proto.getSourceType()); } - return new FilterChainMatch( + return FilterChainMatch.create( proto.getDestinationPort().getValue(), - prefixRanges, - proto.getApplicationProtocolsList(), - sourcePrefixRanges, + prefixRanges.build(), + ImmutableList.copyOf(proto.getApplicationProtocolsList()), + sourcePrefixRanges.build(), sourceType, - proto.getSourcePortsList(), - proto.getServerNamesList(), + ImmutableList.copyOf(proto.getSourcePortsList()), + ImmutableList.copyOf(proto.getServerNamesList()), proto.getTransportProtocol()); } diff --git a/xds/src/main/java/io/grpc/xds/EnvoyServerProtoData.java b/xds/src/main/java/io/grpc/xds/EnvoyServerProtoData.java index 09318a8c15..2fa6b868c6 100644 --- a/xds/src/main/java/io/grpc/xds/EnvoyServerProtoData.java +++ b/xds/src/main/java/io/grpc/xds/EnvoyServerProtoData.java @@ -16,17 +16,14 @@ package io.grpc.xds; -import static com.google.common.base.Preconditions.checkNotNull; - +import com.google.auto.value.AutoValue; import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.MoreObjects; +import com.google.common.collect.ImmutableList; import io.envoyproxy.envoy.extensions.transport_sockets.tls.v3.CommonTlsContext; import io.grpc.Internal; import io.grpc.xds.internal.sds.SslContextProviderSupplier; import java.net.InetAddress; import java.net.UnknownHostException; -import java.util.Collections; -import java.util.List; import java.util.Objects; import javax.annotation.Nullable; @@ -142,47 +139,16 @@ public final class EnvoyServerProtoData { } } - static final class CidrRange { - private final InetAddress addressPrefix; - private final int prefixLen; + @AutoValue + abstract static class CidrRange { - CidrRange(String addressPrefix, int prefixLen) throws UnknownHostException { - this.addressPrefix = InetAddress.getByName(addressPrefix); - this.prefixLen = prefixLen; - } + abstract InetAddress addressPrefix(); - public InetAddress getAddressPrefix() { - return addressPrefix; - } + abstract int prefixLen(); - public int getPrefixLen() { - return prefixLen; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - CidrRange cidrRange = (CidrRange) o; - return prefixLen == cidrRange.prefixLen - && java.util.Objects.equals(addressPrefix, cidrRange.addressPrefix); - } - - @Override - public int hashCode() { - return java.util.Objects.hash(addressPrefix, prefixLen); - } - - @Override - public String toString() { - return "CidrRange{" - + "addressPrefix='" + addressPrefix + '\'' - + ", prefixLen=" + prefixLen - + '}'; + static CidrRange create(String addressPrefix, int prefixLen) throws UnknownHostException { + return new AutoValue_EnvoyServerProtoData_CidrRange( + InetAddress.getByName(addressPrefix), prefixLen); } } @@ -201,259 +167,91 @@ public final class EnvoyServerProtoData { * Corresponds to Envoy proto message * {@link io.envoyproxy.envoy.api.v2.listener.FilterChainMatch}. */ - static final class FilterChainMatch { - private final int destinationPort; - private final List prefixRanges; - private final List applicationProtocols; - private final List sourcePrefixRanges; - private final ConnectionSourceType sourceType; - private final List sourcePorts; - private final List serverNames; - private final String transportProtocol; + @AutoValue + abstract static class FilterChainMatch { - @VisibleForTesting - FilterChainMatch( - int destinationPort, - List prefixRanges, - List applicationProtocols, - List sourcePrefixRanges, - ConnectionSourceType sourceType, - List sourcePorts, - List serverNames, - String transportProtocol) { - this.destinationPort = destinationPort; - this.prefixRanges = Collections.unmodifiableList(prefixRanges); - this.applicationProtocols = Collections.unmodifiableList(applicationProtocols); - this.sourcePrefixRanges = sourcePrefixRanges; - this.sourceType = sourceType; - this.sourcePorts = sourcePorts; - this.serverNames = Collections.unmodifiableList(serverNames); - this.transportProtocol = transportProtocol; - } + abstract int destinationPort(); - public int getDestinationPort() { - return destinationPort; - } + abstract ImmutableList prefixRanges(); - public List getPrefixRanges() { - return prefixRanges; - } + abstract ImmutableList applicationProtocols(); - public List getApplicationProtocols() { - return applicationProtocols; - } + abstract ImmutableList sourcePrefixRanges(); - public List getSourcePrefixRanges() { - return sourcePrefixRanges; - } + abstract ConnectionSourceType connectionSourceType(); - public ConnectionSourceType getConnectionSourceType() { - return sourceType; - } + abstract ImmutableList sourcePorts(); - public List getSourcePorts() { - return sourcePorts; - } + abstract ImmutableList serverNames(); - public List getServerNames() { - return serverNames; - } + abstract String transportProtocol(); - public String getTransportProtocol() { - return transportProtocol; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - FilterChainMatch that = (FilterChainMatch) o; - return destinationPort == that.destinationPort - && Objects.equals(prefixRanges, that.prefixRanges) - && Objects.equals(applicationProtocols, that.applicationProtocols) - && Objects.equals(sourcePrefixRanges, that.sourcePrefixRanges) - && sourceType == that.sourceType - && Objects.equals(sourcePorts, that.sourcePorts) - && Objects.equals(serverNames, that.serverNames) - && Objects.equals(transportProtocol, that.transportProtocol); - } - - @Override - public int hashCode() { - return Objects.hash( - destinationPort, - prefixRanges, - applicationProtocols, - sourcePrefixRanges, - sourceType, - sourcePorts, - serverNames, - transportProtocol); - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(this) - .add("destinationPort", destinationPort) - .add("prefixRanges", prefixRanges) - .add("applicationProtocols", applicationProtocols) - .add("sourcePrefixRanges", sourcePrefixRanges) - .add("sourceType", sourceType) - .add("sourcePorts", sourcePorts) - .add("serverNames", serverNames) - .add("transportProtocol", transportProtocol) - .toString(); + public static FilterChainMatch create(int destinationPort, + ImmutableList prefixRanges, + ImmutableList applicationProtocols, ImmutableList sourcePrefixRanges, + ConnectionSourceType connectionSourceType, ImmutableList sourcePorts, + ImmutableList serverNames, String transportProtocol) { + return new AutoValue_EnvoyServerProtoData_FilterChainMatch( + destinationPort, prefixRanges, applicationProtocols, sourcePrefixRanges, + connectionSourceType, sourcePorts, serverNames, transportProtocol); } } /** * Corresponds to Envoy proto message {@link io.envoyproxy.envoy.api.v2.listener.FilterChain}. */ - static final class FilterChain { - // possibly empty - private final String name; - // TODO(sanjaypujare): flatten structure by moving FilterChainMatch class members here. - private final FilterChainMatch filterChainMatch; - private final HttpConnectionManager httpConnectionManager; - @Nullable - private final SslContextProviderSupplier sslContextProviderSupplier; + @AutoValue + abstract static class FilterChain { - FilterChain( + // possibly empty + abstract String name(); + + // TODO(sanjaypujare): flatten structure by moving FilterChainMatch class members here. + abstract FilterChainMatch filterChainMatch(); + + abstract HttpConnectionManager httpConnectionManager(); + + @Nullable + abstract SslContextProviderSupplier sslContextProviderSupplier(); + + static FilterChain create( String name, FilterChainMatch filterChainMatch, HttpConnectionManager httpConnectionManager, @Nullable DownstreamTlsContext downstreamTlsContext, TlsContextManager tlsContextManager) { - SslContextProviderSupplier sslContextProviderSupplier1 = downstreamTlsContext == null ? null - : new SslContextProviderSupplier(downstreamTlsContext, tlsContextManager); - this.name = checkNotNull(name, "name"); - // TODO(chengyuanzhang): enforce non-null, change tests to use a default/empty - // FilterChainMatch instead of null, as that's how the proto is converted. - this.filterChainMatch = filterChainMatch; - this.sslContextProviderSupplier = sslContextProviderSupplier1; - this.httpConnectionManager = checkNotNull(httpConnectionManager, "httpConnectionManager"); - } - - String getName() { - return name; - } - - public FilterChainMatch getFilterChainMatch() { - return filterChainMatch; - } - - HttpConnectionManager getHttpConnectionManager() { - return httpConnectionManager; - } - - @Nullable - public SslContextProviderSupplier getSslContextProviderSupplier() { - return sslContextProviderSupplier; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - FilterChain that = (FilterChain) o; - return Objects.equals(name, that.name) - && Objects.equals(filterChainMatch, that.filterChainMatch) - && Objects.equals(httpConnectionManager, that.httpConnectionManager) - && Objects.equals(sslContextProviderSupplier, that.sslContextProviderSupplier); - } - - @Override - public int hashCode() { - return Objects.hash( + SslContextProviderSupplier sslContextProviderSupplier = + downstreamTlsContext == null + ? null : new SslContextProviderSupplier(downstreamTlsContext, tlsContextManager); + return new AutoValue_EnvoyServerProtoData_FilterChain( name, filterChainMatch, httpConnectionManager, sslContextProviderSupplier); } - - @Override - public String toString() { - return MoreObjects.toStringHelper(this) - .add("name", name) - .add("filterChainMatch", filterChainMatch) - .add("httpConnectionManager", httpConnectionManager) - .add("sslContextProviderSupplier", sslContextProviderSupplier) - .toString(); - } } /** * Corresponds to Envoy proto message {@link io.envoyproxy.envoy.api.v2.Listener} & related * classes. */ - public static final class Listener { - private final String name; - @Nullable - private final String address; - private final List filterChains; - @Nullable - private final FilterChain defaultFilterChain; + @AutoValue + abstract static class Listener { - /** Construct a Listener. */ - public Listener(String name, @Nullable String address, - List filterChains, @Nullable FilterChain defaultFilterChain) { - this.name = checkNotNull(name, "name"); - this.address = address; - this.filterChains = Collections.unmodifiableList(checkNotNull(filterChains, "filterChains")); - this.defaultFilterChain = defaultFilterChain; - } - - public String getName() { - return name; - } + abstract String name(); @Nullable - public String getAddress() { - return address; - } + abstract String address(); - public List getFilterChains() { - return filterChains; - } + abstract ImmutableList filterChains(); @Nullable - public FilterChain getDefaultFilterChain() { - return defaultFilterChain; - } + abstract FilterChain defaultFilterChain(); - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Listener listener = (Listener) o; - return Objects.equals(name, listener.name) - && Objects.equals(address, listener.address) - && Objects.equals(filterChains, listener.filterChains) - && Objects.equals(defaultFilterChain, listener.defaultFilterChain); - } - - @Override - public int hashCode() { - return Objects.hash(name, address, filterChains, defaultFilterChain); - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(this) - .add("name", name) - .add("address", address) - .add("filterChains", filterChains) - .add("defaultFilterChain", defaultFilterChain) - .toString(); + static Listener create( + String name, + @Nullable String address, + ImmutableList filterChains, + @Nullable FilterChain defaultFilterChain) { + return new AutoValue_EnvoyServerProtoData_Listener(name, address, filterChains, + defaultFilterChain); } } } diff --git a/xds/src/main/java/io/grpc/xds/FilterChainMatchingProtocolNegotiators.java b/xds/src/main/java/io/grpc/xds/FilterChainMatchingProtocolNegotiators.java index 5d72151db5..e75440225d 100644 --- a/xds/src/main/java/io/grpc/xds/FilterChainMatchingProtocolNegotiators.java +++ b/xds/src/main/java/io/grpc/xds/FilterChainMatchingProtocolNegotiators.java @@ -39,7 +39,6 @@ import io.grpc.xds.EnvoyServerProtoData.CidrRange; import io.grpc.xds.EnvoyServerProtoData.ConnectionSourceType; import io.grpc.xds.EnvoyServerProtoData.FilterChain; import io.grpc.xds.EnvoyServerProtoData.FilterChainMatch; -import io.grpc.xds.FilterChainMatchingProtocolNegotiators.FilterChainMatchingHandler.FilterChainSelector; import io.grpc.xds.XdsServerWrapper.ServerRoutingConfig; import io.grpc.xds.internal.Matchers.CidrMatcher; import io.grpc.xds.internal.sds.SslContextProviderSupplier; @@ -189,7 +188,7 @@ final class FilterChainMatchingProtocolNegotiators { if (filterChains.size() == 1) { FilterChain selected = Iterables.getOnlyElement(filterChains); return new SelectedConfig( - routingConfigs.get(selected), selected.getSslContextProviderSupplier()); + routingConfigs.get(selected), selected.sslContextProviderSupplier()); } if (defaultRoutingConfig.get() != null) { return new SelectedConfig(defaultRoutingConfig, defaultSslContextProviderSupplier); @@ -202,9 +201,9 @@ final class FilterChainMatchingProtocolNegotiators { Collection filterChains) { ArrayList filtered = new ArrayList<>(filterChains.size()); for (FilterChain filterChain : filterChains) { - FilterChainMatch filterChainMatch = filterChain.getFilterChainMatch(); + FilterChainMatch filterChainMatch = filterChain.filterChainMatch(); - if (filterChainMatch.getApplicationProtocols().isEmpty()) { + if (filterChainMatch.applicationProtocols().isEmpty()) { filtered.add(filterChain); } } @@ -216,9 +215,9 @@ final class FilterChainMatchingProtocolNegotiators { Collection filterChains) { ArrayList filtered = new ArrayList<>(filterChains.size()); for (FilterChain filterChain : filterChains) { - FilterChainMatch filterChainMatch = filterChain.getFilterChainMatch(); + FilterChainMatch filterChainMatch = filterChain.filterChainMatch(); - String transportProtocol = filterChainMatch.getTransportProtocol(); + String transportProtocol = filterChainMatch.transportProtocol(); if (Strings.isNullOrEmpty(transportProtocol) || "raw_buffer".equals(transportProtocol)) { filtered.add(filterChain); } @@ -231,9 +230,9 @@ final class FilterChainMatchingProtocolNegotiators { Collection filterChains) { ArrayList filtered = new ArrayList<>(filterChains.size()); for (FilterChain filterChain : filterChains) { - FilterChainMatch filterChainMatch = filterChain.getFilterChainMatch(); + FilterChainMatch filterChainMatch = filterChain.filterChainMatch(); - if (filterChainMatch.getServerNames().isEmpty()) { + if (filterChainMatch.serverNames().isEmpty()) { filtered.add(filterChain); } } @@ -245,9 +244,9 @@ final class FilterChainMatchingProtocolNegotiators { Collection filterChains) { ArrayList filtered = new ArrayList<>(filterChains.size()); for (FilterChain filterChain : filterChains) { - FilterChainMatch filterChainMatch = filterChain.getFilterChainMatch(); + FilterChainMatch filterChainMatch = filterChain.filterChainMatch(); - if (filterChainMatch.getDestinationPort() + if (filterChainMatch.destinationPort() == UInt32Value.getDefaultInstance().getValue()) { filtered.add(filterChain); } @@ -260,9 +259,9 @@ final class FilterChainMatchingProtocolNegotiators { ArrayList filteredOnMatch = new ArrayList<>(filterChains.size()); ArrayList filteredOnEmpty = new ArrayList<>(filterChains.size()); for (FilterChain filterChain : filterChains) { - FilterChainMatch filterChainMatch = filterChain.getFilterChainMatch(); + FilterChainMatch filterChainMatch = filterChain.filterChainMatch(); - List sourcePortsToMatch = filterChainMatch.getSourcePorts(); + List sourcePortsToMatch = filterChainMatch.sourcePorts(); if (sourcePortsToMatch.isEmpty()) { filteredOnEmpty.add(filterChain); } else if (sourcePortsToMatch.contains(sourcePort)) { @@ -278,9 +277,9 @@ final class FilterChainMatchingProtocolNegotiators { InetAddress destAddress) { ArrayList filtered = new ArrayList<>(filterChains.size()); for (FilterChain filterChain : filterChains) { - FilterChainMatch filterChainMatch = filterChain.getFilterChainMatch(); + FilterChainMatch filterChainMatch = filterChain.filterChainMatch(); ConnectionSourceType sourceType = - filterChainMatch.getConnectionSourceType(); + filterChainMatch.connectionSourceType(); boolean matching = false; if (sourceType == ConnectionSourceType.SAME_IP_OR_LOOPBACK) { @@ -305,18 +304,18 @@ final class FilterChainMatchingProtocolNegotiators { boolean isIPv6 = address instanceof Inet6Address; List cidrRanges = forDestination - ? filterChainMatch.getPrefixRanges() - : filterChainMatch.getSourcePrefixRanges(); + ? filterChainMatch.prefixRanges() + : filterChainMatch.sourcePrefixRanges(); int matchingPrefixLength; if (cidrRanges.isEmpty()) { // if there is no CidrRange assume 0-length match matchingPrefixLength = 0; } else { matchingPrefixLength = -1; for (CidrRange cidrRange : cidrRanges) { - InetAddress cidrAddr = cidrRange.getAddressPrefix(); + InetAddress cidrAddr = cidrRange.addressPrefix(); boolean cidrIsIpv6 = cidrAddr instanceof Inet6Address; if (isIPv6 == cidrIsIpv6) { - int prefixLen = cidrRange.getPrefixLen(); + int prefixLen = cidrRange.prefixLen(); CidrMatcher matcher = CidrMatcher.create(cidrAddr, prefixLen); if (matcher.matches(address) && prefixLen > matchingPrefixLength) { matchingPrefixLength = prefixLen; @@ -335,7 +334,7 @@ final class FilterChainMatchingProtocolNegotiators { int topMatchingPrefixLen = -1; for (FilterChain filterChain : filterChains) { int currentMatchingPrefixLen = getMatchingPrefixLength( - filterChain.getFilterChainMatch(), address, forDestination); + filterChain.filterChainMatch(), address, forDestination); if (currentMatchingPrefixLen >= 0) { if (currentMatchingPrefixLen < topMatchingPrefixLen) { diff --git a/xds/src/main/java/io/grpc/xds/XdsServerWrapper.java b/xds/src/main/java/io/grpc/xds/XdsServerWrapper.java index 58c9692fa6..eef4a9c2fb 100644 --- a/xds/src/main/java/io/grpc/xds/XdsServerWrapper.java +++ b/xds/src/main/java/io/grpc/xds/XdsServerWrapper.java @@ -386,8 +386,8 @@ final class XdsServerWrapper extends Server { releaseSuppliersInFlight(); pendingRds.clear(); } - filterChains = update.listener().getFilterChains(); - defaultFilterChain = update.listener().getDefaultFilterChain(); + filterChains = update.listener().filterChains(); + defaultFilterChain = update.listener().defaultFilterChain(); List allFilterChains = filterChains; if (defaultFilterChain != null) { allFilterChains = new ArrayList<>(filterChains); @@ -395,7 +395,7 @@ final class XdsServerWrapper extends Server { } Set allRds = new HashSet<>(); for (FilterChain filterChain : allFilterChains) { - HttpConnectionManager hcm = filterChain.getHttpConnectionManager(); + HttpConnectionManager hcm = filterChain.httpConnectionManager(); if (hcm.virtualHosts() == null) { RouteDiscoveryState rdsState = routeDiscoveryStates.get(hcm.rdsName()); if (rdsState == null) { @@ -478,7 +478,7 @@ final class XdsServerWrapper extends Server { } FilterChainSelector selector = new FilterChainSelector( Collections.unmodifiableMap(filterChainRouting), - defaultFilterChain == null ? null : defaultFilterChain.getSslContextProviderSupplier(), + defaultFilterChain == null ? null : defaultFilterChain.sslContextProviderSupplier(), defaultFilterChain == null ? new AtomicReference() : generateRoutingConfig(defaultFilterChain)); List toRelease = getSuppliersInUse(); @@ -491,7 +491,7 @@ final class XdsServerWrapper extends Server { } private AtomicReference generateRoutingConfig(FilterChain filterChain) { - HttpConnectionManager hcm = filterChain.getHttpConnectionManager(); + HttpConnectionManager hcm = filterChain.httpConnectionManager(); if (hcm.virtualHosts() != null) { ImmutableMap interceptors = generatePerRouteInterceptors( hcm.httpFilterConfigs(), hcm.virtualHosts()); @@ -602,8 +602,8 @@ final class XdsServerWrapper extends Server { FilterChainSelector selector = filterChainSelectorManager.getSelectorToUpdateSelector(); if (selector != null) { for (FilterChain f: selector.getRoutingConfigs().keySet()) { - if (f.getSslContextProviderSupplier() != null) { - toRelease.add(f.getSslContextProviderSupplier()); + if (f.sslContextProviderSupplier() != null) { + toRelease.add(f.sslContextProviderSupplier()); } } SslContextProviderSupplier defaultSupplier = @@ -618,13 +618,13 @@ final class XdsServerWrapper extends Server { private void releaseSuppliersInFlight() { SslContextProviderSupplier supplier; for (FilterChain filterChain : filterChains) { - supplier = filterChain.getSslContextProviderSupplier(); + supplier = filterChain.sslContextProviderSupplier(); if (supplier != null) { supplier.close(); } } if (defaultFilterChain != null - && (supplier = defaultFilterChain.getSslContextProviderSupplier()) != null) { + && (supplier = defaultFilterChain.sslContextProviderSupplier()) != null) { supplier.close(); } } @@ -689,20 +689,20 @@ final class XdsServerWrapper extends Server { private void updateRdsRoutingConfig() { for (FilterChain filterChain : savedRdsRoutingConfigRef.keySet()) { - if (resourceName.equals(filterChain.getHttpConnectionManager().rdsName())) { + if (resourceName.equals(filterChain.httpConnectionManager().rdsName())) { ServerRoutingConfig updatedRoutingConfig; if (savedVirtualHosts == null) { updatedRoutingConfig = ServerRoutingConfig.FAILING_ROUTING_CONFIG; } else { ImmutableMap updatedInterceptors = generatePerRouteInterceptors( - filterChain.getHttpConnectionManager().httpFilterConfigs(), + filterChain.httpConnectionManager().httpFilterConfigs(), savedVirtualHosts); updatedRoutingConfig = ServerRoutingConfig.create(savedVirtualHosts, updatedInterceptors); } logger.log(Level.FINEST, "Updating filter chain {0} rds routing config: {1}", - new Object[]{filterChain.getName(), updatedRoutingConfig}); + new Object[]{filterChain.name(), updatedRoutingConfig}); savedRdsRoutingConfigRef.get(filterChain).set(updatedRoutingConfig); } } diff --git a/xds/src/test/java/io/grpc/xds/ClientXdsClientDataTest.java b/xds/src/test/java/io/grpc/xds/ClientXdsClientDataTest.java index b195a63eec..2b75c02d4d 100644 --- a/xds/src/test/java/io/grpc/xds/ClientXdsClientDataTest.java +++ b/xds/src/test/java/io/grpc/xds/ClientXdsClientDataTest.java @@ -2180,7 +2180,7 @@ public class ClientXdsClientDataTest { EnvoyServerProtoData.FilterChain parsedFilterChain2 = ClientXdsClient.parseFilterChain( filterChain2, new HashSet(), null, filterRegistry, null, null, true /* does not matter */); - assertThat(parsedFilterChain1.getName()).isEqualTo(parsedFilterChain2.getName()); + assertThat(parsedFilterChain1.name()).isEqualTo(parsedFilterChain2.name()); } @Test diff --git a/xds/src/test/java/io/grpc/xds/ClientXdsClientTestBase.java b/xds/src/test/java/io/grpc/xds/ClientXdsClientTestBase.java index c0ad0b47c5..ba182be76d 100644 --- a/xds/src/test/java/io/grpc/xds/ClientXdsClientTestBase.java +++ b/xds/src/test/java/io/grpc/xds/ClientXdsClientTestBase.java @@ -1282,10 +1282,10 @@ public abstract class ClientXdsClientTestBase { call.sendResponse(LDS, packedListener, VERSION_1, "0000"); verify(ldsResourceWatcher).onChanged(ldsUpdateCaptor.capture()); - assertThat(ldsUpdateCaptor.getValue().listener().getFilterChains()).hasSize(1); + assertThat(ldsUpdateCaptor.getValue().listener().filterChains()).hasSize(1); FilterChain parsedFilterChain = Iterables.getOnlyElement( - ldsUpdateCaptor.getValue().listener().getFilterChains()); - assertThat(parsedFilterChain.getHttpConnectionManager().rdsName()).isEqualTo(RDS_RESOURCE); + ldsUpdateCaptor.getValue().listener().filterChains()); + assertThat(parsedFilterChain.httpConnectionManager().rdsName()).isEqualTo(RDS_RESOURCE); verifyResourceMetadataAcked(LDS, LISTENER_RESOURCE, packedListener, VERSION_1, TIME_INCREMENT); verifyResourceMetadataRequested(RDS, RDS_RESOURCE); verifySubscribedResourcesMetadataSizes(1, 0, 1, 0); @@ -1310,10 +1310,10 @@ public abstract class ClientXdsClientTestBase { Any.pack(mf.buildListenerWithFilterChain(LISTENER_RESOURCE, 7000, "0.0.0.0", filterChain)); call.sendResponse(LDS, packedListener, VERSION_2, "0001"); verify(ldsResourceWatcher, times(2)).onChanged(ldsUpdateCaptor.capture()); - assertThat(ldsUpdateCaptor.getValue().listener().getFilterChains()).hasSize(1); + assertThat(ldsUpdateCaptor.getValue().listener().filterChains()).hasSize(1); parsedFilterChain = Iterables.getOnlyElement( - ldsUpdateCaptor.getValue().listener().getFilterChains()); - assertThat(parsedFilterChain.getHttpConnectionManager().virtualHosts()).hasSize(VHOST_SIZE); + ldsUpdateCaptor.getValue().listener().filterChains()); + assertThat(parsedFilterChain.httpConnectionManager().virtualHosts()).hasSize(VHOST_SIZE); verify(rdsResourceWatcher).onResourceDoesNotExist(RDS_RESOURCE); verifyResourceMetadataDoesNotExist(RDS, RDS_RESOURCE); verifyResourceMetadataAcked( @@ -2608,15 +2608,15 @@ public abstract class ClientXdsClientTestBase { ResourceType.LDS, Collections.singletonList(LISTENER_RESOURCE), "0", "0000", NODE); verify(ldsResourceWatcher).onChanged(ldsUpdateCaptor.capture()); EnvoyServerProtoData.Listener parsedListener = ldsUpdateCaptor.getValue().listener(); - assertThat(parsedListener.getName()).isEqualTo(LISTENER_RESOURCE); - assertThat(parsedListener.getAddress()).isEqualTo("0.0.0.0:7000"); - assertThat(parsedListener.getDefaultFilterChain()).isNull(); - assertThat(parsedListener.getFilterChains()).hasSize(1); - FilterChain parsedFilterChain = Iterables.getOnlyElement(parsedListener.getFilterChains()); - assertThat(parsedFilterChain.getFilterChainMatch().getApplicationProtocols()).isEmpty(); - assertThat(parsedFilterChain.getHttpConnectionManager().rdsName()) + assertThat(parsedListener.name()).isEqualTo(LISTENER_RESOURCE); + assertThat(parsedListener.address()).isEqualTo("0.0.0.0:7000"); + assertThat(parsedListener.defaultFilterChain()).isNull(); + assertThat(parsedListener.filterChains()).hasSize(1); + FilterChain parsedFilterChain = Iterables.getOnlyElement(parsedListener.filterChains()); + assertThat(parsedFilterChain.filterChainMatch().applicationProtocols()).isEmpty(); + assertThat(parsedFilterChain.httpConnectionManager().rdsName()) .isEqualTo("route-foo.googleapis.com"); - assertThat(parsedFilterChain.getHttpConnectionManager().httpFilterConfigs().get(0).filterConfig) + assertThat(parsedFilterChain.httpConnectionManager().httpFilterConfigs().get(0).filterConfig) .isEqualTo(RouterFilter.ROUTER_CONFIG); assertThat(fakeClock.getPendingTasks(LDS_RESOURCE_FETCH_TIMEOUT_TASK_FILTER)).isEmpty(); diff --git a/xds/src/test/java/io/grpc/xds/FilterChainMatchingProtocolNegotiatorsTest.java b/xds/src/test/java/io/grpc/xds/FilterChainMatchingProtocolNegotiatorsTest.java index 32a7bc19b3..a4efb226ce 100644 --- a/xds/src/test/java/io/grpc/xds/FilterChainMatchingProtocolNegotiatorsTest.java +++ b/xds/src/test/java/io/grpc/xds/FilterChainMatchingProtocolNegotiatorsTest.java @@ -60,7 +60,6 @@ import java.net.InetSocketAddress; import java.net.SocketAddress; import java.net.UnknownHostException; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -90,6 +89,16 @@ public class FilterChainMatchingProtocolNegotiatorsTest { @Mock private ProtocolNegotiator mockDelegate; private FilterChainSelectorManager selectorManager = new FilterChainSelectorManager(); + private static final EnvoyServerProtoData.FilterChainMatch DEFAULT_FILTER_CHAIN_MATCH = + EnvoyServerProtoData.FilterChainMatch.create( + 0, + ImmutableList.of(), + ImmutableList.of(), + ImmutableList.of(), + EnvoyServerProtoData.ConnectionSourceType.ANY, + ImmutableList.of(), + ImmutableList.of(), + ""); private static final HttpConnectionManager HTTP_CONNECTION_MANAGER = createRds("routing-config"); private static final String LOCAL_IP = "10.1.2.3"; // dest private static final String REMOTE_IP = "10.4.2.3"; // source @@ -188,18 +197,18 @@ public class FilterChainMatchingProtocolNegotiatorsTest { @Test public void singleFilterChainWithoutAlpn() throws Exception { EnvoyServerProtoData.FilterChainMatch filterChainMatch = - new EnvoyServerProtoData.FilterChainMatch( - 0, - Arrays.asList(), - Arrays.asList(), - Arrays.asList(), - EnvoyServerProtoData.ConnectionSourceType.ANY, - Arrays.asList(), - Arrays.asList(), - null); + EnvoyServerProtoData.FilterChainMatch.create( + 0, + ImmutableList.of(), + ImmutableList.of(), + ImmutableList.of(), + EnvoyServerProtoData.ConnectionSourceType.ANY, + ImmutableList.of(), + ImmutableList.of(), + ""); EnvoyServerProtoData.DownstreamTlsContext tlsContext = CommonTlsContextTestsUtil.buildTestInternalDownstreamTlsContext("CERT1", "VA1"); - EnvoyServerProtoData.FilterChain filterChain = new EnvoyServerProtoData.FilterChain( + EnvoyServerProtoData.FilterChain filterChain = EnvoyServerProtoData.FilterChain.create( "filter-chain-foo", filterChainMatch, HTTP_CONNECTION_MANAGER, tlsContext, tlsContextManager); @@ -213,7 +222,7 @@ public class FilterChainMatchingProtocolNegotiatorsTest { pipeline.fireUserEventTriggered(event); channel.runPendingTasks(); assertThat(sslSet.isDone()).isTrue(); - assertThat(sslSet.get()).isEqualTo(filterChain.getSslContextProviderSupplier()); + assertThat(sslSet.get()).isEqualTo(filterChain.sslContextProviderSupplier()); assertThat(routingSettable.get()).isEqualTo(noopConfig); assertThat(sslSet.get().getTlsContext()).isSameInstanceAs(tlsContext); } @@ -221,28 +230,28 @@ public class FilterChainMatchingProtocolNegotiatorsTest { @Test public void singleFilterChainWithAlpn() throws Exception { EnvoyServerProtoData.FilterChainMatch filterChainMatch = - new EnvoyServerProtoData.FilterChainMatch( - 0, - Arrays.asList(), - Arrays.asList("managed-mtls"), - Arrays.asList(), - EnvoyServerProtoData.ConnectionSourceType.ANY, - Arrays.asList(), - Arrays.asList(), - null); + EnvoyServerProtoData.FilterChainMatch.create( + 0, + ImmutableList.of(), + ImmutableList.of("managed-mtls"), + ImmutableList.of(), + EnvoyServerProtoData.ConnectionSourceType.ANY, + ImmutableList.of(), + ImmutableList.of(), + ""); EnvoyServerProtoData.DownstreamTlsContext tlsContext = CommonTlsContextTestsUtil.buildTestInternalDownstreamTlsContext("CERT1", "VA1"); - EnvoyServerProtoData.FilterChain filterChain = new EnvoyServerProtoData.FilterChain( + EnvoyServerProtoData.FilterChain filterChain = EnvoyServerProtoData.FilterChain.create( "filter-chain-foo", filterChainMatch, HTTP_CONNECTION_MANAGER, tlsContext, tlsContextManager); EnvoyServerProtoData.DownstreamTlsContext defaultTlsContext = CommonTlsContextTestsUtil.buildTestInternalDownstreamTlsContext("CERT2", "VA2"); - EnvoyServerProtoData.FilterChain defaultFilterChain = new EnvoyServerProtoData.FilterChain( - "filter-chain-bar", null, HTTP_CONNECTION_MANAGER, defaultTlsContext, - tlsContextManager); + EnvoyServerProtoData.FilterChain defaultFilterChain = EnvoyServerProtoData.FilterChain.create( + "filter-chain-bar", DEFAULT_FILTER_CHAIN_MATCH, HTTP_CONNECTION_MANAGER, defaultTlsContext, + tlsContextManager); selectorManager.updateSelector(new FilterChainSelector( ImmutableMap.of(filterChain, randomConfig("no-match")), - defaultFilterChain.getSslContextProviderSupplier(), noopConfig)); + defaultFilterChain.sslContextProviderSupplier(), noopConfig)); FilterChainMatchingHandler filterChainMatchingHandler = new FilterChainMatchingHandler(grpcHandler, selectorManager, mockDelegate); @@ -251,7 +260,7 @@ public class FilterChainMatchingProtocolNegotiatorsTest { setupChannel(LOCAL_IP, REMOTE_IP, 15000, filterChainMatchingHandler); pipeline.fireUserEventTriggered(event); channel.runPendingTasks(); - assertThat(sslSet.get()).isEqualTo(defaultFilterChain.getSslContextProviderSupplier()); + assertThat(sslSet.get()).isEqualTo(defaultFilterChain.sslContextProviderSupplier()); assertThat(routingSettable.get()).isEqualTo(noopConfig); assertThat(sslSet.get().getTlsContext()).isSameInstanceAs(defaultTlsContext); } @@ -261,24 +270,24 @@ public class FilterChainMatchingProtocolNegotiatorsTest { EnvoyServerProtoData.DownstreamTlsContext tlsContextWithDestPort = CommonTlsContextTestsUtil.buildTestInternalDownstreamTlsContext("CERT1", "VA1"); EnvoyServerProtoData.FilterChainMatch filterChainMatchWithDestPort = - new EnvoyServerProtoData.FilterChainMatch( - PORT, - Arrays.asList(), - Arrays.asList("managed-mtls"), - Arrays.asList(), - EnvoyServerProtoData.ConnectionSourceType.ANY, - Arrays.asList(), - Arrays.asList(), - null); + EnvoyServerProtoData.FilterChainMatch.create( + PORT, + ImmutableList.of(), + ImmutableList.of("managed-mtls"), + ImmutableList.of(), + EnvoyServerProtoData.ConnectionSourceType.ANY, + ImmutableList.of(), + ImmutableList.of(), + ""); EnvoyServerProtoData.FilterChain filterChainWithDestPort = - new EnvoyServerProtoData.FilterChain( + EnvoyServerProtoData.FilterChain.create( "filter-chain-foo", filterChainMatchWithDestPort, HTTP_CONNECTION_MANAGER, tlsContextWithDestPort, tlsContextManager); EnvoyServerProtoData.DownstreamTlsContext tlsContextForDefaultFilterChain = CommonTlsContextTestsUtil.buildTestInternalDownstreamTlsContext("CERT2", "VA2"); EnvoyServerProtoData.FilterChain defaultFilterChain = - new EnvoyServerProtoData.FilterChain( - "filter-chain-bar", null, HTTP_CONNECTION_MANAGER, + EnvoyServerProtoData.FilterChain.create( + "filter-chain-bar", DEFAULT_FILTER_CHAIN_MATCH, HTTP_CONNECTION_MANAGER, tlsContextForDefaultFilterChain, tlsContextManager); ServerRoutingConfig routingConfig = ServerRoutingConfig.create( @@ -287,7 +296,7 @@ public class FilterChainMatchingProtocolNegotiatorsTest { selectorManager.updateSelector(new FilterChainSelector( ImmutableMap.of(filterChainWithDestPort, new AtomicReference(routingConfig)), - defaultFilterChain.getSslContextProviderSupplier(), noopConfig)); + defaultFilterChain.sslContextProviderSupplier(), noopConfig)); FilterChainMatchingHandler filterChainMatchingHandler = new FilterChainMatchingHandler(grpcHandler, selectorManager, mockDelegate); @@ -297,7 +306,7 @@ public class FilterChainMatchingProtocolNegotiatorsTest { setupChannel(LOCAL_IP, REMOTE_IP, 15000, filterChainMatchingHandler); pipeline.fireUserEventTriggered(event); channel.runPendingTasks(); - assertThat(sslSet.get()).isEqualTo(defaultFilterChain.getSslContextProviderSupplier()); + assertThat(sslSet.get()).isEqualTo(defaultFilterChain.sslContextProviderSupplier()); assertThat(routingSettable.get()).isEqualTo(noopConfig); assertThat(sslSet.get().getTlsContext()) .isSameInstanceAs(tlsContextForDefaultFilterChain); @@ -308,27 +317,27 @@ public class FilterChainMatchingProtocolNegotiatorsTest { EnvoyServerProtoData.DownstreamTlsContext tlsContextMatch = CommonTlsContextTestsUtil.buildTestInternalDownstreamTlsContext("CERT1", "VA1"); EnvoyServerProtoData.FilterChainMatch filterChainMatchWithMatch = - new EnvoyServerProtoData.FilterChainMatch( - 0, - Arrays.asList(new EnvoyServerProtoData.CidrRange("10.1.2.0", 24)), - Arrays.asList(), - Arrays.asList(), - EnvoyServerProtoData.ConnectionSourceType.ANY, - Arrays.asList(), - Arrays.asList(), - null); - EnvoyServerProtoData.FilterChain filterChainWithMatch = new EnvoyServerProtoData.FilterChain( + EnvoyServerProtoData.FilterChainMatch.create( + 0, + ImmutableList.of(EnvoyServerProtoData.CidrRange.create("10.1.2.0", 24)), + ImmutableList.of(), + ImmutableList.of(), + EnvoyServerProtoData.ConnectionSourceType.ANY, + ImmutableList.of(), + ImmutableList.of(), + ""); + EnvoyServerProtoData.FilterChain filterChainWithMatch = EnvoyServerProtoData.FilterChain.create( "filter-chain-foo", filterChainMatchWithMatch, HTTP_CONNECTION_MANAGER, tlsContextMatch, tlsContextManager); EnvoyServerProtoData.DownstreamTlsContext tlsContextForDefaultFilterChain = CommonTlsContextTestsUtil.buildTestInternalDownstreamTlsContext("CERT2", "VA2"); - EnvoyServerProtoData.FilterChain defaultFilterChain = new EnvoyServerProtoData.FilterChain( - "filter-chain-bar", null, HTTP_CONNECTION_MANAGER, + EnvoyServerProtoData.FilterChain defaultFilterChain = EnvoyServerProtoData.FilterChain.create( + "filter-chain-bar", DEFAULT_FILTER_CHAIN_MATCH, HTTP_CONNECTION_MANAGER, tlsContextForDefaultFilterChain, tlsContextManager); selectorManager.updateSelector(new FilterChainSelector( ImmutableMap.of(filterChainWithMatch, noopConfig), - defaultFilterChain.getSslContextProviderSupplier(), randomConfig("no-match"))); + defaultFilterChain.sslContextProviderSupplier(), randomConfig("no-match"))); FilterChainMatchingHandler filterChainMatchingHandler = new FilterChainMatchingHandler(grpcHandler, selectorManager, mockDelegate); @@ -338,7 +347,7 @@ public class FilterChainMatchingProtocolNegotiatorsTest { setupChannel(LOCAL_IP, REMOTE_IP, 15000, filterChainMatchingHandler); pipeline.fireUserEventTriggered(event); channel.runPendingTasks(); - assertThat(sslSet.get()).isEqualTo(filterChainWithMatch.getSslContextProviderSupplier()); + assertThat(sslSet.get()).isEqualTo(filterChainWithMatch.sslContextProviderSupplier()); assertThat(routingSettable.get()).isEqualTo(noopConfig); assertThat(sslSet.get().getTlsContext()).isSameInstanceAs(tlsContextMatch); } @@ -350,27 +359,27 @@ public class FilterChainMatchingProtocolNegotiatorsTest { CommonTlsContextTestsUtil.buildTestInternalDownstreamTlsContext("CERT1", "VA1"); // 10.2.2.0/24 doesn't match LOCAL_IP EnvoyServerProtoData.FilterChainMatch filterChainMatchWithMismatch = - new EnvoyServerProtoData.FilterChainMatch( - 0, - Arrays.asList(new EnvoyServerProtoData.CidrRange("10.2.2.0", 24)), - Arrays.asList(), - Arrays.asList(), - EnvoyServerProtoData.ConnectionSourceType.ANY, - Arrays.asList(), - Arrays.asList(), - null); + EnvoyServerProtoData.FilterChainMatch.create( + 0, + ImmutableList.of(EnvoyServerProtoData.CidrRange.create("10.2.2.0", 24)), + ImmutableList.of(), + ImmutableList.of(), + EnvoyServerProtoData.ConnectionSourceType.ANY, + ImmutableList.of(), + ImmutableList.of(), + ""); EnvoyServerProtoData.FilterChain filterChainWithMismatch = - new EnvoyServerProtoData.FilterChain( + EnvoyServerProtoData.FilterChain.create( "filter-chain-foo", filterChainMatchWithMismatch, HTTP_CONNECTION_MANAGER, tlsContextMismatch, tlsContextManager); EnvoyServerProtoData.DownstreamTlsContext tlsContextForDefaultFilterChain = CommonTlsContextTestsUtil.buildTestInternalDownstreamTlsContext("CERT2", "VA2"); - EnvoyServerProtoData.FilterChain defaultFilterChain = new EnvoyServerProtoData.FilterChain( - "filter-chain-bar", null, HTTP_CONNECTION_MANAGER, + EnvoyServerProtoData.FilterChain defaultFilterChain = EnvoyServerProtoData.FilterChain.create( + "filter-chain-bar", DEFAULT_FILTER_CHAIN_MATCH, HTTP_CONNECTION_MANAGER, tlsContextForDefaultFilterChain, tlsContextManager); selectorManager.updateSelector(new FilterChainSelector( ImmutableMap.of(filterChainWithMismatch, randomConfig("no-match")), - defaultFilterChain.getSslContextProviderSupplier(), noopConfig)); + defaultFilterChain.sslContextProviderSupplier(), noopConfig)); FilterChainMatchingHandler filterChainMatchingHandler = new FilterChainMatchingHandler(grpcHandler, selectorManager, mockDelegate); @@ -381,7 +390,7 @@ public class FilterChainMatchingProtocolNegotiatorsTest { pipeline.fireUserEventTriggered(event); channel.runPendingTasks(); assertThat(sslSet.isDone()).isTrue(); - assertThat(sslSet.get()).isEqualTo(defaultFilterChain.getSslContextProviderSupplier()); + assertThat(sslSet.get()).isEqualTo(defaultFilterChain.sslContextProviderSupplier()); assertThat(routingSettable.get()).isEqualTo(noopConfig); assertThat(sslSet.get().getTlsContext()).isSameInstanceAs(tlsContextForDefaultFilterChain); } @@ -393,27 +402,27 @@ public class FilterChainMatchingProtocolNegotiatorsTest { CommonTlsContextTestsUtil.buildTestInternalDownstreamTlsContext("CERT1", "VA1"); // 10.2.2.0/24 doesn't match LOCAL_IP EnvoyServerProtoData.FilterChainMatch filterChainMatch0Length = - new EnvoyServerProtoData.FilterChainMatch( - 0, - Arrays.asList(new EnvoyServerProtoData.CidrRange("10.2.2.0", 0)), - Arrays.asList(), - Arrays.asList(), - EnvoyServerProtoData.ConnectionSourceType.ANY, - Arrays.asList(), - Arrays.asList(), - null); - EnvoyServerProtoData.FilterChain filterChain0Length = new EnvoyServerProtoData.FilterChain( + EnvoyServerProtoData.FilterChainMatch.create( + 0, + ImmutableList.of(EnvoyServerProtoData.CidrRange.create("10.2.2.0", 0)), + ImmutableList.of(), + ImmutableList.of(), + EnvoyServerProtoData.ConnectionSourceType.ANY, + ImmutableList.of(), + ImmutableList.of(), + ""); + EnvoyServerProtoData.FilterChain filterChain0Length = EnvoyServerProtoData.FilterChain.create( "filter-chain-foo", filterChainMatch0Length, HTTP_CONNECTION_MANAGER, tlsContext0Length, tlsContextManager); EnvoyServerProtoData.DownstreamTlsContext tlsContextForDefaultFilterChain = CommonTlsContextTestsUtil.buildTestInternalDownstreamTlsContext("CERT2", "VA2"); - EnvoyServerProtoData.FilterChain defaultFilterChain = new EnvoyServerProtoData.FilterChain( - "filter-chain-bar", null, HTTP_CONNECTION_MANAGER, + EnvoyServerProtoData.FilterChain defaultFilterChain = EnvoyServerProtoData.FilterChain.create( + "filter-chain-bar", DEFAULT_FILTER_CHAIN_MATCH, HTTP_CONNECTION_MANAGER, tlsContextForDefaultFilterChain, tlsContextManager); selectorManager.updateSelector(new FilterChainSelector( ImmutableMap.of(filterChain0Length, noopConfig), - defaultFilterChain.getSslContextProviderSupplier(), + defaultFilterChain.sslContextProviderSupplier(), new AtomicReference())); FilterChainMatchingHandler filterChainMatchingHandler = new FilterChainMatchingHandler(grpcHandler, selectorManager, mockDelegate); @@ -423,7 +432,7 @@ public class FilterChainMatchingProtocolNegotiatorsTest { setupChannel(LOCAL_IP, REMOTE_IP, 15000, filterChainMatchingHandler); pipeline.fireUserEventTriggered(event); channel.runPendingTasks(); - assertThat(sslSet.get()).isEqualTo(filterChain0Length.getSslContextProviderSupplier()); + assertThat(sslSet.get()).isEqualTo(filterChain0Length.sslContextProviderSupplier()); assertThat(routingSettable.get()).isEqualTo(noopConfig); assertThat(sslSet.get().getTlsContext()).isSameInstanceAs(tlsContext0Length); } @@ -434,43 +443,44 @@ public class FilterChainMatchingProtocolNegotiatorsTest { EnvoyServerProtoData.DownstreamTlsContext tlsContextLessSpecific = CommonTlsContextTestsUtil.buildTestInternalDownstreamTlsContext("CERT1", "VA1"); EnvoyServerProtoData.FilterChainMatch filterChainMatchLessSpecific = - new EnvoyServerProtoData.FilterChainMatch( - 0, - Arrays.asList(new EnvoyServerProtoData.CidrRange("10.1.2.0", 24)), - Arrays.asList(), - Arrays.asList(), - EnvoyServerProtoData.ConnectionSourceType.ANY, - Arrays.asList(), - Arrays.asList(), - null); + EnvoyServerProtoData.FilterChainMatch.create( + 0, + ImmutableList.of(EnvoyServerProtoData.CidrRange.create("10.1.2.0", 24)), + ImmutableList.of(), + ImmutableList.of(), + EnvoyServerProtoData.ConnectionSourceType.ANY, + ImmutableList.of(), + ImmutableList.of(), + ""); EnvoyServerProtoData.FilterChain filterChainLessSpecific = - new EnvoyServerProtoData.FilterChain( + EnvoyServerProtoData.FilterChain.create( "filter-chain-foo", filterChainMatchLessSpecific, HTTP_CONNECTION_MANAGER, tlsContextLessSpecific, tlsContextManager); EnvoyServerProtoData.DownstreamTlsContext tlsContextMoreSpecific = CommonTlsContextTestsUtil.buildTestInternalDownstreamTlsContext("CERT2", "VA2"); EnvoyServerProtoData.FilterChainMatch filterChainMatchMoreSpecific = - new EnvoyServerProtoData.FilterChainMatch( - 0, - Arrays.asList(new EnvoyServerProtoData.CidrRange("10.1.2.2", 31)), - Arrays.asList(), - Arrays.asList(), - EnvoyServerProtoData.ConnectionSourceType.ANY, - Arrays.asList(), - Arrays.asList(), - null); + EnvoyServerProtoData.FilterChainMatch.create( + 0, + ImmutableList.of(EnvoyServerProtoData.CidrRange.create("10.1.2.2", 31)), + ImmutableList.of(), + ImmutableList.of(), + EnvoyServerProtoData.ConnectionSourceType.ANY, + ImmutableList.of(), + ImmutableList.of(), + ""); EnvoyServerProtoData.FilterChain filterChainMoreSpecific = - new EnvoyServerProtoData.FilterChain( + EnvoyServerProtoData.FilterChain.create( "filter-chain-bar", filterChainMatchMoreSpecific, HTTP_CONNECTION_MANAGER, tlsContextMoreSpecific, tlsContextManager); - EnvoyServerProtoData.FilterChain defaultFilterChain = new EnvoyServerProtoData.FilterChain( - "filter-chain-baz", null, HTTP_CONNECTION_MANAGER, null, tlsContextManager); + EnvoyServerProtoData.FilterChain defaultFilterChain = EnvoyServerProtoData.FilterChain.create( + "filter-chain-baz", DEFAULT_FILTER_CHAIN_MATCH, HTTP_CONNECTION_MANAGER, null, + tlsContextManager); selectorManager.updateSelector(new FilterChainSelector( ImmutableMap.of(filterChainLessSpecific, randomConfig("no-match"), filterChainMoreSpecific, noopConfig), - defaultFilterChain.getSslContextProviderSupplier(), randomConfig("default"))); + defaultFilterChain.sslContextProviderSupplier(), randomConfig("default"))); FilterChainMatchingHandler filterChainMatchingHandler = new FilterChainMatchingHandler(grpcHandler, selectorManager, mockDelegate); @@ -480,7 +490,7 @@ public class FilterChainMatchingProtocolNegotiatorsTest { setupChannel(LOCAL_IP, REMOTE_IP, 15000, filterChainMatchingHandler); pipeline.fireUserEventTriggered(event); channel.runPendingTasks(); - assertThat(sslSet.get()).isEqualTo(filterChainMoreSpecific.getSslContextProviderSupplier()); + assertThat(sslSet.get()).isEqualTo(filterChainMoreSpecific.sslContextProviderSupplier()); assertThat(routingSettable.get()).isEqualTo(noopConfig); assertThat(sslSet.get().getTlsContext()).isSameInstanceAs(tlsContextMoreSpecific); } @@ -491,43 +501,44 @@ public class FilterChainMatchingProtocolNegotiatorsTest { EnvoyServerProtoData.DownstreamTlsContext tlsContextLessSpecific = CommonTlsContextTestsUtil.buildTestInternalDownstreamTlsContext("CERT1", "VA1"); EnvoyServerProtoData.FilterChainMatch filterChainMatchLessSpecific = - new EnvoyServerProtoData.FilterChainMatch( - 0, - Arrays.asList(), - Arrays.asList(), - Arrays.asList(), - EnvoyServerProtoData.ConnectionSourceType.ANY, - Arrays.asList(), - Arrays.asList(), - null); + EnvoyServerProtoData.FilterChainMatch.create( + 0, + ImmutableList.of(), + ImmutableList.of(), + ImmutableList.of(), + EnvoyServerProtoData.ConnectionSourceType.ANY, + ImmutableList.of(), + ImmutableList.of(), + ""); EnvoyServerProtoData.FilterChain filterChainLessSpecific = - new EnvoyServerProtoData.FilterChain( + EnvoyServerProtoData.FilterChain.create( "filter-chain-foo", filterChainMatchLessSpecific, HTTP_CONNECTION_MANAGER, tlsContextLessSpecific, tlsContextManager); EnvoyServerProtoData.DownstreamTlsContext tlsContextMoreSpecific = CommonTlsContextTestsUtil.buildTestInternalDownstreamTlsContext("CERT2", "VA2"); EnvoyServerProtoData.FilterChainMatch filterChainMatchMoreSpecific = - new EnvoyServerProtoData.FilterChainMatch( - 0, - Arrays.asList(new EnvoyServerProtoData.CidrRange("8.0.0.0", 5)), - Arrays.asList(), - Arrays.asList(), - EnvoyServerProtoData.ConnectionSourceType.ANY, - Arrays.asList(), - Arrays.asList(), - null); + EnvoyServerProtoData.FilterChainMatch.create( + 0, + ImmutableList.of(EnvoyServerProtoData.CidrRange.create("8.0.0.0", 5)), + ImmutableList.of(), + ImmutableList.of(), + EnvoyServerProtoData.ConnectionSourceType.ANY, + ImmutableList.of(), + ImmutableList.of(), + ""); EnvoyServerProtoData.FilterChain filterChainMoreSpecific = - new EnvoyServerProtoData.FilterChain( + EnvoyServerProtoData.FilterChain.create( "filter-chain-bar", filterChainMatchMoreSpecific, HTTP_CONNECTION_MANAGER, tlsContextMoreSpecific, tlsContextManager); - EnvoyServerProtoData.FilterChain defaultFilterChain = new EnvoyServerProtoData.FilterChain( - "filter-chain-baz", null, HTTP_CONNECTION_MANAGER, null, tlsContextManager); + EnvoyServerProtoData.FilterChain defaultFilterChain = EnvoyServerProtoData.FilterChain.create( + "filter-chain-baz", DEFAULT_FILTER_CHAIN_MATCH, HTTP_CONNECTION_MANAGER, null, + tlsContextManager); selectorManager.updateSelector(new FilterChainSelector( ImmutableMap.of(filterChainLessSpecific, randomConfig("no-match"), filterChainMoreSpecific, noopConfig), - defaultFilterChain.getSslContextProviderSupplier(), randomConfig("default"))); + defaultFilterChain.sslContextProviderSupplier(), randomConfig("default"))); FilterChainMatchingHandler filterChainMatchingHandler = new FilterChainMatchingHandler(grpcHandler, selectorManager, mockDelegate); @@ -536,7 +547,7 @@ public class FilterChainMatchingProtocolNegotiatorsTest { setupChannel(LOCAL_IP, REMOTE_IP, 15000, filterChainMatchingHandler); pipeline.fireUserEventTriggered(event); channel.runPendingTasks(); - assertThat(sslSet.get()).isEqualTo(filterChainMoreSpecific.getSslContextProviderSupplier()); + assertThat(sslSet.get()).isEqualTo(filterChainMoreSpecific.sslContextProviderSupplier()); assertThat(routingSettable.get()).isEqualTo(noopConfig); assertThat(sslSet.get().getTlsContext()).isSameInstanceAs(tlsContextMoreSpecific); } @@ -547,42 +558,44 @@ public class FilterChainMatchingProtocolNegotiatorsTest { EnvoyServerProtoData.DownstreamTlsContext tlsContextLessSpecific = CommonTlsContextTestsUtil.buildTestInternalDownstreamTlsContext("CERT1", "VA1"); EnvoyServerProtoData.FilterChainMatch filterChainMatchLessSpecific = - new EnvoyServerProtoData.FilterChainMatch( - 0, - Arrays.asList(new EnvoyServerProtoData.CidrRange("FE80:0:0:0:0:0:0:0", 60)), - Arrays.asList(), - Arrays.asList(), - EnvoyServerProtoData.ConnectionSourceType.ANY, - Arrays.asList(), - Arrays.asList(), - null); + EnvoyServerProtoData.FilterChainMatch.create( + 0, + ImmutableList.of(EnvoyServerProtoData.CidrRange.create("FE80:0:0:0:0:0:0:0", 60)), + ImmutableList.of(), + ImmutableList.of(), + EnvoyServerProtoData.ConnectionSourceType.ANY, + ImmutableList.of(), + ImmutableList.of(), + ""); EnvoyServerProtoData.FilterChain filterChainLessSpecific = - new EnvoyServerProtoData.FilterChain( + EnvoyServerProtoData.FilterChain.create( "filter-chain-foo", filterChainMatchLessSpecific, HTTP_CONNECTION_MANAGER, tlsContextLessSpecific, tlsContextManager); EnvoyServerProtoData.DownstreamTlsContext tlsContextMoreSpecific = CommonTlsContextTestsUtil.buildTestInternalDownstreamTlsContext("CERT2", "VA2"); EnvoyServerProtoData.FilterChainMatch filterChainMatchMoreSpecific = - new EnvoyServerProtoData.FilterChainMatch( + EnvoyServerProtoData.FilterChainMatch.create( 0, - Arrays.asList(new EnvoyServerProtoData.CidrRange("FE80:0000:0000:0000:0202:0:0:0", 80)), - Arrays.asList(), - Arrays.asList(), + ImmutableList.of( + EnvoyServerProtoData.CidrRange.create("FE80:0000:0000:0000:0202:0:0:0", 80)), + ImmutableList.of(), + ImmutableList.of(), EnvoyServerProtoData.ConnectionSourceType.ANY, - Arrays.asList(), - Arrays.asList(), - null); + ImmutableList.of(), + ImmutableList.of(), + ""); EnvoyServerProtoData.FilterChain filterChainMoreSpecific = - new EnvoyServerProtoData.FilterChain( + EnvoyServerProtoData.FilterChain.create( "filter-chain-bar", filterChainMatchMoreSpecific, HTTP_CONNECTION_MANAGER, tlsContextMoreSpecific, tlsContextManager); - EnvoyServerProtoData.FilterChain defaultFilterChain = new EnvoyServerProtoData.FilterChain( - "filter-chain-baz", null, HTTP_CONNECTION_MANAGER, null, tlsContextManager); + EnvoyServerProtoData.FilterChain defaultFilterChain = EnvoyServerProtoData.FilterChain.create( + "filter-chain-baz", DEFAULT_FILTER_CHAIN_MATCH, HTTP_CONNECTION_MANAGER, null, + tlsContextManager); selectorManager.updateSelector(new FilterChainSelector( ImmutableMap.of(filterChainLessSpecific, randomConfig("no-match"), filterChainMoreSpecific, noopConfig), - defaultFilterChain.getSslContextProviderSupplier(), randomConfig("default"))); + defaultFilterChain.sslContextProviderSupplier(), randomConfig("default"))); FilterChainMatchingHandler filterChainMatchingHandler = new FilterChainMatchingHandler(grpcHandler, selectorManager, mockDelegate); @@ -594,7 +607,7 @@ public class FilterChainMatchingProtocolNegotiatorsTest { 15000, filterChainMatchingHandler); pipeline.fireUserEventTriggered(event); channel.runPendingTasks(); - assertThat(sslSet.get()).isEqualTo(filterChainMoreSpecific.getSslContextProviderSupplier()); + assertThat(sslSet.get()).isEqualTo(filterChainMoreSpecific.sslContextProviderSupplier()); assertThat(routingSettable.get()).isEqualTo(noopConfig); assertThat(sslSet.get().getTlsContext()).isSameInstanceAs(tlsContextMoreSpecific); } @@ -605,45 +618,46 @@ public class FilterChainMatchingProtocolNegotiatorsTest { EnvoyServerProtoData.DownstreamTlsContext tlsContextMoreSpecificWith2 = CommonTlsContextTestsUtil.buildTestInternalDownstreamTlsContext("CERT1", "VA1"); EnvoyServerProtoData.FilterChainMatch filterChainMatchMoreSpecificWith2 = - new EnvoyServerProtoData.FilterChainMatch( - 0, - Arrays.asList( - new EnvoyServerProtoData.CidrRange("10.1.2.0", 24), - new EnvoyServerProtoData.CidrRange(LOCAL_IP, 32)), - Arrays.asList(), - Arrays.asList(), - EnvoyServerProtoData.ConnectionSourceType.ANY, - Arrays.asList(), - Arrays.asList(), - null); + EnvoyServerProtoData.FilterChainMatch.create( + 0, + ImmutableList.of( + EnvoyServerProtoData.CidrRange.create("10.1.2.0", 24), + EnvoyServerProtoData.CidrRange.create(LOCAL_IP, 32)), + ImmutableList.of(), + ImmutableList.of(), + EnvoyServerProtoData.ConnectionSourceType.ANY, + ImmutableList.of(), + ImmutableList.of(), + ""); EnvoyServerProtoData.FilterChain filterChainMoreSpecificWith2 = - new EnvoyServerProtoData.FilterChain( + EnvoyServerProtoData.FilterChain.create( "filter-chain-foo", filterChainMatchMoreSpecificWith2, HTTP_CONNECTION_MANAGER, tlsContextMoreSpecificWith2, tlsContextManager); EnvoyServerProtoData.DownstreamTlsContext tlsContextLessSpecific = CommonTlsContextTestsUtil.buildTestInternalDownstreamTlsContext("CERT2", "VA2"); EnvoyServerProtoData.FilterChainMatch filterChainMatchLessSpecific = - new EnvoyServerProtoData.FilterChainMatch( - 0, - Arrays.asList(new EnvoyServerProtoData.CidrRange("10.1.2.2", 31)), - Arrays.asList(), - Arrays.asList(), - EnvoyServerProtoData.ConnectionSourceType.ANY, - Arrays.asList(), - Arrays.asList(), - null); + EnvoyServerProtoData.FilterChainMatch.create( + 0, + ImmutableList.of(EnvoyServerProtoData.CidrRange.create("10.1.2.2", 31)), + ImmutableList.of(), + ImmutableList.of(), + EnvoyServerProtoData.ConnectionSourceType.ANY, + ImmutableList.of(), + ImmutableList.of(), + ""); EnvoyServerProtoData.FilterChain filterChainLessSpecific = - new EnvoyServerProtoData.FilterChain( + EnvoyServerProtoData.FilterChain.create( "filter-chain-bar", filterChainMatchLessSpecific, HTTP_CONNECTION_MANAGER, tlsContextLessSpecific, tlsContextManager); - EnvoyServerProtoData.FilterChain defaultFilterChain = new EnvoyServerProtoData.FilterChain( - "filter-chain-baz", null, HTTP_CONNECTION_MANAGER, null, tlsContextManager); + EnvoyServerProtoData.FilterChain defaultFilterChain = EnvoyServerProtoData.FilterChain.create( + "filter-chain-baz", DEFAULT_FILTER_CHAIN_MATCH, HTTP_CONNECTION_MANAGER, null, + tlsContextManager); selectorManager.updateSelector(new FilterChainSelector( ImmutableMap.of(filterChainMoreSpecificWith2, noopConfig, filterChainLessSpecific, randomConfig("no-match")), - defaultFilterChain.getSslContextProviderSupplier(), randomConfig("default"))); + defaultFilterChain.sslContextProviderSupplier(), randomConfig("default"))); FilterChainMatchingHandler filterChainMatchingHandler = new FilterChainMatchingHandler(grpcHandler, selectorManager, mockDelegate); @@ -653,7 +667,7 @@ public class FilterChainMatchingProtocolNegotiatorsTest { pipeline.fireUserEventTriggered(event); channel.runPendingTasks(); assertThat(sslSet.get()).isEqualTo( - filterChainMoreSpecificWith2.getSslContextProviderSupplier()); + filterChainMoreSpecificWith2.sslContextProviderSupplier()); assertThat(routingSettable.get()).isEqualTo(noopConfig); assertThat(sslSet.get().getTlsContext()).isSameInstanceAs(tlsContextMoreSpecificWith2); } @@ -663,27 +677,27 @@ public class FilterChainMatchingProtocolNegotiatorsTest { EnvoyServerProtoData.DownstreamTlsContext tlsContextMismatch = CommonTlsContextTestsUtil.buildTestInternalDownstreamTlsContext("CERT1", "VA1"); EnvoyServerProtoData.FilterChainMatch filterChainMatchWithMismatch = - new EnvoyServerProtoData.FilterChainMatch( - 0, - Arrays.asList(), - Arrays.asList(), - Arrays.asList(), - EnvoyServerProtoData.ConnectionSourceType.SAME_IP_OR_LOOPBACK, - Arrays.asList(), - Arrays.asList(), - null); + EnvoyServerProtoData.FilterChainMatch.create( + 0, + ImmutableList.of(), + ImmutableList.of(), + ImmutableList.of(), + EnvoyServerProtoData.ConnectionSourceType.SAME_IP_OR_LOOPBACK, + ImmutableList.of(), + ImmutableList.of(), + ""); EnvoyServerProtoData.FilterChain filterChainWithMismatch = - new EnvoyServerProtoData.FilterChain( + EnvoyServerProtoData.FilterChain.create( "filter-chain-foo", filterChainMatchWithMismatch, HTTP_CONNECTION_MANAGER, tlsContextMismatch, tlsContextManager); EnvoyServerProtoData.DownstreamTlsContext tlsContextForDefaultFilterChain = CommonTlsContextTestsUtil.buildTestInternalDownstreamTlsContext("CERT2", "VA2"); - EnvoyServerProtoData.FilterChain defaultFilterChain = new EnvoyServerProtoData.FilterChain( - "filter-chain-bar", null, HTTP_CONNECTION_MANAGER,tlsContextForDefaultFilterChain, - tlsContextManager); + EnvoyServerProtoData.FilterChain defaultFilterChain = EnvoyServerProtoData.FilterChain.create( + "filter-chain-bar", DEFAULT_FILTER_CHAIN_MATCH, HTTP_CONNECTION_MANAGER, + tlsContextForDefaultFilterChain, tlsContextManager); selectorManager.updateSelector(new FilterChainSelector( ImmutableMap.of(filterChainWithMismatch, randomConfig("no-match")), - defaultFilterChain.getSslContextProviderSupplier(), noopConfig)); + defaultFilterChain.sslContextProviderSupplier(), noopConfig)); FilterChainMatchingHandler filterChainMatchingHandler = new FilterChainMatchingHandler(grpcHandler, selectorManager, mockDelegate); @@ -693,7 +707,7 @@ public class FilterChainMatchingProtocolNegotiatorsTest { setupChannel(LOCAL_IP, REMOTE_IP, 15000, filterChainMatchingHandler); pipeline.fireUserEventTriggered(event); channel.runPendingTasks(); - assertThat(sslSet.get()).isEqualTo(defaultFilterChain.getSslContextProviderSupplier()); + assertThat(sslSet.get()).isEqualTo(defaultFilterChain.sslContextProviderSupplier()); assertThat(routingSettable.get()).isEqualTo(noopConfig); assertThat(sslSet.get().getTlsContext()).isSameInstanceAs(tlsContextForDefaultFilterChain); } @@ -705,33 +719,33 @@ public class FilterChainMatchingProtocolNegotiatorsTest { EnvoyServerProtoData.DownstreamTlsContext tlsContextMatch = CommonTlsContextTestsUtil.buildTestInternalDownstreamTlsContext("CERT1", "VA1"); EnvoyServerProtoData.FilterChainMatch filterChainMatchWithMatch = - new EnvoyServerProtoData.FilterChainMatch( - 0, - Arrays.asList(), - Arrays.asList(), - Arrays.asList(), - EnvoyServerProtoData.ConnectionSourceType.SAME_IP_OR_LOOPBACK, - Arrays.asList(), - Arrays.asList(), - null); - EnvoyServerProtoData.FilterChain filterChainWithMatch = new EnvoyServerProtoData.FilterChain( + EnvoyServerProtoData.FilterChainMatch.create( + 0, + ImmutableList.of(), + ImmutableList.of(), + ImmutableList.of(), + EnvoyServerProtoData.ConnectionSourceType.SAME_IP_OR_LOOPBACK, + ImmutableList.of(), + ImmutableList.of(), + ""); + EnvoyServerProtoData.FilterChain filterChainWithMatch = EnvoyServerProtoData.FilterChain.create( "filter-chain-foo", filterChainMatchWithMatch, HTTP_CONNECTION_MANAGER, tlsContextMatch, tlsContextManager); EnvoyServerProtoData.DownstreamTlsContext tlsContextForDefaultFilterChain = CommonTlsContextTestsUtil.buildTestInternalDownstreamTlsContext("CERT2", "VA2"); - EnvoyServerProtoData.FilterChain defaultFilterChain = new EnvoyServerProtoData.FilterChain( - "filter-chain-bar", null, HTTP_CONNECTION_MANAGER, tlsContextForDefaultFilterChain, - tlsContextManager); + EnvoyServerProtoData.FilterChain defaultFilterChain = EnvoyServerProtoData.FilterChain.create( + "filter-chain-bar", DEFAULT_FILTER_CHAIN_MATCH, HTTP_CONNECTION_MANAGER, + tlsContextForDefaultFilterChain, tlsContextManager); selectorManager.updateSelector(new FilterChainSelector( ImmutableMap.of(filterChainWithMatch, noopConfig), - defaultFilterChain.getSslContextProviderSupplier(), randomConfig("default"))); + defaultFilterChain.sslContextProviderSupplier(), randomConfig("default"))); FilterChainMatchingHandler filterChainMatchingHandler = new FilterChainMatchingHandler(grpcHandler, selectorManager, mockDelegate); setupChannel(LOCAL_IP, LOCAL_IP, 15000, filterChainMatchingHandler); pipeline.fireUserEventTriggered(event); channel.runPendingTasks(); - assertThat(sslSet.get()).isEqualTo(filterChainWithMatch.getSslContextProviderSupplier()); + assertThat(sslSet.get()).isEqualTo(filterChainWithMatch.sslContextProviderSupplier()); assertThat(routingSettable.get()).isEqualTo(noopConfig); assertThat(sslSet.get().getTlsContext()).isSameInstanceAs(tlsContextMatch); } @@ -745,45 +759,46 @@ public class FilterChainMatchingProtocolNegotiatorsTest { EnvoyServerProtoData.DownstreamTlsContext tlsContextMoreSpecificWith2 = CommonTlsContextTestsUtil.buildTestInternalDownstreamTlsContext("CERT1", "VA1"); EnvoyServerProtoData.FilterChainMatch filterChainMatchMoreSpecificWith2 = - new EnvoyServerProtoData.FilterChainMatch( - 0, - Arrays.asList(), - Arrays.asList(), - Arrays.asList( - new EnvoyServerProtoData.CidrRange("10.4.2.0", 24), - new EnvoyServerProtoData.CidrRange(REMOTE_IP, 32)), - EnvoyServerProtoData.ConnectionSourceType.ANY, - Arrays.asList(), - Arrays.asList(), - null); + EnvoyServerProtoData.FilterChainMatch.create( + 0, + ImmutableList.of(), + ImmutableList.of(), + ImmutableList.of( + EnvoyServerProtoData.CidrRange.create("10.4.2.0", 24), + EnvoyServerProtoData.CidrRange.create(REMOTE_IP, 32)), + EnvoyServerProtoData.ConnectionSourceType.ANY, + ImmutableList.of(), + ImmutableList.of(), + ""); EnvoyServerProtoData.FilterChain filterChainMoreSpecificWith2 = - new EnvoyServerProtoData.FilterChain( + EnvoyServerProtoData.FilterChain.create( "filter-chain-foo", filterChainMatchMoreSpecificWith2, HTTP_CONNECTION_MANAGER, tlsContextMoreSpecificWith2, tlsContextManager); EnvoyServerProtoData.DownstreamTlsContext tlsContextLessSpecific = CommonTlsContextTestsUtil.buildTestInternalDownstreamTlsContext("CERT2", "VA2"); EnvoyServerProtoData.FilterChainMatch filterChainMatchLessSpecific = - new EnvoyServerProtoData.FilterChainMatch( - 0, - Arrays.asList(), - Arrays.asList(), - Arrays.asList(new EnvoyServerProtoData.CidrRange("10.4.2.2", 31)), - EnvoyServerProtoData.ConnectionSourceType.ANY, - Arrays.asList(), - Arrays.asList(), - null); + EnvoyServerProtoData.FilterChainMatch.create( + 0, + ImmutableList.of(), + ImmutableList.of(), + ImmutableList.of(EnvoyServerProtoData.CidrRange.create("10.4.2.2", 31)), + EnvoyServerProtoData.ConnectionSourceType.ANY, + ImmutableList.of(), + ImmutableList.of(), + ""); EnvoyServerProtoData.FilterChain filterChainLessSpecific = - new EnvoyServerProtoData.FilterChain( + EnvoyServerProtoData.FilterChain.create( "filter-chain-bar", filterChainMatchLessSpecific, HTTP_CONNECTION_MANAGER, tlsContextLessSpecific, tlsContextManager); - EnvoyServerProtoData.FilterChain defaultFilterChain = new EnvoyServerProtoData.FilterChain( - "filter-chain-baz", null, HTTP_CONNECTION_MANAGER, null, tlsContextManager); + EnvoyServerProtoData.FilterChain defaultFilterChain = EnvoyServerProtoData.FilterChain.create( + "filter-chain-baz", DEFAULT_FILTER_CHAIN_MATCH, HTTP_CONNECTION_MANAGER, null, + tlsContextManager); selectorManager.updateSelector(new FilterChainSelector( ImmutableMap.of(filterChainMoreSpecificWith2, noopConfig, filterChainLessSpecific, randomConfig("no-match")), - defaultFilterChain.getSslContextProviderSupplier(), randomConfig("default"))); + defaultFilterChain.sslContextProviderSupplier(), randomConfig("default"))); FilterChainMatchingHandler filterChainMatchingHandler = new FilterChainMatchingHandler(grpcHandler, selectorManager, mockDelegate); @@ -791,7 +806,7 @@ public class FilterChainMatchingProtocolNegotiatorsTest { pipeline.fireUserEventTriggered(event); channel.runPendingTasks(); assertThat(sslSet.get()).isEqualTo( - filterChainMoreSpecificWith2.getSslContextProviderSupplier()); + filterChainMoreSpecificWith2.sslContextProviderSupplier()); assertThat(routingSettable.get()).isEqualTo(noopConfig); assertThat(sslSet.get().getTlsContext()).isSameInstanceAs(tlsContextMoreSpecificWith2); } @@ -812,42 +827,42 @@ public class FilterChainMatchingProtocolNegotiatorsTest { EnvoyServerProtoData.DownstreamTlsContext tlsContext1 = CommonTlsContextTestsUtil.buildTestInternalDownstreamTlsContext("CERT1", "VA1"); EnvoyServerProtoData.FilterChainMatch filterChainMatch1 = - new EnvoyServerProtoData.FilterChainMatch( - 0, - Arrays.asList(), - Arrays.asList(), - Arrays.asList( - new EnvoyServerProtoData.CidrRange("10.4.2.0", 24), - new EnvoyServerProtoData.CidrRange("192.168.10.2", 32)), - EnvoyServerProtoData.ConnectionSourceType.ANY, - Arrays.asList(), - Arrays.asList(), - null); - EnvoyServerProtoData.FilterChain filterChain1 = new EnvoyServerProtoData.FilterChain( + EnvoyServerProtoData.FilterChainMatch.create( + 0, + ImmutableList.of(), + ImmutableList.of(), + ImmutableList.of( + EnvoyServerProtoData.CidrRange.create("10.4.2.0", 24), + EnvoyServerProtoData.CidrRange.create("192.168.10.2", 32)), + EnvoyServerProtoData.ConnectionSourceType.ANY, + ImmutableList.of(), + ImmutableList.of(), + ""); + EnvoyServerProtoData.FilterChain filterChain1 = EnvoyServerProtoData.FilterChain.create( "filter-chain-foo", filterChainMatch1, HTTP_CONNECTION_MANAGER, tlsContext1, tlsContextManager); EnvoyServerProtoData.DownstreamTlsContext tlsContext2 = CommonTlsContextTestsUtil.buildTestInternalDownstreamTlsContext("CERT2", "VA2"); EnvoyServerProtoData.FilterChainMatch filterChainMatch2 = - new EnvoyServerProtoData.FilterChainMatch( - 0, - Arrays.asList(), - Arrays.asList(), - Arrays.asList(new EnvoyServerProtoData.CidrRange("10.4.2.0", 24)), - EnvoyServerProtoData.ConnectionSourceType.ANY, - Arrays.asList(), - Arrays.asList(), - null); - EnvoyServerProtoData.FilterChain filterChain2 = new EnvoyServerProtoData.FilterChain( + EnvoyServerProtoData.FilterChainMatch.create( + 0, + ImmutableList.of(), + ImmutableList.of(), + ImmutableList.of(EnvoyServerProtoData.CidrRange.create("10.4.2.0", 24)), + EnvoyServerProtoData.ConnectionSourceType.ANY, + ImmutableList.of(), + ImmutableList.of(), + ""); + EnvoyServerProtoData.FilterChain filterChain2 = EnvoyServerProtoData.FilterChain.create( "filter-chain-bar", filterChainMatch2, HTTP_CONNECTION_MANAGER, tlsContext2, tlsContextManager); - EnvoyServerProtoData.FilterChain defaultFilterChain = new EnvoyServerProtoData.FilterChain( - "filter-chain-baz", null, HTTP_CONNECTION_MANAGER, null, null); + EnvoyServerProtoData.FilterChain defaultFilterChain = EnvoyServerProtoData.FilterChain.create( + "filter-chain-baz", DEFAULT_FILTER_CHAIN_MATCH, HTTP_CONNECTION_MANAGER, null, null); selectorManager.updateSelector(new FilterChainSelector( ImmutableMap.of(filterChain1, noopConfig, filterChain2, noopConfig), - defaultFilterChain.getSslContextProviderSupplier(), noopConfig)); + defaultFilterChain.sslContextProviderSupplier(), noopConfig)); FilterChainMatchingHandler filterChainMatchingHandler = new FilterChainMatchingHandler(grpcHandler, selectorManager, mockDelegate); @@ -871,45 +886,46 @@ public class FilterChainMatchingProtocolNegotiatorsTest { EnvoyServerProtoData.DownstreamTlsContext tlsContextEmptySourcePorts = CommonTlsContextTestsUtil.buildTestInternalDownstreamTlsContext("CERT1", "VA1"); EnvoyServerProtoData.FilterChainMatch filterChainMatchEmptySourcePorts = - new EnvoyServerProtoData.FilterChainMatch( - 0, - Arrays.asList(), - Arrays.asList(), - Arrays.asList( - new EnvoyServerProtoData.CidrRange("10.4.2.0", 24), - new EnvoyServerProtoData.CidrRange("10.4.2.2", 31)), - EnvoyServerProtoData.ConnectionSourceType.ANY, - Arrays.asList(), - Arrays.asList(), - null); + EnvoyServerProtoData.FilterChainMatch.create( + 0, + ImmutableList.of(), + ImmutableList.of(), + ImmutableList.of( + EnvoyServerProtoData.CidrRange.create("10.4.2.0", 24), + EnvoyServerProtoData.CidrRange.create("10.4.2.2", 31)), + EnvoyServerProtoData.ConnectionSourceType.ANY, + ImmutableList.of(), + ImmutableList.of(), + ""); EnvoyServerProtoData.FilterChain filterChainEmptySourcePorts = - new EnvoyServerProtoData.FilterChain( + EnvoyServerProtoData.FilterChain.create( "filter-chain-foo", filterChainMatchEmptySourcePorts, HTTP_CONNECTION_MANAGER, tlsContextEmptySourcePorts, tlsContextManager); EnvoyServerProtoData.DownstreamTlsContext tlsContextSourcePortMatch = CommonTlsContextTestsUtil.buildTestInternalDownstreamTlsContext("CERT2", "VA2"); EnvoyServerProtoData.FilterChainMatch filterChainMatchSourcePortMatch = - new EnvoyServerProtoData.FilterChainMatch( - 0, - Arrays.asList(), - Arrays.asList(), - Arrays.asList(new EnvoyServerProtoData.CidrRange("10.4.2.2", 31)), - EnvoyServerProtoData.ConnectionSourceType.ANY, - Arrays.asList(7000, 15000), - Arrays.asList(), - null); + EnvoyServerProtoData.FilterChainMatch.create( + 0, + ImmutableList.of(), + ImmutableList.of(), + ImmutableList.of(EnvoyServerProtoData.CidrRange.create("10.4.2.2", 31)), + EnvoyServerProtoData.ConnectionSourceType.ANY, + ImmutableList.of(7000, 15000), + ImmutableList.of(), + ""); EnvoyServerProtoData.FilterChain filterChainSourcePortMatch = - new EnvoyServerProtoData.FilterChain( + EnvoyServerProtoData.FilterChain.create( "filter-chain-bar", filterChainMatchSourcePortMatch, HTTP_CONNECTION_MANAGER, tlsContextSourcePortMatch, tlsContextManager); - EnvoyServerProtoData.FilterChain defaultFilterChain = new EnvoyServerProtoData.FilterChain( - "filter-chain-baz", null, HTTP_CONNECTION_MANAGER, null, tlsContextManager); + EnvoyServerProtoData.FilterChain defaultFilterChain = EnvoyServerProtoData.FilterChain.create( + "filter-chain-baz", DEFAULT_FILTER_CHAIN_MATCH, HTTP_CONNECTION_MANAGER, null, + tlsContextManager); selectorManager.updateSelector(new FilterChainSelector( ImmutableMap.of(filterChainEmptySourcePorts, randomConfig("no-match"), filterChainSourcePortMatch, noopConfig), - defaultFilterChain.getSslContextProviderSupplier(), randomConfig("default"))); + defaultFilterChain.sslContextProviderSupplier(), randomConfig("default"))); FilterChainMatchingHandler filterChainMatchingHandler = new FilterChainMatchingHandler(grpcHandler, selectorManager, mockDelegate); @@ -918,7 +934,7 @@ public class FilterChainMatchingProtocolNegotiatorsTest { setupChannel(LOCAL_IP, REMOTE_IP, 15000, filterChainMatchingHandler); pipeline.fireUserEventTriggered(event); channel.runPendingTasks(); - assertThat(sslSet.get()).isEqualTo(filterChainSourcePortMatch.getSslContextProviderSupplier()); + assertThat(sslSet.get()).isEqualTo(filterChainSourcePortMatch.sslContextProviderSupplier()); assertThat(routingSettable.get()).isEqualTo(noopConfig); assertThat(sslSet.get().getTlsContext()).isSameInstanceAs(tlsContextSourcePortMatch); } @@ -947,16 +963,16 @@ public class FilterChainMatchingProtocolNegotiatorsTest { // has dest port and specific prefix ranges: gets eliminated in step 1 EnvoyServerProtoData.FilterChainMatch filterChainMatch1 = - new EnvoyServerProtoData.FilterChainMatch( - PORT, - Arrays.asList(), - Arrays.asList(), - Arrays.asList(new EnvoyServerProtoData.CidrRange(REMOTE_IP, 32)), - EnvoyServerProtoData.ConnectionSourceType.ANY, - Arrays.asList(), - Arrays.asList(), - null); - EnvoyServerProtoData.FilterChain filterChain1 = new EnvoyServerProtoData.FilterChain( + EnvoyServerProtoData.FilterChainMatch.create( + PORT, + ImmutableList.of(), + ImmutableList.of(), + ImmutableList.of(EnvoyServerProtoData.CidrRange.create(REMOTE_IP, 32)), + EnvoyServerProtoData.ConnectionSourceType.ANY, + ImmutableList.of(), + ImmutableList.of(), + ""); + EnvoyServerProtoData.FilterChain filterChain1 = EnvoyServerProtoData.FilterChain.create( "filter-chain-1", filterChainMatch1, HTTP_CONNECTION_MANAGER, tlsContext1, tlsContextManager); @@ -964,94 +980,95 @@ public class FilterChainMatchingProtocolNegotiatorsTest { // has single prefix range: and less specific source prefix range: gets eliminated in step 4 EnvoyServerProtoData.FilterChainMatch filterChainMatch2 = - new EnvoyServerProtoData.FilterChainMatch( - 0, - Arrays.asList(new EnvoyServerProtoData.CidrRange("10.1.2.0", 30)), - Arrays.asList(), - Arrays.asList(new EnvoyServerProtoData.CidrRange("10.4.0.0", 16)), - EnvoyServerProtoData.ConnectionSourceType.ANY, - Arrays.asList(), - Arrays.asList(), - null); - EnvoyServerProtoData.FilterChain filterChain2 = new EnvoyServerProtoData.FilterChain( + EnvoyServerProtoData.FilterChainMatch.create( + 0, + ImmutableList.of(EnvoyServerProtoData.CidrRange.create("10.1.2.0", 30)), + ImmutableList.of(), + ImmutableList.of(EnvoyServerProtoData.CidrRange.create("10.4.0.0", 16)), + EnvoyServerProtoData.ConnectionSourceType.ANY, + ImmutableList.of(), + ImmutableList.of(), + ""); + EnvoyServerProtoData.FilterChain filterChain2 = EnvoyServerProtoData.FilterChain.create( "filter-chain-2", filterChainMatch2, HTTP_CONNECTION_MANAGER, tlsContext2, tlsContextManager); // has prefix ranges with one not matching and source type local: gets eliminated in step 3 EnvoyServerProtoData.FilterChainMatch filterChainMatch3 = - new EnvoyServerProtoData.FilterChainMatch( - 0, - Arrays.asList( - new EnvoyServerProtoData.CidrRange("192.168.2.0", 24), - new EnvoyServerProtoData.CidrRange("10.1.2.0", 30)), - Arrays.asList(), - Arrays.asList(), - EnvoyServerProtoData.ConnectionSourceType.SAME_IP_OR_LOOPBACK, - Arrays.asList(), - Arrays.asList(), - null); - EnvoyServerProtoData.FilterChain filterChain3 = new EnvoyServerProtoData.FilterChain( + EnvoyServerProtoData.FilterChainMatch.create( + 0, + ImmutableList.of( + EnvoyServerProtoData.CidrRange.create("192.168.2.0", 24), + EnvoyServerProtoData.CidrRange.create("10.1.2.0", 30)), + ImmutableList.of(), + ImmutableList.of(), + EnvoyServerProtoData.ConnectionSourceType.SAME_IP_OR_LOOPBACK, + ImmutableList.of(), + ImmutableList.of(), + ""); + EnvoyServerProtoData.FilterChain filterChain3 = EnvoyServerProtoData.FilterChain.create( "filter-chain-3", filterChainMatch3, HTTP_CONNECTION_MANAGER, tlsContext3, tlsContextManager); // has prefix ranges with both matching and source type external but non matching source port: // gets eliminated in step 5 EnvoyServerProtoData.FilterChainMatch filterChainMatch4 = - new EnvoyServerProtoData.FilterChainMatch( - 0, - Arrays.asList( - new EnvoyServerProtoData.CidrRange("10.1.0.0", 16), - new EnvoyServerProtoData.CidrRange("10.1.2.0", 30)), - Arrays.asList(), - Arrays.asList(new EnvoyServerProtoData.CidrRange("10.4.2.0", 24)), - EnvoyServerProtoData.ConnectionSourceType.EXTERNAL, - Arrays.asList(16000, 9000), - Arrays.asList(), - null); + EnvoyServerProtoData.FilterChainMatch.create( + 0, + ImmutableList.of( + EnvoyServerProtoData.CidrRange.create("10.1.0.0", 16), + EnvoyServerProtoData.CidrRange.create("10.1.2.0", 30)), + ImmutableList.of(), + ImmutableList.of(EnvoyServerProtoData.CidrRange.create("10.4.2.0", 24)), + EnvoyServerProtoData.ConnectionSourceType.EXTERNAL, + ImmutableList.of(16000, 9000), + ImmutableList.of(), + ""); EnvoyServerProtoData.FilterChain filterChain4 = - new EnvoyServerProtoData.FilterChain( + EnvoyServerProtoData.FilterChain.create( "filter-chain-4", filterChainMatch4, HTTP_CONNECTION_MANAGER, tlsContext4, tlsContextManager); // has prefix ranges with both matching and source type external and matching source port: this // gets selected EnvoyServerProtoData.FilterChainMatch filterChainMatch5 = - new EnvoyServerProtoData.FilterChainMatch( - 0, - Arrays.asList( - new EnvoyServerProtoData.CidrRange("10.1.0.0", 16), - new EnvoyServerProtoData.CidrRange("10.1.2.0", 30)), - Arrays.asList(), - Arrays.asList( - new EnvoyServerProtoData.CidrRange("10.4.2.0", 24), - new EnvoyServerProtoData.CidrRange("192.168.2.0", 24)), - EnvoyServerProtoData.ConnectionSourceType.ANY, - Arrays.asList(15000, 8000), - Arrays.asList(), - null); + EnvoyServerProtoData.FilterChainMatch.create( + 0, + ImmutableList.of( + EnvoyServerProtoData.CidrRange.create("10.1.0.0", 16), + EnvoyServerProtoData.CidrRange.create("10.1.2.0", 30)), + ImmutableList.of(), + ImmutableList.of( + EnvoyServerProtoData.CidrRange.create("10.4.2.0", 24), + EnvoyServerProtoData.CidrRange.create("192.168.2.0", 24)), + EnvoyServerProtoData.ConnectionSourceType.ANY, + ImmutableList.of(15000, 8000), + ImmutableList.of(), + ""); EnvoyServerProtoData.FilterChain filterChain5 = - new EnvoyServerProtoData.FilterChain( + EnvoyServerProtoData.FilterChain.create( "filter-chain-5", filterChainMatch5, HTTP_CONNECTION_MANAGER, tlsContext5, tlsContextManager); // has prefix range with prefixLen of 29: gets eliminated in step 2 EnvoyServerProtoData.FilterChainMatch filterChainMatch6 = - new EnvoyServerProtoData.FilterChainMatch( - 0, - Arrays.asList(new EnvoyServerProtoData.CidrRange("10.1.2.0", 29)), - Arrays.asList(), - Arrays.asList(), - EnvoyServerProtoData.ConnectionSourceType.ANY, - Arrays.asList(), - Arrays.asList(), - null); + EnvoyServerProtoData.FilterChainMatch.create( + 0, + ImmutableList.of(EnvoyServerProtoData.CidrRange.create("10.1.2.0", 29)), + ImmutableList.of(), + ImmutableList.of(), + EnvoyServerProtoData.ConnectionSourceType.ANY, + ImmutableList.of(), + ImmutableList.of(), + ""); EnvoyServerProtoData.FilterChain filterChain6 = - new EnvoyServerProtoData.FilterChain( + EnvoyServerProtoData.FilterChain.create( "filter-chain-6", filterChainMatch6, HTTP_CONNECTION_MANAGER, tlsContext6, tlsContextManager); - EnvoyServerProtoData.FilterChain defaultFilterChain = new EnvoyServerProtoData.FilterChain( - "filter-chain-7", null, HTTP_CONNECTION_MANAGER, null, tlsContextManager); + EnvoyServerProtoData.FilterChain defaultFilterChain = EnvoyServerProtoData.FilterChain.create( + "filter-chain-7", DEFAULT_FILTER_CHAIN_MATCH, HTTP_CONNECTION_MANAGER, null, + tlsContextManager); Map> map = new HashMap<>(); map.put(filterChain1, randomConfig("1")); @@ -1061,7 +1078,7 @@ public class FilterChainMatchingProtocolNegotiatorsTest { map.put(filterChain5, noopConfig); map.put(filterChain6, randomConfig("6")); selectorManager.updateSelector(new FilterChainSelector( - map, defaultFilterChain.getSslContextProviderSupplier(), randomConfig("default"))); + map, defaultFilterChain.sslContextProviderSupplier(), randomConfig("default"))); FilterChainMatchingHandler filterChainMatchingHandler = new FilterChainMatchingHandler(grpcHandler, selectorManager, mockDelegate); @@ -1071,7 +1088,7 @@ public class FilterChainMatchingProtocolNegotiatorsTest { setupChannel(LOCAL_IP, REMOTE_IP, 15000, filterChainMatchingHandler); pipeline.fireUserEventTriggered(event); channel.runPendingTasks(); - assertThat(sslSet.get()).isEqualTo(filterChain5.getSslContextProviderSupplier()); + assertThat(sslSet.get()).isEqualTo(filterChain5.sslContextProviderSupplier()); assertThat(routingSettable.get()).isEqualTo(noopConfig); assertThat(sslSet.get().getTlsContext()).isSameInstanceAs(tlsContext5); } @@ -1087,54 +1104,54 @@ public class FilterChainMatchingProtocolNegotiatorsTest { CommonTlsContextTestsUtil.buildTestInternalDownstreamTlsContext("CERT3", "ROOTCA"); EnvoyServerProtoData.FilterChainMatch filterChainMatch1 = - new EnvoyServerProtoData.FilterChainMatch( + EnvoyServerProtoData.FilterChainMatch.create( 0 /* destinationPort */, - Collections.singletonList( - new EnvoyServerProtoData.CidrRange("10.1.0.0", 16)) /* prefixRange */, - Arrays.asList("managed-mtls", "h2") /* applicationProtocol */, - Collections.emptyList() /* sourcePrefixRanges */, + ImmutableList.of( + EnvoyServerProtoData.CidrRange.create("10.1.0.0", 16)) /* prefixRange */, + ImmutableList.of("managed-mtls", "h2") /* applicationProtocol */, + ImmutableList.of() /* sourcePrefixRanges */, EnvoyServerProtoData.ConnectionSourceType.ANY /* sourceType */, - Collections.emptyList() /* sourcePorts */, - Arrays.asList("server1", "server2") /* serverNames */, + ImmutableList.of() /* sourcePorts */, + ImmutableList.of("server1", "server2") /* serverNames */, "tls" /* transportProtocol */); EnvoyServerProtoData.FilterChainMatch filterChainMatch2 = - new EnvoyServerProtoData.FilterChainMatch( + EnvoyServerProtoData.FilterChainMatch.create( 0 /* destinationPort */, - Collections.singletonList( - new EnvoyServerProtoData.CidrRange("10.0.0.0", 8)) /* prefixRange */, - Collections.emptyList() /* applicationProtocol */, - Collections.emptyList() /* sourcePrefixRanges */, + ImmutableList.of( + EnvoyServerProtoData.CidrRange.create("10.0.0.0", 8)) /* prefixRange */, + ImmutableList.of() /* applicationProtocol */, + ImmutableList.of() /* sourcePrefixRanges */, EnvoyServerProtoData.ConnectionSourceType.ANY /* sourceType */, - Collections.emptyList() /* sourcePorts */, - Collections.emptyList() /* serverNames */, + ImmutableList.of() /* sourcePorts */, + ImmutableList.of() /* serverNames */, "" /* transportProtocol */); EnvoyServerProtoData.FilterChainMatch defaultFilterChainMatch = - new EnvoyServerProtoData.FilterChainMatch( + EnvoyServerProtoData.FilterChainMatch.create( 0 /* destinationPort */, - Collections.emptyList() /* prefixRange */, - Collections.emptyList() /* applicationProtocol */, - Collections.emptyList() /* sourcePrefixRanges */, + ImmutableList.of() /* prefixRange */, + ImmutableList.of() /* applicationProtocol */, + ImmutableList.of() /* sourcePrefixRanges */, EnvoyServerProtoData.ConnectionSourceType.ANY /* sourceType */, - Collections.emptyList() /* sourcePorts */, - Collections.emptyList() /* serverNames */, + ImmutableList.of() /* sourcePorts */, + ImmutableList.of() /* serverNames */, "" /* transportProtocol */); - EnvoyServerProtoData.FilterChain filterChain1 = new EnvoyServerProtoData.FilterChain( + EnvoyServerProtoData.FilterChain filterChain1 = EnvoyServerProtoData.FilterChain.create( "filter-chain-foo", filterChainMatch1, HTTP_CONNECTION_MANAGER, tlsContext1, mock(TlsContextManager.class)); - EnvoyServerProtoData.FilterChain filterChain2 = new EnvoyServerProtoData.FilterChain( + EnvoyServerProtoData.FilterChain filterChain2 = EnvoyServerProtoData.FilterChain.create( "filter-chain-bar", filterChainMatch2, HTTP_CONNECTION_MANAGER, tlsContext2, mock(TlsContextManager.class)); - EnvoyServerProtoData.FilterChain defaultFilterChain = new EnvoyServerProtoData.FilterChain( + EnvoyServerProtoData.FilterChain defaultFilterChain = EnvoyServerProtoData.FilterChain.create( "filter-chain-baz", defaultFilterChainMatch, HTTP_CONNECTION_MANAGER, tlsContext3, mock(TlsContextManager.class)); selectorManager.updateSelector(new FilterChainSelector( ImmutableMap.of(filterChain1, randomConfig("1"), filterChain2, randomConfig("2")), - defaultFilterChain.getSslContextProviderSupplier(), noopConfig)); + defaultFilterChain.sslContextProviderSupplier(), noopConfig)); FilterChainMatchingHandler filterChainMatchingHandler = new FilterChainMatchingHandler(grpcHandler, selectorManager, mockDelegate); @@ -1143,7 +1160,7 @@ public class FilterChainMatchingProtocolNegotiatorsTest { setupChannel(LOCAL_IP, REMOTE_IP, 15000, filterChainMatchingHandler); pipeline.fireUserEventTriggered(event); channel.runPendingTasks(); - assertThat(sslSet.get()).isEqualTo(defaultFilterChain.getSslContextProviderSupplier()); + assertThat(sslSet.get()).isEqualTo(defaultFilterChain.sslContextProviderSupplier()); assertThat(routingSettable.get()).isEqualTo(noopConfig); assertThat(sslSet.get().getTlsContext().getCommonTlsContext() .getTlsCertificateCertificateProviderInstance() diff --git a/xds/src/test/java/io/grpc/xds/XdsClientWrapperForServerSdsTestMisc.java b/xds/src/test/java/io/grpc/xds/XdsClientWrapperForServerSdsTestMisc.java index a39a5495c0..e7d090b6cd 100644 --- a/xds/src/test/java/io/grpc/xds/XdsClientWrapperForServerSdsTestMisc.java +++ b/xds/src/test/java/io/grpc/xds/XdsClientWrapperForServerSdsTestMisc.java @@ -29,6 +29,7 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import com.google.common.collect.ImmutableList; import com.google.common.util.concurrent.SettableFuture; import io.grpc.Server; import io.grpc.ServerBuilder; @@ -66,8 +67,6 @@ import io.netty.handler.codec.http2.Http2Settings; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.SocketAddress; -import java.util.Arrays; -import java.util.Collections; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; @@ -160,10 +159,10 @@ public class XdsClientWrapperForServerSdsTestMisc { assertThat(ldsWatched).isEqualTo("grpc/server?udpa.resource.listening_address=0.0.0.0:" + PORT); EnvoyServerProtoData.Listener listener = - new EnvoyServerProtoData.Listener( + EnvoyServerProtoData.Listener.create( "listener1", "10.1.2.3", - Collections.emptyList(), + ImmutableList.of(), null); LdsUpdate listenerUpdate = LdsUpdate.forTcpListener(listener); xdsClient.ldsWatcher.onChanged(listenerUpdate); @@ -268,7 +267,7 @@ public class XdsClientWrapperForServerSdsTestMisc { assertThat(returnedSupplier.getTlsContext()).isSameInstanceAs(tlsContext1); callUpdateSslContext(returnedSupplier); XdsServerTestHelper - .generateListenerUpdate(xdsClient, Arrays.asList(1234), tlsContext2, + .generateListenerUpdate(xdsClient, ImmutableList.of(1234), tlsContext2, tlsContext3, tlsContextManager); returnedSupplier = getSslContextProviderSupplier(selectorManager.getSelectorToUpdateSelector()); assertThat(returnedSupplier.getTlsContext()).isSameInstanceAs(tlsContext2); @@ -379,7 +378,7 @@ public class XdsClientWrapperForServerSdsTestMisc { }); xdsClient.ldsResource.get(5, TimeUnit.SECONDS); XdsServerTestHelper - .generateListenerUpdate(xdsClient, Arrays.asList(), tlsContext, + .generateListenerUpdate(xdsClient, ImmutableList.of(), tlsContext, tlsContextForDefaultFilterChain, tlsContextManager); start.get(5, TimeUnit.SECONDS); InetAddress ipRemoteAddress = InetAddress.getByName("10.4.5.6"); diff --git a/xds/src/test/java/io/grpc/xds/XdsSdsClientServerTest.java b/xds/src/test/java/io/grpc/xds/XdsSdsClientServerTest.java index 579542a277..3666953725 100644 --- a/xds/src/test/java/io/grpc/xds/XdsSdsClientServerTest.java +++ b/xds/src/test/java/io/grpc/xds/XdsSdsClientServerTest.java @@ -49,6 +49,7 @@ import io.grpc.testing.GrpcCleanupRule; import io.grpc.testing.protobuf.SimpleRequest; import io.grpc.testing.protobuf.SimpleResponse; import io.grpc.testing.protobuf.SimpleServiceGrpc; +import io.grpc.xds.EnvoyServerProtoData.ConnectionSourceType; import io.grpc.xds.EnvoyServerProtoData.DownstreamTlsContext; import io.grpc.xds.EnvoyServerProtoData.UpstreamTlsContext; import io.grpc.xds.Filter.FilterConfig; @@ -364,15 +365,15 @@ public class XdsSdsClientServerTest { String name, String address, DownstreamTlsContext tlsContext, TlsContextManager tlsContextManager) { EnvoyServerProtoData.FilterChainMatch filterChainMatch = - new EnvoyServerProtoData.FilterChainMatch( + EnvoyServerProtoData.FilterChainMatch.create( 0, - Arrays.asList(), - Arrays.asList(), - Arrays.asList(), - null, - Arrays.asList(), - Arrays.asList(), - null); + ImmutableList.of(), + ImmutableList.of(), + ImmutableList.of(), + ConnectionSourceType.ANY, + ImmutableList.of(), + ImmutableList.of(), + ""); String fullPath = "/" + SimpleServiceGrpc.SERVICE_NAME + "/" + "UnaryRpc"; RouteMatch routeMatch = RouteMatch.create( @@ -386,11 +387,11 @@ public class XdsSdsClientServerTest { HttpConnectionManager httpConnectionManager = HttpConnectionManager.forVirtualHosts( 0L, Collections.singletonList(virtualHost), new ArrayList()); - EnvoyServerProtoData.FilterChain defaultFilterChain = new EnvoyServerProtoData.FilterChain( + EnvoyServerProtoData.FilterChain defaultFilterChain = EnvoyServerProtoData.FilterChain.create( "filter-chain-foo", filterChainMatch, httpConnectionManager, tlsContext, tlsContextManager); - EnvoyServerProtoData.Listener listener = - new EnvoyServerProtoData.Listener(name, address, Arrays.asList(defaultFilterChain), null); + EnvoyServerProtoData.Listener listener = EnvoyServerProtoData.Listener.create( + name, address, ImmutableList.of(defaultFilterChain), null); return listener; } diff --git a/xds/src/test/java/io/grpc/xds/XdsServerTestHelper.java b/xds/src/test/java/io/grpc/xds/XdsServerTestHelper.java index 66b3d00a84..15868ba414 100644 --- a/xds/src/test/java/io/grpc/xds/XdsServerTestHelper.java +++ b/xds/src/test/java/io/grpc/xds/XdsServerTestHelper.java @@ -18,11 +18,13 @@ package io.grpc.xds; import static com.google.common.truth.Truth.assertThat; +import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.util.concurrent.SettableFuture; import io.grpc.InsecureChannelCredentials; import io.grpc.internal.ObjectPool; import io.grpc.xds.Bootstrapper.BootstrapInfo; +import io.grpc.xds.EnvoyServerProtoData.ConnectionSourceType; import io.grpc.xds.EnvoyServerProtoData.FilterChain; import io.grpc.xds.EnvoyServerProtoData.Listener; import io.grpc.xds.Filter.FilterConfig; @@ -61,13 +63,13 @@ public class XdsServerTestHelper { EnvoyServerProtoData.DownstreamTlsContext tlsContext, TlsContextManager tlsContextManager) { EnvoyServerProtoData.Listener listener = buildTestListener("listener1", "10.1.2.3", - Arrays.asList(), tlsContext, null, tlsContextManager); + ImmutableList.of(), tlsContext, null, tlsContextManager); LdsUpdate listenerUpdate = LdsUpdate.forTcpListener(listener); xdsClient.deliverLdsUpdate(listenerUpdate); } static void generateListenerUpdate( - FakeXdsClient xdsClient, List sourcePorts, + FakeXdsClient xdsClient, ImmutableList sourcePorts, EnvoyServerProtoData.DownstreamTlsContext tlsContext, EnvoyServerProtoData.DownstreamTlsContext tlsContextForDefaultFilterChain, TlsContextManager tlsContextManager) { @@ -78,35 +80,45 @@ public class XdsServerTestHelper { } static EnvoyServerProtoData.Listener buildTestListener( - String name, String address, List sourcePorts, + String name, String address, ImmutableList sourcePorts, EnvoyServerProtoData.DownstreamTlsContext tlsContext, EnvoyServerProtoData.DownstreamTlsContext tlsContextForDefaultFilterChain, TlsContextManager tlsContextManager) { EnvoyServerProtoData.FilterChainMatch filterChainMatch1 = - new EnvoyServerProtoData.FilterChainMatch( + EnvoyServerProtoData.FilterChainMatch.create( 0, - Arrays.asList(), - Arrays.asList(), - Arrays.asList(), - null, + ImmutableList.of(), + ImmutableList.of(), + ImmutableList.of(), + ConnectionSourceType.ANY, sourcePorts, - Arrays.asList(), - null); + ImmutableList.of(), + ""); + EnvoyServerProtoData.FilterChainMatch defaultFilterChainMatch = + EnvoyServerProtoData.FilterChainMatch.create( + 0, + ImmutableList.of(), + ImmutableList.of(), + ImmutableList.of(), + ConnectionSourceType.ANY, + ImmutableList.of(), + ImmutableList.of(), + ""); VirtualHost virtualHost = VirtualHost.create( "virtual-host", Collections.singletonList("auth"), new ArrayList(), ImmutableMap.of()); HttpConnectionManager httpConnectionManager = HttpConnectionManager.forVirtualHosts( 0L, Collections.singletonList(virtualHost), new ArrayList()); - EnvoyServerProtoData.FilterChain filterChain1 = new EnvoyServerProtoData.FilterChain( + EnvoyServerProtoData.FilterChain filterChain1 = EnvoyServerProtoData.FilterChain.create( "filter-chain-foo", filterChainMatch1, httpConnectionManager, tlsContext, tlsContextManager); - EnvoyServerProtoData.FilterChain defaultFilterChain = new EnvoyServerProtoData.FilterChain( - "filter-chain-bar", null, httpConnectionManager, tlsContextForDefaultFilterChain, - tlsContextManager); + EnvoyServerProtoData.FilterChain defaultFilterChain = EnvoyServerProtoData.FilterChain.create( + "filter-chain-bar", defaultFilterChainMatch, httpConnectionManager, + tlsContextForDefaultFilterChain, tlsContextManager); EnvoyServerProtoData.Listener listener = - new EnvoyServerProtoData.Listener( - name, address, Arrays.asList(filterChain1), defaultFilterChain); + EnvoyServerProtoData.Listener.create( + name, address, ImmutableList.of(filterChain1), defaultFilterChain); return listener; } @@ -202,8 +214,8 @@ public class XdsServerTestHelper { void deliverLdsUpdate(List filterChains, FilterChain defaultFilterChain) { - ldsWatcher.onChanged(LdsUpdate.forTcpListener(new Listener( - "listener", "0.0.0.0:1", filterChains, defaultFilterChain))); + ldsWatcher.onChanged(LdsUpdate.forTcpListener(Listener.create( + "listener", "0.0.0.0:1", ImmutableList.copyOf(filterChains), defaultFilterChain))); } void deliverLdsUpdate(LdsUpdate ldsUpdate) { diff --git a/xds/src/test/java/io/grpc/xds/XdsServerWrapperTest.java b/xds/src/test/java/io/grpc/xds/XdsServerWrapperTest.java index ac7f41e65a..f8b8ca2e10 100644 --- a/xds/src/test/java/io/grpc/xds/XdsServerWrapperTest.java +++ b/xds/src/test/java/io/grpc/xds/XdsServerWrapperTest.java @@ -234,8 +234,8 @@ public class XdsServerWrapperTest { assertThat(xdsClient.ldsResource).isNull(); assertThat(xdsClient.shutdown).isTrue(); verify(mockServer).shutdown(); - assertThat(f0.getSslContextProviderSupplier().isShutdown()).isTrue(); - assertThat(f1.getSslContextProviderSupplier().isShutdown()).isTrue(); + assertThat(f0.sslContextProviderSupplier().isShutdown()).isTrue(); + assertThat(f1.sslContextProviderSupplier().isShutdown()).isTrue(); when(mockServer.isTerminated()).thenReturn(true); when(mockServer.awaitTermination(anyLong(), any(TimeUnit.class))).thenReturn(true); assertThat(xdsServerWrapper.awaitTermination(5, TimeUnit.SECONDS)).isTrue(); @@ -276,8 +276,8 @@ public class XdsServerWrapperTest { assertThat(xdsClient.ldsResource).isNull(); assertThat(xdsClient.shutdown).isTrue(); verify(mockServer).shutdown(); - assertThat(f0.getSslContextProviderSupplier().isShutdown()).isTrue(); - assertThat(f1.getSslContextProviderSupplier().isShutdown()).isTrue(); + assertThat(f0.sslContextProviderSupplier().isShutdown()).isTrue(); + assertThat(f1.sslContextProviderSupplier().isShutdown()).isTrue(); assertThat(start.isDone()).isFalse(); //shall we set initialStatus when shutdown? } @@ -335,7 +335,7 @@ public class XdsServerWrapperTest { xdsClient.ldsResource.get(5, TimeUnit.SECONDS); when(mockServer.start()).thenThrow(new IOException("error!")); FilterChain filterChain = createFilterChain("filter-chain-1", createRds("rds")); - SslContextProviderSupplier sslSupplier = filterChain.getSslContextProviderSupplier(); + SslContextProviderSupplier sslSupplier = filterChain.sslContextProviderSupplier(); xdsClient.deliverLdsUpdate(Collections.singletonList(filterChain), null); xdsClient.rdsCount.await(5, TimeUnit.SECONDS); xdsClient.deliverRdsUpdate("rds", @@ -437,7 +437,7 @@ public class XdsServerWrapperTest { ImmutableMap.of()); HttpConnectionManager httpConnectionManager = HttpConnectionManager.forVirtualHosts( 0L, Collections.singletonList(virtualHost), new ArrayList()); - EnvoyServerProtoData.FilterChain filterChain = new EnvoyServerProtoData.FilterChain( + EnvoyServerProtoData.FilterChain filterChain = EnvoyServerProtoData.FilterChain.create( "filter-chain-foo", createMatch(), httpConnectionManager, createTls(), mock(TlsContextManager.class)); xdsClient.deliverLdsUpdate(Collections.singletonList(filterChain), null); @@ -509,7 +509,7 @@ public class XdsServerWrapperTest { assertThat(realConfig.virtualHosts()).isEqualTo( Collections.singletonList(createVirtualHost("virtual-host-2"))); assertThat(selectorManager.getSelectorToUpdateSelector().getDefaultSslContextProviderSupplier()) - .isEqualTo(f3.getSslContextProviderSupplier()); + .isEqualTo(f3.sslContextProviderSupplier()); } @Test @@ -557,7 +557,7 @@ public class XdsServerWrapperTest { Collections.singletonList(createVirtualHost("virtual-host-0"))); assertThat(realConfig.interceptors()).isEqualTo(ImmutableMap.of()); assertThat(selectorManager.getSelectorToUpdateSelector().getDefaultSslContextProviderSupplier()) - .isSameInstanceAs(f2.getSslContextProviderSupplier()); + .isSameInstanceAs(f2.sslContextProviderSupplier()); EnvoyServerProtoData.FilterChain f3 = createFilterChain("filter-chain-3", createRds("r0")); EnvoyServerProtoData.FilterChain f4 = createFilterChain("filter-chain-4", createRds("r1")); @@ -587,7 +587,7 @@ public class XdsServerWrapperTest { assertThat(realConfig.interceptors()).isEqualTo(ImmutableMap.of()); assertThat(selectorManager.getSelectorToUpdateSelector().getDefaultSslContextProviderSupplier()) - .isSameInstanceAs(f4.getSslContextProviderSupplier()); + .isSameInstanceAs(f4.sslContextProviderSupplier()); verify(mockServer, times(1)).start(); xdsServerWrapper.shutdown(); verify(mockServer, times(1)).shutdown(); @@ -675,7 +675,7 @@ public class XdsServerWrapperTest { verify(listener, times(1)).onNotServing(any(StatusException.class)); verify(mockBuilder, times(1)).build(); FilterChain filterChain0 = createFilterChain("filter-chain-0", createRds("rds")); - SslContextProviderSupplier sslSupplier0 = filterChain0.getSslContextProviderSupplier(); + SslContextProviderSupplier sslSupplier0 = filterChain0.sslContextProviderSupplier(); xdsClient.deliverLdsUpdate(Collections.singletonList(filterChain0), null); xdsClient.ldsWatcher.onError(Status.INTERNAL); assertThat(selectorManager.getSelectorToUpdateSelector()) @@ -688,7 +688,7 @@ public class XdsServerWrapperTest { when(mockServer.start()).thenThrow(new IOException("error!")) .thenReturn(mockServer); FilterChain filterChain1 = createFilterChain("filter-chain-1", createRds("rds")); - SslContextProviderSupplier sslSupplier1 = filterChain1.getSslContextProviderSupplier(); + SslContextProviderSupplier sslSupplier1 = filterChain1.sslContextProviderSupplier(); xdsClient.deliverLdsUpdate(Collections.singletonList(filterChain1), null); assertThat(sslSupplier0.isShutdown()).isTrue(); xdsClient.deliverRdsUpdate("rds", @@ -752,7 +752,7 @@ public class XdsServerWrapperTest { .thenThrow(new IOException("error2!")) .thenReturn(mockServer); FilterChain filterChain2 = createFilterChain("filter-chain-2", createRds("rds")); - SslContextProviderSupplier sslSupplier2 = filterChain2.getSslContextProviderSupplier(); + SslContextProviderSupplier sslSupplier2 = filterChain2.sslContextProviderSupplier(); xdsClient.deliverLdsUpdate(Collections.singletonList(filterChain2), null); xdsClient.deliverRdsUpdate("rds", Collections.singletonList(createVirtualHost("virtual-host-1"))); @@ -780,7 +780,7 @@ public class XdsServerWrapperTest { // serving after not serving FilterChain filterChain3 = createFilterChain("filter-chain-2", createRds("rds")); - SslContextProviderSupplier sslSupplier3 = filterChain3.getSslContextProviderSupplier(); + SslContextProviderSupplier sslSupplier3 = filterChain3.sslContextProviderSupplier(); xdsClient.deliverLdsUpdate(Collections.singletonList(filterChain3), null); xdsClient.deliverRdsUpdate("rds", Collections.singletonList(createVirtualHost("virtual-host-1"))); @@ -1187,7 +1187,7 @@ public class XdsServerWrapperTest { } private static FilterChain createFilterChain(String name, HttpConnectionManager hcm) { - return new EnvoyServerProtoData.FilterChain(name, createMatch(), + return EnvoyServerProtoData.FilterChain.create(name, createMatch(), hcm, createTls(), mock(TlsContextManager.class)); } @@ -1207,15 +1207,15 @@ public class XdsServerWrapperTest { } private static EnvoyServerProtoData.FilterChainMatch createMatch() { - return new EnvoyServerProtoData.FilterChainMatch( - 0, - Arrays.asList(), - Arrays.asList(), - Arrays.asList(), - EnvoyServerProtoData.ConnectionSourceType.ANY, - Arrays.asList(), - Arrays.asList(), - null); + return EnvoyServerProtoData.FilterChainMatch.create( + 0, + ImmutableList.of(), + ImmutableList.of(), + ImmutableList.of(), + EnvoyServerProtoData.ConnectionSourceType.ANY, + ImmutableList.of(), + ImmutableList.of(), + ""); } private static ServerRoutingConfig createRoutingConfig(String path, String domain,