cluster

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2015 License: Apache-2.0 Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNodeNotConnected      = errors.New("node is not connected to docker's REST API")
	ErrNodeAlreadyRegistered = errors.New("node was already added to the cluster")
)

Functions

This section is empty.

Types

type Cluster

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

func NewCluster

func NewCluster(store *state.Store, tlsConfig *tls.Config, overcommitRatio float64) *Cluster

func (*Cluster) AddNode

func (c *Cluster) AddNode(n *Node) error

Register a node within the cluster. The node must have been already initialized.

func (*Cluster) Container

func (c *Cluster) Container(IdOrName string) *Container

Container returns the container with IdOrName in the cluster

func (*Cluster) Containers

func (c *Cluster) Containers() []*Container

Containers returns all the containers in the cluster.

func (*Cluster) DeployContainer

func (c *Cluster) DeployContainer(node *Node, config *dockerclient.ContainerConfig, name string) (*Container, error)

Deploy a container into a `specific` node on the cluster.

func (*Cluster) DestroyContainer

func (c *Cluster) DestroyContainer(container *Container, force bool) error

Destroys a given `container` from the cluster.

func (*Cluster) Events

func (c *Cluster) Events(h EventHandler) error

func (*Cluster) Handle

func (c *Cluster) Handle(e *Event) error

func (*Cluster) Node

func (c *Cluster) Node(addr string) *Node

func (*Cluster) Nodes

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

Nodes returns the list of nodes in the cluster

func (*Cluster) UpdateNodes

func (c *Cluster) UpdateNodes(entries []*discovery.Entry)

type Container

type Container struct {
	dockerclient.Container

	Info dockerclient.ContainerInfo
	Node *Node
}

type Event

type Event struct {
	dockerclient.Event
	Node *Node
}

type EventHandler

type EventHandler interface {
	Handle(*Event) error
}

type Node

type Node struct {
	sync.RWMutex

	ID     string
	IP     string
	Addr   string
	Name   string
	Cpus   int64
	Memory int64
	Labels map[string]string
	// contains filtered or unexported fields
}

func NewNode

func NewNode(addr string, overcommitRatio float64) *Node

func (*Node) AddContainer

func (n *Node) AddContainer(container *Container) error

Inject a container into the internal state.

func (*Node) AddImage

func (n *Node) AddImage(image *dockerclient.Image)

Inject an image into the internal state.

func (*Node) CleanupContainers

func (n *Node) CleanupContainers()

Wipes the internal container state.

func (*Node) Connect

func (n *Node) Connect(config *tls.Config) error

Connect will initialize a connection to the Docker daemon running on the host, gather machine specs (memory, cpu, ...) and monitor state changes.

func (*Node) Container

func (n *Node) Container(IdOrName string) *Container

Container returns the container with IdOrName in the node.

func (*Node) Containers

func (n *Node) Containers() []*Container

Containers returns all the containers in the node.

func (*Node) Create

func (n *Node) Create(config *dockerclient.ContainerConfig, name string, pullImage bool) (*Container, error)

func (*Node) Destroy

func (n *Node) Destroy(container *Container, force bool) error

Destroy and remove a container from the node.

func (*Node) Events

func (n *Node) Events(h EventHandler) error

Register an event handler.

func (*Node) Image

func (n *Node) Image(IdOrName string) *dockerclient.Image

Image returns the image with IdOrName in the node

func (*Node) Images

func (n *Node) Images() []*dockerclient.Image

func (*Node) IsConnected

func (n *Node) IsConnected() bool

IsConnected returns true if the engine is connected to a remote docker API

func (*Node) IsHealthy

func (n *Node) IsHealthy() bool

func (*Node) Pull

func (n *Node) Pull(image string) error

func (*Node) RefreshContainer

func (n *Node) RefreshContainer(ID string, full bool) error

Refresh the status of a container running on the node. If `full` is true, the container will be inspected.

func (*Node) RefreshContainers

func (n *Node) RefreshContainers(full bool) error

Refresh the list and status of containers running on the node. If `full` is true, each container will be inspected.

func (*Node) RefreshContainersAsync

func (n *Node) RefreshContainersAsync()

func (*Node) RemoveContainer

func (n *Node) RemoveContainer(container *Container) error

Remove a container from the internal test.

func (*Node) ReservedCpus

func (n *Node) ReservedCpus() int64

Return the sum of CPUs reserved by containers.

func (*Node) ReservedMemory

func (n *Node) ReservedMemory() int64

Return the sum of memory reserved by containers.

func (*Node) String

func (n *Node) String() string

func (*Node) UsableCpus

func (n *Node) UsableCpus() int64

func (*Node) UsableMemory

func (n *Node) UsableMemory() int64

Jump to

Keyboard shortcuts

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