cluster

package
v0.0.0-...-b392570 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2018 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// NodeLabelsPrefix is the constraint key prefix for node labels.
	NodeLabelsPrefix = "node.labels."
	// EngineLabelsPrefix is the constraint key prefix for engine labels.
	EngineLabelsPrefix = "engine.labels."
)
View Source
const (
	MigrateReady = iota + 1
	Migrating
	MigrateFailure
	MigrateCompleted
)
View Source
const (
	// UpgradeReady is exported, engine container upgrade is ready
	UpgradeReady = iota + 1
	// UpgradeIgnore is exported, engine healthy is false, can't upgrade, migrate container.
	UpgradeIgnore
	// UpgradeCompleted is exported, engine container upgraded completed.
	UpgradeCompleted
	// UpgradeFailure is exported, engine container upgraded failure.
	UpgradeFailure
	// UpgradeRecovery is exported, engine container recovery upgraded.
	UpgradeRecovery
)

Variables

View Source
var (
	//cluster discovery is nil.
	ErrClusterDiscoveryInvalid = errors.New("cluster discovery invalid")
	//cluster meta not found
	ErrClusterMetaDataNotFound = errors.New("cluster metadata not found")
	//cluster group not found
	ErrClusterGroupNotFound = errors.New("cluster group not found")
	//cluster container not found
	ErrClusterContainerNotFound = errors.New("cluster container not found")
	//cluster server not found
	ErrClusterServerNotFound = errors.New("cluster server not found")
	//cluster group no docker engine available
	ErrClusterNoEngineAvailable = errors.New("cluster no docker-engine available")
	//cluster containers instances invalid
	ErrClusterContainersInstancesInvalid = errors.New("cluster containers instances invalid")
	//cluster containers meta create failure
	ErrClusterContainersMetaCreateFailure = errors.New("cluster containers meta create failure")
	//cluster create containers name conflict
	ErrClusterCreateContainerNameConflict = errors.New("cluster create containers name conflict, this cluster already exists")
	//cluster create containers tag already using
	ErrClusterCreateContainerTagAlreadyUsing = errors.New("cluster create containers tag is already using")
	//cluster create containers all failure
	ErrClusterCreateContainerFailure = errors.New("cluster create containers failure")
	//cluster containers is upgrading
	ErrClusterContainersUpgrading = errors.New("cluster containers state is upgrading")
	//cluster containers is migrating
	ErrClusterContainersMigrating = errors.New("cluster containers state is migrating")
	//cluster containers is setting
	ErrClusterContainersSetting = errors.New("cluster containers state is setting")
	//cluster containers instances no change
	ErrClusterContainersInstancesNoChange = errors.New("cluster containers instances no change")
)

cluster errors define

Functions

func FullStateString

func FullStateString(state *types.ContainerState) string

FullStateString returns readable description of the state

func GetAvailabilityText

func GetAvailabilityText(availability Availability) string

GetAvailabilityText is exported return a availability typed text.

func GetStateText

func GetStateText(state EngineState) string

GetStateText is exported return a state typed text.

func MatchConstraints

func MatchConstraints(constraints []Constraint, engine *Engine) bool

MatchConstraints returns true if the node satisfies the given constraints.

func ShortContainerID

func ShortContainerID(containerid string) string

ShortContainerID is exported return a short containerid string.

func StateString

func StateString(state *types.ContainerState) string

StateString returns a single string to describe state

Types

type Availability

type Availability int

Availability define

const (
	//Active, accept scheduling service allocations and failover at any time.
	Active Availability = iota
	//Pasue, pause node scheduling, node assigned services are not affected, and no fault migration occurs.
	Pasue
	//Expel, exclude nodes from the cluster and create all services on that node to other nodes with active availability.
	Drain
)

Engine availability enum value

type Client

type Client struct {
	ApiAddr string
	// contains filtered or unexported fields
}

Client is exported

func NewClient

func NewClient(apiAddr string) *Client

NewClient is exported

func (*Client) Close

func (client *Client) Close()

Close is exported client close

func (*Client) CreateContainerRequest

func (client *Client) CreateContainerRequest(ctx context.Context, config models.Container) (*ctypes.CreateContainerResponse, error)

CreateContainerRequest is exported create a container request.

func (*Client) GetContainerRequest

func (client *Client) GetContainerRequest(ctx context.Context, containerid string) (*types.ContainerJSON, error)

GetContainerRequest is exported get a container type info.

func (*Client) GetContainersRequest

func (client *Client) GetContainersRequest(ctx context.Context) ([]types.Container, error)

GetContainersRequest is exported return all containers info.

func (*Client) GetDockerInfoRequest

