Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xds, rbac: build per route serverInterceptor for httpConfig #8524

Merged
merged 6 commits into from Sep 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -59,6 +59,7 @@
import java.util.Map;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -135,28 +136,29 @@ public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exc

static final class FilterChainSelector {
public static final FilterChainSelector NO_FILTER_CHAIN = new FilterChainSelector(
Collections.<FilterChain, ServerRoutingConfig>emptyMap(), null, null);
private final Map<FilterChain, ServerRoutingConfig> routingConfigs;
Collections.<FilterChain, AtomicReference<ServerRoutingConfig>>emptyMap(),
null, new AtomicReference<ServerRoutingConfig>());
private final Map<FilterChain, AtomicReference<ServerRoutingConfig>> routingConfigs;
@Nullable
private final SslContextProviderSupplier defaultSslContextProviderSupplier;
@Nullable
private final ServerRoutingConfig defaultRoutingConfig;
private final AtomicReference<ServerRoutingConfig> defaultRoutingConfig;

FilterChainSelector(Map<FilterChain, ServerRoutingConfig> routingConfigs,
FilterChainSelector(Map<FilterChain, AtomicReference<ServerRoutingConfig>> routingConfigs,
@Nullable SslContextProviderSupplier defaultSslContextProviderSupplier,
@Nullable ServerRoutingConfig defaultRoutingConfig) {
@Nullable AtomicReference<ServerRoutingConfig> defaultRoutingConfig) {
this.routingConfigs = checkNotNull(routingConfigs, "routingConfigs");
this.defaultSslContextProviderSupplier = defaultSslContextProviderSupplier;
this.defaultRoutingConfig = defaultRoutingConfig;
this.defaultRoutingConfig = checkNotNull(defaultRoutingConfig, "defaultRoutingConfig");
}

@VisibleForTesting
Map<FilterChain, ServerRoutingConfig> getRoutingConfigs() {
Map<FilterChain, AtomicReference<ServerRoutingConfig>> getRoutingConfigs() {
return routingConfigs;
}

@VisibleForTesting
ServerRoutingConfig getDefaultRoutingConfig() {
AtomicReference<ServerRoutingConfig> getDefaultRoutingConfig() {
return defaultRoutingConfig;
}

Expand Down Expand Up @@ -189,7 +191,7 @@ SelectedConfig select(InetSocketAddress localAddr, InetSocketAddress remoteAddr)
return new SelectedConfig(
routingConfigs.get(selected), selected.getSslContextProviderSupplier());
}
if (defaultRoutingConfig != null) {
if (defaultRoutingConfig.get() != null) {
return new SelectedConfig(defaultRoutingConfig, defaultSslContextProviderSupplier);
}
return null;
Expand Down Expand Up @@ -393,11 +395,11 @@ public void close() {
* The FilterChain level configuration.
*/
private static final class SelectedConfig {
private final ServerRoutingConfig routingConfig;
private final AtomicReference<ServerRoutingConfig> routingConfig;
@Nullable
private final SslContextProviderSupplier sslContextProviderSupplier;

private SelectedConfig(ServerRoutingConfig routingConfig,
private SelectedConfig(AtomicReference<ServerRoutingConfig> routingConfig,
@Nullable SslContextProviderSupplier sslContextProviderSupplier) {
this.routingConfig = checkNotNull(routingConfig, "routingConfig");
this.sslContextProviderSupplier = sslContextProviderSupplier;
Expand Down