Skip to content

Commit 0809c6a

Browse files
feat: Add support for Cloud Bigtable Node Scaling Factor for CBT Clusters (#1023)
* feat: Add support for Cloud Bigtable Row Affinity in App Profiles PiperOrigin-RevId: 673093969 Source-Link: googleapis/googleapis@cbf696d Source-Link: googleapis/googleapis-gen@a2f7ec1 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYTJmN2VjMTE5MTgxMzMwNGIzYmQwMDk3Y2FhMzM5NTZiZGIzYjYzNyJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * feat: Add support for Cloud Bigtable Node Scaling Factor for CBT Clusters PiperOrigin-RevId: 676993928 Source-Link: googleapis/googleapis@407deca Source-Link: googleapis/googleapis-gen@4fae779 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNGZhZTc3OTIwZGEwZjQ1MDNiYmY1ZjNjZTM0ZmMwN2JjZDZkM2Q5YSJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 049d45a commit 0809c6a

File tree

3 files changed

+82
-3
lines changed

3 files changed

+82
-3
lines changed

google/cloud/bigtable_admin_v2/types/instance.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,9 @@ class Cluster(proto.Message):
237237
The number of nodes allocated to this
238238
cluster. More nodes enable higher throughput and
239239
more consistent performance.
240+
node_scaling_factor (google.cloud.bigtable_admin_v2.types.Cluster.NodeScalingFactor):
241+
Immutable. The node scaling factor of this
242+
cluster.
240243
cluster_config (google.cloud.bigtable_admin_v2.types.Cluster.ClusterConfig):
241244
Configuration for this cluster.
242245
@@ -284,6 +287,28 @@ class State(proto.Enum):
284287
RESIZING = 3
285288
DISABLED = 4
286289

290+
class NodeScalingFactor(proto.Enum):
291+
r"""Possible node scaling factors of the clusters. Node scaling
292+
delivers better latency and more throughput by removing node
293+
boundaries.
294+
295+
Values:
296+
NODE_SCALING_FACTOR_UNSPECIFIED (0):
297+
No node scaling specified. Defaults to
298+
NODE_SCALING_FACTOR_1X.
299+
NODE_SCALING_FACTOR_1X (1):
300+
The cluster is running with a scaling factor
301+
of 1.
302+
NODE_SCALING_FACTOR_2X (2):
303+
The cluster is running with a scaling factor of 2. All node
304+
count values must be in increments of 2 with this scaling
305+
factor enabled, otherwise an INVALID_ARGUMENT error will be
306+
returned.
307+
"""
308+
NODE_SCALING_FACTOR_UNSPECIFIED = 0
309+
NODE_SCALING_FACTOR_1X = 1
310+
NODE_SCALING_FACTOR_2X = 2
311+
287312
class ClusterAutoscalingConfig(proto.Message):
288313
r"""Autoscaling config for a cluster.
289314
@@ -364,6 +389,11 @@ class EncryptionConfig(proto.Message):
364389
proto.INT32,
365390
number=4,
366391
)
392+
node_scaling_factor: NodeScalingFactor = proto.Field(
393+
proto.ENUM,
394+
number=9,
395+
enum=NodeScalingFactor,
396+
)
367397
cluster_config: ClusterConfig = proto.Field(
368398
proto.MESSAGE,
369399
number=7,
@@ -468,18 +498,47 @@ class MultiClusterRoutingUseAny(proto.Message):
468498
in a region are considered equidistant. Choosing this option
469499
sacrifices read-your-writes consistency to improve availability.
470500
501+
502+
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
503+
471504
Attributes:
472505
cluster_ids (MutableSequence[str]):
473506
The set of clusters to route to. The order is
474507
ignored; clusters will be tried in order of
475508
distance. If left empty, all clusters are
476509
eligible.
510+
row_affinity (google.cloud.bigtable_admin_v2.types.AppProfile.MultiClusterRoutingUseAny.RowAffinity):
511+
Row affinity sticky routing based on the row
512+
key of the request. Requests that span multiple
513+
rows are routed non-deterministically.
514+
515+
This field is a member of `oneof`_ ``affinity``.
477516
"""
478517

518+
class RowAffinity(proto.Message):
519+
r"""If enabled, Bigtable will route the request based on the row
520+
key of the request, rather than randomly. Instead, each row key
521+
will be assigned to a cluster, and will stick to that cluster.
522+
If clusters are added or removed, then this may affect which row
523+
keys stick to which clusters. To avoid this, users can use a
524+
cluster group to specify which clusters are to be used. In this
525+
case, new clusters that are not a part of the cluster group will
526+
not be routed to, and routing will be unaffected by the new
527+
cluster. Moreover, clusters specified in the cluster group
528+
cannot be deleted unless removed from the cluster group.
529+
530+
"""
531+
479532
cluster_ids: MutableSequence[str] = proto.RepeatedField(
480533
proto.STRING,
481534
number=1,
482535
)
536+
row_affinity: "AppProfile.MultiClusterRoutingUseAny.RowAffinity" = proto.Field(
537+
proto.MESSAGE,
538+
number=3,
539+
oneof="affinity",
540+
message="AppProfile.MultiClusterRoutingUseAny.RowAffinity",
541+
)
483542

484543
class SingleClusterRouting(proto.Message):
485544
r"""Unconditionally routes all read/write requests to a specific

scripts/fixup_bigtable_admin_v2_keywords.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class bigtable_adminCallTransformer(cst.CSTTransformer):
8484
'update_app_profile': ('app_profile', 'update_mask', 'ignore_warnings', ),
8585
'update_authorized_view': ('authorized_view', 'update_mask', 'ignore_warnings', ),
8686
'update_backup': ('backup', 'update_mask', ),
87-
'update_cluster': ('name', 'location', 'state', 'serve_nodes', 'cluster_config', 'default_storage_type', 'encryption_config', ),
87+
'update_cluster': ('name', 'location', 'state', 'serve_nodes', 'node_scaling_factor', 'cluster_config', 'default_storage_type', 'encryption_config', ),
8888
'update_instance': ('display_name', 'name', 'state', 'type_', 'labels', 'create_time', 'satisfies_pzs', ),
8989
'update_table': ('table', 'update_mask', ),
9090
}

tests/unit/gapic/bigtable_admin_v2/test_bigtable_instance_admin.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3837,6 +3837,7 @@ def test_get_cluster(request_type, transport: str = "grpc"):
38373837
location="location_value",
38383838
state=instance.Cluster.State.READY,
38393839
serve_nodes=1181,
3840+
node_scaling_factor=instance.Cluster.NodeScalingFactor.NODE_SCALING_FACTOR_1X,
38403841
default_storage_type=common.StorageType.SSD,
38413842
)
38423843
response = client.get_cluster(request)
@@ -3853,6 +3854,10 @@ def test_get_cluster(request_type, transport: str = "grpc"):
38533854
assert response.location == "location_value"
38543855
assert response.state == instance.Cluster.State.READY
38553856
assert response.serve_nodes == 1181
3857+
assert (
3858+
response.node_scaling_factor
3859+
== instance.Cluster.NodeScalingFactor.NODE_SCALING_FACTOR_1X
3860+
)
38563861
assert response.default_storage_type == common.StorageType.SSD
38573862

38583863

@@ -3956,6 +3961,7 @@ async def test_get_cluster_empty_call_async():
39563961
location="location_value",
39573962
state=instance.Cluster.State.READY,
39583963
serve_nodes=1181,
3964+
node_scaling_factor=instance.Cluster.NodeScalingFactor.NODE_SCALING_FACTOR_1X,
39593965
default_storage_type=common.StorageType.SSD,
39603966
)
39613967
)
@@ -4030,6 +4036,7 @@ async def test_get_cluster_async(
40304036
location="location_value",
40314037
state=instance.Cluster.State.READY,
40324038
serve_nodes=1181,
4039+
node_scaling_factor=instance.Cluster.NodeScalingFactor.NODE_SCALING_FACTOR_1X,
40334040
default_storage_type=common.StorageType.SSD,
40344041
)
40354042
)
@@ -4047,6 +4054,10 @@ async def test_get_cluster_async(
40474054
assert response.location == "location_value"
40484055
assert response.state == instance.Cluster.State.READY
40494056
assert response.serve_nodes == 1181
4057+
assert (
4058+
response.node_scaling_factor
4059+
== instance.Cluster.NodeScalingFactor.NODE_SCALING_FACTOR_1X
4060+
)
40504061
assert response.default_storage_type == common.StorageType.SSD
40514062

40524063

@@ -11381,6 +11392,7 @@ def test_create_cluster_rest(request_type):
1138111392
"location": "location_value",
1138211393
"state": 1,
1138311394
"serve_nodes": 1181,
11395+
"node_scaling_factor": 1,
1138411396
"cluster_config": {
1138511397
"cluster_autoscaling_config": {
1138611398
"autoscaling_limits": {
@@ -11800,6 +11812,7 @@ def test_get_cluster_rest(request_type):
1180011812
location="location_value",
1180111813
state=instance.Cluster.State.READY,
1180211814
serve_nodes=1181,
11815+
node_scaling_factor=instance.Cluster.NodeScalingFactor.NODE_SCALING_FACTOR_1X,
1180311816
default_storage_type=common.StorageType.SSD,
1180411817
)
1180511818

@@ -11820,6 +11833,10 @@ def test_get_cluster_rest(request_type):
1182011833
assert response.location == "location_value"
1182111834
assert response.state == instance.Cluster.State.READY
1182211835
assert response.serve_nodes == 1181
11836+
assert (
11837+
response.node_scaling_factor
11838+
== instance.Cluster.NodeScalingFactor.NODE_SCALING_FACTOR_1X
11839+
)
1182311840
assert response.default_storage_type == common.StorageType.SSD
1182411841

1182511842

@@ -12577,6 +12594,7 @@ def test_partial_update_cluster_rest(request_type):
1257712594
"location": "location_value",
1257812595
"state": 1,
1257912596
"serve_nodes": 1181,
12597+
"node_scaling_factor": 1,
1258012598
"cluster_config": {
1258112599
"cluster_autoscaling_config": {
1258212600
"autoscaling_limits": {
@@ -13267,7 +13285,8 @@ def test_create_app_profile_rest(request_type):
1326713285
"etag": "etag_value",
1326813286
"description": "description_value",
1326913287
"multi_cluster_routing_use_any": {
13270-
"cluster_ids": ["cluster_ids_value1", "cluster_ids_value2"]
13288+
"cluster_ids": ["cluster_ids_value1", "cluster_ids_value2"],
13289+
"row_affinity": {},
1327113290
},
1327213291
"single_cluster_routing": {
1327313292
"cluster_id": "cluster_id_value",
@@ -14396,7 +14415,8 @@ def test_update_app_profile_rest(request_type):
1439614415
"etag": "etag_value",
1439714416
"description": "description_value",
1439814417
"multi_cluster_routing_use_any": {
14399-
"cluster_ids": ["cluster_ids_value1", "cluster_ids_value2"]
14418+
"cluster_ids": ["cluster_ids_value1", "cluster_ids_value2"],
14419+
"row_affinity": {},
1440014420
},
1440114421
"single_cluster_routing": {
1440214422
"cluster_id": "cluster_id_value",

0 commit comments

Comments
 (0)