/**
   * Returns a new test listener.
   *  @param ads should RDS for the listener be configured to use XDS?
   * @param rdsTransportVersion the transport_api_version that should be set for RDS
   * @param rdsResourceVersion the resource_api_version that should be set for RDS
   * @param listenerName name of the new listener
   * @param port port to use for the listener
   * @param routeName name of the test route that is associated with this listener
   */
public static Listener createListener(boolean ads,
      io.envoyproxy.envoy.api.v2.core.ApiVersion rdsTransportVersion,
      io.envoyproxy.envoy.api.v2.core.ApiVersion rdsResourceVersion, String listenerName,
      int port, String routeName) {
    ConfigSource.Builder configSourceBuilder = ConfigSource.newBuilder()
        .setResourceApiVersion(rdsResourceVersion);
    ConfigSource rdsSource = ads
        ? configSourceBuilder
        .setAds(AggregatedConfigSource.getDefaultInstance())
        .build()
        : configSourceBuilder
            .setApiConfigSource(ApiConfigSource.newBuilder()
                .setApiType(ApiType.GRPC)
                .setTransportApiVersion(rdsTransportVersion)
                .addGrpcServices(GrpcService.newBuilder()
                    .setEnvoyGrpc(EnvoyGrpc.newBuilder()
                        .setClusterName(XDS_CLUSTER))))
            .build();
    HttpConnectionManager manager = HttpConnectionManager.newBuilder()
        .setCodecType(CodecType.AUTO)
        .setStatPrefix("http")
        .setRds(Rds.newBuilder()
            .setConfigSource(rdsSource)
            .setRouteConfigName(routeName))
        .addHttpFilters(HttpFilter.newBuilder()
            .setName(Resources.FILTER_ENVOY_ROUTER))
        .build();
    return Listener.newBuilder()
        .setName(listenerName)
        .setAddress(Address.newBuilder()
            .setSocketAddress(SocketAddress.newBuilder()
                .setAddress(ANY_ADDRESS)
                .setPortValue(port)
                .setProtocol(Protocol.TCP)))
        .addFilterChains(FilterChain.newBuilder()
            .addFilters(Filter.newBuilder()
                .setName(Resources.FILTER_HTTP_CONNECTION_MANAGER)
                .setTypedConfig(Any.pack(manager))))
        .build();
  }
