Page MenuHomePhabricator

final class DrydockSlotLock
Phabricator Technical Documentation (Drydock)

Simple optimistic locks for Drydock resources and leases.

Most blueprints only need very simple locks: for example, a host blueprint might not want to create multiple resources representing the same physical machine. These optimistic "slot locks" provide a flexible way to do this sort of simple locking.

Tasks

Configuring Storage

Getting Lock Information

  • public static function loadLocks($owner_phid) — Load all locks held by a particular owner.
  • public static function isLockFree($lock) — Test if a lock is currently free.
  • public static function areLocksFree($locks) — Test if a list of locks are all currently free.
  • public static function loadHeldLocks($locks) — Load named locks.

Acquiring and Releasing Locks

No methods for this task.

Other Methods

locks

  • public static function acquireLocks($owner_phid, $locks) — Acquire a set of slot locks.
  • public static function releaseLocks($owner_phid) — Release all locks held by an owner.

Methods

public static function pushStorageNamespace($namespace)
Inherited

This method is not documented.
Parameters
$namespace
Return
wild

public static function popStorageNamespace()
Inherited

This method is not documented.
Return
wild

public static function getDefaultStorageNamespace()
Inherited

This method is not documented.
Return
wild

public static function getStorageNamespace()
Inherited

This method is not documented.
Return
wild

public function setForcedStorageNamespace($namespace)
Inherited

This method is not documented.
Parameters
$namespace
Return
wild

protected function establishLiveConnection($mode)
Inherited

This method is not documented.
Parameters
$mode
Return
wild

private function newClusterConnection($application, $database, $mode)
Inherited

This method is not documented.
Parameters
$application
$database
$mode
Return
wild

private function raiseImproperWrite($database)
Inherited

This method is not documented.
Parameters
$database
Return
wild

private function raiseImpossibleWrite($database)
Inherited

This method is not documented.
Parameters
$database
Return
wild

private function raiseUnconfigured($database)
Inherited

This method is not documented.
Parameters
$database
Return
wild

private function raiseUnreachable($database, $proxy)
Inherited

This method is not documented.
Parameters
$database
Exception$proxy
Return
wild

public function getTableName()
Inherited

This method is not documented.
Return
wild

public function getApplicationName()
Inherited

This method is not documented.
Return
wild

protected function getDatabaseName()
Inherited

This method is not documented.
Return
wild

public static function chunkSQL($fragments, $limit)
Inherited

PhabricatorLiskDAO

Break a list of escaped SQL statement fragments (e.g., VALUES lists for INSERT, previously built with qsprintf()) into chunks which will fit under the MySQL 'max_allowed_packet' limit.

If a statement is too large to fit within the limit, it is broken into its own chunk (but might fail when the query executes).

Parameters
array$fragments
$limit
Return
wild

protected function assertAttached($property)
Inherited

This method is not documented.
Parameters
$property
Return
wild

protected function assertAttachedKey($value, $key)
Inherited

This method is not documented.
Parameters
$value
$key
Return
wild

protected function detectEncodingForStorage($string)
Inherited

This method is not documented.
Parameters
$string
Return
wild

protected function getUTF8StringFromStorage($string, $encoding)
Inherited

This method is not documented.
Parameters
$string
$encoding
Return
wild

protected function willReadData(&$data)
Inherited

This method is not documented.
Parameters
array&$data
Return
wild

protected function willWriteData(&$data)
Inherited

This method is not documented.
Parameters
array&$data
Return
wild

protected function getConfiguration()

This method is not documented.
Return
wild

public static function loadLocks($owner_phid)

Load all locks held by a particular owner.

Parameters
phid$owner_phidOwner PHID.
Return
list<DrydockSlotLock>All held locks.

public static function isLockFree($lock)

Test if a lock is currently free.

Parameters
string$lockLock key to test.
Return
boolTrue if the lock is currently free.

public static function areLocksFree($locks)

Test if a list of locks are all currently free.

Parameters
list<string>$locksList of lock keys to test.
Return
boolTrue if all locks are currently free.

public static function loadHeldLocks($locks)

Load named locks.

Parameters
list<string>$locksList of lock keys to load.
Return
list<DrydockSlotLock>List of held locks.

public static function acquireLocks($owner_phid, $locks)

Acquire a set of slot locks.

This method either acquires all the locks or throws an exception (usually because one or more locks are held).

Parameters
phid$owner_phidLock owner PHID.
list<string>$locksList of locks to acquire.
Return
void

public static function releaseLocks($owner_phid)

Release all locks held by an owner.

Parameters
phid$owner_phidLock owner PHID.
Return
void