salt.modules.zk_concurrency

Concurrency controls in zookeeper

This module allows you to acquire and release a slot. This is primarily useful for ensureing that no more than N hosts take a specific action at once. This can also be used to coordinate between masters.

salt.modules.zk_concurrency.lock(path, zk_hosts, identifier=None, max_concurrency=1, timeout=None, ephemeral_lease=False, force=False)

Get lock (with optional timeout)

path
The path in zookeeper where the lock is
zk_hosts
zookeeper connect string
identifier
Name to identify this minion
max_concurrency
Maximum number of lock holders
timeout
timeout to wait for the lock. A None timeout will block forever
ephemeral_lease
Whether the locks in zookeper should be ephemeral
force
Forcibly acquire the lock regardless of available slots

Example:

... code-block: bash

salt minion zk_concurrency.lock /lock/path host1:1234,host2:1234
salt.modules.zk_concurrency.lock_holders(path, zk_hosts, identifier=None, max_concurrency=1, timeout=None, ephemeral_lease=False)

Return an un-ordered list of lock holders

path
The path in zookeeper where the lock is
zk_hosts
zookeeper connect string
identifier
Name to identify this minion
max_concurrency
Maximum number of lock holders
timeout
timeout to wait for the lock. A None timeout will block forever
ephemeral_lease
Whether the locks in zookeper should be ephemeral

Example:

... code-block: bash

salt minion zk_concurrency.lock_holders /lock/path host1:1234,host2:1234
salt.modules.zk_concurrency.party_members(path, zk_hosts)

Get the List of identifiers in a particular party

path
The path in zookeeper where the lock is
zk_hosts
zookeeper connect string

Example:

... code-block: bash

salt minion zk_concurrency.party_members /lock/path host1:1234,host2:1234
salt.modules.zk_concurrency.unlock(path, zk_hosts=None, identifier=None, max_concurrency=1, ephemeral_lease=False)

Remove lease from semaphore

path
The path in zookeeper where the lock is
zk_hosts
zookeeper connect string
identifier
Name to identify this minion
max_concurrency
Maximum number of lock holders
timeout
timeout to wait for the lock. A None timeout will block forever
ephemeral_lease
Whether the locks in zookeper should be ephemeral

Example:

... code-block: bash

salt minion zk_concurrency.unlock /lock/path host1:1234,host2:1234