state

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2017 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APP_STATE_NORMAL        = "normal"
	APP_STATE_CREATING      = "creating"
	APP_STATE_DELETING      = "deleting"
	APP_STATE_UPDATING      = "updating"
	APP_STATE_CANCEL_UPDATE = "cancel_update"
	APP_STATE_SCALE_UP      = "scale_up"
	APP_STATE_SCALE_DOWN    = "scale_down"
)
View Source
const (
	SLOT_STATE_PENDING_OFFER = "slot_task_pending_offer"
	SLOT_STATE_PENDING_KILL  = "slot_task_pending_killed"
	SLOT_STATE_REAP          = "slot_task_reap"

	SLOT_STATE_TASK_STAGING          = "slot_task_staging"
	SLOT_STATE_TASK_STARTING         = "slot_task_starting"
	SLOT_STATE_TASK_RUNNING          = "slot_task_running"
	SLOT_STATE_TASK_KILLING          = "slot_task_killing"
	SLOT_STATE_TASK_FINISHED         = "slot_task_finished"
	SLOT_STATE_TASK_FAILED           = "slot_task_failed"
	SLOT_STATE_TASK_KILLED           = "slot_task_killed"
	SLOT_STATE_TASK_ERROR            = "slot_task_error"
	SLOT_STATE_TASK_LOST             = "slot_task_lost"
	SLOT_STATE_TASK_DROPPED          = "slot_task_dropped"
	SLOT_STATE_TASK_UNREACHABLE      = "slot_task_unreachable"
	SLOT_STATE_TASK_GONE             = "slot_task_gone"
	SLOT_STATE_TASK_GONE_BY_OPERATOR = "slot_task_gone_by_operator"
	SLOT_STATE_TASK_UNKNOWN          = "slot_task_unknown"
)
View Source
const AND = 57346
View Source
const CONTAINS = 57350
View Source
const EQUAL = 57352
View Source
const IDENTIFIER = 57353
View Source
const LIKE = 57349
View Source
const NOT = 57351
View Source
const OR = 57347
View Source
const UNIQUE = 57348

Variables

Functions

func AppToRaft

func AppToRaft(app *App) *rafttypes.Application

func ContainerFromRaft

func ContainerFromRaft(raftContainer *rafttypes.Container) *types.Container

func ContainerToRaft

func ContainerToRaft(container *types.Container) *rafttypes.Container

func DockerFromRaft

func DockerFromRaft(raftDocker *rafttypes.Docker) *types.Docker

func DockerToRaft

func DockerToRaft(docker *types.Docker) *rafttypes.Docker

func HealthCheckFromRaft

func HealthCheckFromRaft(raftHealthCheck *rafttypes.HealthCheck) *types.HealthCheck

func HealthCheckToRaft

func HealthCheckToRaft(healthCheck *types.HealthCheck) *rafttypes.HealthCheck

func KillPolicyFromRaft

func KillPolicyFromRaft(raftKillPolicy *rafttypes.KillPolicy) *types.KillPolicy

func KillPolicyToRaft

func KillPolicyToRaft(killPolicy *types.KillPolicy) *rafttypes.KillPolicy

func LoadAppData

func LoadAppData(userEventChan chan *event.UserEvent) (map[string]*App, error)

load app data frm persistent data

func LoadOfferAllocatorMap

func LoadOfferAllocatorMap() (map[string]*OfferInfo, error)

func OfferAllocatorItemToRaft

func OfferAllocatorItemToRaft(slotID string, offerInfo *OfferInfo) *rafttypes.OfferAllocatorItem

func ParameterFromRaft

func ParameterFromRaft(raftParameter *rafttypes.Parameter) *types.Parameter

func ParameterToRaft

func ParameterToRaft(parameter *types.Parameter) *rafttypes.Parameter

func PortMappingFromRaft

func PortMappingFromRaft(raftPortMapping *rafttypes.PortMapping) *types.PortMapping

func PortMappingToRaft

func PortMappingToRaft(portMapping *types.PortMapping) *rafttypes.PortMapping

