Skip to content

Documentation for Fccandidateselector Module

FCCandidateSelector

Bases: CandidateSelector

Candidate selector for fully-connected (FC) topologies.

In a fully-connected network, all available candidates are accepted without applying any filtering criteria. This selector simply returns all collected candidates.

Attributes:

Name Type Description
candidates list

List of all discovered candidate nodes.

candidates_lock Locker

Lock to ensure thread-safe access to the candidate list.

Methods:

Name Description
set_config

No-op for fully-connected mode.

add_candidate

Adds a new candidate to the list.

select_candidates

Returns all currently stored candidates.

remove_candidates

Clears the candidate list.

any_candidate

Returns True if there is at least one candidate.

Inherits from

CandidateSelector: Base class interface for candidate selection logic.

Source code in nebula/core/situationalawareness/discovery/candidateselection/fccandidateselector.py
 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
51
52
53
54
55
56
57
58
class FCCandidateSelector(CandidateSelector):
    """
    Candidate selector for fully-connected (FC) topologies.

    In a fully-connected network, all available candidates are accepted
    without applying any filtering criteria. This selector simply returns
    all collected candidates.

    Attributes:
        candidates (list): List of all discovered candidate nodes.
        candidates_lock (Locker): Lock to ensure thread-safe access to the candidate list.

    Methods:
        set_config(config): No-op for fully-connected mode.
        add_candidate(candidate): Adds a new candidate to the list.
        select_candidates(): Returns all currently stored candidates.
        remove_candidates(): Clears the candidate list.
        any_candidate(): Returns True if there is at least one candidate.

    Inherits from:
        CandidateSelector: Base class interface for candidate selection logic.
    """

    def __init__(self):
        self.candidates = []
        self.candidates_lock = Locker(name="candidates_lock")

    async def set_config(self, config):
        pass

    async def add_candidate(self, candidate):
        self.candidates_lock.acquire()
        self.candidates.append(candidate)
        self.candidates_lock.release()

    async def select_candidates(self):
        """
        In Fully-Connected topology all candidates should be selected
        """
        self.candidates_lock.acquire()
        cdts = self.candidates.copy()
        self.candidates_lock.release()
        return (cdts, [])

    async def remove_candidates(self):
        self.candidates_lock.acquire()
        self.candidates = []
        self.candidates_lock.release()

    async def any_candidate(self):
        self.candidates_lock.acquire()
        any = True if len(self.candidates) > 0 else False
        self.candidates_lock.release()
        return any

select_candidates() async

In Fully-Connected topology all candidates should be selected

Source code in nebula/core/situationalawareness/discovery/candidateselection/fccandidateselector.py
40
41
42
43
44
45
46
47
async def select_candidates(self):
    """
    In Fully-Connected topology all candidates should be selected
    """
    self.candidates_lock.acquire()
    cdts = self.candidates.copy()
    self.candidates_lock.release()
    return (cdts, [])