func (client *Client) GetDockerInfoRequest(ctx context.Context) (*types.Info, error)

GetDockerInfoRequest is exported get docker node info

func (*Client) OperateContainerRequest

func (client *Client) OperateContainerRequest(ctx context.Context, operate models.ContainerOperate) error

OperateContainerRequest is exported operate a container request.

func (*Client) RemoveContainerRequest

func (client *Client) RemoveContainerRequest(ctx context.Context, containerid string) error

RemoveContainerRequest is exported remove a container request.

func (*Client) UpgradeContainerRequest

func (client *Client) UpgradeContainerRequest(ctx context.Context, operate models.ContainerOperate) (*ctypes.UpgradeContainerResponse, error)

UpgradeContainerRequest is exported upgrade a container request.

type Cluster

type Cluster struct {
	sync.RWMutex
	Location     string
	NotifySender *notify.NotifySender
	Discovery    *discovery.Discovery
	// contains filtered or unexported fields
}

Cluster is exported

func NewCluster

func NewCluster(driverOpts system.DriverOpts, notifySender *notify.NotifySender, discovery *discovery.Discovery) (*Cluster, error)

NewCluster is exported

func (*Cluster) CreateContainers

func (cluster *Cluster) CreateContainers(groupid string, instances int, webhooks types.WebHooks, placement types.Placement, config models.Container, createOption types.CreateOption) (string, *types.CreatedContainers, error)

CreateContainers is exported

func (*Cluster) GetEngine

func (cluster *Cluster) GetEngine(ip string) *Engine

GetEngine is exported

func (*Cluster) GetEngineGroups

func (cluster *Cluster) GetEngineGroups(engine *Engine) []*Group

GetEngineGroups is exported

func (*Cluster) GetGroup

func (cluster *Cluster) GetGroup(groupid string) *Group

GetGroup is exported

func (*Cluster) GetGroupAllContainers

func (cluster *Cluster) GetGroupAllContainers(groupid string) *types.GroupContainers

GetGroupAllContainers is exported

func (*Cluster) GetGroupAllEngines

func (cluster *Cluster) GetGroupAllEngines(groupid string) []*Engine

GetGroupAllEngines is exported Returns all engine under group and contains offline (cluster engines not exists.)

func (*Cluster) GetGroupContainers

func (cluster *Cluster) GetGroupContainers(metaid string) *types.GroupContainer

GetGroupContainers is exported

func (*Cluster) GetGroupEngines

func (cluster *Cluster) GetGroupEngines(groupid string) []*Engine

GetGroupEngines is exported Returns pairs engine under group and cluster engines is exists

func (*Cluster) GetGroups

func (cluster *Cluster) GetGroups() []*Group

GetGroups is exported

func (*Cluster) GetMetaBase

func (cluster *Cluster) GetMetaBase(metaid string) *MetaBase

GetMetaBase is exported

func (*Cluster) GetMetaData

func (cluster *Cluster) GetMetaData(metaid string) *MetaData

GetMetaData is exported

func (*Cluster) GetMetaDataEngines

func (cluster *Cluster) GetMetaDataEngines(metaid string) (*MetaData, []*Engine, error)

GetMetaDataEngines is exported

func (*Cluster) GetMetaEnginesContainers

func (cluster *Cluster) GetMetaEnginesContainers(metaData *MetaData, metaEngines map[string]*Engine) *types.GroupContainer

GetMetaEnginesContainers is exported

func (*Cluster) GetServerOfEngines

func (cluster *Cluster) GetServerOfEngines(server Server) *Engine

GetServerOfEngines is exported

func (*Cluster) InGroupsContains

func (cluster *Cluster) InGroupsContains(ip string, name string) bool

InGroupsContains is exported

func (*Cluster) NotifyGroupEnginesWatchEvent

func (cluster *Cluster) NotifyGroupEnginesWatchEvent(description string, watchEngines WatchEngines)

NotifyGroupEnginesWatchEvent is exported

func (*Cluster) NotifyGroupMetaContainersEvent

func (cluster *Cluster) NotifyGroupMetaContainersEvent(description string, exception error, metaid string)

NotifyGroupMetaContainersEvent is exported

func (*Cluster) OperateContainer

func (cluster *Cluster) OperateContainer(containerid string, action string) (string, *types.OperatedContainers, error)

OperateContainer is exported

func (*Cluster) OperateContainers

func (cluster *Cluster) OperateContainers(metaid string, containerid string, action string) (*types.OperatedContainers, error)

OperateContainers is exported if containerid is empty string so operate metaid's all containers

func (*Cluster) RecoveryContainers

func (cluster *Cluster) RecoveryContainers(metaid string) error

RecoveryContainers is exported

