def test_init_membership_list(): num_proc = 4 hash_size = 3 # to determine all possible keys in the ring Q = 2 # size of 1 virtual node membership_info = partitioning.init_membership_list(num_proc, hash_size, Q) print(membership_info)
def init_server(params, network_params): membership_information = init_membership_list(params) logging.basicConfig(filename='dynamo_node.log', level=logging.DEBUG) logger = logging.getLogger('dynamo_node') logger.setLevel(logging.DEBUG) logger.debug("Testing...") start_db_background_multiprocess(params, membership_information, network_params, logger)
def test_get_preference_list(): num_proc = 4 hash_size = 3 # to determine all possible keys in the ring Q = 2 # size of 1 virtual node N = 2 params = Params(dict(num_proc=num_proc, hash_size=hash_size, Q=Q, N=N)) membership_info = partitioning.init_membership_list(params) print(membership_info) print(0, partitioning.get_preference_list(n_id=0, membership_info=membership_info, params=params)) print(1, partitioning.get_preference_list(n_id=1, membership_info=membership_info, params=params)) print(2, partitioning.get_preference_list(n_id=2, membership_info=membership_info, params=params)) print(3, partitioning.get_preference_list(n_id=3, membership_info=membership_info, params=params))
def index(): global processes_future logging.basicConfig(filename='simulator.log', level=logging.INFO) logger = logging.getLogger('simulator.log') form = CombinedForm() message = "" if form.validate_on_submit(): message = "Started Dynamo" params = Params({ 'num_proc': form.dynamo_form.num_proc.data, 'hash_size': form.dynamo_form.hash_size.data, 'Q': form.dynamo_form.Q.data, 'N': form.dynamo_form.N.data, 'R': form.dynamo_form.R.data, 'W': form.dynamo_form.W.data, 'w_timeout': form.dynamo_form.w_timeout.data, 'r_timeout': form.dynamo_form.r_timeout.data, 'gossip': form.dynamo_form.gossip.data, 'update_failure_on_rpcs': False }) print(params) membership_information = init_membership_list(params) network_params = NetworkParams({ 'latency': form.network_form.latency.data, 'randomize_latency': form.network_form.randomize_latency.data }) processes_future = start_db_background(params, membership_information, network_params, wait=True, start_port=START_PORT, logger=logger) session['server_name'] = form.dynamo_form.server_name.data session['params'] = params.__dict__ session['network_params'] = network_params.__dict__ session['membership_information'] = membership_information return redirect(url_for('client')) return render_template('index.html', form=form, message=message)
params = { 'num_proc': 8, 'hash_size': 8, # 2^3 = 8 'Q': 16, # 'N': 4, 'w_timeout': 2, 'r_timeout': 2, 'R': 1, 'W': 3, 'gossip': False } network_params = {'latency': 10, 'randomize_latency': False, 'drop_prob': 0} params = Params(params) network_params = NetworkParams(network_params) membership_information = init_membership_list(params) processes_future = start_db_background(params, membership_information, network_params, wait=True, start_port=START_PORT) def run_multiple_get(total, num_requests, get_durations): for i in tqdm(range(total // num_requests)): requests = [client_get] * num_requests requests_params = [{ 'port': get_start_port(), 'client_id': CLIENT_ID, 'key': randint(0, 2**params.hash_size - 1)
def main(): """ This tests that the get and put operations are working properly. """ logging.basicConfig(filename='get_put.log', level=logging.DEBUG) logger = logging.getLogger('get_put.log') # start server params = { 'num_proc' : 8, 'hash_size': 8, # 2^3 = 8 'Q' : 2, # 'N' : 2, # actually N-1, excluding coordinator node 'w_timeout': 2, 'r_timeout': 2, 'R': 2, 'W': 2, 'gossip': False, 'update_failure_on_rpcs': True } network_params = { 'latency': 0, 'randomize_latency': False, 'drop_prob': 0 } print("constructing...") params = Params(params) membership_information = init_membership_list(params) network_params = NetworkParams(network_params) server = start_db_background(params, membership_information, network_params, num_tasks=2, logger=logger) time.sleep(1) # fire client request ports = [2333,2334,2335,2336] start_node = 3 # let's hit node 3 with this put request key = 2 # this should go into node 0 val = "2" key2 = 7 # this should go into node 3 val2 = "7" port = ports[start_node] client_put(port, 0, key, val) client_put(port, 0, key2, val2) mem0, repmem0 = client_get_memory(ports[0]) mem1, repmem1 = client_get_memory(ports[1]) mem2, repmem2 = client_get_memory(ports[2]) mem3, repmem3 = client_get_memory(ports[3]) s = time.time() response = client_get(port, 0, key) e = time.time() print(f"GET {e - s} secs") print(f"Get response {response}") assert response.items[0].val == val context = response.items[0].context response = client_get(port, 0, key2) assert response.items[0].val == val2 # Check clock count updation on passing valid context obtained from GET s = time.time() client_put(port, 0, key, val2, context=context) e = time.time() print(f"PUT {e - s} secs") response = client_get(port, 0, key) assert response.items[0].val == val2 assert response.items[0].context.clock[0].count == 2 print("\n-------Test get_put passed--------\n")