func SetStore

func SetStore(newStore store.Store)

func SlotToRaft

func SlotToRaft(slot *Slot) *rafttypes.Slot

func StateMachineToRaft added in v0.1.9

func StateMachineToRaft(machine *StateMachine) *rafttypes.StateMachine

func StateToRaft added in v0.1.9

func StateToRaft(state State) *rafttypes.State

func TaskToRaft

func TaskToRaft(task *Task) *rafttypes.Task

func UpdatePolicyFromRaft

func UpdatePolicyFromRaft(raftUpdatePolicy *rafttypes.UpdatePolicy) *types.UpdatePolicy

func UpdatePolicyToRaft

func UpdatePolicyToRaft(updatePolicy *types.UpdatePolicy) *rafttypes.UpdatePolicy

func VersionFromRaft

func VersionFromRaft(raftVersion *rafttypes.Version) *types.Version

func VersionToRaft

func VersionToRaft(version *types.Version, appID string) *rafttypes.Version

func VolumeFromFaft

func VolumeFromFaft(raftVolume *rafttypes.Volume) *types.Volume

func VolumeToRaft

func VolumeToRaft(volume *types.Volume) *rafttypes.Volume

func WithConvertApp

func WithConvertApp(ctx context.Context, app *App, cb func(), action func(ctx context.Context, app *rafttypes.Application, cb func()) error) error

func WithConvertSlot

func WithConvertSlot(ctx context.Context, slot *Slot, cb func(), action func(ctx context.Context, slot *rafttypes.Slot, cb func()) error) error

func WithConvertTask

func WithConvertTask(ctx context.Context, task *Task, cb func(), action func(ctx context.Context, task *rafttypes.Task, cb func()) error) error

Types

type AndStatement added in v0.1.3

type AndStatement struct {
	Op1 Statement
	Op2 Statement
}

and (unique hostname) (unique ip) and (not (unique hostname)) (unique ip)

func (*AndStatement) Eval added in v0.1.3

func (as *AndStatement) Eval() bool

func (*AndStatement) SetContext added in v0.1.3

func (as *AndStatement) SetContext(ctx *ConstraintParamHolder)

func (*AndStatement) Valid added in v0.1.3

func (as *AndStatement) Valid() error

type App

type App struct {
	ID       string           `json:"id"`
	Name     string           `json:"name"`
	Versions []*types.Version `json:"versions"`

	Slots map[int]*Slot `json:"slots"`

	// app run with CurrentVersion config
	CurrentVersion *types.Version `json:"current_version"`
	// use when app updated, ProposedVersion can either be commit or revert
	ProposedVersion *types.Version `json:"proposed_version"`

	Mode AppMode `json:"mode"` // fixed or repliactes

	Created time.Time
	Updated time.Time

	StateMachine *StateMachine
	ClusterID    string

	UserEventChan chan *event.UserEvent
	// contains filtered or unexported fields
}

func NewApp

func NewApp(version *types.Version,
	userEventChan chan *event.UserEvent) (*App, error)

func (*App) BeginTx

func (app *App) BeginTx()

func (*App) CancelUpdate

func (app *App) CancelUpdate() error

func (*App) Commit

func (app *App) Commit()

here we persist the app anyway, no matter it touched or not

func (*App) Delete

func (app *App) Delete() error

delete a application and all related objects: versions, tasks, slots, proxies, dns record

func (*App) EmitAppEvent

func (app *App) EmitAppEvent(stateString string)

func (*App) GetSlot

func (app *App) GetSlot(index int) (*Slot, bool)

func (*App) GetSlots

func (app *App) GetSlots() []*Slot

func (*App) IsFixed

func (app *App) IsFixed() bool

func (*App) IsReplicates

func (app *App) IsReplicates() bool

func (*App) ProceedingRollingUpdate

func (app *App) ProceedingRollingUpdate(instances int) error

func (*App) Remove

func (app *App) Remove()

1, remove app from persisted storage 2, other cleanup process

func (*App) RemoveSlot

func (app *App) RemoveSlot(index int)