public static Listener createListener(boolean ads,
io.envoyproxy.envoy.api.v2.core.ApiVersion rdsTransportVersion,
io.envoyproxy.envoy.api.v2.core.ApiVersion rdsResourceVersion, String listenerName,
int port, String routeName) {
ConfigSource.Builder configSourceBuilder = ConfigSource.newBuilder()
.setResourceApiVersion(rdsResourceVersion);
ConfigSource rdsSource = ads
? configSourceBuilder
.setAds(AggregatedConfigSource.getDefaultInstance())
.build()
: configSourceBuilder
.setApiConfigSource(ApiConfigSource.newBuilder()
.setApiType(ApiType.GRPC)
.setTransportApiVersion(rdsTransportVersion)
.addGrpcServices(GrpcService.newBuilder()
.setEnvoyGrpc(EnvoyGrpc.newBuilder()
.setClusterName(XDS_CLUSTER))))
.build();
HttpConnectionManager manager = HttpConnectionManager.newBuilder()
.setCodecType(CodecType.AUTO)
.setStatPrefix("http")
.setRds(Rds.newBuilder()
.setConfigSource(rdsSource)
.setRouteConfigName(routeName))
.addHttpFilters(HttpFilter.newBuilder()
.setName(Resources.FILTER_ENVOY_ROUTER))
.build();
return Listener.newBuilder()
.setName(listenerName)
.setAddress(Address.newBuilder()
.setSocketAddress(SocketAddress.newBuilder()
.setAddress(ANY_ADDRESS)
.setPortValue(port)
.setProtocol(Protocol.TCP)))
.addFilterChains(FilterChain.newBuilder()
.addFilters(Filter.newBuilder()
.setName(Resources.FILTER_HTTP_CONNECTION_MANAGER)
.setTypedConfig(Any.pack(manager))))
.build();
}
public static Listener createListener(boolean ads,
io.envoyproxy.envoy.api.v2.core.ApiVersion rdsTransportVersion,
io.envoyproxy.envoy.api.v2.core.ApiVersion rdsResourceVersion, String listenerName,
int port, String routeName) {
ConfigSource.Builder configSourceBuilder = ConfigSource.newBuilder()
.setResourceApiVersion(rdsResourceVersion);
ConfigSource rdsSource = ads
? configSourceBuilder
.setAds(AggregatedConfigSource.getDefaultInstance())
.build()
: configSourceBuilder
.setApiConfigSource(ApiConfigSource.newBuilder()
.setApiType(ApiType.GRPC)
.setTransportApiVersion(rdsTransportVersion)
.addGrpcServices(GrpcService.newBuilder()
.setEnvoyGrpc(EnvoyGrpc.newBuilder()
.setClusterName(XDS_CLUSTER))))
.build();
HttpConnectionManager manager = HttpConnectionManager.newBuilder()
.setCodecType(CodecType.AUTO)
.setStatPrefix("http")
.setRds(Rds.newBuilder()
.setConfigSource(rdsSource)
.setRouteConfigName(routeName))
.addHttpFilters(HttpFilter.newBuilder()
.setName(Resources.FILTER_ENVOY_ROUTER))
.build();
return Listener.newBuilder()
.setName(listenerName)
.setAddress(Address.newBuilder()
.setSocketAddress(SocketAddress.newBuilder()
.setAddress(ANY_ADDRESS)
.setPortValue(port)
.setProtocol(Protocol.TCP)))
.addFilterChains(FilterChain.newBuilder()
.addFilters(Filter.newBuilder()
.setName(Resources.FILTER_HTTP_CONNECTION_MANAGER)
.setTypedConfig(Any.pack(manager))))
.build();
}
public static Listener createListener(boolean ads,
io.envoyproxy.envoy.api.v2.core.ApiVersion rdsTransportVersion,
io.envoyproxy.envoy.api.v2.core.ApiVersion rdsResourceVersion, String listenerName,
int port, String routeName) {
ConfigSource.Builder configSourceBuilder = ConfigSource.newBuilder()
.setResourceApiVersion(rdsResourceVersion);
ConfigSource rdsSource = ads
? configSourceBuilder
.setAds(AggregatedConfigSource.getDefaultInstance())
.build()
: configSourceBuilder
.setApiConfigSource(ApiConfigSource.newBuilder()
.setApiType(ApiType.GRPC)
.setTransportApiVersion(rdsTransportVersion)
.addGrpcServices(GrpcService.newBuilder()
.setEnvoyGrpc(EnvoyGrpc.newBuilder()
.setClusterName(XDS_CLUSTER))))
.build();
HttpConnectionManager manager = HttpConnectionManager.newBuilder()
.setCodecType(CodecType.AUTO)
.setStatPrefix("http")
.setRds(Rds.newBuilder()
.setConfigSource(rdsSource)
.setRouteConfigName(routeName))
.addHttpFilters(HttpFilter.newBuilder()
.setName(Resources.FILTER_ENVOY_ROUTER))
.build();
return Listener.newBuilder()
.setName(listenerName)
.setAddress(Address.newBuilder()
.setSocketAddress(SocketAddress.newBuilder()
.setAddress(ANY_ADDRESS)
.setPortValue(port)
.setProtocol(Protocol.TCP)))
.addFilterChains(FilterChain.newBuilder()
.addFilters(Filter.newBuilder()
.setName(Resources.FILTER_HTTP_CONNECTION_MANAGER)
.setTypedConfig(Any.pack(manager))))
.build();
}