本文整理汇总了Python中pyactive.controller.init_host函数的典型用法代码示例。如果您正苦于以下问题:Python init_host函数的具体用法?Python init_host怎么用?Python init_host使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了init_host函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: create_host
def create_host():
start_controller("pyactive_thread")
tcpconf = ('tcp', ('127.0.0.1', 9899))
global host
host = init_host(tcpconf)
global remote_host
remote_host = host.lookup(settings.PYACTIVE_URL+'controller/Host/0')
开发者ID:iostackproject,项目名称:Crystal-Controller,代码行数:7,代码来源:views.py
示例2: testN
def testN():
net_conf = ('tcp',('127.0.0.1',6664))
host = init_host(net_conf)
print 'TEST ',NUM_NODES,' nodes and', NUM_MSGS, "messages."
nf = host.spawn_id('init', 'ring3','Node',['nf'])
ni = nf;
for i in range (NUM_NODES-2):
ni = host.spawn_id(str(i), 'ring3','Node',[('n',i),ni])
n1 = host.spawn_id('end','ring3','Node',['n1',ni])
nf.set_next(n1)
print 'start time!!'
init = time()
nf.init_token()
while(not n1.is_finished()):
sleep(0.01)
end = time()
print ((end - init)*1000),' ms.'
开发者ID:cloudspaces,项目名称:pyactive,代码行数:26,代码来源:ring3.py
示例3: test3
def test3():
tcpconf = ('tcp',('127.0.0.1',1259))
host = init_host(tcpconf)
registry = host.lookup('tcp://127.0.0.1:6664/first/Registry/1')
registry.bind('third', host)
开发者ID:cloudspaces,项目名称:pyactive,代码行数:7,代码来源:third.py
示例4: start_node
def start_node():
nodes_h = {}
num_nodes = 20
cont = 21
retry = 0
j=0
tcpconf = ('tcp', ('127.0.0.1', 6377))
host = init_host(tcpconf)
for i in range(num_nodes):
nodes_h[i] = host.spawn_id(str(cont), 'chord_remote', 'Node', [])
cont += 1
for i in range(num_nodes):
nodes_h[i].init_node()
remote_aref = 'atom://127.0.0.1:1432/chord/Node/2'
remote_node = host.lookup(remote_aref)
while j < num_nodes:
try:
if(nodes_h[j].join(remote_node)):
print "True"
interval(30, stablilize, nodes_h[j])
interval(30, fix_finger, nodes_h[j])
j += 1
retry = 0
except(TimeoutError):
retry += 1
if retry > 3:
break
interval(100, show, nodes_h[0])
interval(100, show, nodes_h[num_nodes/2])
interval(100, show, nodes_h[num_nodes - 1])
开发者ID:sfcelma,项目名称:pyactive,代码行数:34,代码来源:chord_remote.py
示例5: test
def test():
host = init_host()
# parameters 1 = 'id', 'test_async' = module name, 'Server' = class name
n1 = host.spawn_id('1', 'hello_world_async', 'Server', [])
n1.hello_world()
开发者ID:cloudspaces,项目名称:pyactive,代码行数:7,代码来源:hello_world_async.py
示例6: test3
def test3():
momconf = ('mom',{'name':'c1','ip':'127.0.0.1','port':61613,'namespace':'/topic/test_edgar'})
host = init_host(momconf)
#host = init_host(('127.0.0.1',4329),True)
#host = Host(host)
#oref = 'env2:simple:s1:Server'
aref = 'mom://s1/server/Server/0'
ref = host.lookup(aref)
nodes = {}
for i in range(1, 100):
nodes[i] = host.spawn_id(str(i), 'client', 'Client', [ref])
nodes[i].subscribe()
#for i in range(100):
# ref.resta(34,2)
# try:
# ref.wait_a_lot()
# except TimeoutError:
# print 'correct timeout'
#sleep(1)
#host.shutdown()
check_ref_list = []
for node in nodes.values():
reference = node.get_reference()
if not reference in check_ref_list:
check_ref_list.append(reference)
else:
print 'error: some client has the same reference'
print 'all ok'
print ref.get_references()
开发者ID:cloudspaces,项目名称:pyactive,代码行数:32,代码来源:client.py
示例7: start_node
def start_node():
#Canviar per fer el lookup
nodes_h = {}
num_nodes = 20
cont = 1
retry = 0
index=0
tcpconf = ('tcp', ('127.0.0.1', 1238))
host = init_host(tcpconf)
# log = host.spawn_id('log','chord_log','LogUML',[])
# host.set_tracer(log)
for i in range(num_nodes):
nodes_h[i] = host.spawn_id(str(cont), 'chord', 'Node', [])
cont += 1
for i in range(num_nodes):
nodes_h[i].init_node()
while index < num_nodes:
try:
if(nodes_h[index].join(nodes_h[0])):
print "True"
interval(15, update, nodes_h[index])
index += 1
retry = 0
except TimeoutError:
retry += 1
if retry > 3:
break
interval(100, show, nodes_h[0])
interval(100, show, nodes_h[num_nodes/2])
interval(100, show, nodes_h[num_nodes - 1])
开发者ID:sergitoda,项目名称:pyactive,代码行数:32,代码来源:chord.py
示例8: start_node
def start_node():
nodes_h = {}
num_nodes = 10
cont = 1
retry = 0
index=0
tcpconf = ('tcp', ('127.0.0.1', 1238))
host = init_host(tcpconf)
# momconf = ('mom',{'name':'s1','ip':'127.0.0.1','port':61613,'namespace':'/topic/test'})
# host = init_host(momconf)
for i in range(num_nodes):
nodes_h[i] = host.spawn_id(str(cont), 'scribe', 'ScribeNode', [])
cont += 1
for i in range(num_nodes):
nodes_h[i].init_node()
while index < num_nodes:
try:
if(nodes_h[index].join(nodes_h[0])):
print "True"
interval(5, update, nodes_h[index])
index += 1
retry = 0
# sleep(0.2)
except TimeoutError:
retry += 1
if retry > 3:
index += 1
num_nodes -= 1
"Lookup test"
menu(host, nodes_h, num_nodes)
开发者ID:cloudspaces,项目名称:pyactive,代码行数:32,代码来源:scribe.py
示例9: start_node
def start_node():
nodes_h = {}
num_nodes = 50
# cont = 1
retry = 0
j = 0
# tcpconf = ('tcp', ('127.0.0.1', 1432))
# host = init_host(tcpconf)
sample = uniform(num_nodes, I, MAX)
print sorted(sample)
momconf = ("mom", {"name": "s1", "ip": "127.0.0.1", "port": 61613, "namespace": "/topic/test"})
host = init_host(momconf)
# log = host.spawn_id('log','chord_log','LogUML',[])
# host.set_tracer(log)
for i in range(num_nodes):
nodes_h[i] = host.spawn_id(str(sample[i]), "chord_with_succlist", "SuccNode", [])
# cont += 1
for i in range(num_nodes):
nodes_h[i].init_node()
while j < num_nodes:
try:
if nodes_h[j].join(nodes_h[0]):
print "True"
interval(5, update, nodes_h[j])
except TimeoutError:
retry += 1
if retry > 3:
break
else:
j += 1
interval(200, show, nodes_h[0])
interval(200, show, nodes_h[num_nodes / 2])
interval(200, show, nodes_h[num_nodes - 1])
开发者ID:raqueleyeos,项目名称:pyactive,代码行数:35,代码来源:chord_with_succlist.py
示例10: start_remote_node
def start_remote_node():
nodes_h = {}
num_nodes = 50
# cont = 21 + 50
retry = 0
j = 0
sample = uniform(num_nodes, I, MAX)
# tcpconf = ('tcp', ('127.0.0.1', 6377))
# host = init_host(tcpconf)
momconf = ("mom", {"name": "c2", "ip": "127.0.0.1", "port": 61613, "namespace": "/topic/test"})
host = init_host(momconf)
for i in range(num_nodes):
nodes_h[i] = host.spawn_id(str(sample[i]), "chord_with_succlist", "SuccNode", [])
# cont += 1
for i in range(num_nodes):
nodes_h[i].init_node()
remote_aref = "mom://s1/chord_with_succlist/SuccNode/7"
# remote_aref = 'atom://127.0.0.1:1432/chord/Node/2'
remote_node = host.lookup(remote_aref)
while j < num_nodes:
try:
if nodes_h[j].join(remote_node):
print "True"
interval(5, update, nodes_h[j])
j += 1
retry = 0
except (TimeoutError):
retry += 1
if retry > 3:
break
interval(200, show, nodes_h[0])
interval(200, show, nodes_h[num_nodes / 2])
interval(200, show, nodes_h[num_nodes - 1])
开发者ID:raqueleyeos,项目名称:pyactive,代码行数:35,代码来源:chord_with_succlist.py
示例11: example1
def example1():
nodes = [1,8,14,21,32,38,42,48,51,56]
nodes_h = {}
tcpconf = ('tcp', ('127.0.0.1', 1234))
host = init_host(tcpconf)
# Create and initialize nodes
for i in range(len(nodes)):
print 'iteration', i
nodes_h[i] = host.spawn_id(str(nodes[i]), 'chord_protocol', 'Node', [])
nodes_h[i].init_node()
for i in range(len(nodes)):
j = 0 if i is 0 else i-1
try:
nodes_h[i].join(nodes_h[j])
except:
print 'Node %s fails' % str(i)
else:
interval_host(host, 1, update, nodes_h[i])
interval_host(host, 30, show, nodes_h[0])
interval_host(host, 31, show, nodes_h[5])
interval_host(host, 32, show, nodes_h[9])
开发者ID:cloudspaces,项目名称:pyactive,代码行数:25,代码来源:example1.py
示例12: test3
def test3():
tcpconf = ("tcp", ("127.0.0.1", 1234))
host = init_host(tcpconf)
server = host.spawn_id("0", "s1", "Server", [])
server.substract(4, 3)
print server.add(66, 7)
开发者ID:sergitoda,项目名称:pyactive,代码行数:7,代码来源:s1.py
示例13: test3
def test3():
tcpconf = ('tcp',('127.0.0.1',1234))
host = init_host(tcpconf)
registry = host.spawn_id('1','interval','Registry',[])
registry.init_start()
开发者ID:cloudspaces,项目名称:pyactive,代码行数:7,代码来源:interval.py
示例14: test
def test():
host = init_host()
e1 = host.spawn_id('1', 'actor5c', 'Echo', [])
bot = host.spawn_id('1', 'actor5c', 'Bot', [])
bot.set_channel()
bot.insult()
sleep(4)
开发者ID:cloudspaces,项目名称:pyactive,代码行数:7,代码来源:actor5c.py
示例15: test3
def test3():
tcpconf = ('tcp',('127.0.0.1',1234))
host = init_host(tcpconf)
server = host.spawn_id('0','s1','Server',[])
server.substract(4,3)
print server.add(66,7)
开发者ID:cloudspaces,项目名称:pyactive,代码行数:7,代码来源:s1.py
示例16: example2
def example2():
nodes_h = {}
tcpconf = ('tcp', ('127.0.0.1', 1234))
host = init_host(tcpconf)
t1 = time()
# Create and initialize nodes
for i in range(100):
nodes_h[i] = host.spawn_id(str(id()), 'chord_protocol', 'Node', [])
nodes_h[i].init_node()
for i in range(len(nodes_h)):
j = 0 if i is 0 else i-1
try:
nodes_h[i].join(nodes_h[j])
except:
print 'Node %s fails' % str(i)
else:
interval_host(host, 0.5, update, nodes_h[i])
t2 = time()
print 'Time to create 100 nodes'
print t2 - t1
# Wait to give time to chord to fix its tables.
# Note that if we use the class chord_improved we will need less time to fix the node tables.
sleep(30)
key = hash('pedro')
print key
found = nodes_h[0].find_predecessor(key)
print found.get_id()
开发者ID:cloudspaces,项目名称:pyactive,代码行数:34,代码来源:example2.py
示例17: start_remote_node
def start_remote_node():
nodes_h = {}
num_nodes = 10
cont = 11
retry = 0
index=0
tcpconf = ('tcp', ('127.0.0.1', 6377))
host = init_host(tcpconf)
# momconf = ('mom',{'name':'c1','ip':'127.0.0.1','port':61613,'namespace':'/topic/test'})
# host = init_host(momconf)
for i in range(num_nodes):
nodes_h[i] = host.spawn_id(str(cont), 'scribe', 'ScribeNode', [])
cont += 1
for i in range(num_nodes):
nodes_h[i].init_node()
# remote_aref = 'mom://s1/scribe/ScribeNode/1'
remote_aref = 'atom://127.0.0.1:1238/scribe/ScribeNode/2'
remote_node = host.lookup(remote_aref)
while index < num_nodes:
try:
if(nodes_h[index].join(remote_node)):
print "True"
interval(5, update, nodes_h[index])
index += 1
retry = 0
except(TimeoutError):
retry += 1
print 'Timeout Error: Attempts '+retry
if retry > 3:
index += 1
menu(host, nodes_h, num_nodes)
开发者ID:cloudspaces,项目名称:pyactive,代码行数:32,代码来源:scribe.py
示例18: test3
def test3():
tcpconf = ('tcp',('127.0.0.1',6664))
host = init_host(tcpconf)
registry = host.spawn_id('1','first','Registry',[])
registry.bind('first', host)
开发者ID:raqueleyeos,项目名称:pyactive,代码行数:7,代码来源:first.py
示例19: testN
def testN():
host = init_host()
print 'TEST ',NUM_NODES,' nodes and', NUM_MSGS, "messages."
nf = host.spawn_id('0','ring3','Node',['nf'])
ni = nf;
for i in range (1, NUM_NODES-2):
ni = host.spawn_id(str(i), 'ring3','Node',[('n',i),ni])
n1 = host.spawn_id(str(NUM_NODES -1), 'ring3','Node',['n1',ni])
nf.set_next(n1)
init = time()
n1.init_token()
while(nf.is_finished()):
pass
end = time()
print 'N1', n1
print ((end - init)*1000),' ms.'
开发者ID:sergitoda,项目名称:pyactive,代码行数:26,代码来源:ring3.py
示例20: client_test
def client_test():
tcpconf = ('tcp',('127.0.0.1',4321))
host = init_host(tcpconf)
server = host.lookup('tcp://127.0.0.1:1234/interval/Registry/1')
server.hello()
print server.hello_sync()
开发者ID:cloudspaces,项目名称:pyactive,代码行数:7,代码来源:client.py
注:本文中的pyactive.controller.init_host函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论