Ejemplo n.º 1
0
	parser.add_argument('--verbose', '-v', action='count')
	parser.set_defaults(group=1)
	args = parser.parse_args()

	# supplement id to even number of chars
	# (as hex form must represent whole number bytes)
	if len(args.id) % 2 != 0:
		args.id += '0'
	try:
		eid = map(ord, args.id.decode("hex"))
	except TypeError, e:
		print 'Invalid id:', e
		exit(1)

	session = connect([args.remote], [args.group],
			loglevel=args.loglevel,
			)

	routing_table = session.get_routes()
	sorted_ids = sorted(routing_table, key=lambda x: x[0].id)

	if args.verbose > 1:
		print 'Routing table:'
		print_routing_table(sorted_ids)
		print

	def find_responsible(a, x):
		'''Find responsible routing item in the circular routing table.
		Find righmost value less then or equal to x.
		And last entry is responsible for [0, a[0]) span.
		'''
Ejemplo n.º 2
0
	parser.add_argument('id', help='hexadecimal id (or prefix of) to lookup responsible host for')
	parser.add_argument('--verbose', '-v', action='count')
	args = parser.parse_args()

	remote = args.remote
	# supplement id to even number of chars
	# (as hex form must represent whole number bytes)
	if len(args.id) % 2 != 0:
		args.id += '0'
	try:
		eid = map(ord, args.id.decode("hex"))
	except TypeError, e:
		print 'Invalid id:', e
		exit(1)

	session = connect([remote], [1])

	routing_table = session.get_routes()
	sorted_ids = sorted(routing_table, key=lambda x: x[0].id)

	if args.verbose > 1:
		print 'Routing table:'
		print_routing_table(sorted_ids)
		print

	def find_responsible(a, x):
		'''Find responsible routing item in the circular routing table.
		Find righmost value less then or equal to x.
		And last entry is responsible for [0, a[0]) span.  
		'''
		keys = [i[0].id for i in a]
Ejemplo n.º 3
0
    parser.set_defaults(group=1)
    args = parser.parse_args()

    # supplement id to even number of chars
    # (as hex form must represent whole number bytes)
    if len(args.id) % 2 != 0:
        args.id += '0'
    try:
        eid = map(ord, args.id.decode("hex"))
    except TypeError, e:
        print 'Invalid id:', e
        exit(1)

    session = connect(
        [args.remote],
        [args.group],
        loglevel=args.loglevel,
    )

    routing_table = session.get_routes()
    sorted_ids = sorted(routing_table, key=lambda x: x[0].id)

    if args.verbose > 1:
        print 'Routing table:'
        print_routing_table(sorted_ids)
        print

    def find_responsible(a, x):
        '''Find responsible routing item in the circular routing table.
		Find righmost value less then or equal to x.
		And last entry is responsible for [0, a[0]) span.
Ejemplo n.º 4
0
def _link_node(sender, app_data, user_data):
    if nodes.connect(app_data[0], app_data[1]):
        dpg.add_node_link(app_data[0], app_data[1], parent=sender, user_data=app_data)
Ejemplo n.º 5
0
#!/usr/bin/python
# -*- coding: utf-8 -*-

from nodes import connect
from _queue_stats import exec_on_all_workers

if __name__ == '__main__':
    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument('-r', '--remote', help='address of seed node')
    parser.add_argument('-g', '--group', help='elliptics group')
    args = parser.parse_args()

    s = connect([args.remote], [int(args.group)])
    exec_on_all_workers(s, 'queue@clear')