func (*App) ScaleDown

func (app *App) ScaleDown(removeInstances int) error

func (*App) ScaleUp

func (app *App) ScaleUp(newInstances int, newIps []string) error

also need user pass ip here

func (*App) ServiceDiscoveryURL added in v0.1.3

func (app *App) ServiceDiscoveryURL() string

func (*App) SetSlot

func (app *App) SetSlot(index int, slot *Slot)

func (*App) StateIs

func (app *App) StateIs(state string) bool

func (*App) Step added in v0.1.9

func (app *App) Step()

func (*App) Touch

func (app *App) Touch(force bool)

storage related

func (*App) TransitTo added in v0.1.9

func (app *App) TransitTo(targetState string, args ...interface{}) error

func (*App) Update

func (app *App) Update(version *types.Version, store store.Store) error

type AppMode

type AppMode string
var (
	APP_MODE_FIXED      AppMode = "fixed"
	APP_MODE_REPLICATES AppMode = "replicates"
)

type AppsByUpdated added in v0.1.3

type AppsByUpdated []*App

func (AppsByUpdated) Len added in v0.1.3

func (a AppsByUpdated) Len() int

func (AppsByUpdated) Less added in v0.1.3

func (a AppsByUpdated) Less(i, j int) bool

func (AppsByUpdated) Swap added in v0.1.3

func (a AppsByUpdated) Swap(i, j int)

type ConstraintParamHolder added in v0.1.3

type ConstraintParamHolder struct {
	Slot  *Slot
	Offer *mesos.Offer
}

type ConstraintParser added in v0.1.3

type ConstraintParser struct {
	scanner.Scanner
	// contains filtered or unexported fields
}

func (*ConstraintParser) Error added in v0.1.3

func (l *ConstraintParser) Error(e string)

func (*ConstraintParser) Lex added in v0.1.3

func (l *ConstraintParser) Lex(lval *yySymType) int

type ContainsStatement added in v0.1.3

type ContainsStatement struct {
	ConstraintParamHolder
	What  string
	Regex string
}

contains hostname barfoo

func (*ContainsStatement) Eval added in v0.1.3

func (cs *ContainsStatement) Eval() bool

func (*ContainsStatement) SetContext added in v0.1.3

func (cs *ContainsStatement) SetContext(ctx *ConstraintParamHolder)

func (*ContainsStatement) Valid added in v0.1.3

func (cs *ContainsStatement) Valid() error

type EqualStatement added in v0.1.5

type EqualStatement struct {
	ConstraintParamHolder
	What  string
	Regex string
}

equal hostname xxxx

func (*EqualStatement) Eval added in v0.1.5

func (ls *EqualStatement) Eval() bool

func (*EqualStatement) SetContext added in v0.1.5

func (ls *EqualStatement) SetContext(ctx *ConstraintParamHolder)

func (*EqualStatement) Valid added in v0.1.5

func (ls *EqualStatement) Valid() error

type LikeStatement added in v0.1.3

type LikeStatement struct {
	ConstraintParamHolder
	What  string
	Regex string
}

like hostname foobar*

func (*LikeStatement) Eval added in v0.1.3

func (ls *LikeStatement) Eval() bool

func (*LikeStatement) SetContext added in v0.1.3

func (ls *LikeStatement) SetContext(ctx *ConstraintParamHolder)

func (*LikeStatement) Valid added in v0.1.3

func (ls *LikeStatement) Valid() error

type NotStatement added in v0.1.3

type NotStatement struct {
	Op1 Statement
}

not (unique hostname)

func (*NotStatement) Eval added in v0.1.3

func (ns *NotStatement) Eval() bool

func (*NotStatement) SetContext added in v0.1.3

func (ns *NotStatement) SetContext(ctx *ConstraintParamHolder)

func (*NotStatement) Valid added in v0.1.3

func (ns *NotStatement) Valid() error

type OfferAllocator

type OfferAllocator struct {
	PendingOfferSlots []*Slot

	AllocatedOffer map[string]*OfferInfo // we store every offer that are occupied by running slot
	// contains filtered or unexported fields
}

