Page MenuHomePhorge
Diviner Tech Docs DrydockLeaseUpdateWorker

final class DrydockLeaseUpdateWorker
Phorge Technical Documentation (Drydock)

This class is not documented.

Tasks

Configuring Retries and Failures

  • public function getRequiredLeaseTime() — Return the number of seconds this worker needs hold a lease on the task for while it performs work. For most tasks you can leave this at `null`, which will give you a default lease (currently 2 hours).
  • public function getMaximumRetryCount() — Return the maximum number of times this task may be retried before it is considered permanently failed. By default, tasks retry indefinitely. You can throw a @{class:PhabricatorWorkerPermanentFailureException} to cause an immediate permanent failure.
  • public function getWaitBeforeRetry($task) — Return the number of seconds a task should wait after a failure before retrying. For most tasks you can leave this at `null`, which will give you a short default retry period (currently 60 seconds).

Updating Leases

Processing Commands

Drydock Allocator

  • private function executeAllocator($lease) — Find or build a resource which can satisfy a given lease request, then acquire the lease.
  • private function loadBlueprintsForAllocatingLease($lease) — Get all the concrete @{class:DrydockBlueprint}s which can possibly build a resource to satisfy a lease.
  • private function loadAcquirableResourcesForLease($blueprints, $lease) — Load a list of all resources which a given lease can possibly be allocated against.
  • private function removeUnacquirableResources($resources, $lease) — Remove resources which can not be acquired by a given lease from a list.
  • private function removeOverallocatedBlueprints($blueprints, $lease) — Remove blueprints which are too heavily allocated to build a resource for a lease from a list of blueprints.
  • private function rankBlueprints($blueprints, $lease) — Rank blueprints by suitability for building a new resource for a particular lease.
  • private function rankResources($resources, $lease) — Rank resources by suitability for allocating a particular lease.
  • private function allocateResource($blueprint, $lease) — Perform an actual resource allocation with a particular blueprint.
  • private function validateAllocatedResource($blueprint, $resource, $lease) — Check that the resource a blueprint allocated is roughly the sort of object we expect.

Acquiring Leases

  • private function acquireLease($resource, $lease) — Perform an actual lease acquisition on a particular resource.
  • private function validateAcquiredLease($blueprint, $resource, $lease) — Make sure that a lease was really acquired properly.

Activating Leases

Releasing Leases

Breaking Leases

Destroying Leases

Other Methods

Methods

public function __get($name)
Inherited

This method is not documented.
Parameters
$name
Return
wild

public function __set($name, $value)
Inherited

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

public function current()
Inherited

This method is not documented.
Return
wild

public function key()
Inherited

This method is not documented.
Return
wild

public function next()
Inherited

This method is not documented.
Return
wild

public function rewind()
Inherited

This method is not documented.
Return
wild

public function valid()
Inherited

This method is not documented.
Return
wild

private function throwOnAttemptedIteration()
Inherited

This method is not documented.
Return
wild

public function getPhobjectClassConstant($key, $byte_limit)
Inherited

Phobject

Read the value of a class constant.

This is the same as just typing self::CONSTANTNAME, but throws a more useful message if the constant is not defined and allows the constant to be limited to a maximum length.

Parameters
string$keyName of the constant.
int|null$byte_limitMaximum number of bytes permitted in the value.
Return
stringValue of the constant.

public function getRequiredLeaseTime()
Inherited

PhabricatorWorker

Return the number of seconds this worker needs hold a lease on the task for while it performs work. For most tasks you can leave this at null, which will give you a default lease (currently 2 hours).

For tasks which may take a very long time to complete, you should return an upper bound on the amount of time the task may require.

Return
int|nullNumber of seconds this task needs to remain leased for, or null for a default lease.

public function getMaximumRetryCount()
Inherited

PhabricatorWorker

Return the maximum number of times this task may be retried before it is considered permanently failed. By default, tasks retry indefinitely. You can throw a PhabricatorWorkerPermanentFailureException to cause an immediate permanent failure.

Return
int|nullNumber of times the task will retry before permanent failure. Return `null` to retry indefinitely.

public function getWaitBeforeRetry($task)
Inherited

PhabricatorWorker

Return the number of seconds a task should wait after a failure before retrying. For most tasks you can leave this at null, which will give you a short default retry period (currently 60 seconds).

Parameters
PhabricatorWorkerTask$taskThe task itself. This object is probably useful mostly to examine the failure count if you want to implement staggered retries, or to examine the execution exception if you want to react to different failures in different ways.
Return
int|nullNumber of seconds to wait between retries, or null for a default retry period (currently 60 seconds).

public function setCurrentWorkerTask($task)
Inherited

This method is not documented.
Parameters
PhabricatorWorkerTask$task
Return
wild

public function getCurrentWorkerTask()
Inherited

This method is not documented.
Return
wild

