本文整理汇总了Python中vtdb.topology.read_topology函数的典型用法代码示例。如果您正苦于以下问题:Python read_topology函数的具体用法?Python read_topology怎么用?Python read_topology使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了read_topology函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_up
def set_up(self):
try:
environment.topo_server().setup()
utils.wait_procs([t.init_mysql() for t in self.tablets])
utils.run_vtctl(['CreateKeyspace', self.keyspace])
utils.run_vtctl(['SetKeyspaceShardingInfo', '-force', self.keyspace, 'keyspace_id', 'uint64'])
for t in self.tablets:
t.init_tablet(t.type, keyspace=self.keyspace, shard=t.shard)
utils.run_vtctl(['RebuildKeyspaceGraph', self.keyspace], auto_log=True)
for t in self.tablets:
t.create_db('vt_' + self.keyspace)
t.start_vttablet(
wait_for_state=None,
extra_args=['-queryserver-config-schema-reload-time', '1'],
)
for t in self.tablets:
t.wait_for_vttablet_state('SERVING')
for t in self.tablets:
if t.type == "master":
utils.run_vtctl(['ReparentShard', '-force', self.keyspace+'/'+t.shard, t.tablet_alias], auto_log=True)
utils.run_vtctl(['RebuildKeyspaceGraph', self.keyspace], auto_log=True)
if self.schema:
utils.run_vtctl(['ApplySchemaKeyspace', '-simple', '-sql', self.schema, self.keyspace])
if self.vschema:
if self.vschema[0] == '{':
utils.run_vtctl(['ApplyVSchema', "-vschema", self.vschema])
else:
utils.run_vtctl(['ApplyVSchema', "-vschema_file", self.vschema])
self.vtgate_server, self.vtgate_port = utils.vtgate_start(cache_ttl='500s', vtport=self.vtgate_port)
vtgate_client = zkocc.ZkOccConnection("localhost:%u" % self.vtgate_port, "test_nj", 30.0)
topology.read_topology(vtgate_client)
except:
self.shutdown()
raise
示例2: set_up
def set_up(self):
try:
environment.topo_server_setup()
utils.wait_procs([t.init_mysql() for t in self.tablets])
utils.run_vtctl(['CreateKeyspace', self.keyspace])
utils.run_vtctl(['SetKeyspaceShardingInfo', '-force', self.keyspace, 'keyspace_id', 'uint64'])
for t in self.tablets:
t.init_tablet(t.type, keyspace=self.keyspace, shard=t.shard)
utils.run_vtctl(['RebuildKeyspaceGraph', self.keyspace], auto_log=True)
for t in self.tablets:
t.create_db('vt_' + self.keyspace)
t.mquery(t.dbname, create_table)
t.start_vttablet(wait_for_state=None)
for t in self.tablets:
t.wait_for_vttablet_state('SERVING')
for t in self.tablets:
if t.type == "master":
utils.run_vtctl(['ReparentShard', '-force', self.keyspace+'/'+t.shard, t.tablet_alias], auto_log=True)
utils.run_vtctl(['RebuildKeyspaceGraph', self.keyspace], auto_log=True)
self.vtgate_server, self.vtgate_port = utils.vtgate_start()
vtgate_client = zkocc.ZkOccConnection("localhost:%u" % self.vtgate_port, "test_nj", 30.0)
topology.read_topology(vtgate_client)
except:
self.shutdown()
raise
示例3: setup_tablets
def setup_tablets():
global vtgate_server
global vtgate_port
# Start up a master mysql and vttablet
logging.debug("Setting up tablets")
utils.run_vtctl(['CreateKeyspace', KEYSPACE_NAME])
utils.run_vtctl(['SetKeyspaceShardingInfo', '-force', KEYSPACE_NAME,
'keyspace_id', 'uint64'])
shard_0_master.init_tablet('master', keyspace=KEYSPACE_NAME, shard='-80')
shard_0_replica.init_tablet('replica', keyspace=KEYSPACE_NAME, shard='-80')
shard_1_master.init_tablet('master', keyspace=KEYSPACE_NAME, shard='80-')
shard_1_replica.init_tablet('replica', keyspace=KEYSPACE_NAME, shard='80-')
utils.run_vtctl(['RebuildKeyspaceGraph', KEYSPACE_NAME], auto_log=True)
for t in [shard_0_master, shard_0_replica, shard_1_master, shard_1_replica]:
t.create_db('vt_test_keyspace')
for create_table in create_tables:
t.mquery(shard_0_master.dbname, create_table)
t.start_vttablet(wait_for_state=None)
for t in [shard_0_master, shard_0_replica, shard_1_master, shard_1_replica]:
t.wait_for_vttablet_state('SERVING')
utils.run_vtctl(['ReparentShard', '-force', KEYSPACE_NAME+'/-80',
shard_0_master.tablet_alias], auto_log=True)
utils.run_vtctl(['ReparentShard', '-force', KEYSPACE_NAME+'/80-',
shard_1_master.tablet_alias], auto_log=True)
utils.run_vtctl(['RebuildKeyspaceGraph', KEYSPACE_NAME],
auto_log=True)
utils.check_srv_keyspace('test_nj', KEYSPACE_NAME,
'Partitions(master): -80 80-\n' +
'Partitions(replica): -80 80-\n' +
'TabletTypes: master,replica')
vtgate_server, vtgate_port = utils.vtgate_start()
# FIXME(shrutip): this should be removed once vtgate_cursor's
# dependency on topology goes away.
vtgate_client = zkocc.ZkOccConnection("localhost:%u" % vtgate_port,
"test_nj", 30.0)
topology.read_topology(vtgate_client)
示例4: setup_tablets
def setup_tablets():
global vtgate_server
global vtgate_port
# Start up a master mysql and vttablet
logging.debug("Setting up tablets")
utils.run_vtctl(['CreateKeyspace', 'test_keyspace'])
utils.run_vtctl(['SetKeyspaceShardingInfo', '-force', 'test_keyspace',
'keyspace_id', 'uint64'])
shard_0_master.init_tablet('master', keyspace='test_keyspace', shard='-80')
shard_0_replica.init_tablet('replica', keyspace='test_keyspace', shard='-80')
shard_1_master.init_tablet('master', keyspace='test_keyspace', shard='80-')
shard_1_replica.init_tablet('replica', keyspace='test_keyspace', shard='80-')
utils.run_vtctl(['RebuildKeyspaceGraph', 'test_keyspace'], auto_log=True)
for t in [shard_0_master, shard_0_replica, shard_1_master, shard_1_replica]:
t.create_db('vt_test_keyspace')
t.mquery(shard_0_master.dbname, create_vt_insert_test)
t.mquery(shard_0_master.dbname, create_vt_a)
t.start_vttablet(wait_for_state=None)
for t in [shard_0_master, shard_0_replica, shard_1_master, shard_1_replica]:
t.wait_for_vttablet_state('SERVING')
utils.run_vtctl(['ReparentShard', '-force', 'test_keyspace/-80',
shard_0_master.tablet_alias], auto_log=True)
utils.run_vtctl(['ReparentShard', '-force', 'test_keyspace/80-',
shard_1_master.tablet_alias], auto_log=True)
utils.run_vtctl(['RebuildKeyspaceGraph', 'test_keyspace'],
auto_log=True)
utils.check_srv_keyspace('test_nj', 'test_keyspace',
'Partitions(master): -80 80-\n' +
'Partitions(replica): -80 80-\n' +
'TabletTypes: master,replica')
vtgate_server, vtgate_port = utils.vtgate_start()
vtgate_client = zkocc.ZkOccConnection("localhost:%u" % vtgate_port,
"test_nj", 30.0)
topology.read_topology(vtgate_client)
示例5: setup_tablets
def setup_tablets():
# Start up a master mysql and vttablet
logging.debug('Setting up tablets')
utils.run_vtctl(['CreateKeyspace', 'test_keyspace'])
utils.run_vtctl(['SetKeyspaceShardingInfo', '-force', 'test_keyspace',
'keyspace_id', 'uint64'])
shard_0_master.init_tablet('master', keyspace='test_keyspace', shard='-80')
shard_0_replica.init_tablet('replica', keyspace='test_keyspace', shard='-80')
shard_1_master.init_tablet('master', keyspace='test_keyspace', shard='80-')
shard_1_replica.init_tablet('replica', keyspace='test_keyspace', shard='80-')
utils.run_vtctl(['RebuildKeyspaceGraph', 'test_keyspace'], auto_log=True)
for t in [shard_0_master, shard_0_replica, shard_1_master, shard_1_replica]:
t.create_db('vt_test_keyspace')
t.mquery(shard_0_master.dbname, create_vt_insert_test)
t.mquery(shard_0_master.dbname, create_vt_a)
t.start_vttablet(wait_for_state=None)
for t in [shard_0_master, shard_0_replica, shard_1_master, shard_1_replica]:
t.wait_for_vttablet_state('SERVING')
utils.run_vtctl(
['InitShardMaster', 'test_keyspace/-80',
shard_0_master.tablet_alias], auto_log=True)
utils.run_vtctl(
['InitShardMaster', 'test_keyspace/80-',
shard_1_master.tablet_alias], auto_log=True)
utils.run_vtctl(
['RebuildKeyspaceGraph', 'test_keyspace'], auto_log=True)
utils.check_srv_keyspace('test_nj', 'test_keyspace',
'Partitions(master): -80 80-\n'
'Partitions(rdonly): -80 80-\n'
'Partitions(replica): -80 80-\n')
utils.VtGate().start()
vtgate_client = zkocc.ZkOccConnection(utils.vtgate.addr(), 'test_nj', 30.0)
topology.read_topology(vtgate_client)
示例6: setup_tablets
def setup_tablets():
global vtgate_server
global vtgate_port
# Start up a master mysql and vttablet
logging.debug("Setting up tablets")
utils.run_vtctl(["CreateKeyspace", "test_keyspace"])
utils.run_vtctl(["SetKeyspaceShardingInfo", "-force", "test_keyspace", "keyspace_id", "uint64"])
shard_0_master.init_tablet("master", keyspace="test_keyspace", shard="-80")
shard_0_replica.init_tablet("replica", keyspace="test_keyspace", shard="-80")
shard_1_master.init_tablet("master", keyspace="test_keyspace", shard="80-")
shard_1_replica.init_tablet("replica", keyspace="test_keyspace", shard="80-")
utils.run_vtctl(["RebuildKeyspaceGraph", "test_keyspace"], auto_log=True)
for t in [shard_0_master, shard_0_replica, shard_1_master, shard_1_replica]:
t.create_db("vt_test_keyspace")
t.mquery(shard_0_master.dbname, create_vt_insert_test)
t.mquery(shard_0_master.dbname, create_vt_a)
t.start_vttablet(wait_for_state=None)
for t in [shard_0_master, shard_0_replica, shard_1_master, shard_1_replica]:
t.wait_for_vttablet_state("SERVING")
utils.run_vtctl(["ReparentShard", "-force", "test_keyspace/-80", shard_0_master.tablet_alias], auto_log=True)
utils.run_vtctl(["ReparentShard", "-force", "test_keyspace/80-", shard_1_master.tablet_alias], auto_log=True)
utils.run_vtctl(["RebuildKeyspaceGraph", "test_keyspace"], auto_log=True)
utils.check_srv_keyspace(
"test_nj",
"test_keyspace",
"Partitions(master): -80 80-\n" + "Partitions(replica): -80 80-\n" + "TabletTypes: master,replica",
)
vtgate_server, vtgate_port = utils.vtgate_start()
vtgate_client = zkocc.ZkOccConnection("localhost:%u" % vtgate_port, "test_nj", 30.0)
topology.read_topology(vtgate_client)
示例7: main
def main():
env = TestEnv(options)
if args and args[0] == 'setup':
env.set_up()
# prime the vtgate topology cache, so if the topo service goes away
# when we exit this python script, the cache is already primed.
vtgate_client = zkocc.ZkOccConnection(utils.vtgate.addr(), "test_nj",
30.0)
topology.read_topology(vtgate_client)
sys.stdout.write(json.dumps({
"port": utils.vtgate.port,
}) + "\n")
sys.stdout.flush()
elif args and args[0] == 'teardown':
env.shutdown()
else:
env.set_up()
sys.stdout.write(json.dumps({
"port": utils.vtgate.port,
}) + "\n")
sys.stdout.flush()
raw_input()
env.shutdown()
示例8: setUpModule
def setUpModule():
global vtgate_server, vtgate_port
logging.debug("in setUpModule")
try:
environment.topo_server().setup()
setup_topology()
# start mysql instance external to the test
global __tablets
setup_procs = []
for tablet in __tablets:
setup_procs.append(tablet.init_mysql())
utils.wait_procs(setup_procs)
create_db()
start_tablets()
vtgate_server, vtgate_port = utils.vtgate_start()
# FIXME(shrutip): this should be removed once vtgate_cursor's
# dependency on topology goes away.
vtgate_client = zkocc.ZkOccConnection("localhost:%u" % vtgate_port,
"test_nj", 30.0)
topology.read_topology(vtgate_client)
except:
tearDownModule()
raise
示例9: VALUES
# Parse args
parser = argparse.ArgumentParser()
parser.add_argument('--server', dest='server', default='localhost:15001')
parser.add_argument('--timeout', dest='timeout', type=float, default='10.0')
args = parser.parse_args()
vtgate_addrs = {"_vt": [args.server]}
# Connect
conn = vtgatev2.connect(vtgate_addrs, args.timeout)
# Read topology
# This is a temporary work-around until the VTGate V2 client is topology-free.
topoconn = zkocc.ZkOccConnection(args.server, 'test_cell', args.timeout)
topology.read_topology(topoconn)
topoconn.close()
# Insert something.
print('Inserting into master...')
cursor = conn.cursor(cursorclass, conn, 'test_keyspace', 'master',
keyranges=UNSHARDED, writable=True)
cursor.begin()
cursor.execute(
"INSERT INTO test_table (msg) VALUES (%(msg)s)",
{'msg': 'V is for speed'})
cursor.commit()
# Read it back from the master.
print('Reading from master...')
示例10: setUp
def setUp(self):
self.vtgate_client = zkocc.ZkOccConnection(vtgate_socket_file,
"test_nj", 30.0)
topology.read_topology(self.vtgate_client)
示例11: _populate_topo_cache
def _populate_topo_cache(self):
topology.read_topology(self.vtgate_client)
示例12: setUp
def setUp(self):
self.vtgate_client = zkocc.ZkOccConnection(utils.vtgate.addr(),
'test_nj', 30.0)
topology.read_topology(self.vtgate_client)
示例13: setUp
def setUp(self):
self.vtgate_client = zkocc.ZkOccConnection("localhost:%u" % vtgate_port,
"test_nj", 30.0)
topology.read_topology(self.vtgate_client)
self.perform_insert(400)
示例14: setUp
def setUp(self):
self.vtgate_client = zkocc.ZkOccConnection(utils.vtgate.addr(),
"test_nj", 30.0)
topology.read_topology(self.vtgate_client)
self.perform_insert(400)