func OfferAllocatorInstance

func OfferAllocatorInstance() *OfferAllocator

func (*OfferAllocator) PopNextPendingOffer

func (allocator *OfferAllocator) PopNextPendingOffer() *Slot

func (*OfferAllocator) PutSlotBackToPendingQueue

func (allocator *OfferAllocator) PutSlotBackToPendingQueue(slot *Slot)

func (*OfferAllocator) RemoveOfferSlotMapByOfferId

func (allocator *OfferAllocator) RemoveOfferSlotMapByOfferId(offerId string)

func (*OfferAllocator) RemoveOfferSlotMapBySlot

func (allocator *OfferAllocator) RemoveOfferSlotMapBySlot(slot *Slot)

func (*OfferAllocator) RemoveSlotFromAllocator added in v0.1.3

func (allocator *OfferAllocator) RemoveSlotFromAllocator(slot *Slot)

func (*OfferAllocator) RemoveSlotFromPendingOfferQueue

func (allocator *OfferAllocator) RemoveSlotFromPendingOfferQueue(slot *Slot)

func (*OfferAllocator) RetrieveSlotIdWithOfferId added in v0.1.3

func (allocator *OfferAllocator) RetrieveSlotIdWithOfferId(offerId string) (string, error)

func (*OfferAllocator) SetOfferSlotMap

func (allocator *OfferAllocator) SetOfferSlotMap(offer *mesos.Offer, slot *Slot)

func (*OfferAllocator) SlotsByAgentID added in v0.1.3

func (allocator *OfferAllocator) SlotsByAgentID(agentID string) []string

func (*OfferAllocator) SlotsByHostname added in v0.1.3

func (allocator *OfferAllocator) SlotsByHostname(hostname string) []string

type OfferInfo added in v0.1.3

type OfferInfo struct {
	OfferID  string
	AgentID  string
	Hostname string
	AgentIP  string
}

func OfferAllocatorItemFromRaft

func OfferAllocatorItemFromRaft(item *rafttypes.OfferAllocatorItem) (slotID string, offerInfo *OfferInfo)

type OfferWrapper

type OfferWrapper struct {
	Offer        *mesos.Offer
	CpusUsed     float64
	MemUsed      float64
	DiskUsed     float64
	PortUsedSize int
}

wrapper offer to record offer reserve history

func NewOfferWrapper

func NewOfferWrapper(offer *mesos.Offer) *OfferWrapper

func (*OfferWrapper) CpuRemain

func (ow *OfferWrapper) CpuRemain() float64

func (*OfferWrapper) DiskRemain

func (ow *OfferWrapper) DiskRemain() float64

func (*OfferWrapper) MemRemain

func (ow *OfferWrapper) MemRemain() float64

func (*OfferWrapper) PortsRemain

func (ow *OfferWrapper) PortsRemain() []uint64

type OrStatement added in v0.1.3

type OrStatement struct {
	ConstraintParamHolder
	Op1 Statement
	Op2 Statement
}

or (like ip foobar) (unique hostname)

func (*OrStatement) Eval added in v0.1.3

func (os *OrStatement) Eval() bool

func (*OrStatement) SetContext added in v0.1.3

func (os *OrStatement) SetContext(ctx *ConstraintParamHolder)

func (*OrStatement) Valid added in v0.1.3

func (os *OrStatement) Valid() error

type RestartPolicy

type RestartPolicy struct {
	BackoffSeconds        time.Duration
	BackoffFactor         float64
	MaxLaunchDelaySeconds time.Duration
	// contains filtered or unexported fields
}

func NewRestartPolicy

func NewRestartPolicy(slot *Slot, BackoffSeconds time.Duration, BackoffFactor float64,
	MaxLaunchDelaySeconds time.Duration, restartFunc TestAndRestartFunc) *RestartPolicy

func (*RestartPolicy) Stop

func (rs *RestartPolicy) Stop()

type Slot