public function getCurrentWorkerTaskID()
Inherited

This method is not documented.
Return
wild

protected function doWork()

This method is not documented.
Return
wild

final public function __construct($data)
Inherited

This method is not documented.
Parameters
$data
Return
this//Implicit.//

final protected function getTaskData()
Inherited

This method is not documented.
Return
wild

final protected function getTaskDataValue($key, $default)
Inherited

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

final public function executeTask()
Inherited

This method is not documented.
Return
wild

final public static function scheduleTask($task_class, $data, $options)
Inherited

This method is not documented.
Parameters
$task_class
$data
$options
Return
wild

public function renderForDisplay($viewer)
Inherited

This method is not documented.
Parameters
PhabricatorUser$viewer
Return
wild

public static function setRunAllTasksInProcess($all)
Inherited

PhabricatorWorker

Set this flag to execute scheduled tasks synchronously, in the same process. This is useful for debugging, and otherwise dramatically worse in every way imaginable.

Parameters
$all
Return
wild

final protected function log($pattern)
Inherited

This method is not documented.
Parameters
$pattern
Return
wild

final protected function queueTask($class, $data, $options)
Inherited

PhabricatorWorker

Queue a task to be executed after this one succeeds.

The followup task will be queued only if this task completes cleanly.

Parameters
string$classTask class to queue.
array$dataData for the followup task.
array$optionsOptions for the followup task.
Return
this

final protected function getQueuedTasks()
Inherited

PhabricatorWorker

Get tasks queued as followups by queueTask().

Return
list<tuple<string, wild, int|null>>Queued task specifications.

final public function flushTaskQueue($defaults)
Inherited

PhabricatorWorker

Schedule any queued tasks, then empty the task queue.

By default, the queue is flushed only if a task succeeds. You can call this method to force the queue to flush before failing (for example, if you are using queues to improve locking behavior).

Parameters
map<string,$defaultswild> Optional default options.
Return
wild

final public static function awakenTaskIDs($ids)
Inherited

PhabricatorWorker

Awaken tasks that have yielded.

Reschedules the specified tasks if they are currently queued in a yielded, unleased, unretried state so they'll execute sooner. This can let the queue avoid unnecessary waits.

This method does not provide any assurances about when these tasks will execute, or even guarantee that it will have any effect at all.

Parameters
list<id>$idsList of task IDs to try to awaken.
Return
void

protected function newContentSource()
Inherited

This method is not documented.
Return
wild

protected function getViewer()
Inherited

This method is not documented.
Return
wild

protected function loadLease($lease_phid)
Inherited

This method is not documented.
Parameters
$lease_phid
Return
wild

protected function loadResource($resource_phid)
Inherited

This method is not documented.
Parameters
$resource_phid
Return
wild

protected function loadOperation($operation_phid)
Inherited

This method is not documented.
Parameters
$operation_phid
Return
wild

protected function loadCommands($target_phid)
Inherited

This method is not documented.
Parameters
$target_phid
Return
wild

protected function checkLeaseExpiration($lease)
Inherited

This method is not documented.
Parameters
DrydockLease$lease
Return
wild

protected function checkResourceExpiration($resource)
Inherited

This method is not documented.
Parameters
DrydockResource$resource
Return
wild

private function checkObjectExpiration($object)
Inherited

This method is not documented.
Parameters
$object
Return
wild

protected function yieldIfExpiringLease($lease)
Inherited

This method is not documented.
Parameters
DrydockLease$lease
Return
wild

protected function yieldIfExpiringResource($resource)
Inherited

This method is not documented.
Parameters
DrydockResource$resource
Return
wild

private function yieldIfExpiring($expires)
Inherited

This method is not documented.
Parameters
$expires
Return
wild

protected function isTemporaryException($ex)
Inherited

This method is not documented.
Parameters
Exception$ex
Return
wild

protected function getYieldDurationFromException($ex)
Inherited

This method is not documented.
Parameters
Exception$ex
Return
wild

protected function flushDrydockTaskQueue()
Inherited

This method is not documented.
Return
wild

protected function canReclaimResource($resource)
Inherited

This method is not documented.
Parameters
DrydockResource$resource
Return
wild

protected function reclaimResource($resource, $lease)
Inherited

This method is not documented.
Parameters
DrydockResource$resource
DrydockLease$lease
Return
wild

private function handleUpdate($lease)

This method is not documented.
Parameters
DrydockLease$lease
Return
wild

private function updateLease($lease)

This method is not documented.
Parameters
DrydockLease$lease
Return
wild

private function yieldLease($lease, $ex)

This method is not documented.
Parameters
DrydockLease$lease
Exception$ex
Return
wild

private function processLeaseCommands($lease)

This method is not documented.
Parameters
DrydockLease$lease
Return
wild

private function processLeaseCommand($lease, $command)

This method is not documented.
Parameters
DrydockLease$lease
DrydockCommand$command
Return
wild

