Skip to content

Commit

Permalink
Support multi-cluster routing for Google CloudBigtable.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 331019716
  • Loading branch information
yuyantingzero authored and copybara-github committed Sep 10, 2020
1 parent 5702023 commit bc16979
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,8 @@ def Run(benchmark_spec):
'bigtable_replication_zone'] = FLAGS.bigtable_replication_cluster_zone
metadata['bigtable_storage_type'] = FLAGS.bigtable_storage_type
metadata['bigtable_node_count'] = FLAGS.bigtable_node_count
metadata['bigtable_multicluster_routing'] = (
FLAGS.bigtable_multicluster_routing)

# By default YCSB uses a BufferedMutator for Puts / Deletes.
# This leads to incorrect update latencies, since since the call returns
Expand Down
22 changes: 22 additions & 0 deletions perfkitbenchmarker/providers/gcp/gcp_bigtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ def _ValidateReplicationFlags(flag_dict):
return (not flag_dict['bigtable_replication_cluster'] or
flag_dict['bigtable_replication_cluster_zone'])


def _ValidateRoutingFlags(flag_dict):
"""Verifies correct usage of the bigtable routing flags."""
return (not flag_dict['bigtable_multicluster_routing'] or
flag_dict['bigtable_replication_cluster'])


flags.DEFINE_integer('bigtable_node_count', 3,
'Number of nodes to create in the bigtable cluster.')
flags.DEFINE_enum('bigtable_storage_type', 'ssd', ['ssd', 'hdd'],
Expand All @@ -41,10 +48,16 @@ def _ValidateReplicationFlags(flag_dict):
'Whether to create a Bigtable replication cluster.')
flags.DEFINE_string('bigtable_replication_cluster_zone', None,
'Zone in which to create a Bigtable replication cluster.')
flags.DEFINE_boolean('bigtable_multicluster_routing', False,
'Whether to use multi-cluster routing.')
flags.register_multi_flags_validator(
['bigtable_replication_cluster', 'bigtable_replication_cluster_zone'],
_ValidateReplicationFlags, message='bigtable_replication_cluster_zone must '
'be set if bigtable_replication_cluster is True.')
flags.register_multi_flags_validator(
['bigtable_replication_cluster', 'bigtable_multicluster_routing'],
_ValidateRoutingFlags, message='bigtable_replication_cluster must '
'be set if bigtable_multicluster_routing is True.')


class GcpBigtableInstance(resource.BaseResource):
Expand Down Expand Up @@ -89,6 +102,15 @@ def _Create(self):

logging.info('Creating instance %s.', self.name)

if FLAGS.bigtable_multicluster_routing:
cmd = util.GcloudCommand(self, 'beta', 'bigtable', 'app-profiles',
'update', 'default')
cmd.flags['instance'] = self.name
cmd.flags['route-any'] = True
cmd.flags['force'] = True
cmd.flags['zone'] = []
cmd.Issue()

def _Delete(self):
"""Deletes the instance."""
cmd = util.GcloudCommand(self, 'beta', 'bigtable', 'instances', 'delete',
Expand Down

0 comments on commit bc16979

Please sign in to comment.