task

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: May 8, 2019 License: GPL-3.0 Imports: 18 Imported by: 0

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

View Source
const (
	CONFIGURE = Event("CONFIGURE")
	RESET     = Event("RESET")
	START     = Event("START")
	STOP      = Event("STOP")
	EXIT      = Event("EXIT")
	GO_ERROR  = Event("GO_ERROR")
	RECOVER   = Event("RECOVER")
)
View Source
const (
	UNDEFINED = iota
	INACTIVE
	PARTIAL
	ACTIVE
)

Variables

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 DeploymentMap

type DeploymentMap map[*Task]*Descriptor

type Descriptor

type Descriptor struct {
	TaskRole        parentRole
	TaskClassName   string
	RoleConstraints constraint.Constraints
}

type Descriptors

type Descriptors []*Descriptor

type Event

type Event string

func (Event) String

func (e Event) String() string

type EventArgs

type EventArgs map[string]string

type Filter

type Filter func(*Task) bool
var Filter_NIL Filter = func(*Task) bool {
	return true
}

type GenericTaskError

type GenericTaskError struct {
	// contains filtered or unexported fields
}

func (GenericTaskError) Error

func (r GenericTaskError) Error() string

func (GenericTaskError) GetTaskId

func (r GenericTaskError) GetTaskId() 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 Manager

type Manager struct {
	AgentCache AgentCache
	// contains filtered or unexported fields
}

func NewManager

func NewManager(cfgman configuration.ROSource,
	resourceOffersDone <-chan DeploymentMap,
	tasksToDeploy chan<- Descriptors,
	reviveOffersTrg chan struct{},
	cq *controlcommands.CommandQueue) (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) Cleanup

func (m *Manager) Cleanup() (killed Tasks, running Tasks, err error)

func (*Manager) ConfigureTasks

func (m *Manager) ConfigureTasks(envId uuid.Array, tasks Tasks) error

func (*Manager) GetTask

func (m *Manager) GetTask(id string) *Task

func (*Manager) GetTaskClass

func (m *Manager) GetTaskClass(name string) (b *TaskClass)

func (*Manager) GetTasks

func (m *Manager) GetTasks() Tasks

func (*Manager) GetWantsForDescriptor

func (m *Manager) GetWantsForDescriptor(descriptor *Descriptor) (r *Wants)

func (*Manager) KillTasks

func (m *Manager) KillTasks(taskIds []string) (killed Tasks, running Tasks, err error)

func (*Manager) NewTaskForMesosOffer

func (m *Manager) NewTaskForMesosOffer(offer *mesos.Offer, descriptor *Descriptor, bindPorts map[string]uint64, 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). The new role is not assigned to an environment and comes without a roleClass function, as those two are filled out later on by Manager.AcquireTasks.

func (*Manager) RefreshClasses

func (m *Manager) RefreshClasses() (err error)

func (*Manager) ReleaseTasks

func (m *Manager) ReleaseTasks(envId uuid.Array, tasks Tasks) error

func (*Manager) TaskCount

func (m *Manager) TaskCount() int

func (*Manager) TransitionTasks

func (m *Manager) TransitionTasks(envId uuid.Array, tasks Tasks, src string, event string, dest string) error

func (*Manager) UpdateTaskState

func (m *Manager) UpdateTaskState(taskId string, state string)

func (*Manager) UpdateTaskStatus

func (m *Manager) UpdateTaskStatus(status *mesos.TaskStatus)

type Range

type Range struct {
	Begin uint64 `json:"begin" yaml:"begin"`
	End   uint64 `json:"end"   yaml:"end"`
}

type Ranges

type Ranges []Range

func (Ranges) Equals

func (this Ranges) Equals(other Ranges) (response bool)

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 Resources

type Resources mesos.Resources

func (Resources) Satisfy

func (r Resources) Satisfy(wants *Wants) bool

type State

type State int
const (
	UNKNOWN State = iota
	STANDBY
	CONFIGURED
	RUNNING
	ERROR
	DONE
	MIXED
)

func StateFromString

func StateFromString(s string) State

func (State) String

func (s State) String() string

func (State) X

func (s State) X(other State) State

type Status

type Status uint8

func (Status) String

func (s Status) String() string

func (Status) X

func (s Status) X(other Status) Status

type Task

type Task struct {
	GetTaskClass func() *TaskClass
	// contains filtered or unexported fields
}

func (Task) BuildPropertyMap

func (t Task) BuildPropertyMap(bindMap channel.BindMap) controlcommands.PropertyMap

func (Task) BuildTaskCommand

func (t Task) BuildTaskCommand() (cmd *common.TaskCommandInfo)

Returns a consolidated CommandInfo for this Task, based on Roles tree and TaskClass.

func (Task) GetAgentId

func (t Task) GetAgentId() string

func (Task) GetBindPorts

func (t Task) GetBindPorts() map[string]uint64

func (*Task) GetClassName

func (t *Task) GetClassName() string

func (Task) GetEnvironmentId

func (t Task) GetEnvironmentId() uuid.Array

func (Task) GetExecutorId

func (t Task) GetExecutorId() string

func (Task) GetHostname

func (t Task) GetHostname() string

func (Task) GetMesosCommandTarget

func (t Task) GetMesosCommandTarget() controlcommands.MesosCommandTarget

func (*Task) GetName

func (t *Task) GetName() string

func (Task) GetOfferId

func (t Task) GetOfferId() string

func (*Task) GetParentRole

func (t *Task) GetParentRole() interface{}

func (*Task) GetParentRolePath

func (t *Task) GetParentRolePath() string

func (Task) GetTaskId

func (t Task) GetTaskId() string

func (*Task) GetWantsCPU

func (t *Task) GetWantsCPU() float64

func (*Task) GetWantsMemory

func (t *Task) GetWantsMemory() float64

func (*Task) GetWantsPorts

func (t *Task) GetWantsPorts() Ranges

func (Task) IsLocked

func (t Task) IsLocked() bool

type TaskAlreadyReleasedError

type TaskAlreadyReleasedError taskErrorBase

func (TaskAlreadyReleasedError) Error

func (r TaskAlreadyReleasedError) Error() string

type TaskClass

type TaskClass info

type TaskError

type TaskError interface {
	error
	GetTaskId() 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

func (TaskLockedError) GetTaskId

func (r TaskLockedError) GetTaskId() 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) Contains

func (m Tasks) Contains(filter Filter) (has bool)

func (Tasks) Filtered

func (m Tasks) Filtered(filter Filter) (tasks Tasks)

func (Tasks) FilteredForClass

func (m Tasks) FilteredForClass(className string) (tasks Tasks)

func (Tasks) GetByTaskId

func (m Tasks) GetByTaskId(id string) *Task

func (Tasks) GetMesosCommandTargets

func (m Tasks) GetMesosCommandTargets() (receivers []controlcommands.MesosCommandTarget, err error)

type TasksDeploymentError

type TasksDeploymentError tasksErrorBase

func (TasksDeploymentError) Error

func (r TasksDeploymentError) Error() string

type TasksError

type TasksError interface {
	error
	GetTaskIds() []string
}

type Transition

type Transition struct {
	Evt  Event
	Src  State
	Dst  State
	Args EventArgs
}

type VarMap

type VarMap map[string]string

type Wants

type Wants struct {
	Cpu         float64
	Memory      float64
	StaticPorts Ranges
	BindPorts   []channel.Inbound
}

Directories

Path Synopsis
Package constraint implements support for predicates on agent attributes.
Package constraint implements support for predicates on agent attributes.

Jump to

Keyboard shortcuts

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