Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion generator/generator_config.textproto
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ service {
omit_client: true
omit_connection: true
omit_stub_factory: true
generate_round_robin_decorator: true
generate_round_robin_decorator: false
experimental_bigtable_operation_context: true
omitted_rpcs: [
"GenerateInitialChangeStreamPartitions",
Expand Down
6 changes: 4 additions & 2 deletions google/cloud/bigtable/internal/async_bulk_apply_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ class MockMetric : public Metric {
ElementDeliveryParams const&),
(override));
MOCK_METHOD(std::unique_ptr<Metric>, clone,
(ResourceLabels resource_labels, DataLabels data_labels),
(TableResourceLabels const& resource_labels,
TableDataLabels const& data_labels),
(const, override));
};

Expand All @@ -172,7 +173,8 @@ class CloningMetric : public Metric {
public:
explicit CloningMetric(std::unique_ptr<MockMetric> metric)
: metric_(std::move(metric)) {}
std::unique_ptr<Metric> clone(ResourceLabels, DataLabels) const override {
std::unique_ptr<Metric> clone(TableResourceLabels const&,
TableDataLabels const&) const override {
return std::move(metric_);
}

Expand Down
7 changes: 5 additions & 2 deletions google/cloud/bigtable/internal/async_row_reader_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

#include "google/cloud/bigtable/internal/async_row_reader.h"
#include "google/cloud/bigtable/internal/operation_context.h"
#include "google/cloud/bigtable/row_reader.h"
#include "google/cloud/bigtable/testing/mock_bigtable_stub.h"
#include "google/cloud/internal/async_streaming_read_rpc_impl.h"
Expand Down Expand Up @@ -115,7 +116,8 @@ class MockMetric : public Metric {
ElementDeliveryParams const&),
(override));
MOCK_METHOD(std::unique_ptr<Metric>, clone,
(ResourceLabels resource_labels, DataLabels data_labels),
(TableResourceLabels const& resource_labels,
TableDataLabels const& data_labels),
(const, override));
};

Expand All @@ -124,7 +126,8 @@ class CloningMetric : public Metric {
public:
explicit CloningMetric(std::unique_ptr<MockMetric> metric)
: metric_(std::move(metric)) {}
std::unique_ptr<Metric> clone(ResourceLabels, DataLabels) const override {
std::unique_ptr<Metric> clone(TableResourceLabels const&,
TableDataLabels const&) const override {
return std::move(metric_);
}

Expand Down
7 changes: 5 additions & 2 deletions google/cloud/bigtable/internal/async_row_sampler_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

#include "google/cloud/bigtable/internal/async_row_sampler.h"
#include "google/cloud/bigtable/internal/operation_context.h"
#include "google/cloud/bigtable/testing/mock_bigtable_stub.h"
#include "google/cloud/grpc_options.h"
#include "google/cloud/internal/async_streaming_read_rpc_impl.h"
Expand Down Expand Up @@ -103,7 +104,8 @@ class MockMetric : public Metric {
ElementDeliveryParams const&),
(override));
MOCK_METHOD(std::unique_ptr<Metric>, clone,
(ResourceLabels resource_labels, DataLabels data_labels),
(TableResourceLabels const& resource_labels,
TableDataLabels const& data_labels),
(const, override));
};

