コード例 #1
0
ファイル: two-server-test.py プロジェクト: jolynch/modata
import coding
import restlib
from runner import ServerManager

manager = ServerManager()
manager.async_start_block_server(1234)
manager.async_start_block_server(1235)

try:
    data_chunks = [str(x) for x in xrange(10)]
    chunks_meta = coding.make_chunk_dicts(data_chunks)

    for chunk in chunks_meta:
        restlib.store(chunk['data'], chunk['digest'], local=False)

    print len(chunks_meta), "items stored"
    success = True
    for chunk in chunks_meta:
        data = restlib.findvalue(chunk['digest'])
        distrib_data = restlib.findvalue(chunk['digest'], local=False)
        if data != chunk['data']:
            print "DATA MISMATCH FOR DIGEST", chunk['digest']

        if distrib_data != chunk['data']:
            success = False
            print "DISTRIB DATA MISMATCH FOR DIGEST"
            print "Expecting", chunk['data'], "got", distrib_data
        
    if success:
        print len(chunks_meta), "items retrieved sucessfully"
        
コード例 #2
0
ファイル: start_cluster.py プロジェクト: jolynch/modata
from runner import ServerManager
import time

NUMSERVERS = 10

def help():
    result =  " show_servers      | ss         Show available servers\n"
    result += " bring_up [port]   | bu [port]  Bring up a server\n"
    result += " kill [port]       | k [port]   Kill a server\n"
    result += " quit              | q          Quit\n"
    return result

if __name__ == "__main__":
    try:
        manager = ServerManager()
        print "Done with starting manager"
        ports = [1234]
        manager.async_start_block_server(1234, 1337)
        print "Spun up primary"

        for i in range(NUMSERVERS):
            manager.async_start_block_server(1235 + i)
            ports.append(1235 + i)

        while 1:
            inp = raw_input("(modata) ")
            if inp == "help" or inp == "h":
                print help()
            elif inp == "bring_up" or inp == "bu":
                port = int(raw_input("port? "))
                manager.async_start_block_server(port)
コード例 #3
0
import coding
import restlib
from runner import ServerManager

manager = ServerManager()

def verify_chunks(chunks_meta):
    for chunk in chunks_meta:
        distrib_data = restlib.findvalue(chunk['digest'], local=False)
        if distrib_data != chunk['data']:
            return False
    return True

try:
    n = 20
    ports = range(1000, 1000+n)
    for port in ports:
        manager.async_start_block_server(port)

    data_chunks = [str(x) for x in xrange(10)]
    chunks_meta = coding.make_chunk_dicts(data_chunks)
    
    for chunk in chunks_meta:
        # TODO: pick a random server
        restlib.store(chunk['data'], chunk['digest'], local=False)

    verify_chunks(chunks_meta)

    # Don't kill ports 0, who is us
    for i, port in enumerate(ports[1:]):
        chunks_all_good = verify_chunks(chunks_meta)