Skip to content

Commit 2a7f16d

Browse files
authored
impl(bigtable): adds the DynamicChannelPool class and implements some methods (#16039)
1 parent 5da2e08 commit 2a7f16d

File tree

7 files changed

+909
-3
lines changed

7 files changed

+909
-3
lines changed

ci/cloudbuild/dockerfiles/gcc-oldest.Dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ FROM opensuse/leap:15
1616
ARG NCPU=4
1717

1818
RUN zypper refresh && \
19-
zypper install --allow-downgrade -y automake cmake curl gcc gcc-c++ \
19+
zypper install --allow-downgrade -y automake cmake curl gcc9 gcc9-c++ \
2020
git gzip libtool make ninja patch tar wget \
2121
c-ares-devel libcurl-devel libopenssl-devel libcrc32c-devel
2222

@@ -25,6 +25,12 @@ RUN (echo "/usr/local/lib" ; echo "/usr/local/lib64") | \
2525
ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig
2626
ENV PATH=/usr/local/bin:${PATH}
2727

28+
ENV CXX=g++-9
29+
ENV CC=gcc-9
30+
31+
RUN ln -s /usr/bin/g++-9 /usr/local/bin/g++
32+
RUN ln -s /usr/bin/gcc-9 /usr/local/bin/gcc
33+
2834
WORKDIR /var/tmp/build
2935
RUN curl -fsSL https://github.com/abseil/abseil-cpp/archive/20250127.2.tar.gz | \
3036
tar -xzf - --strip-components=1 && \

google/cloud/bigtable/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ add_library(
184184
internal/default_row_reader.h
185185
internal/defaults.cc
186186
internal/defaults.h
187+
internal/dynamic_channel_pool.h
187188
internal/endpoint_options.h
188189
internal/google_bytes_traits.cc
189190
internal/google_bytes_traits.h
@@ -453,6 +454,7 @@ if (BUILD_TESTING)
453454
internal/data_tracing_connection_test.cc
454455
internal/default_row_reader_test.cc
455456
internal/defaults_test.cc
457+
internal/dynamic_channel_pool_test.cc
456458
internal/google_bytes_traits_test.cc
457459
internal/logging_result_set_reader_test.cc
458460
internal/metrics_test.cc

google/cloud/bigtable/bigtable_client_unit_tests.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ bigtable_client_unit_tests = [
5252
"internal/data_tracing_connection_test.cc",
5353
"internal/default_row_reader_test.cc",
5454
"internal/defaults_test.cc",
55+
"internal/dynamic_channel_pool_test.cc",
5556
"internal/google_bytes_traits_test.cc",
5657
"internal/logging_result_set_reader_test.cc",
5758
"internal/metrics_test.cc",

google/cloud/bigtable/google_cloud_cpp_bigtable.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ google_cloud_cpp_bigtable_hdrs = [
9090
"internal/data_tracing_connection.h",
9191
"internal/default_row_reader.h",
9292
"internal/defaults.h",
93+
"internal/dynamic_channel_pool.h",
9394
"internal/endpoint_options.h",
9495
"internal/google_bytes_traits.h",
9596
"internal/logging_result_set_reader.h",

google/cloud/bigtable/internal/channel_usage.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,23 @@ class ChannelUsage : public std::enable_shared_from_this<ChannelUsage<T>> {
4141
std::make_shared<Clock>())
4242
: stub_(std::move(stub)), clock_(std::move(clock)) {}
4343

44+
// This constructor is only used in testing.
45+
ChannelUsage(std::shared_ptr<T> stub, std::shared_ptr<Clock> clock,
46+
int initial_outstanding_rpcs)
47+
: stub_(std::move(stub)),
48+
clock_(std::move(clock)),
49+
outstanding_rpcs_(initial_outstanding_rpcs) {}
50+
4451
// Computes the weighted average of outstanding RPCs on the channel over the
4552
// past 60 seconds.
4653
StatusOr<int> average_outstanding_rpcs() {
4754
auto constexpr kWindowSeconds = 60;
4855
auto constexpr kWindowDuration = std::chrono::seconds(kWindowSeconds);
4956
std::scoped_lock lk(mu_);
5057
if (!last_refresh_status_.ok()) return last_refresh_status_;
51-
// If there are no measurements then the stub has never been used.
52-
if (measurements_.empty()) return 0;
58+
// If there are no measurements then the stub has never been used. In real
59+
// use this will be 0. In testing we sometimes set an initial value.
60+
if (measurements_.empty()) return outstanding_rpcs_;
5361
auto now = clock_->Now();
5462
auto last_time = now;
5563
auto window_start = now - kWindowDuration;

0 commit comments

Comments
 (0)