Documentation ¶
Index ¶
- type APIClient
- type Queue
- func (cq *Queue) Cancel(uuid string) error
- func (cq *Queue) Entries() (entries map[string]QueueEnt, threshold time.Time)
- func (cq *Queue) Forget(uuid string)
- func (cq *Queue) Get(uuid string) (arvados.Container, bool)
- func (cq *Queue) Lock(uuid string) error
- func (cq *Queue) Subscribe() <-chan struct{}
- func (cq *Queue) Unlock(uuid string) error
- func (cq *Queue) Unsubscribe(ch <-chan struct{})
- func (cq *Queue) Update() error
- type QueueEnt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIClient ¶
type APIClient interface {
RequestAndDecode(dst interface{}, method, path string, body io.Reader, params interface{}) error
}
An APIClient performs Arvados API requests. It is typically an *arvados.Client.
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
A Queue is an interface to an Arvados cluster's container database. It presents only the containers that are eligible to be run by, are already being run by, or have recently been run by the present dispatcher.
The Entries, Get, and Forget methods do not block: they return immediately, using cached data.
The updating methods (Cancel, Lock, Unlock, Update) do block: they return only after the operation has completed.
A Queue's Update method should be called periodically to keep the cache up to date.
func NewQueue ¶
func NewQueue(logger logrus.FieldLogger, reg *prometheus.Registry, chooseType typeChooser, client APIClient) *Queue
NewQueue returns a new Queue. When a new container appears in the Arvados cluster's queue during Update, chooseType will be called to assign an appropriate arvados.InstanceType for the queue entry.
func (*Queue) Cancel ¶
Cancel cancels the given container.
func (*Queue) Entries ¶
Entries returns all cache entries, keyed by container UUID.
The returned threshold indicates the maximum age of any cached data returned in the map. This makes it possible for a scheduler to determine correctly the outcome of a remote process that updates container state. It must first wait for the remote process to exit, then wait for the Queue to start and finish its next Update -- i.e., it must wait until threshold > timeProcessExited.
func (*Queue) Forget ¶
Forget drops the specified container from the cache. It should be called on finalized containers to avoid leaking memory over time. It is a no-op if the indicated container is not in a finalized state.
func (*Queue) Get ¶
Get returns the (partial) Container record for the specified container. Like a map lookup, its second return value is false if the specified container is not in the Queue.
func (*Queue) Lock ¶
Lock acquires the dispatch lock for the given container.
func (*Queue) Subscribe ¶
func (cq *Queue) Subscribe() <-chan struct{}
Subscribe returns a channel that becomes ready to receive when an entry in the Queue is updated.
ch := q.Subscribe() defer q.Unsubscribe(ch) for range ch { // ... }
func (*Queue) Unlock ¶
Unlock releases the dispatch lock for the given container.
type QueueEnt ¶
type QueueEnt struct { // The container to run. Only the UUID, State, Priority, // RuntimeConstraints, ContainerImage, SchedulingParameters, // and CreatedAt fields are populated. Container arvados.Container `json:"container"` InstanceTypes []arvados.InstanceType `json:"instance_types"` FirstSeenAt time.Time `json:"first_seen_at"` }
A QueueEnt is an entry in the queue, consisting of a container record and the instance type that should be used to run it.