-
Notifications
You must be signed in to change notification settings - Fork 98
feat/idle-channel-eviction #2651
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
Open
nicholsl
wants to merge
17
commits into
googleapis:main
Choose a base branch
from
nicholsl:feat/idle-channel-eviction
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 15 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
20e012d
feat/idle-channel-eviction
nicholsl d2b6129
create noop channel primer
nicholsl 333e9e9
no-op channel primer changes
nicholsl 4ddefce
update ignored diffs
nicholsl ba9e039
chore: Update generation configuration at Thu Aug 7 02:49:23 UTC 202…
cloud-java-bot 3646452
deps: update shared dependencies (#2654)
mutianf b741869
chore(main): release 2.64.0 (#2652)
release-please[bot] bafedf9
feat(bigtable): lower the value for max rpc channels as channel resiz…
sushanb cbdb4e2
chore(main): release 2.64.1-SNAPSHOT (#2655)
release-please[bot] 0422092
chore(main): release 2.65.0 (#2657)
release-please[bot] 171ac40
chore(main): release 2.65.1-SNAPSHOT (#2658)
release-please[bot] 5b619b1
Merge branch 'googleapis:main' into feat/idle-channel-eviction
nicholsl 862135b
more noop channel primer changes
nicholsl c0082cf
remove outdated comments
nicholsl 7a007bf
cleanup
nicholsl beda46e
pr feedback
nicholsl dff1361
Merge branch 'googleapis:main' into feat/idle-channel-eviction
nicholsl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ | |
|
||
import com.google.api.core.InternalApi; | ||
import com.google.api.gax.grpc.ChannelFactory; | ||
import com.google.api.gax.grpc.ChannelPrimer; | ||
import com.google.cloud.bigtable.gaxx.grpc.ChannelPoolHealthChecker.ProbeResult; | ||
import com.google.common.annotations.VisibleForTesting; | ||
import com.google.common.base.Preconditions; | ||
import com.google.common.collect.ImmutableList; | ||
|
@@ -31,9 +31,11 @@ | |
import io.grpc.MethodDescriptor; | ||
import io.grpc.Status; | ||
import java.io.IOException; | ||
import java.time.Clock; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.concurrent.CancellationException; | ||
import java.util.concurrent.ConcurrentLinkedQueue; | ||
import java.util.concurrent.Executors; | ||
import java.util.concurrent.ScheduledExecutorService; | ||
import java.util.concurrent.TimeUnit; | ||
|
@@ -62,11 +64,11 @@ public class BigtableChannelPool extends ManagedChannel { | |
private final BigtableChannelPoolSettings settings; | ||
private final ChannelFactory channelFactory; | ||
|
||
private final ChannelPrimer channelPrimer; | ||
private ChannelPrimer channelPrimer; | ||
private final ScheduledExecutorService executor; | ||
|
||
private final Object entryWriteLock = new Object(); | ||
@VisibleForTesting final AtomicReference<ImmutableList<Entry>> entries = new AtomicReference<>(); | ||
private ChannelPoolHealthChecker channelPoolHealthChecker; | ||
private final AtomicInteger indexTicker = new AtomicInteger(); | ||
private final String authority; | ||
|
||
|
@@ -96,6 +98,10 @@ public static BigtableChannelPool create( | |
this.settings = settings; | ||
this.channelFactory = channelFactory; | ||
this.channelPrimer = channelPrimer; | ||
Clock systemClock = Clock.systemUTC(); | ||
this.channelPoolHealthChecker = | ||
new ChannelPoolHealthChecker(() -> entries.get(), channelPrimer, executor, systemClock); | ||
this.channelPoolHealthChecker.start(); | ||
|
||
ImmutableList.Builder<Entry> initialListBuilder = ImmutableList.builder(); | ||
|
||
|
@@ -445,15 +451,27 @@ static class Entry { | |
|
||
private final AtomicInteger maxOutstanding = new AtomicInteger(); | ||
|
||
@VisibleForTesting | ||
final ConcurrentLinkedQueue<ProbeResult> probeHistory = new ConcurrentLinkedQueue<>(); | ||
nicholsl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// we keep both so that we don't have to check size() on the ConcurrentLinkedQueue all the time | ||
AtomicInteger failedProbesInWindow = new AtomicInteger(); | ||
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. final? |
||
AtomicInteger successfulProbesInWindow = new AtomicInteger(); | ||
|
||
// Flag that the channel should be closed once all of the outstanding RPC complete. | ||
private final AtomicBoolean shutdownRequested = new AtomicBoolean(); | ||
// Flag that the channel has been closed. | ||
private final AtomicBoolean shutdownInitiated = new AtomicBoolean(); | ||
|
||
private Entry(ManagedChannel channel) { | ||
@VisibleForTesting | ||
Entry(ManagedChannel channel) { | ||
this.channel = channel; | ||
} | ||
|
||
ManagedChannel getManagedChannel() { | ||
return this.channel; | ||
} | ||
|
||
int getAndResetMaxOutstanding() { | ||
return maxOutstanding.getAndSet(outstandingRpcs.get()); | ||
} | ||
|
@@ -468,7 +486,7 @@ private boolean retain() { | |
// register desire to start RPC | ||
int currentOutstanding = outstandingRpcs.incrementAndGet(); | ||
|
||
// Rough book keeping | ||
// Rough bookkeeping | ||
int prevMax = maxOutstanding.get(); | ||
if (currentOutstanding > prevMax) { | ||
maxOutstanding.incrementAndGet(); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit