Skip to content

Commit 83c28d8

Browse files
add/remove comments
1 parent 6fb66ca commit 83c28d8

File tree

12 files changed

+24
-152
lines changed

12 files changed

+24
-152
lines changed

nebula/core/situationalawareness/README.txt

Lines changed: 0 additions & 127 deletions
This file was deleted.

nebula/core/situationalawareness/awareness/sanetwork/neighborpolicies/distanceneighborpolicy.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def __init__(self):
1616
self.nodes_known_lock = Locker(name="nodes_known_lock", async_lock=True)
1717
self.nodes_distances: dict[str, tuple[float, tuple[float, float]]] = None
1818
self.nodes_distances_lock = Locker("nodes_distances_lock", async_lock=True)
19+
self._verbose = False
1920

2021
async def set_config(self, config):
2122
"""
@@ -25,7 +26,7 @@ async def set_config(self, config):
2526
config[2] -> self addr
2627
config[3] -> stricted_topology
2728
"""
28-
logging.info("Initializing Random Topology Neighbor Policy")
29+
logging.info("Initializing Distance Topology Neighbor Policy")
2930
async with self.neighbors_lock:
3031
self.neighbors = config[0]
3132
for addr in config[1]:
@@ -51,7 +52,7 @@ async def need_more_neighbors(self):
5152
if distancia < self.MAX_DISTANCE_THRESHOLD
5253
}
5354
available_nodes = closest_nodes.difference(self.neighbors)
54-
logging.info(f"Available neighbors based on distance: {available_nodes}")
55+
if self._verbose: logging.info(f"Available neighbors based on distance: {available_nodes}")
5556
return len(available_nodes) > 0
5657

5758
async def accept_connection(self, source, joining=False):
@@ -116,12 +117,12 @@ async def update_neighbors(self, node, remove=False):
116117
if remove:
117118
try:
118119
self.neighbors.remove(node)
119-
logging.info(f"Remove neighbor | addr: {node}")
120+
if self._verbose: logging.info(f"Remove neighbor | addr: {node}")
120121
except KeyError:
121122
pass
122123
else:
123124
self.neighbors.add(node)
124-
logging.info(f"Add neighbor | addr: {node}")
125+
if self._verbose: logging.info(f"Add neighbor | addr: {node}")
125126

126127
async def get_posible_neighbors(self):
127128
"""Return set of posible neighbors to connect to."""
@@ -132,9 +133,9 @@ async def get_posible_neighbors(self):
132133
for nodo_id, (distancia, _) in self.nodes_distances.items()
133134
if distancia < self.MAX_DISTANCE_THRESHOLD-20
134135
}
135-
logging.info(f"Closest nodes: {closest_nodes}, neighbors: {self.neighbors}")
136+
if self._verbose: logging.info(f"Closest nodes: {closest_nodes}, neighbors: {self.neighbors}")
136137
available_nodes = closest_nodes.difference(self.neighbors)
137-
logging.info(f"Available neighbors based on distance: {available_nodes}")
138+
if self._verbose: logging.info(f"Available neighbors based on distance: {available_nodes}")
138139
return available_nodes
139140

140141
async def any_leftovers_neighbors(self):
@@ -150,7 +151,7 @@ async def any_leftovers_neighbors(self):
150151
if distancia > self.MAX_DISTANCE_THRESHOLD
151152
}
152153
distant_nodes = self.neighbors.intersection(distant_nodes)
153-
logging.info(f"Distant neighbors based on distance: {distant_nodes}")
154+
if self._verbose: logging.info(f"Distant neighbors based on distance: {distant_nodes}")
154155
return len(distant_nodes) > 0
155156

156157
async def get_neighbors_to_remove(self):
@@ -163,7 +164,7 @@ async def get_neighbors_to_remove(self):
163164
if distancia > self.MAX_DISTANCE_THRESHOLD
164165
}
165166
distant_nodes = self.neighbors.intersection(distant_nodes)
166-
logging.info(f"Remove neighbors based on distance: {distant_nodes}")
167+
if self._verbose: logging.info(f"Remove neighbors based on distance: {distant_nodes}")
167168
return distant_nodes
168169

169170
def stricted_topology_status(stricted_topology: bool):

nebula/core/situationalawareness/awareness/sanetwork/neighborpolicies/fcneighborpolicy.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ def __init__(self):
1111
self.addr = None
1212
self.neighbors_lock = Locker(name="neighbors_lock")
1313
self.nodes_known_lock = Locker(name="nodes_known_lock")
14+
self._verbose = False
1415

1516
async def need_more_neighbors(self):
1617
"""
@@ -108,12 +109,12 @@ async def update_neighbors(self, node, remove=False):
108109
if remove:
109110
try:
110111
self.neighbors.remove(node)
111-
logging.info(f"Remove neighbor | addr: {node}")
112+
if self._verbose: logging.info(f"Remove neighbor | addr: {node}")
112113
except KeyError:
113114
pass
114115
else:
115116
self.neighbors.add(node)
116-
logging.info(f"Add neighbor | addr: {node}")
117+
if self._verbose: logging.info(f"Add neighbor | addr: {node}")
117118
self.neighbors_lock.release()
118119

119120
async def any_leftovers_neighbors(self):

nebula/core/situationalawareness/awareness/sanetwork/neighborpolicies/idleneighborpolicy.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ def __init__(self):
1111
self.addr = None
1212
self.neighbors_lock = Locker(name="neighbors_lock")
1313
self.nodes_known_lock = Locker(name="nodes_known_lock")
14+
self._verbose = False
1415

1516
async def need_more_neighbors(self):
1617
"""
@@ -108,12 +109,12 @@ async def update_neighbors(self, node, remove=False):
108109
if remove:
109110
try:
110111
self.neighbors.remove(node)
111-
logging.info(f"Remove neighbor | addr: {node}")
112+
if self._verbose: logging.info(f"Remove neighbor | addr: {node}")
112113
except KeyError:
113114
pass
114115
else:
115116
self.neighbors.add(node)
116-
logging.info(f"Add neighbor | addr: {node}")
117+
if self._verbose: logging.info(f"Add neighbor | addr: {node}")
117118
self.neighbors_lock.release()
118119

119120
async def any_leftovers_neighbors(self):

nebula/core/situationalawareness/awareness/sanetwork/neighborpolicies/ringneighborpolicy.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def __init__(self):
1616
self.addr = ""
1717
self._excess_neighbors_removed = set()
1818
self._excess_neighbors_removed_lock = Locker("excess_neighbors_removed_lock", async_lock=True)
19+
self._verbose = False
1920

2021
async def need_more_neighbors(self):
2122
self.neighbors_lock.acquire()
@@ -33,7 +34,7 @@ async def set_config(self, config):
3334
"""
3435
logging.info("Initializing Ring Topology Neighbor Policy")
3536
self.neighbors_lock.acquire()
36-
logging.info(f"neighbors: {config[0]}")
37+
if self._verbose: logging.info(f"neighbors: {config[0]}")
3738
self.neighbors = config[0]
3839
self.neighbors_lock.release()
3940
for addr in config[1]:

nebula/core/situationalawareness/awareness/sanetwork/neighborpolicies/starneighborpolicy.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ def __init__(self):
1111
self.neighbors_lock = Locker(name="neighbors_lock")
1212
self.nodes_known_lock = Locker(name="nodes_known_lock")
1313
self.addr = ""
14+
self._verbose = False
1415

1516
async def need_more_neighbors(self):
1617
self.neighbors_lock.acquire()

nebula/core/situationalawareness/awareness/sautils/sacommand.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class SACommandType(Enum):
99
CONNECTIVITY = "Connectivity"
1010
AGGREGATION = "Aggregation"
1111

12-
#TODO separar por tipos de commands
12+
#TODO make differents parts
1313
class SACommandAction(Enum):
1414
IDLE = "idle"
1515
DISCONNECT = "disconnect"

nebula/core/situationalawareness/awareness/sautils/sasystemmonitor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def __init__(self):
2727
# Try to initialize NVIDIA library if available
2828
try:
2929
nvmlInit()
30-
self.gpu_available = True # Flag to check if GPU is available
30+
self.gpu_available = True # Flag to check if GPU is available
3131
except Exception:
3232
self.gpu_available = False # If not, set GPU availability to False
3333
self._initialized = True

nebula/core/situationalawareness/discovery/candidateselection/distcandidateselector.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66

77
class DistanceCandidateSelector(CandidateSelector):
88
MAX_DISTANCE_THRESHOLD = 200
9-
MIN_DISTANCE_THRESHOLD = 100
109

1110
def __init__(self):
1211
self.candidates = []
1312
self.candidates_lock = Locker(name="candidates_lock", async_lock=True)
1413
self.nodes_distances: dict[str, tuple[float, tuple[float, float]]] = None
1514
self.nodes_distances_lock = Locker("nodes_distances_lock", async_lock=True)
15+
self._verbose = False
1616

1717
async def set_config(self, config):
1818
await EventManager.get_instance().subscribe_addonevent(GPSEvent, self._udpate_distances)
@@ -29,13 +29,12 @@ async def add_candidate(self, candidate):
2929
async def select_candidates(self):
3030
async with self.candidates_lock:
3131
async with self.nodes_distances_lock:
32-
# Filtrar candidatos cuya ID está en nodes_distances y su distancia < MAX_DISTANCE_THRESHOLD
3332
nodes_available = [
3433
candidate for candidate in self.candidates
3534
if candidate[0] in self.nodes_distances and
3635
self.nodes_distances[candidate[0]][0] < self.MAX_DISTANCE_THRESHOLD
3736
]
38-
logging.info(f"Nodes availables: {nodes_available}")
37+
if self._verbose: logging.info(f"Nodes availables: {nodes_available}")
3938
return (nodes_available, [])
4039

4140
async def remove_candidates(self):

nebula/core/situationalawareness/discovery/candidateselection/ringcandidateselector.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ async def add_candidate(self, candidate):
1717
To avoid topology problems select 1st candidate found
1818
"""
1919
self.candidates_lock.acquire()
20-
# if len(self._candidates) == 0:
2120
self._candidates.append(candidate)
22-
# else:
23-
# self._rejected_candidates.append(candidate)
2421
self.candidates_lock.release()
2522

2623
async def select_candidates(self):

0 commit comments

Comments
 (0)