cluster

package
v0.0.0-...-b52e348 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2017 License: Apache-2.0 Imports: 25 Imported by: 3

Documentation

Index

Constants

View Source
const (
	NodeStatusWaiting             = "waiting"
	NodeStatusReady               = "ready"
	NodeStatusRetry               = "ready for retry"
	NodeStatusTemporarilyDisabled = "temporarily disabled"
	NodeStatusHealing             = "healing"

	NodeCreationStatusCreated  = "created"
	NodeCreationStatusError    = "error"
	NodeCreationStatusPending  = "pending"
	NodeCreationStatusDisabled = "disabled"
)

Variables

View Source
var (
	ErrNoSuchNode            = errors.New("No such node in storage")
	ErrDuplicatedNodeAddress = errors.New("Node address shouldn't repeat")
)
View Source
var ErrConnRefused = errors.New("connection refused")

Functions

This section is empty.

Types

type Cluster

type Cluster struct {
	Healer Healer
	Hook   ClusterHook
	// contains filtered or unexported fields
}

Cluster is the basic type of the package. It manages internal nodes, and provide methods for interaction with those nodes

func New

func New(storage Storage, nodes ...Node) (*Cluster, error)

New creates a new Cluster, initially composed by the given nodes. The storage parameter is the storage the cluster instance will use.

func (*Cluster) AttachDisk

func (c *Cluster) AttachDisk(v *disk.VmDisk, region string) error

func (*Cluster) AttachNics

func (c *Cluster) AttachNics(policy *provision.PolicyOps, vmid, region, storage string) error

func (*Cluster) AvailIps

func (c *Cluster) AvailIps(names, ips []string, vnets *onenet.VNetPool, region string) ([]*template.NIC, error)

func (*Cluster) CreateVM

func (c *Cluster) CreateVM(opts compute.VirtualMachine, throttle, storage string, nics []*template.NIC) (string, string, string, error)

func (*Cluster) DestroyVM

func (c *Cluster) DestroyVM(opts compute.VirtualMachine) error

DestroyVM kills a vm, returning an error in case of failure.

func (*Cluster) DetachDisk

func (c *Cluster) DetachDisk(v *disk.VmDisk, region string) error

func (*Cluster) DetachNics

func (c *Cluster) DetachNics(net_ids []string, vmid, region string) error

func (*Cluster) ForceDestoryVM

func (c *Cluster) ForceDestoryVM(opts compute.VirtualMachine) error

DestroyVM kills a vm, returning an error in case of failure.

func (*Cluster) ForceRestartVM

func (c *Cluster) ForceRestartVM(opts compute.VirtualMachine) error

func (*Cluster) ForceStopVM

func (c *Cluster) ForceStopVM(opts compute.VirtualMachine) error

func (*Cluster) GetDiskId

func (c *Cluster) GetDiskId(vd *disk.VmDisk, region string) ([]int, error)

func (*Cluster) GetImage

func (c *Cluster) GetImage(opts images.Image, region string) (*images.Image, error)

func (*Cluster) GetIpsNetwork

func (c *Cluster) GetIpsNetwork(region string, Ips map[string][]string) ([]*template.NIC, error)

func (*Cluster) GetTemplate

func (c *Cluster) GetTemplate(region string) (*template.UserTemplate, error)

func (*Cluster) GetVM

func (c *Cluster) GetVM(opts virtualmachine.Vnc, region string) (*virtualmachine.VM, error)

func (*Cluster) GetVNetPool

func (c *Cluster) GetVNetPool(region string) (*onenet.VNetPool, error)

func (*Cluster) GetVNets

func (c *Cluster) GetVNets(region string) (*onenet.VNetPool, error)

func (*Cluster) ImageCreate

func (c *Cluster) ImageCreate(opts images.Image, region string) (interface{}, error)

func (*Cluster) ImagePersistent

func (c *Cluster) ImagePersistent(opts images.Image, region string) error

func (*Cluster) ImageTypeChange

func (c *Cluster) ImageTypeChange(opts images.Image, region string) error

func (*Cluster) InstantiateVM

func (c *Cluster) InstantiateVM(opts *template.UserTemplate, vname, throttle, region string) (string, error)

func (*Cluster) IsImageReady

func (c *Cluster) IsImageReady(v *images.Image, region string) error

func (*Cluster) IsSnapReady

func (c *Cluster) IsSnapReady(v *images.Image, region string) error

func (*Cluster) Nodes

func (c *Cluster) Nodes() ([]Node, error)

func (*Cluster) Register

func (c *Cluster) Register(node Node) error

Register adds new nodes to the cluster.

func (*Cluster) RemoveImage

func (c *Cluster) RemoveImage(opts compute.Image) error

func (*Cluster) RemoveSnap

