public function getType()
wild |
public function isEnabled()
wild |
public function getBlueprintName()
wild |
public function getDescription()
wild |
public function getBlueprintIcon()
wild |
public function getFieldSpecifications()Inherited
wild |
protected function getCustomFieldSpecifications()
wild |
public function getViewer()Inherited
wild |
public function canAcquireLeaseOnResource($blueprint, $resource, $lease)
Enforce basic checks on lease/resource compatibility. Allows resources to reject leases if they are incompatible, even if the resource types match.
For example, if a resource represents a 32-bit host, this method might reject leases that need a 64-bit host. The blueprint might also reject a resource if the lease needs 8GB of RAM and the resource only has 6GB free.
This method should not acquire locks or expect anything to be locked. This is a coarse compatibility check between a lease and a resource.
DrydockBlueprint | $blueprint | Concrete blueprint to allocate for. |
DrydockResource | $resource | Candidate resource to allocate the lease on. |
DrydockLease | $lease | Pending lease that wants to allocate here. |
bool | True if the resource and lease are compatible. |
public function acquireLease($blueprint, $resource, $lease)
Acquire a lease. Allows resources to perform setup as leases are brought online.
If acquisition fails, throw an exception.
DrydockBlueprint | $blueprint | Blueprint which built the resource. |
DrydockResource | $resource | Resource to acquire a lease on. |
DrydockLease | $lease | Requested lease. |
void |
public function activateLease($blueprint, $resource, $lease)Inherited
DrydockBlueprint | $blueprint | |
DrydockResource | $resource | |
DrydockLease | $lease |
void |
public function didReleaseLease($blueprint, $resource, $lease)
React to a lease being released.
This callback is primarily useful for automatically releasing resources once all leases are released.
DrydockBlueprint | $blueprint | Blueprint which built the resource. |
DrydockResource | $resource | Resource a lease was released on. |
DrydockLease | $lease | Recently released lease. |
void |
public function destroyLease($blueprint, $resource, $lease)
Destroy any temporary data associated with a lease.
If a lease creates temporary state while held, destroy it here.
DrydockBlueprint | $blueprint | Blueprint which built the resource. |
DrydockResource | $resource | Resource the lease is acquired on. |
DrydockLease | $lease | The lease being destroyed. |
void |
public function shouldAllocateSupplementalResource($blueprint, $resource, $lease)
Return true to try to allocate a new resource and expand the resource pool instead of permitting an otherwise valid acquisition on an existing resource.
This allows the blueprint to provide a soft hint about when the resource pool should grow.
Returning "true" in all cases generally makes sense when a blueprint controls a fixed pool of resources, like a particular number of physical hosts: you want to put all the hosts in service, so whenever it is possible to allocate a new host you want to do this.
Returning "false" in all cases generally make sense when a blueprint has a flexible pool of expensive resources and you want to pack leases onto them as tightly as possible.
DrydockBlueprint | $blueprint | The blueprint for an existing resource being acquired. |
DrydockResource | $resource | The resource being acquired, which we may want to build a supplemental resource for. |
DrydockLease | $lease | The current lease performing acquisition. |
bool | True to prefer allocating a supplemental resource. |
public function canAnyBlueprintEverAllocateResourceForLease($lease)
Enforce fundamental implementation/lease checks. Allows implementations to reject a lease which no concrete blueprint can ever satisfy.
For example, if a lease only builds ARM hosts and the lease needs a PowerPC host, it may be rejected here.
This is the earliest rejection phase, and followed by canEverAllocateResourceForLease().
This method should not actually check if a resource can be allocated right now, or even if a blueprint which can allocate a suitable resource really exists, only if some blueprint may conceivably exist which could plausibly be able to build a suitable resource.
DrydockLease | $lease | Requested lease. |
bool | True if some concrete blueprint of this implementation's type might ever be able to build a resource for the lease. |
public function canEverAllocateResourceForLease($blueprint, $lease)
Enforce basic blueprint/lease checks. Allows blueprints to reject a lease which they can not build a resource for.
This is the second rejection phase. It follows canAnyBlueprintEverAllocateResourceForLease() and is followed by canAllocateResourceForLease().
This method should not check if a resource can be built right now, only if the blueprint as configured may, at some time, be able to build a suitable resource.
DrydockBlueprint | $blueprint | Blueprint which may be asked to allocate a resource. |
DrydockLease | $lease | Requested lease. |
bool | True if this blueprint can eventually build a suitable resource for the lease, as currently configured. |
public function canAllocateResourceForLease($blueprint, $lease)
Enforce basic availability limits. Allows blueprints to reject resource allocation if they are currently overallocated.
This method should perform basic capacity/limit checks. For example, if it has a limit of 6 resources and currently has 6 resources allocated, it might reject new leases.
This method should not acquire locks or expect locks to be acquired. This is a coarse check to determine if the operation is likely to succeed right now without needing to acquire locks.
It is expected that this method will sometimes return true (indicating that a resource can be allocated) but find that another allocator has eaten up free capacity by the time it actually tries to build a resource. This is normal and the allocator will recover from it.
DrydockBlueprint | $blueprint | The blueprint which may be asked to allocate a resource. |
DrydockLease | $lease | Requested lease. |
bool | True if this blueprint appears likely to be able to allocate a suitable resource. |
public function allocateResource($blueprint, $lease)
Allocate a suitable resource for a lease.
This method MUST acquire, hold, and manage locks to prevent multiple allocations from racing. World state is not locked before this method is called. Blueprints are entirely responsible for any lock handling they need to perform.
DrydockBlueprint | $blueprint | The blueprint which should allocate a resource. |
DrydockLease | $lease | Requested lease. |
DrydockResource | Allocated resource. |
public function activateResource($blueprint, $resource)Inherited
DrydockBlueprint | $blueprint | |
DrydockResource | $resource |
wild |
public function destroyResource($blueprint, $resource)
Destroy any temporary data associated with a resource.
If a resource creates temporary state when allocated, destroy that state here. For example, you might shut down a virtual host or destroy a working copy on disk.
DrydockBlueprint | $blueprint | Blueprint which built the resource. |
DrydockResource | $resource | Resource being destroyed. |
void |
public function getResourceName($blueprint, $resource)
Get a human readable name for a resource.
DrydockBlueprint | $blueprint | Blueprint which built the resource. |
DrydockResource | $resource | Resource to get the name of. |
string | Human-readable resource name. |
public function getInterface($blueprint, $resource, $lease, $type)
DrydockBlueprint | $blueprint | |
DrydockResource | $resource | |
DrydockLease | $lease | |
$type |
wild |
public static function getAllBlueprintImplementations()Inherited
wild |
public static function getNamedImplementation($class)Inherited
$class |
wild |
protected function newResourceTemplate($blueprint)Inherited
DrydockBlueprint | $blueprint |
wild |
protected function newLease($blueprint)Inherited
DrydockBlueprint | $blueprint |
wild |
protected function requireActiveLease($lease)Inherited
DrydockLease | $lease |
wild |
protected function shouldUseConcurrentResourceLimit()Inherited
Does this implementation use concurrent resource limits?
Implementations can override this method to opt into standard limit behavior, which provides a simple concurrent resource limit.
bool | True to use limits. |
protected function getConcurrentResourceLimit($blueprint)Inherited
Get the effective concurrent resource limit for this blueprint.
DrydockBlueprint | $blueprint | Blueprint to get the limit for. |
int|null | Limit, or `null` for no limit. |
protected function getConcurrentResourceLimitSlotLock($blueprint)Inherited
DrydockBlueprint | $blueprint |
wild |
protected function shouldLimitAllocatingPoolSize($blueprint)Inherited
Apply standard limits on resource allocation rate.
DrydockBlueprint | $blueprint | The blueprint requesting an allocation. |
bool | True if further allocations should be limited. |
private function loadServices($blueprint)
DrydockBlueprint | $blueprint |
wild |
private function loadAllBindings($services)
array | $services |
wild |
private function loadFreeBindings($blueprint)
DrydockBlueprint | $blueprint |
wild |
private function getAlmanacServiceTypes()
wild |
private function loadBindingForResource($resource)
DrydockResource | $resource |
wild |