本文整理汇总了Python中lib.tarantool_server.TarantoolServer.cfgfile_source方法的典型用法代码示例。如果您正苦于以下问题:Python TarantoolServer.cfgfile_source方法的具体用法?Python TarantoolServer.cfgfile_source怎么用?Python TarantoolServer.cfgfile_source使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib.tarantool_server.TarantoolServer
的用法示例。
在下文中一共展示了TarantoolServer.cfgfile_source方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TarantoolServer
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import cfgfile_source [as 别名]
master = server
master.admin("space = box.schema.create_space('test', {id = 42})")
master.admin("space:create_index('primary', { type = 'hash'})")
master.admin('for k = 1, 9 do space:insert{k, k*k} end')
for k in glob.glob(os.path.join(master.vardir, '*.xlog')):
os.unlink(k)
print '-------------------------------------------------------------'
print 'replica test 1 (no such space)'
print '-------------------------------------------------------------'
replica = TarantoolServer(server.ini)
replica.cfgfile_source = 'replication/cfg/replica.cfg'
replica.vardir = os.path.join(server.vardir, 'replica')
replica.rpl_master = master
replica.deploy()
replica.admin('box.space.test')
replica.stop()
replica.cleanup(True)
master.admin('box.snapshot()')
master.restart()
master.admin('for k = 10, 19 do box.space[42]:insert{k, k*k*k} end')
lsn = master.get_param('lsn')
print '-------------------------------------------------------------'
print 'replica test 2 (must be ok)'
示例2: insert_tuples
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import cfgfile_source [as 别名]
def insert_tuples(_server, begin, end, msg = "tuple"):
for i in range(begin, end):
_server.sql("insert into t0 values (%d, '%s %d')" % (i, msg, i))
def select_tuples(_server, begin, end, lsn):
_server.wait_lsn(lsn)
for i in range(begin, end):
_server.sql("select * from t0 where k0 = %d" % i)
# master server
master = server
cfgfile_bkp = server.cfgfile_source
# replica server
replica = TarantoolServer()
replica.rpl_master = master
replica.cfgfile_source = "replication/cfg/replica.cfg"
replica.vardir = os.path.join(server.vardir, 'replica')
replica.deploy()
master.admin("box.schema.user.grant('guest', 'read,write,execute', 'universe')")
replica.admin("while box.space['_priv']:len() < 1 do box.fiber.sleep(0.01) end")
master.admin("s = box.schema.create_space('tweedledum', {id = 0})")
master.admin("s:create_index('primary', {type = 'hash'})")
id = ID_BEGIN
for i in range(REPEAT):
print "test %d iteration" % i
# insert to master
insert_tuples(master, id, id + ID_STEP)
# select from replica
select_tuples(replica, id, id + ID_STEP, master.get_param("lsn"))