Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HostCache ¶
type HostCache interface { // AcquireLeases acquires leases on hosts that match the filter constraints. AcquireLeases(hostFilter *hostmgr.HostFilter) ([]*hostmgr.HostLease, map[string]uint32) // TerminateLease is called when the lease is not going to be used, and we // want to release the lock on the host. TerminateLease(hostname string, leaseID string) error // CompleteLease is called when launching pods on a host that has been // previously leased to the Placement engine. CompleteLease(hostname string, leaseID string, podToResMap map[string]hmscalar.Resources) error // GetClusterCapacity gets the total capacity and allocation of the cluster. GetClusterCapacity() (capacity, allocation hmscalar.Resources) // Start will start the goroutine that listens for host events. Start() // Stop will stop the host cache go routine that listens for host events. Stop() // GetSummaries returns a list of host summaries that the host cache is // managing. GetSummaries() (summaries []HostSummary) // ResetExpiredHeldHostSummaries resets the status of each hostSummary if // the helds have expired and returns the hostnames which got reset. ResetExpiredHeldHostSummaries(now time.Time) []string // GetHostHeldForPod returns the host that is held for the pod. GetHostHeldForPod(podID *peloton.PodID) string // HoldForPods holds the host for the pods specified. HoldForPods(hostname string, podIDs []*peloton.PodID) error // ReleaseHoldForPods release the hold of host for the pods specified. ReleaseHoldForPods(hostname string, podIDs []*peloton.PodID) error }
HostCache manages cluster resources, and provides necessary abstractions to interact with underlying system.
type HostStatus ¶
type HostStatus int
HostStatus represents status (Ready/Placing/Reserved/Held) of the host in host cache
const ( // ReadyHost represents a host ready to be used. ReadyHost HostStatus = iota + 1 // PlacingHost represents a host being used by placement engine. PlacingHost // ReservedHost represents a host that is reserved for tasks. ReservedHost )
type HostSummary ¶
type HostSummary interface { // TryMatch atomically tries to match the current host with given // HostFilter, and lock the host if it does. TryMatch(filter *hostmgr.HostFilter) Match // CompleteLease verifies that the leaseID on this host is still valid. CompleteLease(leaseID string, newPodToResMap map[string]scalar.Resources) error // CasStatus sets the status to new value if current value is old, otherwise // returns error. CasStatus(old, new HostStatus) error // GetCapacity returns the capacity of the host. GetCapacity() scalar.Resources // GetAllocated returns the allocation of the host. GetAllocated() scalar.Resources // GetAvailable returns the available resources of the host. GetAvailable() scalar.Resources // SetCapacity sets the capacity of the host. SetCapacity(r scalar.Resources) // SetAvailable sets the available resource of the host. SetAvailable(r scalar.Resources) // GetVersion returns the version of the host. GetVersion() string // SetVersion sets the version of the host. SetVersion(v string) // GetHostname returns the hostname of the host. GetHostname() string // GetHostStatus returns the HostStatus of the host. GetHostStatus() HostStatus // GetHostLease creates and returns a host lease. GetHostLease() *hostmgr.HostLease // TerminateLease is called when terminating the lease on a host. TerminateLease(leaseID string) error // HandlePodEvent is called when a pod event occurs for a pod // that affects this host. HandlePodEvent(event *p2kscalar.PodEvent) error // HoldForPod holds the host for the pod specified. // If an error is returned, hostsummary would guarantee that // the host is not held for the task. HoldForPod(id *peloton.PodID) error // ReleaseHoldForPod release the hold of host for the pod specified. ReleaseHoldForPod(id *peloton.PodID) // GetHeldPods returns a slice of pods that puts the host in held. GetHeldPods() []*peloton.PodID // DeleteExpiredHolds deletes expired held pods in a hostSummary, returns // whether the hostSummary is free of helds, // available resource, // and the pods held expired. DeleteExpiredHolds(now time.Time) (bool, scalar.Resources, []*peloton.PodID) }
type Match ¶
type Match struct { // The result of the match Result hostmgr.HostFilterResult // host name of the matched host HostName string }
Match represents the result of a match
type Matcher ¶
type Matcher struct {
// contains filtered or unexported fields
}
Matcher keeps track of matched hosts for given constraints. This struct is not thread-safe.
func NewMatcher ¶
func NewMatcher(hostFilter *hostmgr.HostFilter) *Matcher
NewMatcher returns a new instance of Matcher.
Click to show internal directories.
Click to hide internal directories.