patroni.dcs.raft module
- class _patroni.dcs.raft.DynMemberSyncObj(_selfAddress: str | None, partnerAddrs: Collection[ str], conf: SyncObjConf, retry_timeout: int = 10) View on GitHub
-
Bases:
SyncObj
+- __init\\__(selfAddress: str | None, partnerAddrs: Collection[ str], conf: SyncObjConf, retry_timeout: int = 10) → None View on GitHub
-
Main SyncObj class, you should inherit your own class from it. +
- Parameters
-
+
- onTick(_timeToWait: float = 0.0) View on GitHub
-
+
- getMembers(args: Any, callback: Callable[[ Any, Any], Any]) → None View on GitHub
- class _patroni.dcs.raft.KVStoreTTL(_on_ready: Callable[[…], Any] | None, on_set: Callable[[ str, Dict[ str, Any]], None] | None, on_delete: Callable[[ str], None] | None, **config: Any) View on GitHub
-
Bases:
DynMemberSyncObj
+- __check_requirements(_**kwargs: Any_) → bool
-
+
- \__expire_keys() → None
-
+
- __init\\__(on_ready: Callable[[…], Any] | None, on_set: Callable[[ str, Dict[ str, Any]], None] | None, on_delete: Callable[[ str], None] | None, **config: Any) → None View on GitHub
-
Main SyncObj class, you should inherit your own class from it. +
- Parameters
-
+
- __pop(_key: str_) → None
-
+
- __values_match(_new: Dict[ str, Any]_) → bool
-
+
- _autoTickThread() → None View on GitHub
-
+
- delete(_key: str, recursive: bool = False, **kwargs: Any) → bool View on GitHub
-
+
- delete_v0(_key: str, recursive: bool = False, **kwargs: Any) → bool View on GitHub
-
+
- expire(_key: str, value: Dict[ str, Any], callback: Callable[[…], Any] | None = None) → None View on GitHub
-
+
- expire_v0(_key: str, value: Dict[ str, Any], callback: Callable[[…], Any] | None = None) → None View on GitHub
-
+
- onTick(_timeToWait: float = 0.0) → None View on GitHub
-
+
- set(_key: str, value: Dict[ str, Any], **kwargs: Any) → bool | Dict[ str, Any] View on GitHub
-
+
- set_v0(_key: str, value: Dict[ str, Any], **kwargs: Any) → bool | Dict[ str, Any] View on GitHub
-
+
- delete(key: str, recursive: bool = False, **kwargs: Any) → bool View on GitHub
-
+
- destroy() → None View on GitHub
-
Correctly destroy SyncObj. Stop autoTickThread, close connections, etc. +
- get(key: str, recursive: bool = False) → None | Dict[ str, Any] | Dict[ str, Dict[ str, Any]] View on GitHub
-
+
- retry(func: Callable[[…], Any], *args: Any, **kwargs: Any) → Any View on GitHub
-
+
- set(key: str, value: str, ttl: int | None = None, handle_raft_error: bool = True, **kwargs: Any) → bool | Dict[ str, Any] View on GitHub
-
+
- set_retry_timeout(retry_timeout: int) → None View on GitHub
-
+
- startAutoTick() → None View on GitHub
- class _patroni.dcs.raft.Raft(_config: Dict[ str, Any], mpp: AbstractMPP) View on GitHub
-
Bases:
AbstractDCS
+- __init\\__(config: Dict[ str, Any], mpp: AbstractMPP) → None View on GitHub
-
Prepare DCS paths, MPP object, initial values for state information and processing dependencies. +
- Variables
-
config –
dict
, reference to config section of selected DCS. i.e.:zookeeper
for zookeeper,etcd
for etcd, etc… +
- abc_impl = <_abc._abc_data object>_
-
+
- cluster_from_nodes(_nodes: Dict[ str, Any]) → Cluster View on GitHub
-
+
- delete_leader(_leader: Leader) → bool View on GitHub
-
Remove leader key from DCS. + This method should remove leader key if current instance is the leader. +
- Parameters
-
leader –
Leader
object with information about the leader. - Returns
-
True
if successfully committed to DCS. +
- load_cluster(_path: str, loader: Callable[[ str], Cluster | Dict[ int, Cluster]]) → Cluster | Dict[ int, Cluster] View on GitHub
-
Main abstract method that implements the loading of
Cluster
instance. + NoteInternally this method should call the _loader_ method that will build `+Cluster+` object which represents current state and topology of the cluster in DCS. This method supposed to be called only by the `+get_cluster()+` method. + Parameters::: Raise::: `+DCSError+` in case of communication problems with DCS. If the current node was running as a primary and exception raised, instance would be demoted. +
- mpp_cluster_loader(_path: str) → Dict[ int, Cluster] View on GitHub
-
Load and build all PostgreSQL clusters from a single MPP cluster. +
- Parameters
-
path – the path in DCS where to load Cluster(s) from.
- Returns
-
all MPP groups as
dict
, with group IDs as keys andCluster
objects as values. +
- on_delete(_key: str) → None View on GitHub
-
+
- on_set(_key: str, value: Dict[ str, Any]) → None View on GitHub
-
+
- postgresql_cluster_loader(_path: str) → Cluster View on GitHub
-
Load and build the
Cluster
object from DCS, which represents a single PostgreSQL cluster. +- Parameters
-
path – the path in DCS where to load
Cluster
from. - Returns
-
Cluster
instance. +
- update_leader(_leader: Leader) → bool View on GitHub
-
Update
leader
key (or session) ttl. + NoteYou have to use CAS (Compare And Swap) operation in order to update leader key, for example for etcd `+prevValue+` parameter must be used.
If update fails due to DCS not being accessible or because it is not able to process requests (hopefully temporary), the `+DCSError+` exception should be raised. + Parameters::: *leader* – a reference to a current `+leader+` object. Returns::: `+True+` if `+leader+` key (or session) has been updated successfully. +
- write_failsafe(_value: str) → bool View on GitHub
-
Write current cluster topology to DCS that will be used by failsafe mechanism (if enabled). +
- Parameters
-
value – failsafe topology serialized in JSON format.
- Returns
-
True
if successfully committed to DCS. +
- write_leader_optime(_last_lsn: str) → bool View on GitHub
-
Write current WAL LSN into
/optime/leader
key in DCS. +- Parameters
-
last_lsn – absolute WAL LSN in bytes.
- Returns
-
True
if successfully committed to DCS. +
- write_status(_value: str) → bool View on GitHub
-
Write current WAL LSN and
confirmed_flush_lsn
of permanent slots into the/status
key in DCS. +- Parameters
-
value – status serialized in JSON format.
- Returns
-
True
if successfully committed to DCS. +
- attempt_to_acquire_leader() → bool View on GitHub
-
Attempt to acquire leader lock. + Note
This method should create `+/leader+` key with the value `+_name+`.
The key must be created atomically. In case the key already exists it should not be overwritten and `+False+` must be returned.
If key creation fails due to DCS not being accessible or because it is not able to process requests (hopefully temporary), the `+DCSError+` exception should be raised. + Returns::: `+True+` if key has been created successfully. +
- cancel_initialization() → bool View on GitHub
-
Removes the
initialize
key for a cluster. +- Returns
-
True
if successfully committed to DCS. +
- delete_cluster() → bool View on GitHub
-
Delete cluster from DCS. +
- Returns
-
True
if successfully committed to DCS. +
- delete_sync_state(version: int | None = None) → bool View on GitHub
-
Delete the synchronous state from DCS. +
- Parameters
-
version – for conditional deletion of the key/object.
- Returns
-
True
if delete successful. +
- initialize(create_new: bool = True, sysid: str = '') → bool View on GitHub
-
Race for cluster initialization. + This method should atomically create
initialize
key and returnTrue
, otherwise it should returnFalse
. +- Parameters
- Returns
-
True
if key has been created successfully. +
- static _member(_key: str, value: Dict[ str, Any]) → Member View on GitHub
-
+
- reload_config(config: Config | Dict[ str, Any]) → None View on GitHub
-
Load and set relevant values from configuration. + Sets
loop_wait
,ttl
andretry_timeout
properties. +- Parameters
-
config – Loaded configuration information object or dictionary of key value pairs. +
- set_config_value(value: str, version: int | None = None) → bool View on GitHub
-
Create or update
/config
key in DCS. +- Parameters
- Returns
-
True
if successfully committed to DCS. +
- set_failover_value(value: str, version: int | None = None) → bool View on GitHub
-
Create or update
/failover
key. +- Parameters
- Returns
-
True
if successfully committed to DCS. +
- set_history_value(value: str) → bool View on GitHub
-
Set value for
history
in DCS. +- Parameters
-
value – new value of
history
key/object. - Returns
-
True
if successfully committed to DCS. +
- set_retry_timeout(retry_timeout: int) → None View on GitHub
-
Set the new value for retry_timeout. +
- set_sync_state_value(value: str, version: int | None = None) → int | bool View on GitHub
-
Set synchronous state in DCS. +
- Parameters
- Returns
-
version of the new object or
False
in case of error. +
- set_ttl(ttl: int) → bool | None View on GitHub
-
Set the new ttl value for DCS keys. +
- take_leader() → bool View on GitHub
-
Establish a new leader in DCS. + Note
This method should create leader key with value of `+_name+` and `+ttl+` of `+ttl+`.
Since it could be called only on initial cluster bootstrap it could create this key regardless, overwriting the key if necessary. + Returns::: `+True+` if successfully committed to DCS. +
- touch_member(data: Dict[ str, Any]) → bool View on GitHub
-
Update member key in DCS. + Note
This method should create or update key with the name with `+/members/+` + `+_name+` and the value of _data_ in a given DCS. + Parameters::: *data* – information about an instance (including connection strings). Returns::: `+True+` if successfully committed to DCS. +
- property _ttl: int_
-
Get current
ttl
value. + - watch(leader_version: int | None, timeout: float) → bool View on GitHub
-
Sleep if the current node is a leader, otherwise, watch for changes of leader key with a given timeout. +
- Parameters
- Returns
-
if
True
this will reschedule the next run of the HA cycle.
- exception _patroni.dcs.raft.RaftError(_value: Any) View on GitHub
-
Bases:
DCSError
- class _patroni.dcs.raft.SyncObjUtility(_otherNodes: Collection[ str | TCPNode], conf: SyncObjConf, retry_timeout: int = 10) View on GitHub
-
Bases:
object
+- __init\\__(otherNodes: Collection[ str | TCPNode], conf: SyncObjConf, retry_timeout: int = 10) → None View on GitHub
-
+
- executeCommand(command: List[ Any]) → Any View on GitHub
-
+
- getMembers() → List[ str] | None View on GitHub
- class _patroni.dcs.raft._TCPTransport(_syncObj: DynMemberSyncObj, selfNode: TCPNode | None, otherNodes: Collection[TCPNode]) View on GitHub
-
Bases:
TCPTransport
+- __init\\__(syncObj: DynMemberSyncObj, selfNode: TCPNode | None, otherNodes: Collection[TCPNode]) → None View on GitHub
-
Initialise the TCP transport. On normal (non-read-only) nodes, this will start a TCP server. On all nodes, it will initiate relevant connections to other nodes. +
- Parameters
-
+
- connectIfNecessarySingle(_node: TCPNode) → bool View on GitHub
-
Connect to a node if necessary. +
- Parameters
-
node (Node) – node to connect to
- patroni.dcs.raft.resolve_host(self: TCPNode) → str | None View on GitHub
© Copyright 2015 Compose, Zalando SE. Revision 9d231aee
.
Built with Sphinx using a theme provided by Read the Docs.
Read the Docs v: latest
+ Builds