Package ganeti :: Module locking
[hide private]
[frames] | no frames]

Module locking

source code

Module implementing the Ganeti locking code.

Classes [hide private]
  _SingleNotifyPipeConditionWaiter
Helper class for SingleNotifyPipeCondition
  _BaseCondition
Base class containing common code for conditions.
  SingleNotifyPipeCondition
Condition which can only be notified once.
  PipeCondition
Group-only non-polling condition with counters.
  _PipeConditionWithMode
  SharedLock
Implements a shared lock.
  _AcquireTimeout
Internal exception to abort an acquire on a timeout.
  LockSet
Implements a set of locks.
  GanetiLockManager
The Ganeti Locking Library
  LockMonitor
Functions [hide private]
 
ssynchronized(mylock, shared=0)
Shared Synchronization decorator.
source code
 
_TimeoutZero()
Returns the number zero.
source code
tuple
_GetLsAcquireModeAndTimeouts(want_all, timeout, opportunistic)
Determines modes and timeouts for LockSet.acquire.
source code
 
_MonitorSortKey((item, idx, num))
Sorting key function.
source code
Variables [hide private]
  _EXCLUSIVE_TEXT = "exclusive"
  _SHARED_TEXT = "shared"
  _DELETED_TEXT = "deleted"
  _DEFAULT_PRIORITY = 0
  _LOCK_ACQUIRE_MIN_TIMEOUT = 1.0/ 1000
Minimum timeout required to consider scheduling a pending acquisition (seconds)
  _LS_ACQUIRE_MODES = compat.UniqueFrozenset([_LS_ACQUIRE_EXACT,...
  ALL_SET = None
  LEVELS = [LEVEL_CLUSTER, LEVEL_INSTANCE, LEVEL_NODE_ALLOC, LEV...
  LEVELS_MOD = compat.UniqueFrozenset([LEVEL_NODE_RES, LEVEL_NOD...
  LEVEL_NAMES = {LEVEL_CLUSTER: "cluster", LEVEL_INSTANCE: "inst...
Lock level names (make sure to use singular form)
  BGL = "BGL"
  NAL = "NAL"
Node allocation lock

Imports: os, select, threading, errno, weakref, logging, heapq, itertools, time, errors, utils, compat, query


Function Details [hide private]

ssynchronized(mylock, shared=0)

source code 

Shared Synchronization decorator.

Calls the function holding the given lock, either in exclusive or shared mode. It requires the passed lock to be a SharedLock (or support its semantics).

Parameters:
  • mylock (lockable object or string) - lock to acquire or class member name of the lock to acquire

_GetLsAcquireModeAndTimeouts(want_all, timeout, opportunistic)

source code 

Determines modes and timeouts for LockSet.acquire.

Parameters:
  • want_all (boolean) - Whether all locks in set should be acquired
  • timeout - Timeout in seconds or None
  • opportunistic - Whther locks should be acquired opportunistically
Returns: tuple
Tuple containing mode to be passed to LockSet.__acquire_inner (one of _LS_ACQUIRE_MODES), a function to calculate timeout for acquiring the lockset-internal lock (might be None) and a function to calculate the timeout for acquiring individual locks

_MonitorSortKey((item, idx, num))

source code 

Sorting key function.

Sort by name, registration order and then order of information. This provides a stable sort order over different providers, even if they return the same name.


Variables Details [hide private]

_LS_ACQUIRE_MODES

Value:
compat.UniqueFrozenset([_LS_ACQUIRE_EXACT, _LS_ACQUIRE_ALL, _LS_ACQUIR\
E_OPPORTUNISTIC,])

LEVELS

Value:
[LEVEL_CLUSTER, LEVEL_INSTANCE, LEVEL_NODE_ALLOC, LEVEL_NODEGROUP, LEV\
EL_NODE, LEVEL_NODE_RES, LEVEL_NETWORK,]

LEVELS_MOD

Value:
compat.UniqueFrozenset([LEVEL_NODE_RES, LEVEL_NODE, LEVEL_NODEGROUP, L\
EVEL_INSTANCE, LEVEL_NETWORK,])

LEVEL_NAMES

Lock level names (make sure to use singular form)

Value:
{LEVEL_CLUSTER: "cluster", LEVEL_INSTANCE: "instance", LEVEL_NODE_ALLO\
C: "node-alloc", LEVEL_NODEGROUP: "nodegroup", LEVEL_NODE: "node", LEV\
EL_NODE_RES: "node-res", LEVEL_NETWORK: "network",}