func (*Cluster) RefreshEnginesContainers

func (cluster *Cluster) RefreshEnginesContainers(metaEngines map[string]*Engine)

RefreshEnginesContainers is exported

func (*Cluster) RemoveContainer

func (cluster *Cluster) RemoveContainer(containerid string) (string, *types.RemovedContainers, error)

RemoveContainer is exported

func (*Cluster) RemoveContainers

func (cluster *Cluster) RemoveContainers(metaid string, containerid string) (*types.RemovedContainers, error)

RemoveContainers is exported if containerid is empty string so remove metaid's all containers

func (*Cluster) RemoveContainersOfMetaName

func (cluster *Cluster) RemoveContainersOfMetaName(groupid string, metaname string) (string, *types.RemovedContainers, error)

RemoveContainersOfMetaName is exported remove meta's all containers

func (*Cluster) RemoveGroup

func (cluster *Cluster) RemoveGroup(groupid string) bool

RemoveGroup is exported

func (*Cluster) SetGroup

func (cluster *Cluster) SetGroup(group *Group)

SetGroup is exported

func (*Cluster) SetServerNodeLabels

func (cluster *Cluster) SetServerNodeLabels(server Server, labels map[string]string) error

SetServerNodeLabels is exported

func (*Cluster) Start

func (cluster *Cluster) Start() error

Start is exported Cluster start, init container config cache watch open discovery service

func (*Cluster) Stop

func (cluster *Cluster) Stop()

Stop is exported Cluster stop close discovery service stop pendEngines loop

func (*Cluster) UpdateContainers

func (cluster *Cluster) UpdateContainers(metaid string, instances int, webhooks types.WebHooks, placement types.Placement, config models.Container, updateOption types.UpdateOption) (*types.CreatedContainers, error)

UpdateContainers is exported

func (*Cluster) UpgradeContainers

func (cluster *Cluster) UpgradeContainers(metaid string, imagetag string) (*types.UpgradeContainers, error)

UpgradeContainers is exported

type Constraint

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

Constraint defines a constraint.

func ParseConstraints

func ParseConstraints(constraints []string) ([]Constraint, error)

ParseConstraints parses list of constraints.

func (*Constraint) Match

func (c *Constraint) Match(whats ...string) bool

Match checks if the Constraint matches the target strings.

type Container

type Container struct {
	BaseConfig *ContainerBaseConfig
	Config     *ContainerConfig
	Info       types.ContainerJSON
	Engine     *Engine
}

Container is exported

func (*Container) GroupID

func (c *Container) GroupID() string

GroupID is exported Return Container GroupID

func (*Container) Index

func (c *Container) Index() int

Index is exported Return Container Index

func (*Container) MetaID

func (c *Container) MetaID() string

MetaID is exported Return Container MetaID

func (*Container) OriginalName

func (c *Container) OriginalName() string

OriginalName is exported Return Container OriginalName

func (*Container) ValidateConfig

func (c *Container) ValidateConfig() bool

ValidateConfig is exported

type ContainerBaseConfig

type ContainerBaseConfig struct {
	Index int `json:"Index"`
	models.Container
	MetaData *MetaData `json:"-"`
}

ContainerBaseConfig is exported

type ContainerConfig

type ContainerConfig struct {
	models.Container
}

ContainerConfig is exported

type Containers

type Containers []*Container

Containers represents a list of containers

func (Containers) Get

func (containers Containers) Get(IDOrName string) *Container

Get returns a container using its ID or Name

type ContainersConfigCache

type ContainersConfigCache struct {
	sync.RWMutex
	Root string
	// contains filtered or unexported fields
}

ContainersConfigCache is exported

func NewContainersConfigCache

func NewContainersConfigCache(root string) (*ContainersConfigCache, error)

NewContainersConfigCache is exported Structure ContainersCache

func (*ContainersConfigCache) ClearContainerBaseConfig

func (cache *ContainersConfigCache) ClearContainerBaseConfig(metaid string)

ClearContainerBaseConfig is exported

func (*ContainersConfigCache) ContainsMetaData

func (cache *ContainersConfigCache) ContainsMetaData(groupid string, name string) bool

ContainsMetaData is exported Return bool, find metadata name

func (*ContainersConfigCache) CreateContainerBaseConfig

func (cache *ContainersConfigCache) CreateContainerBaseConfig(metaid string, baseConfig *ContainerBaseConfig)

CreateContainerBaseConfig is exported

func (*ContainersConfigCache) CreateMetaData

func (cache *ContainersConfigCache) CreateMetaData(groupid string, instances int, webhooks types.WebHooks, placement types.Placement, config models.Container, isremovedelay bool, isrecovery bool) (*MetaData, error)