private function executeAllocator($lease)

Find or build a resource which can satisfy a given lease request, then acquire the lease.

Parameters
DrydockLease$leaseRequested lease.
Return
void

private function reclaimAnyResource($lease, $blueprints)

This method is not documented.
Parameters
DrydockLease$lease
array$blueprints
Return
wild

private function yieldForPendingResources($lease)

This method is not documented.
Parameters
DrydockLease$lease
Return
wild

private function yieldForReclaimingResources($lease)

This method is not documented.
Parameters
DrydockLease$lease
Return
wild

private function newLeasedResource($lease, $blueprints)

This method is not documented.
Parameters
DrydockLease$lease
array$blueprints
Return
wild

private function partitionResources($lease, $resources)

This method is not documented.
Parameters
DrydockLease$lease
array$resources
Return
wild

private function newResources($lease, $blueprints)

This method is not documented.
Parameters
DrydockLease$lease
array$blueprints
Return
wild

private function leaseAnyResource($lease, $resources)

This method is not documented.
Parameters
DrydockLease$lease
array$resources
Return
wild

private function loadBlueprintsForAllocatingLease($lease)

Get all the concrete DrydockBlueprints which can possibly build a resource to satisfy a lease.

Parameters
DrydockLease$leaseRequested lease.
Return
list<DrydockBlueprint>List of qualifying blueprints.

private function loadAcquirableResourcesForLease($blueprints, $lease)

Load a list of all resources which a given lease can possibly be allocated against.

Parameters
list<DrydockBlueprint>$blueprintsBlueprints which may produce suitable resources.
DrydockLease$leaseRequested lease.
Return
list<DrydockResource>Resources which may be able to allocate the lease.

private function removeUnacquirableResources($resources, $lease)

Remove resources which can not be acquired by a given lease from a list.

Parameters
list<DrydockResource>$resourcesCandidate resources.
DrydockLease$leaseAcquiring lease.
Return
list<DrydockResource>Resources which the lease may be able to acquire.

private function removeOverallocatedBlueprints($blueprints, $lease)

Remove blueprints which are too heavily allocated to build a resource for a lease from a list of blueprints.

Parameters
list<DrydockBlueprint>$blueprintsList of blueprints.
DrydockLease$lease
Return
list<DrydockBlueprint>List with blueprints that can not allocate a resource for the lease right now removed.

private function rankBlueprints($blueprints, $lease)

Rank blueprints by suitability for building a new resource for a particular lease.

Parameters
list<DrydockBlueprint>$blueprintsList of blueprints.
DrydockLease$leaseRequested lease.
Return
list<DrydockBlueprint>Ranked list of blueprints.

private function rankResources($resources, $lease)

Rank resources by suitability for allocating a particular lease.

Parameters
list<DrydockResource>$resourcesList of resources.
DrydockLease$leaseRequested lease.
Return
list<DrydockResource>Ranked list of resources.

private function allocateResource($blueprint, $lease)

Perform an actual resource allocation with a particular blueprint.

Parameters
DrydockBlueprint$blueprintThe blueprint to allocate a resource from.
DrydockLease$leaseRequested lease.
Return
DrydockResourceAllocated resource.

private function validateAllocatedResource($blueprint, $resource, $lease)

Check that the resource a blueprint allocated is roughly the sort of object we expect.

Parameters
DrydockBlueprint$blueprintBlueprint which built the resource.
wild$resourceThing which the blueprint claims is a valid resource.
DrydockLease$leaseLease the resource was allocated for.
Return
void

private function reclaimResources($blueprint, $lease)

This method is not documented.
Parameters
DrydockBlueprint$blueprint
DrydockLease$lease
Return
wild

private function acquireLease($resource, $lease)

Perform an actual lease acquisition on a particular resource.

Parameters
DrydockResource$resourceResource to acquire a lease on.
DrydockLease$leaseLease to acquire.
Return
void

private function validateAcquiredLease($blueprint, $resource, $lease)

Make sure that a lease was really acquired properly.

Parameters
DrydockBlueprint$blueprintBlueprint which created the resource.
DrydockResource$resourceResource which was acquired.
DrydockLease$leaseThe lease which was supposedly acquired.
Return
void

private function activateLease($lease)

This method is not documented.
Parameters
DrydockLease$lease
Return
wild

private function validateActivatedLease($blueprint, $resource, $lease)

This method is not documented.
Parameters
DrydockBlueprint$blueprint
DrydockResource$resource
DrydockLease$lease
Return
wild

private function releaseLease($lease)

This method is not documented.
Parameters
DrydockLease$lease
Return
wild

protected function breakLease($lease, $ex)

This method is not documented.
Parameters
DrydockLease$lease
Exception$ex
Return
wild

private function destroyLease($lease)

This method is not documented.
Parameters
DrydockLease$lease
Return
wild