func (c *Cluster) RemoveSnap(opts snapshot.Snapshot, region string) error

func (*Cluster) RestartVM

func (c *Cluster) RestartVM(opts compute.VirtualMachine) error

func (*Cluster) RestoreSnap

func (c *Cluster) RestoreSnap(opts snapshot.Snapshot, region string) error

func (*Cluster) SaveDiskImage

func (c *Cluster) SaveDiskImage(opts compute.Image) (string, error)

func (*Cluster) Showback

func (c *Cluster) Showback(start int64, end int64, region string) ([]interface{}, error)

Showback returns the metrics of the one cluster

func (*Cluster) SnapVMDisk

func (c *Cluster) SnapVMDisk(opts snapshot.Snapshot, region string) (string, error)

func (*Cluster) StartVM

func (c *Cluster) StartVM(opts compute.VirtualMachine) error

func (*Cluster) StopVM

func (c *Cluster) StopVM(opts compute.VirtualMachine) error

func (*Cluster) SuspendVM

func (c *Cluster) SuspendVM(opts compute.VirtualMachine) error

func (*Cluster) UnfilteredNodes

func (c *Cluster) UnfilteredNodes() ([]Node, error)

func (*Cluster) Unregister

func (c *Cluster) Unregister(region string) error

Unregister removes nodes from the cluster.

func (*Cluster) UnregisterNodes

func (c *Cluster) UnregisterNodes(regions ...string) error

func (*Cluster) UpdateNode

func (c *Cluster) UpdateNode(node Node) (Node, error)

func (*Cluster) VM

func (c *Cluster) VM(opts compute.VirtualMachine, action string) error

type ClusterHook

type ClusterHook interface {
	BeforeCreateMachine(node Node) error
}

type DefaultHealer

type DefaultHealer struct{}

func (DefaultHealer) HandleError

func (DefaultHealer) HandleError(node *Node) time.Duration

type Healer

type Healer interface {
	HandleError(node *Node) time.Duration
}

type HealingData

type HealingData struct {
	LockedUntil time.Time
	IsFailure   bool
}

type MapStorage

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

func (*MapStorage) ExtendNodeLock

func (s *MapStorage) ExtendNodeLock(region string, timeout time.Duration) error

func (*MapStorage) LockNodeForHealing

func (s *MapStorage) LockNodeForHealing(region string, isFailure bool, timeout time.Duration) (bool, error)

func (*MapStorage) RemoveNode

func (s *MapStorage) RemoveNode(region string) error

func (*MapStorage) RemoveNodes

func (s *MapStorage) RemoveNodes(regions []string) error

func (*MapStorage) RetrieveNode

func (s *MapStorage) RetrieveNode(region string) (Node, error)

func (*MapStorage) RetrieveNodes

func (s *MapStorage) RetrieveNodes() ([]Node, error)

func (*MapStorage) StoreNode

func (s *MapStorage) StoreNode(node Node) error

func (*MapStorage) UnlockNode

func (s *MapStorage) UnlockNode(region string) error

func (*MapStorage) UpdateNode

func (s *MapStorage) UpdateNode(node Node) error

type Node

type Node struct {
	Address        string
	Region         string `json:"_id"`
	Healing        HealingData
	Metadata       map[string]string
	Clusters       map[string]map[string][]string
	CreationStatus string
}

Node represents a farm with endpoint of One. Each node has an Address (in the form <scheme>://<host>:<port>/RPC2) and map with arbritary metadata.

func (*Node) CleanMetadata

func (n *Node) CleanMetadata() map[string]string

func (*Node) FailureCount

func (n *Node) FailureCount() int

func (*Node) HasSuccess

func (n *Node) HasSuccess() bool

func (Node) MarshalJSON

func (n Node) MarshalJSON() ([]byte, error)

func (*Node) ResetFailures

func (n *Node) ResetFailures()

func (*Node) Status

func (n *Node) Status() string

type NodeList

type NodeList []Node

func (NodeList) Len

func (a NodeList) Len() int

func (NodeList) Less

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

func (NodeList) Swap

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

type NodeStorage

type NodeStorage interface {
	StoreNode(node Node) error
	RetrieveNodes() ([]Node, error)
	RetrieveNode(address string) (Node, error)
	UpdateNode(node Node) error
	RemoveNode(address string) error
	RemoveNodes(addresses []string) error
	LockNodeForHealing(address string, isFailure bool, timeout time.Duration) (bool, error)
	ExtendNodeLock(address string, timeout time.Duration) error
	UnlockNode(address string) error
}

type OneNodeError

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

func (OneNodeError) BaseError

func (n OneNodeError) BaseError() error

func (OneNodeError) Error

func (n OneNodeError) Error() string

type Storage

type Storage interface {
	NodeStorage
}

Jump to

Keyboard shortcuts

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