CreateMetaData is exported

func (*ContainersConfigCache) GetContainerBaseConfig

func (cache *ContainersConfigCache) GetContainerBaseConfig(metaid string, containerid string) *ContainerBaseConfig

GetContainerBaseConfig is exported

func (*ContainersConfigCache) GetGroupMetaData

func (cache *ContainersConfigCache) GetGroupMetaData(groupid string) []*MetaData

GetGroupMetaData is exported

func (*ContainersConfigCache) GetMetaData

func (cache *ContainersConfigCache) GetMetaData(metaid string) *MetaData

GetMetaData is exported Return metaid of a metadata

func (*ContainersConfigCache) GetMetaDataBaseConfigs

func (cache *ContainersConfigCache) GetMetaDataBaseConfigs(metaid string) []*ContainerBaseConfig

GetMetaDataBaseConfigs is exported

func (*ContainersConfigCache) GetMetaDataBaseConfigsCount

func (cache *ContainersConfigCache) GetMetaDataBaseConfigsCount(metaid string) int

GetMetaDataBaseConfigsCount is exported result < 0, not found metadata

func (*ContainersConfigCache) GetMetaDataOfContainer

func (cache *ContainersConfigCache) GetMetaDataOfContainer(containerid string) *MetaData

GetMetaDataOfContainer is exported Return containerid of a metadata

func (*ContainersConfigCache) GetMetaDataOfName

func (cache *ContainersConfigCache) GetMetaDataOfName(groupid string, name string) *MetaData

GetMetaDataOfName is exported Return name of a metadata

func (*ContainersConfigCache) Init

func (cache *ContainersConfigCache) Init()

Init is exported Initialize containers baseConfig, load cache directory's metaData First clear containers cache

func (*ContainersConfigCache) MakeContainerIdleIndex

func (cache *ContainersConfigCache) MakeContainerIdleIndex(metaid string) int

MakeContainerIdleIndex is exported Return a baseContainerConfig idle index

func (*ContainersConfigCache) MakeUniqueMetaID

func (cache *ContainersConfigCache) MakeUniqueMetaID() string

MakeUniqueMetaID is exported Return a new create unique metaid

func (*ContainersConfigCache) RemoveContainerBaseConfig

func (cache *ContainersConfigCache) RemoveContainerBaseConfig(metaid string, containerid string)

RemoveContainerBaseConfig is exported

func (*ContainersConfigCache) RemoveGroupMetaData

func (cache *ContainersConfigCache) RemoveGroupMetaData(groupid string) bool

RemoveGroupMetaData is exported

func (*ContainersConfigCache) RemoveMetaData

func (cache *ContainersConfigCache) RemoveMetaData(metaid string) bool

RemoveMetaData is exported Remove metaid of a metadata

func (*ContainersConfigCache) SetAvailableNodesChanged

func (cache *ContainersConfigCache) SetAvailableNodesChanged(metaid string, changed bool)

SetAvailableNodesChanged is exported

func (*ContainersConfigCache) SetImageTag

func (cache *ContainersConfigCache) SetImageTag(metaid string, imagetag string) bool

SetImageTag is exported Return set tag result

func (*ContainersConfigCache) SetMetaData

func (cache *ContainersConfigCache) SetMetaData(metaid string, instances int, webhooks types.WebHooks, placement types.Placement, config models.Container, isremovedelay bool, isrecovery bool)

SetMetaData is exported

type Engine

type Engine struct {
	sync.RWMutex
	ID               string            `json:"ID"`
	Name             string            `json:"Name"`
	IP               string            `json:"IP"`
	APIAddr          string            `json:"APIAddr"`
	Cpus             int64             `json:"Cpus"`
	Memory           int64             `json:"Memory"`
	StorageDirver    string            `json:"StorageDirver"`
	KernelVersion    string            `json:"KernelVersion"`
	Architecture     string            `json:"Architecture"`
	OperatingSystem  string            `json:"OperatingSystem"`
	OSType           string            `json:"OSType"`
	EngineLabels     map[string]string `json:"EngineLabels"`
	NodeLabels       map[string]string `json:"NodeLabels"`
	AppVersion       string            `json:"AppVersion"`
	DockerVersion    string            `json:"DockerVersion"`
	AvailabilityText string            `json:"AvailabilityText"`
	StateText        string            `json:"StateText"`
	// contains filtered or unexported fields
}

Engine is exported

func NewEngine

func NewEngine(nodeData *types.NodeData, overcommitRatio float64, removeDelay time.Duration, configCache *ContainersConfigCache) (*Engine, error)

NewEngine is exported

func NewWatchEngine

