@@ -34,55 +34,6 @@ namespace cloud {
3434namespace bigtable_internal {
3535GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
3636
37- // TODO(#16035): Move this struct and Option to bigtable/options.h in the
38- // experimental namespace when the feature is ready.
39- struct DynamicChannelPoolSizingPolicy {
40- // To reduce channel churn, the pool will not add channels more frequently
41- // than this period.
42- std::chrono::milliseconds pool_size_increase_cooldown_interval =
43- std::chrono::seconds (10 );
44-
45- // Removing unused channels is not as performance critical as adding channels
46- // to handle a surge in RPC calls. Thus, there are separate cooldown settings
47- // for each.
48- std::chrono::milliseconds pool_size_decrease_cooldown_interval =
49- std::chrono::seconds (120 );
50-
51- struct DiscreteChannels {
52- explicit DiscreteChannels (int number = 0 ) : number(number) {}
53- int number;
54- };
55- struct PercentageOfPoolSize {
56- explicit PercentageOfPoolSize (double percentage = 0.0 )
57- : percentage(percentage) {}
58- double percentage;
59- };
60- absl::variant<DiscreteChannels, PercentageOfPoolSize>
61- channels_to_add_per_resize = DiscreteChannels{1 };
62-
63- // If the average number of outstanding RPCs is below this threshold,
64- // the pool size will be decreased.
65- int minimum_average_outstanding_rpcs_per_channel = 1 ;
66- // If the average number of outstanding RPCs is above this threshold,
67- // the pool size will be increased.
68- int maximum_average_outstanding_rpcs_per_channel = 25 ;
69-
70- // When channels are removed from the pool, we have to wait until all
71- // outstanding RPCs on that channel are completed before destroying it.
72- std::chrono::milliseconds remove_channel_polling_interval =
73- std::chrono::seconds (30 );
74-
75- // Limits how large the pool can grow. Default is twice the minimum_pool_size.
76- std::size_t maximum_channel_pool_size = 0 ;
77-
78- // This is set to the value of GrpcNumChannelsOption.
79- std::size_t minimum_channel_pool_size = 0 ;
80- };
81-
82- struct DynamicChannelPoolSizingPolicyOption {
83- using Type = DynamicChannelPoolSizingPolicy;
84- };
85-
8637//
8738// This class manages a pool of Stubs wrapped in a ChannelUsage object, and
8839// selects one for use using a "Random Two Least Used" strategy.
@@ -107,7 +58,8 @@ class DynamicChannelPool
10758 std::vector<std::shared_ptr<ChannelUsage<T>>> initial_channels,
10859 std::shared_ptr<ConnectionRefreshState> refresh_state,
10960 StubFactoryFn stub_factory_fn,
110- DynamicChannelPoolSizingPolicy sizing_policy = {}) {
61+ bigtable::experimental::DynamicChannelPoolSizingPolicy sizing_policy =
62+ {}) {
11163 auto pool = std::shared_ptr<DynamicChannelPool>(new DynamicChannelPool (
11264 std::move (instance_name), std::move (cq), std::move (initial_channels),
11365 std::move (refresh_state), std::move (stub_factory_fn),
@@ -207,7 +159,7 @@ class DynamicChannelPool
207159 std::vector<std::shared_ptr<ChannelUsage<T>>> initial_wrapped_channels,
208160 std::shared_ptr<ConnectionRefreshState> refresh_state,
209161 StubFactoryFn stub_factory_fn,
210- DynamicChannelPoolSizingPolicy sizing_policy)
162+ bigtable::experimental:: DynamicChannelPoolSizingPolicy sizing_policy)
211163 : instance_name_(std::move(instance_name)),
212164 cq_ (std::move(cq)),
213165 refresh_state_(std::move(refresh_state)),
@@ -293,13 +245,13 @@ class DynamicChannelPool
293245 std::size_t pool_size;
294246 explicit ChannelAddVisitor (std::size_t pool_size) : pool_size(pool_size) {}
295247 std::size_t operator ()(
296- typename DynamicChannelPoolSizingPolicy::DiscreteChannels const & c)
297- const {
248+ typename bigtable::experimental:: DynamicChannelPoolSizingPolicy::
249+ DiscreteChannels const & c) const {
298250 return c.number ;
299251 }
300252 std::size_t operator ()(
301- typename DynamicChannelPoolSizingPolicy::PercentageOfPoolSize const & c)
302- const {
253+ typename bigtable::experimental:: DynamicChannelPoolSizingPolicy::
254+ PercentageOfPoolSize const & c) const {
303255 return static_cast <std::size_t >(
304256 std::floor (static_cast <double >(pool_size) * c.percentage ));
305257 }
@@ -487,7 +439,7 @@ class DynamicChannelPool
487439 StubFactoryFn stub_factory_fn_;
488440 std::vector<std::shared_ptr<ChannelUsage<T>>> channels_;
489441 std::size_t num_pending_channels_ = 0 ;
490- DynamicChannelPoolSizingPolicy sizing_policy_;
442+ bigtable::experimental:: DynamicChannelPoolSizingPolicy sizing_policy_;
491443 std::vector<std::shared_ptr<ChannelUsage<T>>> draining_channels_;
492444 future<void > remove_channel_poll_timer_;
493445 future<StatusOr<std::chrono::system_clock::time_point>>
0 commit comments