Skip to content
This repository was archived by the owner on May 8, 2026. It is now read-only.

Commit beda46e

Browse files
committed
pr feedback
Change-Id: Ie0fde53cd17b1feeaaffd15382e936a46d84c5c1
1 parent 7a007bf commit beda46e

4 files changed

Lines changed: 17 additions & 15 deletions

File tree

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/NoOpChannelPrimer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ static NoOpChannelPrimer create() {
3030
private NoOpChannelPrimer() {}
3131

3232
@Override
33-
public void primeChannel(ManagedChannel managedChannel) {
33+
public void primeChannel(ManagedChannel channel) {
3434
// No op
3535
}
3636

3737
@Override
38-
public SettableApiFuture<PingAndWarmResponse> sendPrimeRequestsAsync(ManagedChannel var1) {
38+
public SettableApiFuture<PingAndWarmResponse> sendPrimeRequestsAsync(ManagedChannel channel) {
3939
SettableApiFuture future = SettableApiFuture.create();
4040
future.set(PingAndWarmResponse.getDefaultInstance());
4141
return future;

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/gaxx/grpc/BigtableChannelPool.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -451,14 +451,19 @@ static class Entry {
451451

452452
private final AtomicInteger maxOutstanding = new AtomicInteger();
453453

454+
/**
455+
* Queue storing the last 5 minutes of probe results
456+
*/
454457
@VisibleForTesting
455458
final ConcurrentLinkedQueue<ProbeResult> probeHistory = new ConcurrentLinkedQueue<>();
456459

457-
// we keep both so that we don't have to check size() on the ConcurrentLinkedQueue all the time
458-
AtomicInteger failedProbesInWindow = new AtomicInteger();
459-
AtomicInteger successfulProbesInWindow = new AtomicInteger();
460+
/**
461+
* Keep both # of failed and # of successful probes so that we don't have to check size() on the ConcurrentLinkedQueue all the time
462+
*/
463+
final AtomicInteger failedProbesInWindow = new AtomicInteger();
464+
final AtomicInteger successfulProbesInWindow = new AtomicInteger();
460465

461-
// Flag that the channel should be closed once all of the outstanding RPC complete.
466+
// Flag that the channel should be closed once all the outstanding RPCs complete.
462467
private final AtomicBoolean shutdownRequested = new AtomicBoolean();
463468
// Flag that the channel has been closed.
464469
private final AtomicBoolean shutdownInitiated = new AtomicBoolean();

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/gaxx/grpc/ChannelPoolHealthChecker.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@
3636
import javax.annotation.Nullable;
3737

3838
/** Class that manages the health checking in the BigtableChannelPool */
39-
public class ChannelPoolHealthChecker {
39+
class ChannelPoolHealthChecker {
4040

4141
// Configuration constants
4242
// Window_Duration is the duration over which we keep probe results
4343
private static final Duration WINDOW_DURATION = Duration.ofMinutes(5);
4444
// Interval at which we probe channel health
45-
static final Duration PROBE_INTERVAL = Duration.ofSeconds(30);
45+
private static final Duration PROBE_INTERVAL = Duration.ofSeconds(30);
4646
// Timeout deadline for a probe
4747
@VisibleForTesting static final Duration PROBE_DEADLINE = Duration.ofMillis(500);
4848
// Minimum interval between new idle channel evictions
@@ -121,9 +121,6 @@ void runProbes() {
121121
if (channelPrimer instanceof BigtableChannelPrimer) {
122122
BigtableChannelPrimer primer = (BigtableChannelPrimer) channelPrimer;
123123
probeFuture = primer.sendPrimeRequestsAsync(entry.getManagedChannel());
124-
} else if (channelPrimer instanceof NoOpChannelPrimer) {
125-
NoOpChannelPrimer primer = (NoOpChannelPrimer) channelPrimer;
126-
probeFuture = primer.sendPrimeRequestsAsync(entry.getManagedChannel());
127124
} else {
128125
continue;
129126
}
@@ -156,7 +153,7 @@ void addProbeResult(Entry entry, ProbeResult result) {
156153
}
157154

158155
@VisibleForTesting
159-
void pruneHistoryFor(Entry entry) {
156+
void pruneHistory(Entry entry) {
160157
Instant windowStart = clock.instant().minus(WINDOW_DURATION);
161158
while (!entry.probeHistory.isEmpty()
162159
&& entry.probeHistory.peek().startTime().isBefore(windowStart)) {
@@ -186,14 +183,14 @@ boolean isEntryHealthy(Entry entry) {
186183
/**
187184
* Finds a channel that is an outlier in terms of health.
188185
*
189-
* @return Entry
186+
* @return the entry to be evicted. Returns null if nothing to evict.
190187
*/
191188
@Nullable
192189
@VisibleForTesting
193190
Entry findOutlierEntry() {
194191
List<Entry> unhealthyEntries =
195192
this.entrySupplier.get().stream()
196-
.peek(this::pruneHistoryFor)
193+
.peek(this::pruneHistory)
197194
.filter(entry -> !isEntryHealthy(entry))
198195
.collect(Collectors.toList());
199196

google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/gaxx/grpc/ChannelPoolHealthCheckerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public void testPruning_removesOldProbesAndCounters() {
118118

119119
Instant newTime = mockClock.instant().plus(Duration.ofMinutes(6));
120120
Mockito.when(mockClock.instant()).thenReturn(newTime);
121-
healthChecker.pruneHistoryFor(entry); // Manually call for direct testing
121+
healthChecker.pruneHistory(entry); // Manually call for direct testing
122122

123123
assertThat(entry.probeHistory).isEmpty();
124124
assertThat(entry.failedProbesInWindow.get()).isEqualTo(0);

0 commit comments

Comments
 (0)