func NewWatchEngine(ip string, name string, state EngineState) *Engine

NewWatchEngine is exported

func (*Engine) Close

func (engine *Engine) Close()

Close is exported Engine stop refresh containers loop

func (*Engine) Container

func (engine *Engine) Container(containerid string) *Container

Container is exported Return engine container of containerid.

func (*Engine) Containers

func (engine *Engine) Containers(metaid string) Containers

Containers is exported Return engine containers. if metaid is empty string so return engine's all containers

func (*Engine) CreateContainer

func (engine *Engine) CreateContainer(config models.Container) (*Container, error)

CreateContainer is exported Engine create a container

func (*Engine) EngineLabelsPairs

func (engine *Engine) EngineLabelsPairs() map[string]string

EngineLabelsPairs is exported

func (*Engine) ForceUpgradeContainer

func (engine *Engine) ForceUpgradeContainer(operate models.ContainerOperate) (*Container, error)

ForceUpgradeContainer is exported Engine force upgrade a container.

func (*Engine) HasContainer

func (engine *Engine) HasContainer(containerid string) bool

HasContainer is exported find containerid in engine containers

func (*Engine) HasMeta

func (engine *Engine) HasMeta(metaid string) bool

HasMeta is exported find metaid in engine containers

func (*Engine) IsDisconnected

func (engine *Engine) IsDisconnected() bool

IsDisconnected is exported Determine if the engine is in disconnected state

func (*Engine) IsHealthy

func (engine *Engine) IsHealthy() bool

IsHealthy is exported Determine if the engine is in healthy state

func (*Engine) IsPending

func (engine *Engine) IsPending() bool

IsPending is exported Determine if the engine is in pending state

func (*Engine) MetaIds

func (engine *Engine) MetaIds() []string

MetaIds is exported Return engine containers all metaids array.

func (*Engine) NodeLabelsPairs

func (engine *Engine) NodeLabelsPairs() map[string]string

NodeLabelsPairs is exported

func (*Engine) Open

func (engine *Engine) Open()

Open is exported Engine start refresh containers loop

func (*Engine) OperateContainer

func (engine *Engine) OperateContainer(operate models.ContainerOperate) error

OperateContainer is exported Engine operate a container.

func (*Engine) RefreshContainers

func (engine *Engine) RefreshContainers() error

RefreshContainers is exported Engine refresh all containers.

func (*Engine) RemoveContainer

func (engine *Engine) RemoveContainer(containerid string) error

RemoveContainer is exported Engine remove a container.

func (*Engine) SetNodeLabelsPairs

func (engine *Engine) SetNodeLabelsPairs(labels map[string]string)

SetNodeLabelsPairs is exported

func (*Engine) SetState

func (engine *Engine) SetState(state EngineState)

SetState is exported Set engine state.

func (*Engine) State

func (engine *Engine) State() string

State is exported Return a engine status string result.

func (*Engine) TotalCpus

func (engine *Engine) TotalCpus() int64

TotalCpus is exported Return engine total cpus size.

func (*Engine) TotalMemory

func (engine *Engine) TotalMemory() int64

TotalMemory is exported Return engine total memory size.

func (*Engine) Update

func (engine *Engine) Update(nodeData *types.NodeData)

Update is exported Engine update info

func (*Engine) UpgradeContainer

func (engine *Engine) UpgradeContainer(operate models.ContainerOperate) (*Container, error)

UpgradeContainer is exported Engine upgrade a container.

func (*Engine) UsedCpus

func (engine *Engine) UsedCpus() int64

UsedCpus is exported Return engine all containers used cpus size.

func (*Engine) UsedMemory

func (engine *Engine) UsedMemory() int64

UsedMemory is exported Return engine all containers used memory size.

func (*Engine) ValidateContainers

func (engine *Engine) ValidateContainers()

ValidateContainers is exported clear cluster engine invalid containers

type EnginePriorities

type EnginePriorities struct {
	sync.RWMutex
	Engines map[string]*Engine
}

EnginePriorities is exported

func NewEnginePriorities

func NewEnginePriorities(metaData *MetaData, engines []*Engine) *EnginePriorities

NewEnginePriorities is exported

func (*EnginePriorities) Add

func (priorities *EnginePriorities) Add(containerid string, engine *Engine)

Add is exported

func (*EnginePriorities) EngineStrings

func (priorities *EnginePriorities) EngineStrings() []string

EngineStrings is exported

func (*EnginePriorities) Remove

func (priorities *EnginePriorities) Remove(containerid string)

Remove is exported

func (*EnginePriorities) Select

func (priorities *EnginePriorities) Select() *Engine

Select is exported

func (*EnginePriorities) Size

