xds: rename experimental routing flag to GRPC_XDS_EXPERIMENTAL_ROUTING

This commit is contained in:
ZHANG Dapeng 2020-05-08 16:15:12 -07:00 committed by GitHub
parent 96a32ed768
commit 61938bd032
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 11 deletions

View File

@ -96,10 +96,9 @@ final class XdsClientImpl extends XdsClient {
static final String ADS_TYPE_URL_EDS = static final String ADS_TYPE_URL_EDS =
"type.googleapis.com/envoy.api.v2.ClusterLoadAssignment"; "type.googleapis.com/envoy.api.v2.ClusterLoadAssignment";
// For now we do not support path matching unless enabled manually.
// Mutable for testing. // Mutable for testing.
static boolean enablePathMatching = Boolean.parseBoolean( static boolean enableExperimentalRouting = Boolean.parseBoolean(
System.getenv("ENABLE_EXPERIMENTAL_PATH_MATCHING")); System.getenv("GRPC_XDS_EXPERIMENTAL_ROUTING"));
private final MessagePrinter respPrinter = new MessagePrinter(); private final MessagePrinter respPrinter = new MessagePrinter();
@ -645,7 +644,7 @@ final class XdsClientImpl extends XdsClient {
if (routes != null) { if (routes != null) {
// Found routes in the in-lined RouteConfiguration. // Found routes in the in-lined RouteConfiguration.
ConfigUpdate configUpdate; ConfigUpdate configUpdate;
if (!enablePathMatching) { if (!enableExperimentalRouting) {
EnvoyProtoData.Route defaultRoute = Iterables.getLast(routes); EnvoyProtoData.Route defaultRoute = Iterables.getLast(routes);
configUpdate = configUpdate =
ConfigUpdate.newBuilder() ConfigUpdate.newBuilder()
@ -828,7 +827,7 @@ final class XdsClientImpl extends XdsClient {
// Found routes in the in-lined RouteConfiguration. // Found routes in the in-lined RouteConfiguration.
ConfigUpdate configUpdate; ConfigUpdate configUpdate;
if (!enablePathMatching) { if (!enableExperimentalRouting) {
EnvoyProtoData.Route defaultRoute = Iterables.getLast(routes); EnvoyProtoData.Route defaultRoute = Iterables.getLast(routes);
configUpdate = configUpdate =
ConfigUpdate.newBuilder() ConfigUpdate.newBuilder()
@ -916,7 +915,7 @@ final class XdsClientImpl extends XdsClient {
} }
// We only validate the default route unless path matching is enabled. // We only validate the default route unless path matching is enabled.
if (!enablePathMatching) { if (!enableExperimentalRouting) {
EnvoyProtoData.Route route = routes.get(routes.size() - 1); EnvoyProtoData.Route route = routes.get(routes.size() - 1);
RouteMatch routeMatch = route.getRouteMatch(); RouteMatch routeMatch = route.getRouteMatch();
if (!routeMatch.isDefaultMatcher()) { if (!routeMatch.isDefaultMatcher()) {

View File

@ -303,7 +303,7 @@ public class XdsClientImplTest {
@After @After
public void tearDown() { public void tearDown() {
XdsClientImpl.enablePathMatching = false; XdsClientImpl.enableExperimentalRouting = false;
xdsClient.shutdown(); xdsClient.shutdown();
assertThat(adsEnded.get()).isTrue(); assertThat(adsEnded.get()).isTrue();
assertThat(lrsEnded.get()).isTrue(); assertThat(lrsEnded.get()).isTrue();
@ -643,7 +643,7 @@ public class XdsClientImplTest {
*/ */
@Test @Test
public void resolveVirtualHostWithPathMatchingInRdsResponse() { public void resolveVirtualHostWithPathMatchingInRdsResponse() {
XdsClientImpl.enablePathMatching = true; XdsClientImpl.enableExperimentalRouting = true;
xdsClient.watchConfigData(TARGET_AUTHORITY, configWatcher); xdsClient.watchConfigData(TARGET_AUTHORITY, configWatcher);
StreamObserver<DiscoveryResponse> responseObserver = responseObservers.poll(); StreamObserver<DiscoveryResponse> responseObserver = responseObservers.poll();
StreamObserver<DiscoveryRequest> requestObserver = requestObservers.poll(); StreamObserver<DiscoveryRequest> requestObserver = requestObservers.poll();

View File

@ -185,7 +185,7 @@ public class XdsNameResolverTest {
@After @After
public void tearDown() { public void tearDown() {
xdsNameResolver.shutdown(); xdsNameResolver.shutdown();
XdsClientImpl.enablePathMatching = false; XdsClientImpl.enableExperimentalRouting = false;
} }
@Test @Test
@ -345,7 +345,7 @@ public class XdsNameResolverTest {
@Test @Test
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void resolve_resourceUpdated_multipleRoutes() { public void resolve_resourceUpdated_multipleRoutes() {
XdsClientImpl.enablePathMatching = true; XdsClientImpl.enableExperimentalRouting = true;
xdsNameResolver.start(mockListener); xdsNameResolver.start(mockListener);
assertThat(responseObservers).hasSize(1); assertThat(responseObservers).hasSize(1);
StreamObserver<DiscoveryResponse> responseObserver = responseObservers.poll(); StreamObserver<DiscoveryResponse> responseObserver = responseObservers.poll();
@ -482,7 +482,7 @@ public class XdsNameResolverTest {
@Test @Test
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void resolve_resourceUpdated_allowDuplicateMatchers() { public void resolve_resourceUpdated_allowDuplicateMatchers() {
XdsClientImpl.enablePathMatching = true; XdsClientImpl.enableExperimentalRouting = true;
xdsNameResolver.start(mockListener); xdsNameResolver.start(mockListener);
assertThat(responseObservers).hasSize(1); assertThat(responseObservers).hasSize(1);
StreamObserver<DiscoveryResponse> responseObserver = responseObservers.poll(); StreamObserver<DiscoveryResponse> responseObserver = responseObservers.poll();