Search in sources :

Example 1 with ClusterSpecifierPlugin

use of io.envoyproxy.envoy.config.route.v3.ClusterSpecifierPlugin 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)

Aggregations

ClusterSpecifierPlugin (io.envoyproxy.envoy.config.route.v3.ClusterSpecifierPlugin)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