func (priorities *EnginePriorities) Size() int

Size is exported

type EngineState

type EngineState int

EngineState define

const (
	//StatePending, engine added to cluster engines pool, but not been validated.
	StatePending EngineState = iota
	//StateUnhealthy, engine is unreachable.
	StateUnhealthy
	//StateHealthy, engine is ready reachable.
	StateHealthy
	//StateDisconnected, engine is removed from discovery
	StateDisconnected
)

State enum value

type EnginesFilter

type EnginesFilter struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

EnginesFilter is exported

func NewEnginesFilter

func NewEnginesFilter() *EnginesFilter

NewEnginesFilter is exported

func (*EnginesFilter) AllocEngines

func (filter *EnginesFilter) AllocEngines() []*Engine

AllocEngines is exported

func (*EnginesFilter) FailEngines

func (filter *EnginesFilter) FailEngines() []*Engine

FailEngines is exported

func (*EnginesFilter) Filter

func (filter *EnginesFilter) Filter(engines []*Engine) []*Engine

Filter is exported

func (*EnginesFilter) SetAllocEngine

func (filter *EnginesFilter) SetAllocEngine(engine *Engine)

SetAllocEngine is exported

func (*EnginesFilter) SetFailEngine

func (filter *EnginesFilter) SetFailEngine(engine *Engine)

SetFailEngine is exported

func (*EnginesFilter) Size

func (filter *EnginesFilter) Size() int

Size is exported

type EnginesPool

type EnginesPool struct {
	sync.RWMutex
	Cluster *Cluster
	// contains filtered or unexported fields
}

EnginesPool is exported

func NewEnginesPool

func NewEnginesPool() *EnginesPool

NewEnginesPool is exported

func (*EnginesPool) AddEngine

func (pool *EnginesPool) AddEngine(ip string, name string)

AddEngine is exported

func (*EnginesPool) InitEngineNodeLabels

func (pool *EnginesPool) InitEngineNodeLabels(engine *Engine)

InitEngineNodeLabels is exported

func (*EnginesPool) Release

func (pool *EnginesPool) Release()

Release is exported

func (*EnginesPool) RemoveEngine

func (pool *EnginesPool) RemoveEngine(ip string, name string)

RemoveEngine is exported

func (*EnginesPool) SetCluster

func (pool *EnginesPool) SetCluster(cluster *Cluster)

SetCluster is exported

type Group

type Group struct {
	ID          string   `json:"ID"`
	Name        string   `json:"Name"`
	IsCluster   bool     `json:"IsCluster"`
	Location    string   `json:"ClusterLocation"`
	Servers     []Server `json:"Servers"`
	ContactInfo string   `json:"ContactInfo"`
}

Group is exported Servers: cluster group's servers. ContactInfo: cluster manager contactinfo.

type Hook

type Hook struct {
	Timestamp int64    `json:"Timestamp"`
	Event     string   `json:"Event"`
	MetaBase  MetaBase `json:"MetaBase"`
	HookContainers
	// contains filtered or unexported fields
}

Hook is exported

func (*Hook) Submit

func (hook *Hook) Submit()

Submit is exported

type HookContainer

type HookContainer struct {
	IP        string           `json:"IP"`
	Name      string           `json:"Name"`
	Container models.Container `json:"Container"`
}

HookContainer is exported

type HookContainers

type HookContainers []*HookContainer

HookContainers is exported

type HookEvent

type HookEvent int

HookEvent is exported

const (
	CreateMetaEvent HookEvent = iota + 1
	RemoveMetaEvent
	OperateMetaEvent
	UpdateMetaEvent
	UpgradeMetaEvent
	MigrateMetaEvent
	RecoveryMetaEvent
)

func (HookEvent) String

func (event HookEvent) String() string

type HooksProcessor

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

HooksProcessor is exported

func NewHooksProcessor

func NewHooksProcessor() *HooksProcessor

NewHooksProcessor is exported

func (*HooksProcessor) Close

func (processor *HooksProcessor) Close()

func (*HooksProcessor) Start

func (processor *HooksProcessor) Start()

func (*HooksProcessor) SubmitHook

func (processor *HooksProcessor) SubmitHook(metaBase MetaBase, hookContainers HookContainers, hookEvent HookEvent)

SubmitHook is exported

type MetaBase

type MetaBase struct {
	GroupID               string           `json:"GroupId"`
	MetaID                string           `json:"MetaId"`
	IsRemoveDelay         bool             `json:"IsRemoveDelay"`
	IsRecovery            bool             `json:"IsRecovery"`
	Instances             int              `json:"Instances"`
	WebHooks              types.WebHooks   `json:"WebHooks"`
	Placement             types.Placement  `json:"Placement"`
	ImageTag              string           `json:"ImageTag"`
	Config                models.Container `json:"Config"`
	CreateAt              int64            `json:"CreateAt"`
	LastUpdateAt          int64            `json:"LastUpdateAt"`
	AvailableNodesChanged bool             `json:"AvailableNodesChanged"`
}

