Repository navigation
feat(bigtable): add per-method session diversion configuration #14681
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
base: main
Are you sure you want to change the base?
Changes from all commits
cc0ad8f
21d9342
1d37bde
bd1d4db
7678fac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,7 +21,9 @@ | |
| import com.google.bigtable.v2.ClientConfiguration.PollingCase; | ||
| import com.google.bigtable.v2.FeatureFlags; | ||
| import com.google.bigtable.v2.GetClientConfigurationRequest; | ||
| import com.google.bigtable.v2.SessionClientConfiguration; | ||
| import com.google.bigtable.v2.SessionClientConfiguration.ChannelPoolConfiguration.DirectAccessOnly; | ||
| import com.google.bigtable.v2.SessionDiversionConfiguration; | ||
| import com.google.bigtable.v2.TelemetryConfiguration; | ||
| import com.google.cloud.bigtable.data.v2.internal.api.ChannelProviders.ChannelProvider; | ||
| import com.google.cloud.bigtable.data.v2.internal.api.Util; | ||
|
|
@@ -447,16 +449,39 @@ private ClientConfiguration normalizeConfig(ClientConfiguration cfg) { | |
| // When sessions are disabled make sure to clear out the config. Read from the builder, not | ||
| // cfg, so that a nonzero session_load supplied via the override sys-prop is honoured even when | ||
| // the server-returned config has session_load=0. | ||
| if (builder.getSessionConfiguration().getSessionLoad() == 0) { | ||
| if (!divertsAnyTrafficToSessions(builder.getSessionConfiguration())) { | ||
| builder.clearSessionConfiguration(); | ||
| return builder.build(); | ||
| } | ||
|
|
||
| return builder.build(); | ||
| } | ||
|
|
||
| /** | ||
| * Returns true if the configuration routes a nonzero share of traffic to sessions, either via the | ||
| * flat {@code session_load} or via a diversion configuration that carries a nonzero load. | ||
| */ | ||
| private static boolean divertsAnyTrafficToSessions(SessionClientConfiguration session) { | ||
| if (session.getSessionLoad() > 0) { | ||
| return true; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why are we returning
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it just short circut the check in nomarlize config. |
||
| } | ||
|
|
||
| SessionDiversionConfiguration diversion = session.getSessionDiversionConfiguration(); | ||
| switch (diversion.getDiversionStrategyCase()) { | ||
| case GLOBAL_DIVERSION: | ||
| return diversion.getGlobalDiversion().getSessionLoad() > 0; | ||
| case PER_SCOPE_DIVERSION: | ||
| return diversion.getPerScopeDiversion().getScopeDiversionsMap().values().stream() | ||
| .anyMatch(scope -> scope.getSessionLoad() > 0); | ||
| default: | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| public boolean areSessionsRequired() { | ||
| return overrideConfig.map(c -> c.getSessionConfiguration().getSessionLoad() > 0).orElse(false); | ||
| return overrideConfig | ||
| .map(c -> divertsAnyTrafficToSessions(c.getSessionConfiguration())) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is fine, because this uses override config to bypass session compatibility check. And it seems to be redundant because base feature flag already sets it to true. We should probably clean it up in a follow up PR. |
||
| .orElse(false); | ||
| } | ||
|
|
||
| private long getRetryDelay(int attempt) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.