Expand All @@ -112,7 +114,8 @@ class CloningMetric : public Metric {
public:
explicit CloningMetric(std::unique_ptr<MockMetric> metric)
: metric_(std::move(metric)) {}
std::unique_ptr<Metric> clone(ResourceLabels, DataLabels) const override {
std::unique_ptr<Metric> clone(TableResourceLabels const&,
TableDataLabels const&) const override {
return std::move(metric_);
}

Expand Down

Large diffs are not rendered by default.

114 changes: 69 additions & 45 deletions google/cloud/bigtable/internal/bigtable_round_robin_decorator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// Generated by the Codegen C++ plugin.
// If you make any local changes, they will be lost.
// source: google/bigtable/v2/bigtable.proto

#include "google/cloud/bigtable/internal/bigtable_round_robin_decorator.h"
#include "google/cloud/bigtable/internal/defaults.h"
#include "google/cloud/bigtable/internal/metrics.h"
#include "google/cloud/bigtable/internal/operation_context.h"
#include <memory>
#include <mutex>
#include <vector>
Expand All @@ -40,8 +39,9 @@ BigtableRoundRobin::ReadRows(
google::bigtable::v2::ReadRowsRequest const& request,
std::shared_ptr<google::cloud::bigtable_internal::OperationContext>
operation_context) {
return Child()->ReadRows(std::move(context), options, request,
std::move(operation_context));
return Child(*operation_context, RpcType::kStreaming)
->ReadRows(std::move(context), options, request,
std::move(operation_context));
}

std::unique_ptr<google::cloud::internal::StreamingReadRpc<
Expand All @@ -51,15 +51,17 @@ BigtableRoundRobin::SampleRowKeys(
google::bigtable::v2::SampleRowKeysRequest const& request,
std::shared_ptr<google::cloud::bigtable_internal::OperationContext>
operation_context) {
return Child()->SampleRowKeys(std::move(context), options, request,
std::move(operation_context));
return Child(*operation_context, RpcType::kStreaming)
->SampleRowKeys(std::move(context), options, request,
std::move(operation_context));
}

StatusOr<google::bigtable::v2::MutateRowResponse> BigtableRoundRobin::MutateRow(
grpc::ClientContext& context, Options const& options,
google::bigtable::v2::MutateRowRequest const& request,
google::cloud::bigtable_internal::OperationContext& operation_context) {
return Child()->MutateRow(context, options, request, operation_context);
return Child(operation_context, RpcType::kUnary)
->MutateRow(context, options, request, operation_context);
}

std::unique_ptr<google::cloud::internal::StreamingReadRpc<
Expand All @@ -69,42 +71,45 @@ BigtableRoundRobin::MutateRows(
google::bigtable::v2::MutateRowsRequest const& request,
std::shared_ptr<google::cloud::bigtable_internal::OperationContext>
operation_context) {
return Child()->MutateRows(std::move(context), options, request,
std::move(operation_context));
return Child(*operation_context, RpcType::kStreaming)
->MutateRows(std::move(context), options, request,
std::move(operation_context));
}

StatusOr<google::bigtable::v2::CheckAndMutateRowResponse>
BigtableRoundRobin::CheckAndMutateRow(
grpc::ClientContext& context, Options const& options,
google::bigtable::v2::CheckAndMutateRowRequest const& request,
google::cloud::bigtable_internal::OperationContext& operation_context) {
return Child()->CheckAndMutateRow(context, options, request,
operation_context);
return Child(operation_context, RpcType::kUnary)
->CheckAndMutateRow(context, options, request, operation_context);
}

StatusOr<google::bigtable::v2::PingAndWarmResponse>
BigtableRoundRobin::PingAndWarm(
grpc::ClientContext& context, Options const& options,
google::bigtable::v2::PingAndWarmRequest const& request,
google::cloud::bigtable_internal::OperationContext& operation_context) {
return Child()->PingAndWarm(context, options, request, operation_context);
return Child(operation_context, RpcType::kUnary)
->PingAndWarm(context, options, request, operation_context);
}

StatusOr<google::bigtable::v2::ReadModifyWriteRowResponse>
BigtableRoundRobin::ReadModifyWriteRow(
grpc::ClientContext& context, Options const& options,
google::bigtable::v2::ReadModifyWriteRowRequest const& request,
google::cloud::bigtable_internal::OperationContext& operation_context) {
return Child()->ReadModifyWriteRow(context, options, request,
operation_context);
return Child(operation_context, RpcType::kUnary)
->ReadModifyWriteRow(context, options, request, operation_context);
}

StatusOr<google::bigtable::v2::PrepareQueryResponse>
BigtableRoundRobin::PrepareQuery(
grpc::ClientContext& context, Options const& options,
google::bigtable::v2::PrepareQueryRequest const& request,
google::cloud::bigtable_internal::OperationContext& operation_context) {
return Child()->PrepareQuery(context, options, request, operation_context);
return Child(operation_context, RpcType::kUnary)
->PrepareQuery(context, options, request, operation_context);
}

std::unique_ptr<google::cloud::internal::StreamingReadRpc<
Expand All @@ -114,17 +119,18 @@ BigtableRoundRobin::ExecuteQuery(
google::bigtable::v2::ExecuteQueryRequest const& request,
std::shared_ptr<google::cloud::bigtable_internal::OperationContext>
operation_context) {
return Child()->ExecuteQuery(std::move(context), options, request,
std::move(operation_context));
return Child(*operation_context, RpcType::kStreaming)
->ExecuteQuery(std::move(context), options, request,
std::move(operation_context));
}

StatusOr<google::bigtable::v2::ClientConfiguration>
BigtableRoundRobin::GetClientConfiguration(
grpc::ClientContext& context, Options const& options,
google::bigtable::v2::GetClientConfigurationRequest const& request,
google::cloud::bigtable_internal::OperationContext& operation_context) {
return Child()->GetClientConfiguration(context, options, request,
operation_context);
return Child(operation_context, RpcType::kUnary)
->GetClientConfiguration(context, options, request, operation_context);
}

std::unique_ptr<google::cloud::AsyncStreamingReadWriteRpc<
Expand All @@ -136,8 +142,9 @@ BigtableRoundRobin::AsyncOpenTable(
google::cloud::internal::ImmutableOptions options,
std::shared_ptr<google::cloud::bigtable_internal::OperationContext>
operation_context) {
return Child()->AsyncOpenTable(cq, std::move(context), std::move(options),
std::move(operation_context));
return Child(*operation_context, RpcType::kStreaming)
->AsyncOpenTable(cq, std::move(context), std::move(options),
std::move(operation_context));
}

std::unique_ptr<google::cloud::AsyncStreamingReadWriteRpc<
Expand All @@ -149,8 +156,9 @@ BigtableRoundRobin::AsyncOpenAuthorizedView(
google::cloud::internal::ImmutableOptions options,
std::shared_ptr<google::cloud::bigtable_internal::OperationContext>
operation_context) {
return Child()->AsyncOpenAuthorizedView(
cq, std::move(context), std::move(options), std::move(operation_context));
return Child(*operation_context, RpcType::kStreaming)
->AsyncOpenAuthorizedView(cq, std::move(context), std::move(options),
std::move(operation_context));
}

std::unique_ptr<google::cloud::AsyncStreamingReadWriteRpc<
Expand All @@ -162,8 +170,9 @@ BigtableRoundRobin::AsyncOpenMaterializedView(
google::cloud::internal::ImmutableOptions options,
std::shared_ptr<google::cloud::bigtable_internal::OperationContext>
operation_context) {
return Child()->AsyncOpenMaterializedView(
cq, std::move(context), std::move(options), std::move(operation_context));
return Child(*operation_context, RpcType::kStreaming)
->AsyncOpenMaterializedView(cq, std::move(context), std::move(options),
std::move(operation_context));
}

std::unique_ptr<google::cloud::internal::AsyncStreamingReadRpc<
Expand All @@ -175,8 +184,9 @@ BigtableRoundRobin::AsyncReadRows(
google::bigtable::v2::ReadRowsRequest const& request,
std::shared_ptr<google::cloud::bigtable_internal::OperationContext>
operation_context) {
return Child()->AsyncReadRows(cq, std::move(context), std::move(options),
request, std::move(operation_context));
return Child(*operation_context, RpcType::kStreaming)
->AsyncReadRows(cq, std::move(context), std::move(options), request,
std::move(operation_context));
}

std::unique_ptr<google::cloud::internal::AsyncStreamingReadRpc<
Expand All @@ -188,8 +198,9 @@ BigtableRoundRobin::AsyncSampleRowKeys(
google::bigtable::v2::SampleRowKeysRequest const& request,
std::shared_ptr<google::cloud::bigtable_internal::OperationContext>
operation_context) {
return Child()->AsyncSampleRowKeys(cq, std::move(context), std::move(options),
request, std::move(operation_context));
return Child(*operation_context, RpcType::kStreaming)
->AsyncSampleRowKeys(cq, std::move(context), std::move(options), request,
std::move(operation_context));
}

future<StatusOr<google::bigtable::v2::MutateRowResponse>>
Expand All @@ -200,8 +211,9 @@ BigtableRoundRobin::AsyncMutateRow(
google::bigtable::v2::MutateRowRequest const& request,
std::shared_ptr<google::cloud::bigtable_internal::OperationContext>
operation_context) {
return Child()->AsyncMutateRow(cq, std::move(context), std::move(options),
request, std::move(operation_context));
return Child(*operation_context, RpcType::kUnary)
->AsyncMutateRow(cq, std::move(context), std::move(options), request,
std::move(operation_context));
}

std::unique_ptr<google::cloud::internal::AsyncStreamingReadRpc<
Expand All @@ -213,8 +225,9 @@ BigtableRoundRobin::AsyncMutateRows(
google::bigtable::v2::MutateRowsRequest const& request,
std::shared_ptr<google::cloud::bigtable_internal::OperationContext>
operation_context) {
return Child()->AsyncMutateRows(cq, std::move(context), std::move(options),
request, std::move(operation_context));
return Child(*operation_context, RpcType::kStreaming)
->AsyncMutateRows(cq, std::move(context), std::move(options), request,
std::move(operation_context));
}

future<StatusOr<google::bigtable::v2::CheckAndMutateRowResponse>>
Expand All @@ -225,9 +238,9 @@ BigtableRoundRobin::AsyncCheckAndMutateRow(
google::bigtable::v2::CheckAndMutateRowRequest const& request,
std::shared_ptr<google::cloud::bigtable_internal::OperationContext>
operation_context) {
return Child()->AsyncCheckAndMutateRow(cq, std::move(context),
std::move(options), request,
std::move(operation_context));
return Child(*operation_context, RpcType::kUnary)
->AsyncCheckAndMutateRow(cq, std::move(context), std::move(options),
request, std::move(operation_context));
}

future<StatusOr<google::bigtable::v2::PingAndWarmResponse>>
Expand All @@ -238,8 +251,9 @@ BigtableRoundRobin::AsyncPingAndWarm(
google::bigtable::v2::PingAndWarmRequest const& request,
std::shared_ptr<google::cloud::bigtable_internal::OperationContext>
operation_context) {
return Child()->AsyncPingAndWarm(cq, std::move(context), std::move(options),
request, std::move(operation_context));
return Child(*operation_context, RpcType::kUnary)
->AsyncPingAndWarm(cq, std::move(context), std::move(options), request,
std::move(operation_context));
}

future<StatusOr<google::bigtable::v2::ReadModifyWriteRowResponse>>
Expand All @@ -250,9 +264,9 @@ BigtableRoundRobin::AsyncReadModifyWriteRow(
google::bigtable::v2::ReadModifyWriteRowRequest const& request,
std::shared_ptr<google::cloud::bigtable_internal::OperationContext>
operation_context) {
return Child()->AsyncReadModifyWriteRow(cq, std::move(context),
std::move(options), request,
std::move(operation_context));
return Child(*operation_context, RpcType::kUnary)
->AsyncReadModifyWriteRow(cq, std::move(context), std::move(options),
request, std::move(operation_context));
}

future<StatusOr<google::bigtable::v2::PrepareQueryResponse>>
Expand All @@ -263,8 +277,9 @@ BigtableRoundRobin::AsyncPrepareQuery(
google::bigtable::v2::PrepareQueryRequest const& request,
std::shared_ptr<google::cloud::bigtable_internal::OperationContext>
operation_context) {
return Child()->AsyncPrepareQuery(cq, std::move(context), std::move(options),
request, std::move(operation_context));
return Child(*operation_context, RpcType::kUnary)
->AsyncPrepareQuery(cq, std::move(context), std::move(options), request,
std::move(operation_context));
}

std::shared_ptr<BigtableStub> BigtableRoundRobin::Child() {
Expand All @@ -275,6 +290,15 @@ std::shared_ptr<BigtableStub> BigtableRoundRobin::Child() {
return children_[current];
}

std::shared_ptr<BigtableStub> BigtableRoundRobin::Child(OperationContext& oc,
RpcType rpc_type) {
// TODO(sdhart): correctly determine transport
auto transport = TransportType::kCloudPath;
oc.StubSelection(StubSelectionParams{0, ChannelPoolLbPolicy::kRoundRobin,
transport, rpc_type});
return Child();
}

GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
} // namespace bigtable_internal
} // namespace cloud
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// Generated by the Codegen C++ plugin.
// If you make any local changes, they will be lost.
// source: google/bigtable/v2/bigtable.proto

#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_INTERNAL_BIGTABLE_ROUND_ROBIN_DECORATOR_H
#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_INTERNAL_BIGTABLE_ROUND_ROBIN_DECORATOR_H

#include "google/cloud/bigtable/internal/bigtable_stub.h"
#include "google/cloud/bigtable/internal/metrics.h"
#include "google/cloud/version.h"
#include <memory>
#include <mutex>
Expand Down Expand Up @@ -211,6 +208,7 @@ class BigtableRoundRobin : public BigtableStub {

private:
std::shared_ptr<BigtableStub> Child();
std::shared_ptr<BigtableStub> Child(OperationContext& oc, RpcType rpc_type);

std::vector<std::shared_ptr<BigtableStub>> const children_;
std::mutex mu_;
Expand Down
5 changes: 4 additions & 1 deletion google/cloud/bigtable/internal/bigtable_stub_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,10 @@ std::shared_ptr<BigtableStub> CreateBigtableStubRandomTwoLeastUsed(
std::move(children), std::move(refresh_state),
std::move(refreshing_channel_stub_factory),
options.get<
bigtable::experimental::DynamicChannelPoolSizingPolicyOption>()));
bigtable::experimental::DynamicChannelPoolSizingPolicyOption>(),
bigtable::internal::IsDirectPath(options)
? TransportType::kDirectPath
: TransportType::kCloudPath));
}

std::shared_ptr<BigtableStub> CreateDecoratedStubs(
Expand Down
Loading
Loading