Rule Manager

Definition of rule manager.

This module defines the rule manager, which is used by the resource manager to instantiate and control entanglement protocols. This is achieved through rules (also defined in this module), which if met define a set of actions to take.

class src.resource_management.rule_manager.Rule(priority: int, action: Callable[[List[MemoryInfo], Dict[str, Any]], Tuple[EntanglementProtocol, List[str], List[Callable[[EntanglementProtocol], bool]]]], condition: (typing.Callable[[ForwardRef('MemoryInfo'), ForwardRef('MemoryManager'), typing.Dict[str, typing.Any]], typing.List[ForwardRef('MemoryInfo')]],), action_args: Dict[str, Any], condition_args: Dict[str, Any])

Definition of rule for the rule manager.

Rule objects are installed on and interacted with by the rule manager.

priority

priority of the rule, used as a tiebreaker when conditions of multiple rules are met.

Type:

int

action

action to take when rule condition is met.

Type:

Callable[[List[“MemoryInfo”]], Tuple[“Protocol”, List[“str”], List[Callable[[“Protocol”], bool]]]]

condition

condition required by rule.

Type:

Callable[[“MemoryInfo”, “MemoryManager”], List[“MemoryInfo”]]

protocols

protocols created by rule.

Type:

List[Protocols]

rule_manager

reference to rule manager object where rule is installed.

Type:

RuleManager

reservation

associated reservation.

Type:

Reservation

do(memories_info: List[MemoryInfo]) None

Method to perform rule activation and send requirements to other nodes.

Parameters:

memories_info (List[MemoryInfo]) – list of memory infos for memories meeting requirements.

is_valid(memory_info: MemoryInfo) List[MemoryInfo]

Method to check for memories meeting condition.

Parameters:

memory_info (MemoryInfo) – memory info object to test.

Returns:

list of memory info objects meeting requirements of rule.

Return type:

List[memory_info]

set_rule_manager(rule_manager: RuleManager) None

Method to assign rule to a rule manager.

Parameters:

rule_manager (RuleManager) – manager to assign.

class src.resource_management.rule_manager.RuleManager

Class to manage and follow installed rules.

The RuleManager checks available rules when the state of a memory is updated. Rules that are met have their action executed by the rule manager.

rules

List of installed rules.

Type:

List[Rules]

resource_manager

reference to the resource manager using this rule manager.

Type:

ResourceManager

expire(rule: Rule) List[EntanglementProtocol]

Method to remove expired protocol.

Parameters:

rule (Rule) – rule to remove.

Returns:

list of protocols created by rule (if any).

Return type:

List[EntanglementProtocol]

load(rule: Rule) bool

Method to load rule into ruleset.

Tries to insert rule into internal rules list based on priority.

Parameters:

rule (Rule) – rule to insert.

Returns:

success of rule insertion.

Return type:

bool

set_resource_manager(resource_manager: ResourceManager)

Method to set overseeing resource manager.

Parameters:

resource_manager (ResourceManager) – resource manager to attach to.