MetaBase is exported

type MetaData

type MetaData struct {
	MetaBase
	BaseConfigs []*ContainerBaseConfig `json:"BaseConfigs"`
}

MetaData is exported

type MigrateContainer

type MigrateContainer struct {
	sync.RWMutex
	ID string
	// contains filtered or unexported fields
}

MigrateContainer is exported

func NewMigrateContainer

func NewMigrateContainer(containerid string, baseConfig *ContainerBaseConfig) *MigrateContainer

NewMigrateContainer is exported

func (*MigrateContainer) Execute

func (mContainer *MigrateContainer) Execute(cluster *Cluster)

Execute is exported

func (*MigrateContainer) GetState

func (mContainer *MigrateContainer) GetState() MigrateState

GetState is exported

func (*MigrateContainer) SetState

func (mContainer *MigrateContainer) SetState(state MigrateState)

SetState is exported

type MigrateContainersCache

type MigrateContainersCache struct {
	sync.RWMutex
	MigratorHandler
	Cluster *Cluster
	// contains filtered or unexported fields
}

MigrateContainersCache is exported

func NewMigrateContainersCache

func NewMigrateContainersCache(migrateDelay time.Duration) *MigrateContainersCache

NewMigrateContainersCache is exported

func (*MigrateContainersCache) Cancel

func (cache *MigrateContainersCache) Cancel(engine *Engine)

Cancel is exported engine online, cancel migrate containers of state is MigrateReady. engine parameter is online engine pointer.

func (*MigrateContainersCache) Contains

func (cache *MigrateContainersCache) Contains(metaid string) bool

Contains is exported

func (*MigrateContainersCache) OnMigratorNotifyHandleFunc

func (cache *MigrateContainersCache) OnMigratorNotifyHandleFunc(migrator *Migrator, err error)

OnMigratorNotifyHandleFunc is exported

func (*MigrateContainersCache) OnMigratorQuitHandleFunc

func (cache *MigrateContainersCache) OnMigratorQuitHandleFunc(migrator *Migrator)

OnMigratorQuitHandleFunc is exported

func (*MigrateContainersCache) RemoveGroup

func (cache *MigrateContainersCache) RemoveGroup(groupid string)

RemoveGroup is exported cancel group all metadata migrate.

func (*MigrateContainersCache) SetCluster

func (cache *MigrateContainersCache) SetCluster(cluster *Cluster)

SetCluster is exported

func (*MigrateContainersCache) Start

func (cache *MigrateContainersCache) Start(engine *Engine)

Start is exported engine offline, start migrate containers. engine parameter is offline engine pointer.

type MigrateState

type MigrateState int

MigrateState is exported

func (MigrateState) String

func (state MigrateState) String() string

type Migrator

type Migrator struct {
	sync.RWMutex
	MetaID  string
	Cluster *Cluster
	// contains filtered or unexported fields
}

Migrator is exported

func NewMigrator

func NewMigrator(metaid string, containers Containers, cluster *Cluster, migrateDelay time.Duration, handler MigratorHandler) *Migrator

NewMigrator is exported

func (*Migrator) Cancel

func (migrator *Migrator) Cancel(metaid string, containers Containers)

Cancel is exported

func (*Migrator) Clear

func (migrator *Migrator) Clear()

Clear is exported

func (*Migrator) Container

func (migrator *Migrator) Container(containerid string) *MigrateContainer

Container is exported

func (*Migrator) Containers

func (migrator *Migrator) Containers() []*MigrateContainer

Containers is exported

func (*Migrator) Start

func (migrator *Migrator) Start()

Start is exported

func (*Migrator) Update

func (migrator *Migrator) Update(metaid string, containers Containers)

Update is exported

type MigratorHandler

type MigratorHandler interface {
	OnMigratorQuitHandleFunc(migrator *Migrator)
	OnMigratorNotifyHandleFunc(migrator *Migrator, err error)
}

MigratorHandler is exported

type MigratorNotifyHandleFunc

type MigratorNotifyHandleFunc func(migrator *Migrator, err error)

MigratorNotifyHandleFunc is exported

func (MigratorNotifyHandleFunc) OnMigratorNotifyHandleFunc

func (fn MigratorNotifyHandleFunc) OnMigratorNotifyHandleFunc(migrator *Migrator, err error)

OnMigratorNotifyHandleFunc is exported

