kubernetes.v0: gopkg.in/kubernetes/kubernetes.v0/pkg/registry/service/portallocator Index | Files | Directories

package portallocator

import "gopkg.in/kubernetes/kubernetes.v0/pkg/registry/service/portallocator"


Package Files

allocator.go operation.go


var (
    ErrFull              = errors.New("range is full")
    ErrNotInRange        = errors.New("provided port is not in the valid range")
    ErrAllocated         = errors.New("provided port is already allocated")
    ErrMismatchedNetwork = errors.New("the provided port range does not match the current port range")

func StartOperation Uses

func StartOperation(pa Interface) *portAllocationOperation

Creates a portAllocationOperation, tracking a set of allocations & releases

type Interface Uses

type Interface interface {
    Allocate(int) error
    AllocateNext() (int, error)
    Release(int) error

Interface manages the allocation of ports out of a range. Interface should be threadsafe.

type PortAllocator Uses

type PortAllocator struct {
    // contains filtered or unexported fields

func NewPortAllocator Uses

func NewPortAllocator(pr util.PortRange) *PortAllocator

Helper that wraps NewAllocatorCIDRRange, for creating a range backed by an in-memory store.

func NewPortAllocatorCustom Uses

func NewPortAllocatorCustom(pr util.PortRange, allocatorFactory allocator.AllocatorFactory) *PortAllocator

NewPortAllocatorCustom creates a PortAllocator over a util.PortRange, calling allocatorFactory to construct the backing store.

func (*PortAllocator) Allocate Uses

func (r *PortAllocator) Allocate(port int) error

Allocate attempts to reserve the provided port. ErrNotInRange or ErrAllocated will be returned if the port is not valid for this range or has already been reserved. ErrFull will be returned if there are no ports left.

func (*PortAllocator) AllocateNext Uses

func (r *PortAllocator) AllocateNext() (int, error)

AllocateNext reserves one of the ports from the pool. ErrFull may be returned if there are no ports left.

func (*PortAllocator) Free Uses

func (r *PortAllocator) Free() int

Free returns the count of port left in the range.

func (*PortAllocator) Has Uses

func (r *PortAllocator) Has(port int) bool

Has returns true if the provided port is already allocated and a call to Allocate(port) would fail with ErrAllocated.

func (*PortAllocator) Release Uses

func (r *PortAllocator) Release(port int) error

Release releases the port back to the pool. Releasing an unallocated port or a port out of the range is a no-op and returns no error.

func (*PortAllocator) Restore Uses

func (r *PortAllocator) Restore(pr util.PortRange, data []byte) error

Restore restores the pool to the previously captured state. ErrMismatchedNetwork is returned if the provided port range doesn't exactly match the previous range.

func (*PortAllocator) Snapshot Uses

func (r *PortAllocator) Snapshot(dst *api.RangeAllocation) error

Snapshot saves the current state of the pool.



Package portallocator imports 5 packages (graph). Updated 2016-07-25. Refresh now. Tools for package owners.