Search in sources :

Example 1 with VirtualHost

use of io.envoyproxy.envoy.config.route.v3.VirtualHost in project grpc-java by grpc.

the class ClientXdsClient method extractVirtualHosts.

private static List<VirtualHost> extractVirtualHosts(RouteConfiguration routeConfig, FilterRegistry filterRegistry, boolean parseHttpFilter) throws ResourceInvalidException {
    Map<String, PluginConfig> pluginConfigMap = new HashMap<>();
    if (enableRouteLookup) {
        List<ClusterSpecifierPlugin> plugins = routeConfig.getClusterSpecifierPluginsList();
        for (ClusterSpecifierPlugin plugin : plugins) {
            PluginConfig existing = pluginConfigMap.put(plugin.getExtension().getName(), parseClusterSpecifierPlugin(plugin));
            if (existing != null) {
                throw new ResourceInvalidException("Multiple ClusterSpecifierPlugins with the same name: " + plugin.getExtension().getName());
            }
        }
    }
    List<VirtualHost> virtualHosts = new ArrayList<>(routeConfig.getVirtualHostsCount());
    for (io.envoyproxy.envoy.config.route.v3.VirtualHost virtualHostProto : routeConfig.getVirtualHostsList()) {
        StructOrError<VirtualHost> virtualHost = parseVirtualHost(virtualHostProto, filterRegistry, parseHttpFilter, pluginConfigMap);
        if (virtualHost.getErrorDetail() != null) {
            throw new ResourceInvalidException("RouteConfiguration contains invalid virtual host: " + virtualHost.getErrorDetail());
        }
        virtualHosts.add(virtualHost.getStruct());
    }
    return virtualHosts;
}
Also used : ClusterSpecifierPlugin(io.envoyproxy.envoy.config.route.v3.ClusterSpecifierPlugin) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) NamedPluginConfig(io.grpc.xds.ClusterSpecifierPlugin.NamedPluginConfig) PluginConfig(io.grpc.xds.ClusterSpecifierPlugin.PluginConfig)

Example 2 with VirtualHost

use of io.envoyproxy.envoy.config.route.v3.VirtualHost in project grpc-java by grpc.

the class FakeControlPlaneXdsIntegrationTest method serverListener.

private static Listener serverListener(String name) {
    HttpFilter routerFilter = HttpFilter.newBuilder().setName("terminal-filter").setTypedConfig(Any.pack(Router.newBuilder().build())).setIsOptional(true).build();
    VirtualHost virtualHost = io.envoyproxy.envoy.config.route.v3.VirtualHost.newBuilder().setName("virtual-host-0").addDomains("*").addRoutes(Route.newBuilder().setMatch(RouteMatch.newBuilder().setPrefix("/").build()).setNonForwardingAction(NonForwardingAction.newBuilder().build()).build()).build();
    RouteConfiguration routeConfig = RouteConfiguration.newBuilder().addVirtualHosts(virtualHost).build();
    Filter filter = Filter.newBuilder().setName("network-filter-0").setTypedConfig(Any.pack(HttpConnectionManager.newBuilder().setRouteConfig(routeConfig).addAllHttpFilters(Collections.singletonList(routerFilter)).build())).build();
    FilterChainMatch filterChainMatch = FilterChainMatch.newBuilder().setSourceType(FilterChainMatch.ConnectionSourceType.ANY).build();
    FilterChain filterChain = FilterChain.newBuilder().setName("filter-chain-0").setFilterChainMatch(filterChainMatch).addFilters(filter).build();
    return Listener.newBuilder().setName(name).setTrafficDirection(TrafficDirection.INBOUND).addFilterChains(filterChain).build();
}
Also used : Filter(io.envoyproxy.envoy.config.listener.v3.Filter) HttpFilter(io.envoyproxy.envoy.extensions.filters.network.http_connection_manager.v3.HttpFilter) RouteConfiguration(io.envoyproxy.envoy.config.route.v3.RouteConfiguration) FilterChain(io.envoyproxy.envoy.config.listener.v3.FilterChain) FilterChainMatch(io.envoyproxy.envoy.config.listener.v3.FilterChainMatch) HttpFilter(io.envoyproxy.envoy.extensions.filters.network.http_connection_manager.v3.HttpFilter) VirtualHost(io.envoyproxy.envoy.config.route.v3.VirtualHost)

Aggregations

Filter (io.envoyproxy.envoy.config.listener.v3.Filter)1 FilterChain (io.envoyproxy.envoy.config.listener.v3.FilterChain)1 FilterChainMatch (io.envoyproxy.envoy.config.listener.v3.FilterChainMatch)1 ClusterSpecifierPlugin (io.envoyproxy.envoy.config.route.v3.ClusterSpecifierPlugin)1 RouteConfiguration (io.envoyproxy.envoy.config.route.v3.RouteConfiguration)1 VirtualHost (io.envoyproxy.envoy.config.route.v3.VirtualHost)1 HttpFilter (io.envoyproxy.envoy.extensions.filters.network.http_connection_manager.v3.HttpFilter)1 NamedPluginConfig (io.grpc.xds.ClusterSpecifierPlugin.NamedPluginConfig)1 PluginConfig (io.grpc.xds.ClusterSpecifierPlugin.PluginConfig)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1