Exemple #1
0
"""

import sys
sys.path.append('gen-py')

from locator.ttypes import Location
from storeserver import remote_call, parser, DEFAULTPORT, SERVICENAME
from location import find_matching_service, str2loc

usage = '''
  python %prog [options] <key>

Looks for a storage node at PEER, either as specified, or 
auto-discovered on the localhost starting from the default 
port. Sends the remote command there, which gets forwarded 
to the actual node that has it.'''

parser.set_usage(usage)
parser.remove_option('--port')

if __name__ == '__main__':
    (options, args) = parser.parse_args()
    if len(args) != 1:
        parser.error("incorrect number of arguments")
    (key,) = args
    if options.peer:
        loc = str2loc(options.peer)
    else:
        loc = find_matching_service(Location('localhost', DEFAULTPORT), SERVICENAME) or sys.exit()
    print remote_call('get', loc, key)
Exemple #2
0
"""

import sys
sys.path.append('gen-py')

from locator.ttypes import Location
from storeserver import remote_call, parser, DEFAULTPORT, SERVICENAME
from location import find_matching_service, str2loc

usage = '''
  python %prog [options] <key> <value>

Looks for a storage node at PEER, either as specified, or 
auto-discovered on the localhost starting from the default 
port. Sends the remote command there, which gets forwarded 
to the actual node that has it.'''

parser.set_usage(usage)
parser.remove_option('--port')

if __name__ == '__main__':
    (options, args) = parser.parse_args()
    if len(args) != 2:
        parser.error("incorrect number of arguments")
    (key, value) = args
    if options.peer:
        loc = str2loc(options.peer)
    else:
        loc = find_matching_service(Location('localhost', DEFAULTPORT), SERVICENAME) or sys.exit()
    remote_call('put', loc, key, value)
Exemple #3
0
sys.path.append('gen-py')

from locator.ttypes import Location
from storeserver import remote_call, parser, DEFAULTPORT, SERVICENAME
from location import find_matching_service, str2loc

usage = '''
  python %prog

Looks for a storage node at PEER, either as specified, or 
auto-discovered on the localhost starting from the default 
port. Sends a bunch of keys for resolution.'''

parser.set_usage(usage)
parser.remove_option('--port')

KEYS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

if __name__ == '__main__':
    (options, args) = parser.parse_args()
    if options.peer:
        loc = str2loc(options.peer)
    else:
        loc = find_matching_service(Location('localhost', DEFAULTPORT), SERVICENAME) or sys.exit()
    for key in KEYS:
        value = remote_call('get', loc, key)
        if value:
            print value
        else:
            print "None received from expected %s" % remote_call('get_node', loc, key)