rep

package module
v0.0.0-...-b61a845 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 15, 2016 License: Apache-2.0 Imports: 11 Imported by: 0

README

The Rep

Vote Quimby

The Rep bids on tasks and schedules them on an associated Executor.

####Learn more about Diego and its components at diego-design-notes

Documentation

Index

Constants

View Source
const (
	LifecycleTag  = "lifecycle"
	ResultFileTag = "result-file"
	DomainTag     = "domain"

	TaskLifecycle = "task"
	LRPLifecycle  = "lrp"

	ProcessGuidTag  = "process-guid"
	InstanceGuidTag = "instance-guid"
	ProcessIndexTag = "process-index"
)
View Source
const (
	StateRoute   = "STATE"
	PerformRoute = "PERFORM"

	StopLRPInstanceRoute = "StopLRPInstance"
	CancelTaskRoute      = "CancelTask"

	Sim_ResetRoute = "RESET"

	PingRoute     = "Ping"
	EvacuateRoute = "Evacuate"
)

Variables

View Source
var (
	ErrContainerMissingTags = errors.New("container is missing tags")
	ErrInvalidProcessIndex  = errors.New("container does not have a valid process index")
)
View Source
var ErrorIncompatibleRootfs = errors.New("rootfs not found")
View Source
var ErrorInsufficientResources = errors.New("insufficient resources")
View Source
var Routes = rata.Routes{
	{Path: "/state", Method: "GET", Name: StateRoute},
	{Path: "/work", Method: "POST", Name: PerformRoute},

	{Path: "/v1/lrps/:process_guid/instances/:instance_guid/stop", Method: "POST", Name: StopLRPInstanceRoute},
	{Path: "/v1/tasks/:task_guid/cancel", Method: "POST", Name: CancelTaskRoute},

	{Path: "/sim/reset", Method: "POST", Name: Sim_ResetRoute},

	{Path: "/ping", Method: "GET", Name: PingRoute},
	{Path: "/evacuate", Method: "POST", Name: EvacuateRoute},
}

Functions

func ActualLRPInstanceKeyFromContainer

func ActualLRPInstanceKeyFromContainer(container executor.Container, cellID string) (*models.ActualLRPInstanceKey, error)

func ActualLRPKeyFromTags

func ActualLRPKeyFromTags(tags executor.Tags) (*models.ActualLRPKey, error)

func ActualLRPNetInfoFromContainer

func ActualLRPNetInfoFromContainer(container executor.Container) (*models.ActualLRPNetInfo, error)

func ConvertPortMappings

func ConvertPortMappings(containerPorts []uint32) []executor.PortMapping

func LRPContainerGuid

func LRPContainerGuid(processGuid, instanceGuid string) string

func NewRunRequestFromDesiredLRP

func NewRunRequestFromDesiredLRP(
	containerGuid string,
	desiredLRP *models.DesiredLRP,
	lrpKey *models.ActualLRPKey,
	lrpInstanceKey *models.ActualLRPInstanceKey,
) (executor.RunRequest, error)

func NewRunRequestFromTask

func NewRunRequestFromTask(task *models.Task) (executor.RunRequest, error)

Types

type ArbitraryRootFSProvider

type ArbitraryRootFSProvider struct{}

func (ArbitraryRootFSProvider) MarshalJSON

func (provider ArbitraryRootFSProvider) MarshalJSON() ([]byte, error)

func (ArbitraryRootFSProvider) Match

func (ArbitraryRootFSProvider) Type

type AuctionCellClient

type AuctionCellClient interface {
	State() (CellState, error)
	Perform(work Work) (Work, error)
}

type CellState

type CellState struct {
	RootFSProviders    RootFSProviders
	AvailableResources Resources
	TotalResources     Resources
	LRPs               []LRP
	Tasks              []Task
	Zone               string
	Evacuating         bool
}

func NewCellState

func NewCellState(root RootFSProviders, avail Resources, total Resources, lrps []LRP, tasks []Task, zone string, isEvac bool) CellState

func (*CellState) AddLRP

func (c *CellState) AddLRP(lrp *LRP)

func (*CellState) AddTask

func (c *CellState) AddTask(task *Task)

func (CellState) ComputeScore

func (c CellState) ComputeScore(res *Resource) float64

func (*CellState) Copy

func (c *CellState) Copy() CellState

func (*CellState) MatchRootFS

func (c *CellState) MatchRootFS(rootfs string) bool

func (*CellState) ResourceMatch

func (c *CellState) ResourceMatch(res *Resource) error

type Client

