Resource Manager

Definition of resource managemer.

This module defines the resource manager, which composes the SeQUeNCe resource management module. The manager uses a memory manager and rule manager to track memories and control entanglement operations, respectively. This module also defines the message type used by the resource manager.

class src.resource_management.resource_manager.ResourceManager(owner: QuantumRouter, memory_array_name: str)

Class to define the resource manager.

The resource manager uses a memory manager to track memory states for the entanglement protocols. It also uses a rule manager to direct the creation and operation of entanglement protocols.

name

label for manager instance.

Type:

str

owner

node that resource manager is attached to.

Type:

QuantumRouter

memory_manager

internal memory manager object.

Type:

MemoryManager

rule_manager

internal rule manager object.

Type:

RuleManager

pending_protocols

list of protocols awaiting a response for a remote resource request.

Type:

List[Protocol]

waiting_protocols

list of protocols awaiting a request from a remote protocol.

Type:

List[Protocol]

expire(rule: Rule) None

Method to remove expired rule.

Will update rule in rule manager. Will also update and modify protocols connected to the rule (if they have already been created).

Parameters:

rule (Rule) – rule to remove.

load(rule: Rule) bool

Method to load rules for entanglement management.

Attempts to add rules to the rule manager. Will automatically execute rule action if conditions met.

Parameters:

rule (Rule) – rule to load.

Returns:

if rule was loaded successfully.

Return type:

bool

memory_expire(memory: Memory)

Method to receive memory expiration events.

received_message(src: str, msg: ResourceManagerMessage) None

Method to receive resoruce manager messages.

Messages come in 4 types, as detailed in the ResourceManagerMessage class.

Parameters:
release_remote_memory(dst: str, memory_id: str) None

Method to release memories on distant nodes.

Release the remote memory ‘memory_id’ on the node ‘dst’. The entanglement protocol of remote memory was paired with the local protocol ‘init_protocol’, but local protocol becomes invalid. The resource manager needs to notify the remote node to release the occupied memory.

Parameters:
  • dst (str) – name of destination node.

  • memory_id (str) – name of memory to release.

release_remote_protocol(dst: str, protocol: str) None

Method to release protocols from memories on distant nodes.

Release the remote protocol ‘protocol’ on the remote node ‘dst’. The local protocol was paired with the remote protocol but local protocol becomes invalid. The resource manager needs to notify the remote node to cancel the paired protocol.

Parameters:
  • dst (str) – name of the destination node.

  • protocol (str) – name of protocol to release on node.

send_request(protocol: EntanglementProtocol, req_dst: str, req_condition_func: RequestConditionFunc, req_args: Arguments)

Method to send protocol request to another node.

Send the request to pair the local ‘protocol’ with the protocol on the remote node ‘req_dst’. The function req_condition_func describes the desired protocol.

Parameters:
  • protocol (EntanglementProtocol) – protocol sending the request.

  • req_dst (str) – name of destination node.

  • req_condition_func (Callable[[List[EntanglementProtocol]], EntanglementProtocol]) – function used to evaluate condition on distant node.

  • req_args (Dict[str, Any]) – arguments for req_cond_func.

update(protocol: EntanglementProtocol, memory: Memory, state: str) None

Method to update state of memory after completion of entanglement management protocol.

Parameters:
  • protocol (EntanglementProtocol) – concerned protocol.

  • memory (Memory) – memory to update.

  • state (str) – new state for the memory.

Side Effects:

May modify memory state, and modify any attached protocols.

class src.resource_management.resource_manager.ResourceManagerMessage(msg_type: ResourceManagerMsgType, **kwargs)

Message for resource manager communication.

There are four types of ResourceManagerMessage:

  • REQUEST: request eligible protocols from remote resource manager to pair entanglement protocols.

  • RESPONSE: approve or reject received request.

  • RELEASE_PROTOCOL: release the protocol on the remote node

  • RELEASE_MEMORY: release the memory on the remote node

ini_protocol_name

name of protocol that creates the original REQUEST message.

Type:

str

request_fun

a function using ResourceManager to search eligible protocols on remote node (if msg_type == REQUEST).

Type:

func

is_approved

acceptance/failure of condition function (if msg_type == RESPONSE).

Type:

bool

paired_protocol

protocol that is paired with ini_protocol (if msg-type == RESPONSE).

Type:

str

class src.resource_management.resource_manager.ResourceManagerMsgType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Available message types for the ResourceManagerMessage.