def main(cmdline_options): topology = vttest_pb2.VTTestTopology() if cmdline_options.proto_topo: # Text-encoded proto topology object, just parse it. topology = text_format.Parse(cmdline_options.proto_topo, topology) if not topology.cells: topology.cells.append('test') else: cells = [] keyspaces = [] shard_counts = [] if cmdline_options.cells: cells = cmdline_options.cells.split(',') if cmdline_options.keyspaces: keyspaces = cmdline_options.keyspaces.split(',') if cmdline_options.num_shards: shard_counts = [ int(x) for x in cmdline_options.num_shards.split(',') ] for cell in cells: topology.cells.append(cell) for keyspace, num_shards in zip(keyspaces, shard_counts): ks = topology.keyspaces.add(name=keyspace) for shard in sharding_utils.get_shard_names(num_shards): ks.shards.add(name=shard) ks.replica_count = cmdline_options.replica_count ks.rdonly_count = cmdline_options.rdonly_count environment.base_port = cmdline_options.port init_data_opts = None if cmdline_options.initialize_with_random_data: init_data_opts = init_data_options.InitDataOptions() init_data_opts.rng_seed = cmdline_options.rng_seed init_data_opts.min_table_shard_size = cmdline_options.min_table_shard_size init_data_opts.max_table_shard_size = cmdline_options.max_table_shard_size init_data_opts.null_probability = cmdline_options.null_probability with local_database.LocalDatabase( topology, cmdline_options.schema_dir, cmdline_options.mysql_only, init_data_opts, web_dir=cmdline_options.web_dir, web_dir2=cmdline_options.web_dir2, default_schema_dir=cmdline_options.default_schema_dir, extra_my_cnf=os.path.join(os.environ['VTTOP'], 'config/mycnf/vtcombo.cnf')) as local_db: print json.dumps(local_db.config()) sys.stdout.flush() try: raw_input() except EOFError: sys.stderr.write( 'WARNING: %s: No empty line was received on stdin.' ' Instead, stdin was closed and the cluster will be shut down now.' ' Make sure to send the empty line instead to proactively shutdown' ' the local cluster. For example, did you forget the shutdown in' ' your test\'s tearDown()?\n' % os.path.basename(__file__))
def main(cmdline_options): topology = vttest_pb2.VTTestTopology() if cmdline_options.proto_topo: # Text-encoded proto topology object, just parse it. topology = text_format.Parse(cmdline_options.proto_topo, topology) environment.base_port = cmdline_options.port init_data_opts = None if cmdline_options.initialize_with_random_data: init_data_opts = init_data_options.InitDataOptions() init_data_opts.rng_seed = cmdline_options.rng_seed init_data_opts.min_table_shard_size = cmdline_options.min_table_shard_size init_data_opts.max_table_shard_size = cmdline_options.max_table_shard_size init_data_opts.null_probability = cmdline_options.null_probability with local_database.LocalDatabase( topology, cmdline_options.schema_dir, cmdline_options.vschema, cmdline_options.mysql_only, init_data_opts, web_dir=cmdline_options.web_dir) as local_db: print json.dumps(local_db.config()) sys.stdout.flush() try: raw_input() except EOFError: sys.stderr.write( 'WARNING: %s: No empty line was received on stdin.' ' Instead, stdin was closed and the cluster will be shut down now.' ' Make sure to send the empty line instead to proactively shutdown' ' the local cluster. For example, did you forget the shutdown in' ' your test\'s tearDown()?\n' % os.path.basename(__file__))
def main(cmdline_options): topology = vttest_pb2.VTTestTopology() if cmdline_options.topology: # old style topology, will disappear soon. Build a new style # topology from it. keyspaces = {} for shard in cmdline_options.topology.split(','): m = shard_exp.match(shard) if not m: sys.stderr.write('invalid --shard flag format: %s\n' % shard) sys.exit(1) keyspace = m.group(1) shard_name = m.group(2) db_name = m.group(3) if keyspace not in keyspaces: kpb = topology.keyspaces.add(name=keyspace) keyspaces[keyspace] = kpb keyspaces[keyspace].shards.add(name=shard_name, db_name_override=db_name) elif cmdline_options.proto_topo: # new style topology, just parse it as text topology = text_format.Parse(cmdline_options.proto_topo, topology) environment.base_port = cmdline_options.port init_data_opts = None if cmdline_options.initialize_with_random_data: init_data_opts = init_data_options.InitDataOptions() init_data_opts.rng_seed = cmdline_options.rng_seed init_data_opts.min_table_shard_size = cmdline_options.min_table_shard_size init_data_opts.max_table_shard_size = cmdline_options.max_table_shard_size init_data_opts.null_probability = cmdline_options.null_probability with local_database.LocalDatabase( topology, cmdline_options.schema_dir, cmdline_options.vschema, cmdline_options.mysql_only, init_data_opts, web_dir=cmdline_options.web_dir) as local_db: print json.dumps(local_db.config()) sys.stdout.flush() try: raw_input() except EOFError: sys.stderr.write( 'WARNING: %s: No empty line was received on stdin.' ' Instead, stdin was closed and the cluster will be shut down now.' ' Make sure to send the empty line instead to proactively shutdown' ' the local cluster. For example, did you forget the shutdown in' ' your test\'s tearDown()?\n' % os.path.basename(__file__))
def main(cmdline_options): shards = [] for shard in cmdline_options.topology.split(','): m = shard_exp.match(shard) if m: shards.append( vt_processes.ShardInfo(m.group(1), m.group(2), m.group(3))) else: sys.stderr.write('invalid --shard flag format: %s\n' % shard) sys.exit(1) environment.base_port = cmdline_options.port init_data_opts = None if cmdline_options.initialize_with_random_data: init_data_opts = init_data_options.InitDataOptions() init_data_opts.rng_seed = cmdline_options.rng_seed init_data_opts.min_table_shard_size = cmdline_options.min_table_shard_size init_data_opts.max_table_shard_size = cmdline_options.max_table_shard_size init_data_opts.null_probability = cmdline_options.null_probability with local_database.LocalDatabase( shards, cmdline_options.schema_dir, cmdline_options.vschema, cmdline_options.mysql_only, init_data_opts, web_dir=cmdline_options.web_dir) as local_db: print json.dumps(local_db.config()) sys.stdout.flush() try: raw_input() except EOFError: sys.stderr.write( 'WARNING: %s: No empty line was received on stdin.' ' Instead, stdin was closed and the cluster will be shut down now.' ' Make sure to send the empty line instead to proactively shutdown' ' the local cluster. For example, did you forget the shutdown in' ' your test\'s tearDown()?\n' % os.path.basename(__file__))