The distributed lock is a configdb backed way of synchronizing system-wide tasks. More...
|DistributedLock (const ConnectionString &conn, const string &name, unsigned long long lockTimeout=0, bool asProcess=false)|
|The constructor does not connect to the configdb yet and constructing does not mean the lock was acquired. More...|
|bool||lock_try (const string &why, bool reenter=false, BSONObj *other=0, double timeout=0.0)|
|Attempts to acquire 'this' lock, checking if it could or should be stolen from the previous holder. More...|
|bool||isLockHeld (double timeout, string *errMsg)|
|Returns true if we currently believe we hold this lock and it was possible to confirm that, within 'timeout' seconds, if provided, with the config servers. More...|
|void||unlock (BSONObj *oldLockPtr=NULL)|
|Releases a previously taken lock. |
|const string &||getProcessId ()|
|const ConnectionString &||getRemoteConnection ()|
|static bool||checkSkew (const ConnectionString &cluster, unsigned skewChecks=NUM_LOCK_SKEW_CHECKS, unsigned long long maxClockSkew=MAX_LOCK_CLOCK_SKEW, unsigned long long maxNetSkew=MAX_LOCK_NET_SKEW)|
|Check the skew between a cluster of servers. |
|static Date_t||remoteTime (const ConnectionString &cluster, unsigned long long maxNetSkew=MAX_LOCK_NET_SKEW)|
|Get the remote time from a server or cluster. More...|
|static bool||killPinger (DistributedLock &lock)|
|const unsigned long long||_lockTimeout|
|const unsigned long long||_maxClockSkew|
|const unsigned long long||_maxNetSkew|
|const unsigned long long||_lockPing|
|static const string||lockPingNS|
|Namespace for lock pings. |
|static const string||locksNS|
|Namespace for locks. |
The distributed lock is a configdb backed way of synchronizing system-wide tasks.
A task must be identified by a unique name across the system (e.g., "balancer"). A lock is taken by writing a document in the configdb's locks collection with that name.
To be maintained, each taken lock needs to be revalidated ("pinged") within a pre-established amount of time. This class does this maintenance automatically once a DistributedLock object was constructed.
|mongo::DistributedLock::DistributedLock||(||const ConnectionString &||conn,|
|const string &||name,|
|unsigned long long||lockTimeout =
The constructor does not connect to the configdb yet and constructing does not mean the lock was acquired.
Create a new distributed lock, potentially with a custom sleep and takeover time.
Construction does trigger a lock "pinging" mechanism, though.
|conn||address of config(s) server(s)|
|name||identifier for the lock|
|lockTimeout||how long can the log go "unpinged" before a new attempt to lock steals it (in minutes).|
|lockPing||how long to wait between lock pings|
|legacy||use legacy logic|
If a custom sleep time is specified (time between pings)
Returns true if we currently believe we hold this lock and it was possible to confirm that, within 'timeout' seconds, if provided, with the config servers.
If the lock is not held or if we failed to contact the config servers within the timeout, returns false.
|bool mongo::DistributedLock::lock_try||(||const string &||why,|
|BSONObj *||other =
Attempts to acquire 'this' lock, checking if it could or should be stolen from the previous holder.
Please consider using the dist_lock_try construct to acquire this lock in an exception safe way.
|why||human readable description of why the lock is being taken (used to log)|
|whether||this is a lock re-entry or a new lock|
|other||configdb's lock document that is currently holding the lock, if lock is taken, or our own lock details if not|
Get the remote time from a server or cluster.
Returns the remote time as reported by the cluster or server.
The maximum difference between the reported time and the actual time on the remote server (at the completion of the function) is the maxNetSkew