type Slot struct {
	Index   int
	ID      string
	App     *App
	Version *types.Version
	State   string

	CurrentTask *Task
	TaskHistory []*Task

	OfferID       string
	AgentID       string
	Ip            string
	AgentHostName string
	// contains filtered or unexported fields
}

func LoadAppSlots

func LoadAppSlots(app *App) ([]*Slot, error)

func NewSlot

func NewSlot(app *App, version *types.Version, index int) *Slot

func SlotFromRaft

func SlotFromRaft(raftSlot *rafttypes.Slot) *Slot

func (*Slot) Abnormal

func (slot *Slot) Abnormal() bool

func (*Slot) Archive

func (slot *Slot) Archive()

func (*Slot) BeginTx

func (slot *Slot) BeginTx()

func (*Slot) BuildTaskEvent

func (slot *Slot) BuildTaskEvent(eventType string) *eventbus.Event

func (*Slot) Commit

func (slot *Slot) Commit()

here we persist the app anyway, no matter it touched or not

func (*Slot) DispatchNewTask

func (slot *Slot) DispatchNewTask(version *types.Version)

func (*Slot) Dispatched

func (slot *Slot) Dispatched() bool

func (*Slot) EmitTaskEvent

func (slot *Slot) EmitTaskEvent(eventType string)

func (*Slot) Healthy

func (slot *Slot) Healthy() bool

func (*Slot) KillTask

func (slot *Slot) KillTask()

kill task doesn't need cleanup slot from app.Slots

func (*Slot) Remove

func (slot *Slot) Remove()

func (*Slot) ReserveOfferAndPrepareTaskInfo

func (slot *Slot) ReserveOfferAndPrepareTaskInfo(ow *OfferWrapper) (*OfferWrapper, *mesos.TaskInfo)

func (*Slot) ResourcesNeeded

func (slot *Slot) ResourcesNeeded() []*mesos.Resource

func (*Slot) ResourcesUsed

func (slot *Slot) ResourcesUsed() *SlotResource

func (*Slot) ServiceDiscoveryURL added in v0.1.3

func (slot *Slot) ServiceDiscoveryURL() string

func (*Slot) SetHealthy

func (slot *Slot) SetHealthy(healthy bool)

func (*Slot) SetState

func (slot *Slot) SetState(state string) error

func (*Slot) StateIs

func (slot *Slot) StateIs(state string) bool

func (*Slot) StopRestartPolicy

func (slot *Slot) StopRestartPolicy()

func (*Slot) TestOfferMatch

func (slot *Slot) TestOfferMatch(ow *OfferWrapper) bool

func (*Slot) Touch

func (slot *Slot) Touch(force bool)

func (*Slot) UpdateOfferInfo

func (slot *Slot) UpdateOfferInfo(offer *mesos.Offer) error

type SlotResource

type SlotResource struct {
	CPU  float64
	Mem  float64
	Disk float64
}

type SlotsById

type SlotsById []*Slot

func (SlotsById) Len

func (a SlotsById) Len() int

func (SlotsById) Less

func (a SlotsById) Less(i, j int) bool

func (SlotsById) Swap

func (a SlotsById) Swap(i, j int)

type State added in v0.1.9

type State interface {
	OnEnter()
	OnExit()

	StateName() string
	Step()
	CanTransitTo(targetState string) bool
}

func StateFromRaft added in v0.1.9

func StateFromRaft(app *App, state *rafttypes.State) State

type StateCancelUpdate added in v0.1.9

type StateCancelUpdate struct {
	Name string
	App  *App

	CurrentSlot      *Slot
	CurrentSlotIndex int
	TargetSlotIndex  int
	// contains filtered or unexported fields
}

func NewStateCancelUpdate added in v0.1.9

func NewStateCancelUpdate(app *App) *StateCancelUpdate

func (*StateCancelUpdate) CanTransitTo added in v0.1.9

func (cancelUpdate *StateCancelUpdate) CanTransitTo(targetState string) bool

state machine can transit to any state if current state is cancelUpdate

func (*StateCancelUpdate) OnEnter added in v0.1.9

