libmuscle.manager.snapshot_registry module
- class libmuscle.manager.snapshot_registry.SnapshotNode(num: int, instance: ~ymmsl.identity.Reference, snapshot: ~libmuscle.snapshot.SnapshotMetadata, peers: ~typing.FrozenSet[~ymmsl.identity.Reference], consistent_peers: ~typing.Dict[~ymmsl.identity.Reference, ~typing.List[~libmuscle.manager.snapshot_registry.SnapshotNode]] = <factory>)[source]
Bases:
object
Represents a node in the snapshot graph.
- num
The number of the snapshot. Unique for this instance. Later snapshots always have a higher num.
- Type:
- instance
Which instance this is a snapshot of.
- Type:
ymmsl.identity.Reference
- snapshot
The snapshot metadata reported by the instance.
- peers
The set of peers that the instance is connected to.
- Type:
FrozenSet[ymmsl.identity.Reference]
- consistent_peers
Keeps track of snapshots per peer that are consistent with this one.
- Type:
Dict[ymmsl.identity.Reference, List[libmuscle.manager.snapshot_registry.SnapshotNode]]
- consistent_peers: Dict[Reference, List[SnapshotNode]]
- do_consistency_check(peer_node: SnapshotNode, connections: List[Tuple[Identifier, Identifier, _ConnectionInfo]]) bool [source]
Check if the snapshot of the peer is consistent with us.
When the peer snapshot is consistent, adds it to our list of consistent peer snapshots (in
consistent_peers
) and vice versa.- Parameters:
peer_node – Snapshot of one of our peers
connections – All connections from our instance to the peer instance
- Returns:
True iff the peer snapshot is consistent with ours.
- instance: Reference
- snapshot: SnapshotMetadata
- class libmuscle.manager.snapshot_registry.SnapshotRegistry(config: PartialConfiguration, snapshot_folder: Path, topology_store: TopologyStore)[source]
Bases:
Thread
Registry of all snapshots taken by instances.
Current snapshots are stored in a graph. Every node represents a snapshot taken by an instance (see
SnapshotNode
). When snapshots from peer instances are consistent, the nodes are connected to each other.This class manages the snapshot nodes. New snapshots are registered through
register_snapshot()
.- register_snapshot(instance: Reference, snapshot: SnapshotMetadata) None [source]
Register a new snapshot.
- Parameters:
instance – The instance that created the snapshot
snapshot – Metadata describing the snapshot
- libmuscle.manager.snapshot_registry.calc_consistency(num1: int, num2: int, first_is_sent: bool, num2_is_restart: bool) bool [source]
Calculate consistency of message counts.
- Parameters:
num1 – message count of instance 1
num2 – message count of instance 2
first_is_sent – True iff instance 1 is sending messages over this conduit
num2_is_restart – True iff the snapshot of num2 is a full restart
- Returns:
True iff the two message counts are consistent
- libmuscle.manager.snapshot_registry.calc_consistency_list(num1: List[int], num2: List[int], first_is_sent: bool, num2_is_restart: bool) bool [source]
Calculate consistency of message counts.
- Parameters:
num1 – message count of instance 1
num2 – message count of instance 2
first_is_sent – True iff instance 1 is sending messages over this conduit
num2_is_restart – True iff the snapshot of num2 is a full restart
- Returns:
True iff the two message counts are consistent
- libmuscle.manager.snapshot_registry.safe_get(lst: List[_T], index: int, default: _T) _T [source]
Get an item from the list, returning default when it does not exist.
- Parameters:
lst – List to get the item from
index – Which item to get, should be >= 0
default – Value to return when hitting an IndexError