Skip to content

Commit f1a8e57

Browse files
authored
cleanup(bigtable)!: remove experimental InstanceChannelAffinityOption (#16213)
1 parent f7ad123 commit f1a8e57

7 files changed

Lines changed: 33 additions & 51 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ the APIs in these libraries are stable, and are ready for production use.
1818

1919
### [Bigtable](/google/cloud/bigtable/README.md)
2020

21-
- Explicit instance declaration is now encouraged during client initialization via a new overload of `MakeDataConnection` that takes a `std::vector<InstanceResource>`. Specifying the target instances at client startup enables optimizing connection pooling (pre-warming/priming channels) and telemetry.
21+
- Explicit instance declaration is now encouraged during client initialization via a new overload of `MakeDataConnection` that takes a `std::vector<InstanceResource>`. Specifying the target instances at client startup enables optimizing connection pooling (pre-warming/priming channels) and telemetry. The experimental `InstanceChannelAffinityOption` has been removed; the new `MakeDataConnection` overload should be used instead.
2222

2323
```cpp
2424
#include "google/cloud/bigtable/data_connection.h"

google/cloud/bigtable/data_connection.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ bigtable::RowStream DataConnection::ExecuteQuery(bigtable::ExecuteQueryParams) {
177177

178178
std::shared_ptr<DataConnection> MakeDataConnection(
179179
std::vector<InstanceResource> instances, Options options) {
180-
options.set<experimental::InstanceChannelAffinityOption>(
180+
options.set<bigtable_internal::InstanceChannelAffinityOption>(
181181
std::move(instances));
182182
return MakeDataConnection(std::move(options));
183183
}
@@ -196,7 +196,7 @@ std::shared_ptr<DataConnection> MakeDataConnection(Options options) {
196196
bigtable_internal::MakeMutateRowsLimiter(background->cq(), options);
197197
std::shared_ptr<DataConnection> conn;
198198

199-
if (options.has<experimental::InstanceChannelAffinityOption>()) {
199+
if (options.has<bigtable_internal::InstanceChannelAffinityOption>()) {
200200
auto stub_creation_fn =
201201
[auth, cq = background->cq(), options](
202202
std::string_view instance_name,
@@ -206,7 +206,7 @@ std::shared_ptr<DataConnection> MakeDataConnection(Options options) {
206206
};
207207

208208
auto affinity_stubs = bigtable_internal::CreateBigtableAffinityStubs(
209-
options.get<experimental::InstanceChannelAffinityOption>(),
209+
options.get<bigtable_internal::InstanceChannelAffinityOption>(),
210210
stub_creation_fn);
211211
conn = std::make_shared<bigtable_internal::DataConnectionImpl>(
212212
std::move(background),

google/cloud/bigtable/data_connection.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ class DataConnection {
175175
* pools to scale dynamically based on outstanding RPC load.
176176
*
177177
* The returned connection object should not be used directly; instead it
178-
* should be given to a `Table` instance, and methods should be invoked on
179-
* `Table`.
178+
* should be given to a `Table` or `Client` object, and methods should be
179+
* invoked there.
180180
*
181181
* The optional @p opts argument may be used to configure aspects of the
182182
* returned `DataConnection`. Expected options are any of the following options

google/cloud/bigtable/data_connection_test.cc

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "google/cloud/internal/disable_deprecation_warnings.inc"
1616
#include "google/cloud/bigtable/data_connection.h"
1717
#include "google/cloud/bigtable/internal/bigtable_stub_factory.h"
18+
#include "google/cloud/bigtable/internal/data_connection_impl.h"
1819
#include "google/cloud/bigtable/options.h"
1920
#include "google/cloud/common_options.h"
2021
#include "google/cloud/credentials.h"
@@ -73,24 +74,6 @@ TEST(MakeDataConnection, TracingEnabled) {
7374
Contains(SpanNamed("bigtable::Table::Apply")));
7475
}
7576

76-
TEST(MakeDataConnection, InstanceChannelAffinityOption) {
77-
InstanceResource instance_a{Project("my-project"), "instance-a"};
78-
InstanceResource instance_b{Project("my-project"), "instance-b"};
79-
auto conn =
80-
MakeDataConnection(TestOptions()
81-
.set<AppProfileIdOption>("user-supplied")
82-
.set<experimental::InstanceChannelAffinityOption>(
83-
{instance_a, instance_b}));
84-
auto options = conn->options();
85-
EXPECT_TRUE(options.has<DataBackoffPolicyOption>())
86-
<< "Options are not defaulted in MakeDataConnection()";
87-
EXPECT_EQ(options.get<AppProfileIdOption>(), "user-supplied")
88-
<< "User supplied Options are overridden in MakeDataConnection()";
89-
ASSERT_TRUE(options.has<experimental::InstanceChannelAffinityOption>());
90-
EXPECT_THAT(options.get<experimental::InstanceChannelAffinityOption>().size(),
91-
Eq(2));
92-
}
93-
9477
TEST(MakeDataConnection, TracingDisabled) {
9578
auto span_catcher = testing_util::InstallSpanCatcher();
9679

@@ -112,9 +95,10 @@ TEST(MakeDataConnection, WithInstances) {
11295
<< "Options are not defaulted in MakeDataConnection()";
11396
EXPECT_EQ(options.get<AppProfileIdOption>(), "user-supplied")
11497
<< "User supplied Options are overridden in MakeDataConnection()";
115-
ASSERT_TRUE(options.has<experimental::InstanceChannelAffinityOption>());
116-
EXPECT_THAT(options.get<experimental::InstanceChannelAffinityOption>().size(),
117-
Eq(2));
98+
ASSERT_TRUE(options.has<bigtable_internal::InstanceChannelAffinityOption>());
99+
EXPECT_THAT(
100+
options.get<bigtable_internal::InstanceChannelAffinityOption>().size(),
101+
Eq(2));
118102
}
119103

120104
} // namespace

google/cloud/bigtable/internal/data_connection_impl.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_INTERNAL_DATA_CONNECTION_IMPL_H
1717

1818
#include "google/cloud/bigtable/data_connection.h"
19+
#include "google/cloud/bigtable/instance_resource.h"
1920
#include "google/cloud/bigtable/internal/bigtable_stub.h"
2021
#include "google/cloud/bigtable/internal/mutate_rows_limiter.h"
2122
#include "google/cloud/bigtable/internal/operation_context_factory.h"
@@ -28,12 +29,19 @@
2829
#include "google/cloud/status_or.h"
2930
#include "google/cloud/version.h"
3031
#include <memory>
32+
#include <vector>
3133

3234
namespace google {
3335
namespace cloud {
3436
namespace bigtable_internal {
3537
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
3638

39+
// TODO(#16216): Remove this option in favor of addind a member variable to
40+
// store the instances.
41+
struct InstanceChannelAffinityOption {
42+
using Type = std::vector<bigtable::InstanceResource>;
43+
};
44+
3745
bigtable::Row TransformReadModifyWriteRowResponse(
3846
google::bigtable::v2::ReadModifyWriteRowResponse response);
3947

google/cloud/bigtable/options.h

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -177,24 +177,11 @@ struct QueryPlanRefreshFunctionRetryPolicyOption {
177177
};
178178

179179
/**
180-
* If set, a dynamic channel pool is created for each instance that requests
181-
* are destined. Instances specified as part of this Option have dynamic
182-
* channel pools created and primed as part of DataConnection construction. If
183-
* no Instances are specified, then dynamic channel pool creation is deferred
184-
* until the first request sent, increasing time to first byte latency.
185-
*
186-
* @note This option must be supplied to `MakeDataConnection()` in order to take
187-
* effect.
188-
*/
189-
struct InstanceChannelAffinityOption {
190-
using Type = std::vector<bigtable::InstanceResource>;
191-
};
192-
193-
/**
194-
* If the `InstanceChannelAffinityOption` is set, then all connections will be
195-
* managed by a Dynamic Channel Pool. The `DynamicChannelPoolSizingPolicy` can
196-
* be provided via the `DynamicChannelPoolSizingPolicyOption` and configures
197-
* the behavior of the `DynamicChannelPool`.
180+
* If `MakeDataConnection(std::vector<InstanceResource>, Options)` is called,
181+
* then all connections will be managed by a Dynamic Channel Pool. The
182+
* `DynamicChannelPoolSizingPolicy` can be provided via the
183+
* `experimental::DynamicChannelPoolSizingPolicyOption` and configures the
184+
* behavior of the `DynamicChannelPool`.
198185
*/
199186
struct DynamicChannelPoolSizingPolicy {
200187
// Removing unused channels is not as performance critical as adding channels
@@ -313,9 +300,10 @@ struct MetricsPeriodOption {
313300
};
314301

315302
using DataPolicyOptionList =
316-
OptionList<DataRetryPolicyOption, DataBackoffPolicyOption,
303+
OptionList<DataRetryPolicyOption, DataBackoffPolicyOption, DeadlineOption,
317304
IdempotentMutationPolicyOption, EnableMetricsOption,
318-
MetricsPeriodOption>;
305+
MetricsPeriodOption,
306+
experimental::DynamicChannelPoolSizingPolicyOption>;
319307

320308
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
321309
} // namespace bigtable

google/cloud/bigtable/testing/table_integration_test.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
#include "google/cloud/internal/disable_deprecation_warnings.inc"
1516
#include "google/cloud/bigtable/testing/table_integration_test.h"
1617
#include "google/cloud/bigtable/resource_names.h"
1718
#include "google/cloud/bigtable/testing/random_names.h"
@@ -126,11 +127,12 @@ void TableIntegrationTest::SetUp() {
126127
if (google::cloud::internal::GetEnv(
127128
"GOOGLE_CLOUD_CPP_BIGTABLE_TESTING_CHANNEL_POOL")
128129
.value_or("") == "dynamic") {
129-
options.set<experimental::InstanceChannelAffinityOption>({});
130+
data_connection_ = MakeDataConnection(
131+
{InstanceResource(Project(project_id()), instance_id())},
132+
std::move(options));
133+
} else {
134+
data_connection_ = MakeDataConnection(std::move(options));
130135
}
131-
data_connection_ = MakeDataConnection(
132-
{InstanceResource(Project(project_id()), instance_id())},
133-
std::move(options));
134136

135137
// In production, we cannot use `DropAllRows()` to cleanup the table because
136138
// the integration tests sometimes consume all the 'DropRowRangeGroup' quota.

0 commit comments

Comments
 (0)