cluster

package
v0.0.0-...-f9f83aa Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2014 License: Apache-2.0 Imports: 9 Imported by: 0

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() *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 ID in the cluster

func (*Cluster) Containers

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

Containers returns all the containers in 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

type Container

type Container struct {
	dockerclient.Container

	Info dockerclient.ContainerInfo
	// contains filtered or unexported fields
}

func (*Container) Kill

func (c *Container) Kill(signal string) error

func (*Container) Node

func (c *Container) Node() *Node

func (*Container) Pause

func (c *Container) Pause() error

func (*Container) Restart

func (c *Container) Restart(timeout int) error

func (*Container) Start

func (c *Container) Start() error

func (*Container) Stop

func (c *Container) Stop() error

func (*Container) Unpause

func (c *Container) Unpause() error

type Event

type Event struct {
	dockerclient.Event

	NodeName string
	NodeID   string
	NodeAddr string
	NodeIP   string
}

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) *Node

func (*Node) AddContainer

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

Inject a container into the internal state.

func (*Node) AvailableMemory

func (n *Node) AvailableMemory() int64

Return the memory availalble on this node.

func (*Node) AvailalbleCpus

func (n *Node) AvailalbleCpus() int64

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) Containers

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

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) 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) ListImages

func (n *Node) ListImages() ([]string, error)

func (*Node) Pull

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

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

Jump to

Keyboard shortcuts

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