func (cancelUpdate *StateCancelUpdate) OnEnter()

func (*StateCancelUpdate) OnExit added in v0.1.9

func (cancelUpdate *StateCancelUpdate) OnExit()

func (*StateCancelUpdate) StateName added in v0.1.9

func (cancelUpdate *StateCancelUpdate) StateName() string

func (*StateCancelUpdate) Step added in v0.1.9

func (cancelUpdate *StateCancelUpdate) Step()

type StateCreating added in v0.1.9

type StateCreating struct {
	Name string
	App  *App

	CurrentSlot      *Slot
	CurrentSlotIndex int
	TargetSlotIndex  int
	// contains filtered or unexported fields
}

func NewStateCreating added in v0.1.9

func NewStateCreating(app *App) *StateCreating

func (*StateCreating) CanTransitTo added in v0.1.9

func (creating *StateCreating) CanTransitTo(targetState string) bool

state machine can transit to any state if current state is creating

func (*StateCreating) OnEnter added in v0.1.9

func (creating *StateCreating) OnEnter()

func (*StateCreating) OnExit added in v0.1.9

func (creating *StateCreating) OnExit()

func (*StateCreating) StateName added in v0.1.9

func (creating *StateCreating) StateName() string

func (*StateCreating) Step added in v0.1.9

func (creating *StateCreating) Step()

type StateDeleting added in v0.1.9

type StateDeleting struct {
	Name string
	App  *App

	CurrentSlot      *Slot
	CurrentSlotIndex int
	TargetSlotIndex  int
	// contains filtered or unexported fields
}

func NewStateDeleting added in v0.1.9

func NewStateDeleting(app *App) *StateDeleting

func (*StateDeleting) CanTransitTo added in v0.1.9

func (deleting *StateDeleting) CanTransitTo(targetState string) bool

state machine can transit to any state if current state is deleting

func (*StateDeleting) OnEnter added in v0.1.9

func (deleting *StateDeleting) OnEnter()

func (*StateDeleting) OnExit added in v0.1.9

func (deleting *StateDeleting) OnExit()

func (*StateDeleting) SlotSafeToRemoveFromApp added in v0.1.9

func (deleting *StateDeleting) SlotSafeToRemoveFromApp(slot *Slot) bool

func (*StateDeleting) StateName added in v0.1.9

func (deleting *StateDeleting) StateName() string

func (*StateDeleting) Step added in v0.1.9

func (deleting *StateDeleting) Step()

type StateMachine added in v0.1.9

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

func NewStateMachine added in v0.1.9

func NewStateMachine() *StateMachine

default state for a new statemachine is creating

func StateMachineFromRaft added in v0.1.9

func StateMachineFromRaft(app *App, machine *rafttypes.StateMachine) *StateMachine

func (*StateMachine) CanTransitTo added in v0.1.9

func (machine *StateMachine) CanTransitTo(targetStateString string) bool

test if targetState is changable

func (*StateMachine) CurrentState added in v0.1.9

func (machine *StateMachine) CurrentState() State

func (*StateMachine) Is added in v0.1.9

func (machine *StateMachine) Is(stateExpected string) bool

test machine.state is stateExpected

func (*StateMachine) ReadableState added in v0.1.9

func (machine *StateMachine) ReadableState() string

func (*StateMachine) Start added in v0.1.9

func (machine *StateMachine) Start(startState State)

func (*StateMachine) Step added in v0.1.9

func (machine *StateMachine) Step()

move state machine step foward

func (*StateMachine) TransitTo added in v0.1.9

func (machine *StateMachine) TransitTo(targetState State) error

transition from one state to another, return error if not a valid transtion condition

type StateNormal added in v0.1.9

type StateNormal struct {
	Name string
	App  *App
}

func NewStateNormal added in v0.1.9

func NewStateNormal(app *App) *StateNormal

func (*StateNormal) CanTransitTo added in v0.1.9

func (normal *StateNormal) CanTransitTo(targetState string) bool

state machine can transit to any state if current state is normal

