Skip to content

Commit 7219706

Browse files
committed
Fix plumbings.
1 parent 0034d9c commit 7219706

26 files changed

+224
-205
lines changed

api/src/main/java/io/grpc/EquivalentAddressGroup.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,7 @@ public final class EquivalentAddressGroup {
5555
*/
5656
public static final Attributes.Key<String> ATTR_LOCALITY_NAME =
5757
Attributes.Key.create("io.grpc.EquivalentAddressGroup.LOCALITY");
58-
/** Name associated with individual address, if available (e.g., DNS name). */
59-
@Attr
60-
public static final Attributes.Key<String> ATTR_ADDRESS_NAME =
61-
Attributes.Key.create("io.grpc.xds.XdsAttributes.addressName");
58+
6259
private final List<SocketAddress> addrs;
6360
private final Attributes attrs;
6461

netty/src/main/java/io/grpc/netty/ProtocolNegotiators.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ public static ProtocolNegotiator tls(SslContext sslContext,
760760
*/
761761
public static ProtocolNegotiator tls(SslContext sslContext,
762762
X509TrustManager x509ExtendedTrustManager) {
763-
return tls(sslContext, null, Optional.absent(), x509ExtendedTrustManager, null, false);
763+
return tls(sslContext, null, Optional.absent(), x509ExtendedTrustManager, null);
764764
}
765765

766766
public static ProtocolNegotiator.ClientFactory tlsClientFactory(SslContext sslContext,

s2a/src/main/java/io/grpc/s2a/internal/handshaker/S2AProtocolNegotiatorFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ public void run() {
259259
s2aStub.close();
260260
}
261261
}),
262-
null, null, false)
262+
null, null)
263263
.newHandler(grpcHandler);
264264

265265
// Delegate the rest of the handshake to the TLS handler. and remove the

xds/src/main/java/io/grpc/xds/ClusterImplLoadBalancer.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import io.grpc.xds.client.XdsClient;
5454
import io.grpc.xds.client.XdsLogger;
5555
import io.grpc.xds.client.XdsLogger.XdsLogLevel;
56+
import io.grpc.xds.internal.XdsInternalAttributes;
5657
import io.grpc.xds.internal.security.SecurityProtocolNegotiators;
5758
import io.grpc.xds.internal.security.SslContextProviderSupplier;
5859
import io.grpc.xds.orca.OrcaPerRequestUtil;
@@ -241,9 +242,9 @@ public Subchannel createSubchannel(CreateSubchannelArgs args) {
241242
.set(ATTR_CLUSTER_LOCALITY, localityAtomicReference);
242243
if (GrpcUtil.getFlag("GRPC_EXPERIMENTAL_XDS_AUTHORITY_REWRITE", false)) {
243244
String hostname = args.getAddresses().get(0).getAttributes()
244-
.get(EquivalentAddressGroup.ATTR_ADDRESS_NAME);
245+
.get(XdsInternalAttributes.ATTR_ADDRESS_NAME);
245246
if (hostname != null) {
246-
attrsBuilder.set(EquivalentAddressGroup.ATTR_ADDRESS_NAME, hostname);
247+
attrsBuilder.set(XdsInternalAttributes.ATTR_ADDRESS_NAME, hostname);
247248
}
248249
}
249250
args = args.toBuilder().setAddresses(addresses).setAttributes(attrsBuilder.build()).build();
@@ -439,7 +440,7 @@ public PickResult pickSubchannel(PickSubchannelArgs args) {
439440
result = PickResult.withSubchannel(result.getSubchannel(),
440441
result.getStreamTracerFactory(),
441442
result.getSubchannel().getAttributes().get(
442-
EquivalentAddressGroup.ATTR_ADDRESS_NAME));
443+
XdsInternalAttributes.ATTR_ADDRESS_NAME));
443444
}
444445
}
445446
return result;

