-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfunctions.py
50 lines (38 loc) · 1.07 KB
/
functions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
def add_video(videos, lv, name, keepers, user_id=None, path=None, size=None):
lv.acquire()
videos[name] = [keepers, user_id, path, size]
lv.release()
def add_node(keepers, lk, node_ip, ports, is_alive):
lk.acquire()
keepers[node_ip] = [ports, is_alive]
lk.release()
def add_port(keepers, lk, node_ip, port_no, is_busy):
lk.acquire()
l = keepers[node_ip]
l[0][port_no] = is_busy
keepers[node_ip] = l
lk.release()
def start_replicate(videos, lv, name, node_ip):
lv.acquire()
l = videos[name]
l[0][node_ip] = False
videos[name] = l
lv.release()
def finish_replicate(videos, lv, name, node_ip):
lv.acquire()
l = videos[name]
l[0][node_ip] = True
videos[name] = l
lv.release()
def set_alive(keepers, lk, node_ip, is_alive):
lk.acquire()
l = keepers[node_ip]
l[-1] = is_alive
keepers[node_ip] = l
lk.release()
def set_busy(keepers, lk, node_ip, port_no, is_busy):
lk.acquire()
l = keepers[node_ip]
l[0][str(port_no)] = is_busy
keepers[node_ip] = l
lk.release()