func (*StateNormal) OnEnter added in v0.1.9

func (normal *StateNormal) OnEnter()

func (*StateNormal) OnExit added in v0.1.9

func (normal *StateNormal) OnExit()

func (*StateNormal) StateName added in v0.1.9

func (normal *StateNormal) StateName() string

func (*StateNormal) Step added in v0.1.9

func (normal *StateNormal) Step()

type StateScaleDown added in v0.1.9

type StateScaleDown struct {
	Name string
	App  *App

	CurrentSlot      *Slot
	CurrentSlotIndex int
	TargetSlotIndex  int
	// contains filtered or unexported fields
}

func NewStateScaleDown added in v0.1.9

func NewStateScaleDown(app *App) *StateScaleDown

func (*StateScaleDown) CanTransitTo added in v0.1.9

func (scaleDown *StateScaleDown) CanTransitTo(targetState string) bool

state machine can transit to any state if current state is scaleDown

func (*StateScaleDown) OnEnter added in v0.1.9

func (scaleDown *StateScaleDown) OnEnter()

func (*StateScaleDown) OnExit added in v0.1.9

func (scaleDown *StateScaleDown) OnExit()

func (*StateScaleDown) SlotSafeToRemoveFromApp added in v0.1.9

func (scaleDown *StateScaleDown) SlotSafeToRemoveFromApp(slot *Slot) bool

func (*StateScaleDown) StateName added in v0.1.9

func (scaleDown *StateScaleDown) StateName() string

func (*StateScaleDown) Step added in v0.1.9

func (scaleDown *StateScaleDown) Step()

type StateScaleUp added in v0.1.9

type StateScaleUp struct {
	Name string
	App  *App

	CurrentSlot      *Slot
	CurrentSlotIndex int
	TargetSlotIndex  int
	// contains filtered or unexported fields
}

func NewStateScaleUp added in v0.1.9

func NewStateScaleUp(app *App) *StateScaleUp

func (*StateScaleUp) CanTransitTo added in v0.1.9

func (scaleUp *StateScaleUp) CanTransitTo(targetState string) bool

state machine can transit to any state if current state is scaleUp

func (*StateScaleUp) OnEnter added in v0.1.9

func (scaleUp *StateScaleUp) OnEnter()

func (*StateScaleUp) OnExit added in v0.1.9

func (scaleUp *StateScaleUp) OnExit()

func (*StateScaleUp) StateName added in v0.1.9

func (scaleUp *StateScaleUp) StateName() string

func (*StateScaleUp) Step added in v0.1.9

func (scaleUp *StateScaleUp) Step()

type StateUpdating added in v0.1.9

type StateUpdating struct {
	Name string
	App  *App

	CurrentSlot         *Slot
	CurrentSlotIndex    int
	TargetSlotIndex     int
	SlotCountNeedUpdate int
	// contains filtered or unexported fields
}

func NewStateUpdating added in v0.1.9

func NewStateUpdating(app *App, slotCountNeedUpdate int) *StateUpdating

func (*StateUpdating) CanTransitTo added in v0.1.9

func (updating *StateUpdating) CanTransitTo(targetState string) bool

state machine can transit to any state if current state is updating

func (*StateUpdating) OnEnter added in v0.1.9

func (updating *StateUpdating) OnEnter()

func (*StateUpdating) OnExit added in v0.1.9

func (updating *StateUpdating) OnExit()

func (*StateUpdating) StateName added in v0.1.9

func (updating *StateUpdating) StateName() string

func (*StateUpdating) Step added in v0.1.9

func (updating *StateUpdating) Step()

type Statement added in v0.1.3

type Statement interface {
	Eval() bool
	Valid() error
	SetContext(ctx *ConstraintParamHolder)
}

func ParseConstraint added in v0.1.3

func ParseConstraint(c string) (Statement, error)

type Task

type Task struct {
	ID      string
	Version *types.Version
	Slot    *Slot

	State  string
	Stdout string
	Stderr string

	HostPorts     []uint64
	OfferID       string
	AgentID       string
	Ip            string
	AgentHostName string

	Reason  string // mesos updateStatus field
	Message string // mesos updateStatus field
	Source  string // mesos updateStatus field

	Created    time.Time
	ArchivedAt time.Time
	// contains filtered or unexported fields
}

func NewTask

func NewTask(version *types.Version, slot *Slot) *Task

func TaskFromRaft

func TaskFromRaft(raftTask *rafttypes.Task) *Task

func (*Task) Kill

func (task *Task) Kill()

func (*Task) PrepareTaskInfo

func (task *Task) PrepareTaskInfo(ow *OfferWrapper) *mesos.TaskInfo

type TaskBuilder

type TaskBuilder struct {
	HostPorts []uint64
	// contains filtered or unexported fields
}

func NewTaskBuilder

func NewTaskBuilder(task *Task) *TaskBuilder

func (*TaskBuilder) AppendContainerDockerEnvironments

func (builder *TaskBuilder) AppendContainerDockerEnvironments(envs map[string]string) *TaskBuilder

func (*TaskBuilder) AppendContainerDockerParameters

func (builder *TaskBuilder) AppendContainerDockerParameters(parameters []*types.Parameter) *TaskBuilder

func (*TaskBuilder) AppendContainerDockerVolumes

func (builder *TaskBuilder) AppendContainerDockerVolumes(volumes []*types.Volume) *TaskBuilder

func (*TaskBuilder) AppendTaskInfoLabels

func (builder *TaskBuilder) AppendTaskInfoLabels(labelMap map[string]string) *TaskBuilder

func (*TaskBuilder) GetTaskInfo

func (builder *TaskBuilder) GetTaskInfo() *mesos.TaskInfo

func (*TaskBuilder) SetAgentId

func (builder *TaskBuilder) SetAgentId(agentId string) *TaskBuilder

func (*TaskBuilder) SetCommand

func (builder *TaskBuilder) SetCommand(needShell bool, cmd string, args []string) *TaskBuilder

func (*TaskBuilder) SetContainerDockerForcePullImage

func (builder *TaskBuilder) SetContainerDockerForcePullImage(force bool) *TaskBuilder

func (*TaskBuilder) SetContainerDockerImage

func (builder *TaskBuilder) SetContainerDockerImage(image string) *TaskBuilder

func (*TaskBuilder) SetContainerDockerPrivileged

func (builder *TaskBuilder) SetContainerDockerPrivileged(privileged bool) *TaskBuilder

func (*TaskBuilder) SetContainerType

func (builder *TaskBuilder) SetContainerType(containerType string) *TaskBuilder

func (*TaskBuilder) SetHealthCheck

func (builder *TaskBuilder) SetHealthCheck(healthCheck *types.HealthCheck) *TaskBuilder

func (*TaskBuilder) SetName

func (builder *TaskBuilder) SetName(name string) *TaskBuilder

func (*TaskBuilder) SetNetwork

func (builder *TaskBuilder) SetNetwork(network string, portsAvailable []uint64) *TaskBuilder

func (*TaskBuilder) SetResources

func (builder *TaskBuilder) SetResources(resources []*mesos.Resource) *TaskBuilder

func (*TaskBuilder) SetTaskId

func (builder *TaskBuilder) SetTaskId(taskId string) *TaskBuilder

func (*TaskBuilder) SetURIs

func (builder *TaskBuilder) SetURIs(uriList []string) *TaskBuilder

type TestAndRestartFunc

type TestAndRestartFunc func(slot *Slot) bool

type UniqueStatment added in v0.1.3

type UniqueStatment struct {
	ConstraintParamHolder
	What string
}

(unique hostname)

func (*UniqueStatment) Eval added in v0.1.3

func (us *UniqueStatment) Eval() bool

func (*UniqueStatment) SetContext added in v0.1.3

func (us *UniqueStatment) SetContext(ctx *ConstraintParamHolder)

func (*UniqueStatment) Valid added in v0.1.3

func (us *UniqueStatment) Valid() error

Jump to

Keyboard shortcuts

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