journal#

The operation journal: every state-changing settings call, in order.

The journal records operations (value writes, commands and object changes), not copies of the server state. It serves two purposes:

  • undo / redo of value writes, using the value read just before each write;

  • catching up a standby session that is not up to date with the active session, starting from the newest checkpoint.

Classes:

CommandOp(path, command[, args, ...])

A command executed with execute_cmd.

Journal(*[, max_ops])

Ordered, bounded record of state-changing operations with undo / redo.

ObjectOp(method, path[, args, seq, created_at])

A structural change: create, delete, rename or a list resize.

SetOp(path, new_value[, old_value, ...])

A value written with set_var.

class ansys.fluent.core.resilient.engine.journal.CommandOp(path, command, args=<factory>, irreversible=False, checkpoint=None, seq=-1, created_at=<factory>)#

Bases: object

A command executed with execute_cmd.

Attributes:

args

checkpoint

command

created_at

full_path

Return the command path including the command name.

irreversible

kind

path

seq

Methods:

describe()

Return a one-line description of the operation.

to_dict()

Return the operation as a plain dictionary.

args: dict[str, Any]#
checkpoint: str | None = None#
command: str#
created_at: float#
describe()#

Return a one-line description of the operation.

property full_path: str#

Return the command path including the command name.

irreversible: bool = False#
kind: ClassVar[str] = 'command'#
path: str#
seq: int = -1#
to_dict()#

Return the operation as a plain dictionary.

class ansys.fluent.core.resilient.engine.journal.Journal(*, max_ops=10000)#

Bases: object

Ordered, bounded record of state-changing operations with undo / redo.

Parameters:
max_opsint, optional

Maximum number of operations kept. When exceeded, the oldest operations are dropped (replay from before that point is then impossible and a failover requires a newer checkpoint).

Methods:

__init__(*[, max_ops])

can_redo()

Return whether there is an undone operation to redo.

can_undo()

Return whether there is an operation to undo.

live_since(seq)

Return the live operations with a sequence number of at least seq.

record(op)

Append an operation, discarding any undone operations after the cursor.

redo(write)

Re-apply the most recently undone value write.

to_script()

Return the live operations as plain dictionaries.

truncate(seq)

Forget every operation with a sequence number of at least seq.

undo(write)

Undo the most recent value write by writing back its previous value.

Attributes:

next_seq

Sequence number the next recorded operation receives.

operations

Return the live operations (oldest first).

__init__(*, max_ops=10000)#
can_redo()#

Return whether there is an undone operation to redo.

can_undo()#

Return whether there is an operation to undo.

live_since(seq)#

Return the live operations with a sequence number of at least seq.

Raises:
ResilientError

If operations after seq were already dropped from the journal.

property next_seq: int#

Sequence number the next recorded operation receives.

property operations: list[SetOp | CommandOp | ObjectOp]#

Return the live operations (oldest first).

record(op)#

Append an operation, discarding any undone operations after the cursor.

redo(write)#

Re-apply the most recently undone value write.

Raises:
ResilientError

If there is nothing to redo.

to_script()#

Return the live operations as plain dictionaries.

truncate(seq)#

Forget every operation with a sequence number of at least seq.

undo(write)#

Undo the most recent value write by writing back its previous value.

Raises:
ResilientError

If there is nothing to undo, if the most recent operation is not a value write, or if its previous value was not captured.

class ansys.fluent.core.resilient.engine.journal.ObjectOp(method, path, args=(), seq=-1, created_at=<factory>)#

Bases: object

A structural change: create, delete, rename or a list resize.

Attributes:

Methods:

describe()

Return a one-line description of the operation.

to_dict()

Return the operation as a plain dictionary.

args: tuple[Any, ...] = ()#
created_at: float#
describe()#

Return a one-line description of the operation.

kind: ClassVar[str] = 'object'#
method: str#
path: str#
seq: int = -1#
to_dict()#

Return the operation as a plain dictionary.

class ansys.fluent.core.resilient.engine.journal.SetOp(path, new_value, old_value=None, old_value_known=False, seq=-1, created_at=<factory>)#

Bases: object

A value written with set_var.

Attributes:

created_at

kind

new_value

old_value

old_value_known

Whether old_value was read before the write (required for undo).

path

seq

Methods:

describe()

Return a one-line description of the operation.

to_dict()

Return the operation as a plain dictionary.

created_at: float#
describe()#

Return a one-line description of the operation.

kind: ClassVar[str] = 'set'#
new_value: Any#
old_value: Any = None#
old_value_known: bool = False#

Whether old_value was read before the write (required for undo).

path: str#
seq: int = -1#
to_dict()#

Return the operation as a plain dictionary.