Exemple #1
0
def put():
    json_data = request.get_json()
    key = json_data['key']
    value = json_data['value']

    timestamp = int(time.time() * 1000000)
    value_b = value.encode()
    value = lattices.LWWPairLattice(timestamp, value_b)
    try:
        kvs_client.put(key, value)
    except UnboundLocalError as e:
        timeout = "TIMEOUT"
        abort(400, description="TIMEOUT of AnnaBellaDB PUT\n".format(e))

    return json.dumps("OK")
Exemple #2
0
kvs_client = client.AnnaTcpClient(args.ip, args.ip, local=True, offset=int(args.nf_id))

ITER_COUNT = 60
WAIT = 1

READ_BOUND = 10
WRITE_BOUND = 1

access_times = []

timestamp = int(time.time()*1000000)
write_counter = 1
str_value = args.ip + "_" + str(write_counter)
byte_value = str_value.encode()
print(byte_value)
value = lattices.LWWPairLattice(timestamp, byte_value)
print("PUT")
try:
    kvs_client.put(args.key, value)
    print("OK")
except UnboundLocalError as e:
    print("TIMEOUT")

##############################################################

time.sleep(2)

print("GET")

state = None
with open('/hydro/anna/client/python/test3_state.txt', 'r') as fin:
Exemple #3
0
parser = argparse.ArgumentParser(description='Client for test2. TODO: a description what this "NF" does in the test2.')
parser.add_argument('ip', type=str, help='IP address of the client.')
parser.add_argument('key', type=str, help='Key that is used to save value.')
args = parser.parse_args()


kvs_client = client.AnnaTcpClient(args.ip, args.ip, local=True)

ITER_COUNT = 60
WAIT = 1

access_times = []

timestamp = int(time.time()*1000000)
value = lattices.LWWPairLattice(timestamp, b'1')
print("PUT")
try:
    kvs_client.put(args.key, value)
    print("OK")
except UnboundLocalError as e:
    print("TIMEOUT")

##############################################################

time.sleep(2)

print("GET")

start_time = time.time()
end_time = time.time()