zk_concurrency

Concurrency controls in zookeeper

Important

This module requires the general Zookeeper setup.

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

saltext.zookeeper.modules.zk_concurrency.lock_holders(path, zk_hosts=None, identifier=None, max_concurrency=1, timeout=None, ephemeral_lease=False, profile=None, scheme=None, username=None, password=None, default_acl=None)[source]

Return an un-ordered list of lock holders

CLI Example:

salt '*' zk_concurrency.lock_holders some/path
path

The path in zookeeper where the lock is

zk_hosts

zookeeper connect string

identifier

Name to identify this minion, if unspecified defaults to hostname

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:

salt minion zk_concurrency.lock_holders /lock/path host1:1234,host2:1234
saltext.zookeeper.modules.zk_concurrency.lock(path, zk_hosts=None, identifier=None, max_concurrency=1, timeout=None, ephemeral_lease=False, force=False, profile=None, scheme=None, username=None, password=None, default_acl=None)[source]

Get lock (with optional timeout)

CLI Example:

salt '*' zk_concurrency.lock some/path
path

The path in zookeeper where the lock is

zk_hosts

zookeeper connect string

identifier

Name to identify this minion, if unspecified defaults to the hostname

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:

salt minion zk_concurrency.lock /lock/path host1:1234,host2:1234
saltext.zookeeper.modules.zk_concurrency.unlock(path, zk_hosts=None, identifier=None, max_concurrency=1, ephemeral_lease=False, scheme=None, profile=None, username=None, password=None, default_acl=None)[source]

Remove lease from semaphore

CLI Example:

salt '*' zk_concurrency.unlock some/path
path

The path in zookeeper where the lock is

zk_hosts

zookeeper connect string

identifier

Name to identify this minion, if unspecified defaults to hostname

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:

salt minion zk_concurrency.unlock /lock/path host1:1234,host2:1234
saltext.zookeeper.modules.zk_concurrency.party_members(path, zk_hosts=None, min_nodes=1, blocking=False, profile=None, scheme=None, username=None, password=None, default_acl=None)[source]

Get the List of identifiers in a particular party, optionally waiting for the specified minimum number of nodes (min_nodes) to appear

CLI Example:

salt '*' zk_concurrency.party_members some/path
path

The path in zookeeper where the lock is

zk_hosts

zookeeper connect string

min_nodes

The minimum number of nodes expected to be present in the party

blocking

The boolean indicating if we need to block until min_nodes are available

Example:

salt minion zk_concurrency.party_members /lock/path host1:1234,host2:1234
salt minion zk_concurrency.party_members /lock/path host1:1234,host2:1234 min_nodes=3 blocking=True