type Client interface {
	AuctionCellClient
	StopLRPInstance(key models.ActualLRPKey, instanceKey models.ActualLRPInstanceKey) error
	CancelTask(taskGuid string) error
	SetStateClient(stateClient *http.Client)
	StateClientTimeout() time.Duration
}

func NewClient

func NewClient(httpClient, stateClient *http.Client, address string) Client

type ClientFactory

type ClientFactory interface {
	CreateClient(address string) Client
}

func NewClientFactory

func NewClientFactory(httpClient, stateClient *http.Client) ClientFactory

type FixedSetRootFSProvider

type FixedSetRootFSProvider struct {
	FixedSet StringSet
}

func NewFixedSetRootFSProvider

func NewFixedSetRootFSProvider(rootfses ...string) FixedSetRootFSProvider

func (FixedSetRootFSProvider) MarshalJSON

func (provider FixedSetRootFSProvider) MarshalJSON() ([]byte, error)

func (FixedSetRootFSProvider) Match

func (provider FixedSetRootFSProvider) Match(rootfs url.URL) bool

func (FixedSetRootFSProvider) Type

func (*FixedSetRootFSProvider) UnmarshalJSON

func (provider *FixedSetRootFSProvider) UnmarshalJSON(payload []byte) error

type LRP

type LRP struct {
	models.ActualLRPKey
	Resource
}

func NewLRP

func NewLRP(key models.ActualLRPKey, res Resource) LRP

func (*LRP) Copy

func (lrp *LRP) Copy() LRP

func (*LRP) Identifier

func (lrp *LRP) Identifier() string

type Resource

type Resource struct {
	MemoryMB int32  `json:"MemoryMB"`
	DiskMB   int32  `json:"DiskMB"`
	RootFs   string `json:"RootFs"`
}

func NewResource

func NewResource(memoryMb, diskMb int32, rootfs string) Resource

func (*Resource) Copy

func (r *Resource) Copy() Resource

func (*Resource) Empty

func (r *Resource) Empty() bool

type Resources

type Resources struct {
	MemoryMB   int32 `json:"MemoryMB"`
	DiskMB     int32 `json:"DiskMB"`
	Containers int   `json:"Containers"`
}

func NewResources

func NewResources(memoryMb, diskMb int32, containerCount int) Resources

func (*Resources) ComputeScore

func (r *Resources) ComputeScore(total *Resources) float64

func (*Resources) Copy

func (r *Resources) Copy() Resources

func (*Resources) Subtract

func (r *Resources) Subtract(res *Resource)

type RootFSProvider

type RootFSProvider interface {
	Type() RootFSProviderType
	Match(url.URL) bool
}

type RootFSProviderType

type RootFSProviderType string
const (
	RootFSProviderTypeArbitrary RootFSProviderType = "arbitrary"
	RootFSProviderTypeFixedSet  RootFSProviderType = "fixed_set"
)

type RootFSProviders

type RootFSProviders map[string]RootFSProvider

func (RootFSProviders) Copy

func (RootFSProviders) Match

func (p RootFSProviders) Match(rootFS url.URL) bool

func (*RootFSProviders) UnmarshalJSON

func (providers *RootFSProviders) UnmarshalJSON(payload []byte) error

type SimClient

type SimClient interface {
	Client
	Reset() error
}

type StackPathMap

type StackPathMap map[string]string

func UnmarshalStackPathMap

func UnmarshalStackPathMap(payload []byte) (StackPathMap, error)

type StringSet

type StringSet map[string]struct{}

func NewStringSet

func NewStringSet(entries ...string) StringSet

func (StringSet) Contains

func (set StringSet) Contains(candidate string) bool

type Task

type Task struct {
	TaskGuid string `json:"TaskGuid"`
	Domain   string `json:"Domain"`
	Resource `json:"Resource"`
	Tags     []string `json:"Tags"`
}

func NewTask

func NewTask(guid string, domain string, res Resource, tags ...string) Task

func (Task) Copy

func (task Task) Copy() Task

func (*Task) Identifier

func (task *Task) Identifier() string

type Work

type Work struct {
	LRPs  []LRP
	Tasks []Task
}

Directories

Path Synopsis
cmd
rep
evacuation_context/fake_evacuation_context
This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter
This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter
generator creates operations for container processing
generator creates operations for container processing
fake_generator
This file was generated by counterfeiter
This file was generated by counterfeiter
internal/fake_internal
This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter
This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter
fakes
This file was generated by counterfeiter
This file was generated by counterfeiter
This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter
This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL