14360: Merge branch 'master'
[arvados.git] / lib / dispatchcloud / scheduler / interfaces.go
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 package scheduler
6
7 import (
8         "time"
9
10         "git.curoverse.com/arvados.git/lib/dispatchcloud/container"
11         "git.curoverse.com/arvados.git/lib/dispatchcloud/worker"
12         "git.curoverse.com/arvados.git/sdk/go/arvados"
13 )
14
15 // A ContainerQueue is a set of containers that need to be started or
16 // stopped. Implemented by container.Queue and test stubs.
17 type ContainerQueue interface {
18         Entries() (entries map[string]container.QueueEnt, updated time.Time)
19         Lock(uuid string) error
20         Unlock(uuid string) error
21         Cancel(uuid string) error
22         Forget(uuid string)
23         Get(uuid string) (arvados.Container, bool)
24         Subscribe() <-chan struct{}
25         Unsubscribe(<-chan struct{})
26         Update() error
27 }
28
29 // A WorkerPool asynchronously starts and stops worker VMs, and starts
30 // and stops containers on them. Implemented by worker.Pool and test
31 // stubs.
32 type WorkerPool interface {
33         Running() map[string]time.Time
34         Unallocated() map[arvados.InstanceType]int
35         Workers() map[worker.State]int
36         AtQuota() bool
37         Create(arvados.InstanceType) error
38         Shutdown(arvados.InstanceType) bool
39         StartContainer(arvados.InstanceType, arvados.Container) bool
40         KillContainer(uuid string)
41         Subscribe() <-chan struct{}
42         Unsubscribe(<-chan struct{})
43 }