xds/src/main/java/io/grpc/xds/ClusterResolverLoadBalancer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import io.grpc.xds.client.Locality;
4848
import io.grpc.xds.client.XdsLogger;
4949
import io.grpc.xds.client.XdsLogger.XdsLogLevel;
50+
import io.grpc.xds.internal.XdsInternalAttributes;
5051
import java.net.InetSocketAddress;
5152
import java.net.SocketAddress;
5253
import java.util.ArrayList;
@@ -194,7 +195,7 @@ StatusOr<ClusterResolutionResult> edsUpdateToResult(
194195
.set(XdsAttributes.ATTR_LOCALITY_WEIGHT,
195196
localityLbInfo.localityWeight())
196197
.set(XdsAttributes.ATTR_SERVER_WEIGHT, weight)
197-
.set(EquivalentAddressGroup.ATTR_ADDRESS_NAME, endpoint.hostname())
198+
.set(XdsInternalAttributes.ATTR_ADDRESS_NAME, endpoint.hostname())
198199
.build();
199200
EquivalentAddressGroup eag;
200201
if (config.isHttp11ProxyAvailable()) {
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package io.grpc.xds.internal;
2+
3+
/*
4+
* Copyright 2019 The gRPC Authors
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
import io.grpc.Attributes;
20+
import io.grpc.EquivalentAddressGroup;
21+
22+
public final class XdsInternalAttributes {
23+
/** Name associated with individual address, if available (e.g., DNS name). */
24+
@EquivalentAddressGroup.Attr
25+
public static final Attributes.Key<String> ATTR_ADDRESS_NAME =
26+
Attributes.Key.create("io.grpc.xds.XdsAttributes.addressName");
27+
}

xds/src/main/java/io/grpc/xds/internal/security/ClientSslContextProviderFactory.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424

2525
/** Factory to create client-side SslContextProvider from UpstreamTlsContext. */
2626
final class ClientSslContextProviderFactory
27-
implements ValueFactory<AbstractMap.SimpleImmutableEntry<UpstreamTlsContext, String>,
28-
SslContextProvider> {
27+
implements ValueFactory<UpstreamTlsContext, SslContextProvider> {
2928

3029
private BootstrapInfo bootstrapInfo;
3130
private final CertProviderClientSslContextProviderFactory
@@ -43,10 +42,9 @@ final class ClientSslContextProviderFactory
4342

4443
/** Creates an SslContextProvider from the given UpstreamTlsContext. */
4544
@Override
46-
public SslContextProvider create(
47-
AbstractMap.SimpleImmutableEntry<UpstreamTlsContext, String> key) {
45+
public SslContextProvider create(UpstreamTlsContext key) {
4846
return certProviderClientSslContextProviderFactory.getProvider(
49-
key.getKey(), key.getValue(),
47+
key,
5048
bootstrapInfo.node().toEnvoyProtoNode(),
5149
bootstrapInfo.certProviders());
5250
}

xds/src/main/java/io/grpc/xds/internal/security/SecurityProtocolNegotiators.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import io.grpc.netty.ProtocolNegotiationEvent;
3434
import io.grpc.xds.EnvoyServerProtoData;
3535
import io.grpc.xds.EnvoyServerProtoData.UpstreamTlsContext;
36+
import io.grpc.xds.internal.XdsInternalAttributes;
3637
import io.grpc.xds.internal.security.trust.CertificateUtils;
3738
import io.netty.channel.ChannelHandler;
3839
import io.netty.channel.ChannelHandlerAdapter;
@@ -150,7 +151,7 @@ public ChannelHandler newHandler(GrpcHttp2ConnectionHandler grpcHandler) {
150151
return fallbackProtocolNegotiator.newHandler(grpcHandler);
151152
}
152153
return new ClientSecurityHandler(grpcHandler, localSslContextProviderSupplier,
153-
grpcHandler.getEagAttributes().get(EquivalentAddressGroup.ATTR_ADDRESS_NAME));
154+
grpcHandler.getEagAttributes().get(XdsInternalAttributes.ATTR_ADDRESS_NAME));
154155
}
155156

156157
@Override
@@ -398,7 +399,7 @@ public void updateSslContextAndExtendedX509TrustManager(
398399
public void onException(Throwable throwable) {
399400
ctx.fireExceptionCaught(throwable);
400401
}
401-
}, null);
402+
});
402403
}
403404
}
404405
}

xds/src/main/java/io/grpc/xds/internal/security/TlsContextManagerImpl.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@
3535
*/
3636
public final class TlsContextManagerImpl implements TlsContextManager {
3737

38-
private final ReferenceCountingMap<AbstractMap.SimpleImmutableEntry<UpstreamTlsContext, String>,
39-
SslContextProvider> mapForClients;
38+
private final ReferenceCountingMap<UpstreamTlsContext, SslContextProvider> mapForClients;
4039
private final ReferenceCountingMap<DownstreamTlsContext, SslContextProvider> mapForServers;
4140

4241
/**
@@ -50,8 +49,7 @@ public final class TlsContextManagerImpl implements TlsContextManager {
5049

5150
@VisibleForTesting
5251
TlsContextManagerImpl(
53-
ValueFactory<AbstractMap.SimpleImmutableEntry<UpstreamTlsContext, String>,
54-
SslContextProvider> clientFactory,
52+
ValueFactory<UpstreamTlsContext, SslContextProvider> clientFactory,
5553
ValueFactory<DownstreamTlsContext, SslContextProvider> serverFactory) {
5654
checkNotNull(clientFactory, "clientFactory");
5755
checkNotNull(serverFactory, "serverFactory");
@@ -74,16 +72,14 @@ public SslContextProvider findOrCreateServerSslContextProvider(
7472
public SslContextProvider findOrCreateClientSslContextProvider(
7573
UpstreamTlsContext upstreamTlsContext) {
7674
checkNotNull(upstreamTlsContext, "upstreamTlsContext");
77-
return mapForClients.get(new AbstractMap.SimpleImmutableEntry<>(upstreamTlsContext, sni));
75+
return mapForClients.get(upstreamTlsContext);
7876
}
7977

8078
@Override
8179
public SslContextProvider releaseClientSslContextProvider(
82-
SslContextProvider clientSslContextProvider, String sni) {
80+
SslContextProvider clientSslContextProvider) {
8381
checkNotNull(clientSslContextProvider, "clientSslContextProvider");
84-
return mapForClients.release(
85-
new AbstractMap.SimpleImmutableEntry<>(
86-
clientSslContextProvider.getUpstreamTlsContext(), sni),
82+
return mapForClients.release(clientSslContextProvider.getUpstreamTlsContext(),
8783
clientSslContextProvider);
8884
}
8985

xds/src/main/java/io/grpc/xds/internal/security/certprovider/CertProviderClientSslContextProvider.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ final class CertProviderClientSslContextProvider extends CertProviderSslContextP
4242
CommonTlsContext.CertificateProviderInstance rootCertInstance,
4343
CertificateValidationContext staticCertValidationContext,
4444
UpstreamTlsContext upstreamTlsContext,
45-
String sniForSanMatching,
4645
CertificateProviderStore certificateProviderStore) {
4746
super(
4847
node,
@@ -51,8 +50,7 @@ final class CertProviderClientSslContextProvider extends CertProviderSslContextP
5150
rootCertInstance,
5251
staticCertValidationContext,
5352
upstreamTlsContext,
54-
certificateProviderStore,
55-
upstreamTlsContext.getAutoSniSanValidation() ? sniForSanMatching : null);
53+
certificateProviderStore);
5654
}
5755

5856
@Override

0 commit comments

Comments
 (0)