flux.resource.ResourcePoolImplementation module

Abstract base class for resource pool implementations.

ResourcePoolImplementation extends ResourceSetImplementation with the scheduler-layer protocol: availability tracking (up/down), allocation, and per-job state management.

exception flux.resource.ResourcePoolImplementation.InfeasibleRequest

Bases: OSError

Request can never be satisfied by this pool.

exception flux.resource.ResourcePoolImplementation.InsufficientResources

Bases: OSError

Not enough resources available right now — retry after a free event.

class flux.resource.ResourcePoolImplementation.ResourcePoolImplementation

Bases: ResourceSetImplementation

ABC for resource pool implementations.

Extends ResourceSetImplementation with availability tracking and allocation management required by the scheduler layer.

The generation counter is incremented by _bump() after every mutation (alloc, free, mark_up/down, update_expiration, etc.). Callers can snapshot pool.generation before a copy() and compare later to detect whether the copy has gone stale.

abstract alloc(jobid: int, request)

Allocate resources for jobid matching request.

abstract check_feasibility(request) None

Check whether request is structurally satisfiable.

abstract copy()

Return a full independent copy preserving allocation state.

abstract copy_allocated()

Return a resource set containing only the allocated resources.

abstract copy_down()

Return a resource set containing only the down (not schedulable) resources.

property expiration: float

Resource expiration timestamp (seconds since epoch, 0 = none).

abstract free(jobid: int, R=None, final: bool = False) None

Return a job's allocated resources to the pool.

generation: int = 0

Monotonically increasing counter; incremented by every mutation. Class-level default shadowed by an instance attribute on first bump.

abstract job_end_times()

Return a list of (jobid, end_time) pairs for all tracked jobs.

log(level: int, msg: str) None

Log a message at syslog priority level.

Replaced at construction time by a BrokerLogger instance (or any callable with the same (level, msg) signature) so that pool implementations can call self.log(level, msg) unconditionally. This no-op default is used when no logger is supplied (e.g. in unit tests).

abstract mark_down(ids: str) None

Mark resources identified by idset string (or "all") as down.

abstract mark_up(ids: str) None

Mark resources identified by idset string (or "all") as up.

abstract parse_resource_request(jobspec: dict)

Parse a jobspec dict and return a pool-specific resource request.

abstract register_alloc(jobid: int, R) None

Register an existing allocation during scheduler reconnect.

abstract to_set()

Return a topology+availability snapshot as a resource set.

abstract update_expiration(jobid: int, expiration: float) None

Update the tracked end time for a running job.