Documentation ¶
Overview ¶
Package task defines the Task type and its Manager, with the purpose of handling the lifetime of O² Task objects. Each Task generally matches a running Mesos Task. All Tasks are kept in a roster in Manager, and the latter also takes care of resource acquisition and deployment.
Index ¶
- Constants
- Variables
- type AgentCache
- type AgentCacheInfo
- type Class
- type DeploymentMap
- type Descriptor
- type Descriptors
- type Event
- type EventArgs
- type Filter
- type GenericTaskError
- type GenericTasksError
- type KillTaskFunc
- type Manager
- func (m *Manager) AcquireTasks(envId uuid.Array, taskDescriptors Descriptors) (err error)
- func (m *Manager) BuildDescriptorConstraints(descriptors Descriptors) (cm map[*Descriptor]constraint.Constraints)
- func (m *Manager) Cleanup() (killed Tasks, running Tasks, err error)
- func (m *Manager) ConfigureTasks(envId uuid.Array, tasks Tasks) error
- func (m *Manager) GetTask(id string) *Task
- func (m *Manager) GetTaskClass(name string) (b *Class)
- func (m *Manager) GetTasks() Tasks
- func (m *Manager) GetWantsForDescriptor(descriptor *Descriptor) (r *Wants)
- func (m *Manager) KillTasks(taskIds []string) (killed Tasks, running Tasks, err error)
- func (m *Manager) NewTaskForMesosOffer(offer *mesos.Offer, descriptor *Descriptor, localBindMap channel.BindMap, ...) (t *Task)
- func (m *Manager) RefreshClasses(taskClassesRequired []string) (err error)
- func (m *Manager) ReleaseTasks(envId uuid.Array, tasks Tasks) error
- func (m *Manager) RemoveReposClasses(repoPath string)
- func (m *Manager) TaskCount() int
- func (m *Manager) TransitionTasks(tasks Tasks, src string, event string, dest string, ...) error
- func (m *Manager) UpdateTaskState(taskId string, state string)
- func (m *Manager) UpdateTaskStatus(status *mesos.TaskStatus)
- type Range
- type Ranges
- type ResourceWants
- type Resources
- type State
- type Status
- type Task
- func (t *Task) BuildPropertyMap(bindMap channel.BindMap) (propMap controlcommands.PropertyMap)
- func (t *Task) BuildTaskCommand(role parentRole) (err error)
- func (t *Task) GetAgentId() string
- func (t *Task) GetClassName() string
- func (t *Task) GetEnvironmentId() uuid.Array
- func (t *Task) GetExecutorId() string
- func (t *Task) GetHostname() string
- func (t *Task) GetLocalBindMap() channel.BindMap
- func (t *Task) GetMesosCommandTarget() controlcommands.MesosCommandTarget
- func (t *Task) GetName() string
- func (t *Task) GetOfferId() string
- func (t *Task) GetParentRole() interface{}
- func (t *Task) GetParentRolePath() string
- func (t *Task) GetProperties() map[string]string
- func (t *Task) GetTaskCommandInfo() *common.TaskCommandInfo
- func (t *Task) GetTaskId() string
- func (t *Task) GetWantsCPU() float64
- func (t *Task) GetWantsMemory() float64
- func (t *Task) GetWantsPorts() Ranges
- func (t *Task) IsLocked() bool
- func (t *Task) IsSafeToStop() bool
- func (t *Task) SetSafeToStop(done bool)
- type TaskAlreadyReleasedError
- type TaskError
- type TaskLockedError
- type TaskNotFoundError
- type Tasks
- func (m Tasks) BuildPropertyMaps(bindMap channel.BindMap) (propMapMap controlcommands.PropertyMapsMap, err error)
- func (m Tasks) Contains(filter Filter) (has bool)
- func (m Tasks) Filtered(filter Filter) (tasks Tasks)
- func (m Tasks) FilteredForClass(className string) (tasks Tasks)
- func (m Tasks) GetByTaskId(id string) *Task
- func (m Tasks) GetMesosCommandTargets() (receivers []controlcommands.MesosCommandTarget, err error)
- func (m Tasks) GetTaskIds() []string
- type TasksDeploymentError
- type TasksError
- type Transition
- type Wants
Constants ¶
const ( CONFIGURE = Event("CONFIGURE") RESET = Event("RESET") START = Event("START") STOP = Event("STOP") EXIT = Event("EXIT") GO_ERROR = Event("GO_ERROR") RECOVER = Event("RECOVER") )
const ( TARGET_SEPARATOR_RUNE = ':' TARGET_SEPARATOR = ":" )
const ( UNDEFINED = iota INACTIVE PARTIAL ACTIVE )
Variables ¶
var ( STATUS_PRODUCT = map[Status]map[Status]Status{ UNDEFINED: { UNDEFINED: UNDEFINED, INACTIVE: UNDEFINED, PARTIAL: UNDEFINED, ACTIVE: UNDEFINED, }, INACTIVE: { UNDEFINED: UNDEFINED, INACTIVE: INACTIVE, PARTIAL: PARTIAL, ACTIVE: PARTIAL, }, PARTIAL: { UNDEFINED: UNDEFINED, INACTIVE: PARTIAL, PARTIAL: PARTIAL, ACTIVE: PARTIAL, }, ACTIVE: { UNDEFINED: UNDEFINED, INACTIVE: PARTIAL, PARTIAL: PARTIAL, ACTIVE: ACTIVE, }, } )
Functions ¶
This section is empty.
Types ¶
type AgentCache ¶
type AgentCache struct {
// contains filtered or unexported fields
}
func (*AgentCache) Count ¶
func (ac *AgentCache) Count() (count int)
func (*AgentCache) Get ¶
func (ac *AgentCache) Get(id mesos.AgentID) (agent *AgentCacheInfo)
func (*AgentCache) Update ¶
func (ac *AgentCache) Update(agents ...AgentCacheInfo)
type AgentCacheInfo ¶
type AgentCacheInfo struct { AgentId mesos.AgentID Attributes constraint.Attributes Hostname string }
type Class ¶ added in v0.12.90
type Class struct { Identifier taskClassIdentifier `yaml:"name"` Defaults gera.StringMap `yaml:"defaults"` Control struct { Mode controlmode.ControlMode `yaml:"mode"` } `yaml:"control"` Command *common.CommandInfo `yaml:"command"` Wants ResourceWants `yaml:"wants"` Bind []channel.Inbound `yaml:"bind"` Properties gera.StringMap `yaml:"properties"` Constraints []constraint.Constraint `yaml:"constraints"` Connect []channel.Outbound `yaml:"connect"` }
↓ We need the roles tree to know *where* to run it and how to *configure* it, but
the following information is enough to run the task even with no environment or role Class.
func (*Class) UnmarshalYAML ¶ added in v0.12.90
type DeploymentMap ¶
type DeploymentMap map[*Task]*Descriptor
type Descriptor ¶
type Descriptor struct { TaskRole parentRole TaskClassName string RoleConstraints constraint.Constraints RoleConnect []channel.Outbound RoleBind []channel.Inbound }
type Descriptors ¶
type Descriptors []*Descriptor
type GenericTaskError ¶
type GenericTaskError struct {
// contains filtered or unexported fields
}
func (GenericTaskError) Error ¶
func (r GenericTaskError) Error() string
type GenericTasksError ¶
type GenericTasksError struct {
// contains filtered or unexported fields
}
func (GenericTasksError) Error ¶
func (r GenericTasksError) Error() string
func (GenericTasksError) GetTaskIds ¶
func (r GenericTasksError) GetTaskIds() []string
type KillTaskFunc ¶ added in v0.9.0
type Manager ¶
type Manager struct { AgentCache AgentCache // contains filtered or unexported fields }
func NewManager ¶
func NewManager(resourceOffersDone <-chan DeploymentMap, tasksToDeploy chan<- Descriptors, reviveOffersTrg chan struct{}, cq *controlcommands.CommandQueue, killTaskFunc KillTaskFunc) (taskman *Manager)
func (*Manager) AcquireTasks ¶
func (m *Manager) AcquireTasks(envId uuid.Array, taskDescriptors Descriptors) (err error)
func (*Manager) BuildDescriptorConstraints ¶
func (m *Manager) BuildDescriptorConstraints(descriptors Descriptors) (cm map[*Descriptor]constraint.Constraints)
func (*Manager) ConfigureTasks ¶
func (*Manager) GetTaskClass ¶
func (*Manager) GetWantsForDescriptor ¶
func (m *Manager) GetWantsForDescriptor(descriptor *Descriptor) (r *Wants)
func (*Manager) KillTasks ¶
Kill a specific list of tasks. If the task list includes locked tasks, TaskNotFoundError is returned.
func (*Manager) NewTaskForMesosOffer ¶
func (m *Manager) NewTaskForMesosOffer( offer *mesos.Offer, descriptor *Descriptor, localBindMap channel.BindMap, executorId mesos.ExecutorID) (t *Task)
NewTaskForMesosOffer accepts a Mesos offer and a Descriptor and returns a newly constructed Task. This function should only be called by the Mesos scheduler controller when matching role requests with offers (matchRoles).
func (*Manager) RefreshClasses ¶
func (*Manager) RemoveReposClasses ¶ added in v0.10.0
func (*Manager) TransitionTasks ¶
func (m *Manager) TransitionTasks(tasks Tasks, src string, event string, dest string, commonArgs controlcommands.PropertyMap) error
func (*Manager) UpdateTaskState ¶
func (*Manager) UpdateTaskStatus ¶
func (m *Manager) UpdateTaskStatus(status *mesos.TaskStatus)
type ResourceWants ¶
type ResourceWants struct { Cpu *float64 `yaml:"cpu"` Memory *float64 `yaml:"memory"` Ports Ranges `yaml:"ports"` }
func (*ResourceWants) UnmarshalYAML ¶
func (rw *ResourceWants) UnmarshalYAML(unmarshal func(interface{}) error) (err error)
type Task ¶
type Task struct { GetTaskClass func() *Class // contains filtered or unexported fields }
func (*Task) BuildPropertyMap ¶
func (t *Task) BuildPropertyMap(bindMap channel.BindMap) (propMap controlcommands.PropertyMap)
func (*Task) BuildTaskCommand ¶
Returns a consolidated CommandInfo for this Task, based on Roles tree and Class.
func (*Task) GetAgentId ¶
func (*Task) GetClassName ¶
func (*Task) GetEnvironmentId ¶
func (*Task) GetExecutorId ¶
func (*Task) GetHostname ¶
func (*Task) GetLocalBindMap ¶ added in v0.13.0
func (*Task) GetMesosCommandTarget ¶
func (t *Task) GetMesosCommandTarget() controlcommands.MesosCommandTarget
func (*Task) GetOfferId ¶
func (*Task) GetParentRole ¶
func (t *Task) GetParentRole() interface{}
func (*Task) GetParentRolePath ¶
func (*Task) GetProperties ¶ added in v0.12.90
func (*Task) GetTaskCommandInfo ¶ added in v0.12.90
func (t *Task) GetTaskCommandInfo() *common.TaskCommandInfo
func (*Task) GetWantsCPU ¶
func (*Task) GetWantsMemory ¶
func (*Task) GetWantsPorts ¶
func (*Task) IsSafeToStop ¶ added in v0.12.0
func (*Task) SetSafeToStop ¶ added in v0.12.0
type TaskAlreadyReleasedError ¶
type TaskAlreadyReleasedError taskErrorBase
func (TaskAlreadyReleasedError) Error ¶
func (r TaskAlreadyReleasedError) Error() string
type TaskLockedError ¶
type TaskLockedError struct {
// contains filtered or unexported fields
}
func (TaskLockedError) EnvironmentId ¶
func (r TaskLockedError) EnvironmentId() uuid.Array
func (TaskLockedError) Error ¶
func (r TaskLockedError) Error() string
type TaskNotFoundError ¶
type TaskNotFoundError taskErrorBase
func (TaskNotFoundError) Error ¶
func (r TaskNotFoundError) Error() string
type Tasks ¶
type Tasks []*Task
func (Tasks) BuildPropertyMaps ¶
func (m Tasks) BuildPropertyMaps(bindMap channel.BindMap) (propMapMap controlcommands.PropertyMapsMap, err error)
func (Tasks) FilteredForClass ¶
func (Tasks) GetByTaskId ¶
func (Tasks) GetMesosCommandTargets ¶
func (m Tasks) GetMesosCommandTargets() (receivers []controlcommands.MesosCommandTarget, err error)
func (Tasks) GetTaskIds ¶ added in v0.9.1
type TasksDeploymentError ¶
type TasksDeploymentError tasksErrorBase
func (TasksDeploymentError) Error ¶
func (r TasksDeploymentError) Error() string
type TasksError ¶
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package constraint implements support for predicates on agent attributes.
|
Package constraint implements support for predicates on agent attributes. |