type MigratorQuitHandleFunc

type MigratorQuitHandleFunc func(migrator *Migrator)

MigratorQuitHandleFunc is exported

func (MigratorQuitHandleFunc) OnMigratorQuitHandleFunc

func (fn MigratorQuitHandleFunc) OnMigratorQuitHandleFunc(migrator *Migrator)

OnMigratorQuitHandleFunc is exported

type ReduceEngine

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

ReduceEngine is exported

func (*ReduceEngine) Containers

func (reduce *ReduceEngine) Containers() Containers

Containers is exported Return engine's containers of metaid

func (*ReduceEngine) Engine

func (reduce *ReduceEngine) Engine() *Engine

Engine is exported

func (*ReduceEngine) ReduceContainer

func (reduce *ReduceEngine) ReduceContainer() *Container

ReduceContainer is exported

type RemoveContainer

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

RemoveContainer is exported remove pool container info.

type RemovePool

type RemovePool struct {
	sync.Mutex
	// contains filtered or unexported fields
}

RemovePool is exported

type Server

type Server struct {
	Name string `json:"Name"`
	IP   string `json:"IP"`
}

Server is exported

func ParseServer

func ParseServer(ipOrName string) Server

ParseServer is exported

type SortContainerBaseConfigs

type SortContainerBaseConfigs []*ContainerBaseConfig

SortContainerBaseConfigs is exported

func (SortContainerBaseConfigs) Len

func (containers SortContainerBaseConfigs) Len() int

func (SortContainerBaseConfigs) Less

func (containers SortContainerBaseConfigs) Less(i, j int) bool

func (SortContainerBaseConfigs) Swap

func (containers SortContainerBaseConfigs) Swap(i, j int)

type UpgradeContainer

type UpgradeContainer struct {
	Original *Container
	New      *Container
	State    UpgradeState
}

UpgradeContainer is exported

func (*UpgradeContainer) Execute

func (upgradeContainer *UpgradeContainer) Execute(newImageTag string) error

Execute is exported upgrade originalContainer to image new tag

func (*UpgradeContainer) Recovery

func (upgradeContainer *UpgradeContainer) Recovery(originalImageTag string) error

Recovery is exported upgrade container failure, recovery completed containers to original image tag

type UpgradeContainersCache

type UpgradeContainersCache struct {
	sync.RWMutex
	Cluster *Cluster
	// contains filtered or unexported fields
}

UpgradeContainersCache is exported

func NewUpgradeContainersCache

func NewUpgradeContainersCache(upgradeDelay time.Duration) *UpgradeContainersCache

NewUpgradeContainersCache is exported

func (*UpgradeContainersCache) Contains

func (cache *UpgradeContainersCache) Contains(metaid string) bool

Contains is exported

func (*UpgradeContainersCache) SetCluster

func (cache *UpgradeContainersCache) SetCluster(cluster *Cluster)

SetCluster is exported

func (*UpgradeContainersCache) Upgrade

func (cache *UpgradeContainersCache) Upgrade(upgradeCh chan<- bool, metaid string, newTag string, containers Containers)

Upgrade is exported

func (*UpgradeContainersCache) UpgraderHandleFunc

func (cache *UpgradeContainersCache) UpgraderHandleFunc(upgrader *Upgrader, errMsgs []string)

UpgraderHandleFunc is exported

type UpgradeState

type UpgradeState int

UpgradeState is exported

type Upgrader

type Upgrader struct {
	sync.RWMutex
	MetaID      string
	OriginalTag string
	NewTag      string
	// contains filtered or unexported fields
}

Upgrader is exported

func NewUpgrader

func NewUpgrader(metaid string, originalTag string, newTag string, containers Containers, upgradeDelay time.Duration,
	configCache *ContainersConfigCache, callback UpgraderHandleFunc) *Upgrader

NewUpgrader is exported

func (*Upgrader) Start

func (upgrader *Upgrader) Start(upgradeCh chan<- bool)

Start is exported

type UpgraderHandleFunc

type UpgraderHandleFunc func(upgrader *Upgrader, errMsgs []string)

UpgraderHandleFunc exported

type WatchEngines

type WatchEngines []*Engine

WatchEngines is exported

type WeightedEngine

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

WeightedEngine is exported

func (*WeightedEngine) Containers

func (weighted *WeightedEngine) Containers() Containers

Containers is exported Return engine's containers

func (*WeightedEngine) Engine

func (weighted *WeightedEngine) Engine() *Engine

Engine is exported

func (*WeightedEngine) Weight

func (weighted *WeightedEngine) Weight() int64

Weight is exported

Directories

Path Synopsis
dao

Jump to

Keyboard shortcuts

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