partition

package
v0.0.0-...-6217932 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2016 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(pmap *PartitionMap, name string)

func RegisterStatsService

func RegisterStatsService(svc PartitionedService)

func RunRebalancer

func RunRebalancer(svc PartitionedService, period time.Duration)

Types

type GetVersionRequest

type GetVersionRequest struct {
	Name string
}

type GetVersionResponse

type GetVersionResponse struct {
	Name    string
	Version string
	Stamp   time.Time
}

type Partition

type Partition struct {
	EndKey string
	Target string
}

type PartitionMap

type PartitionMap struct {
	P partitionList
	// contains filtered or unexported fields
}

func LoadPartitionMap

func LoadPartitionMap(path string) (*PartitionMap, error)

func MustLoadPartitionMap

func MustLoadPartitionMap(path string) *PartitionMap

func NewHexEncodedRandomPartitionMap

func NewHexEncodedRandomPartitionMap(nParts int, keyBits uint, targets []string) *PartitionMap

func NewPartitionMap

func NewPartitionMap() *PartitionMap

func NewSimplePartitionMap

func NewSimplePartitionMap(target string) *PartitionMap

func (*PartitionMap) AllTargets

func (pmap *PartitionMap) AllTargets() []string

AllTargets returns a list of unique targets.

func (*PartitionMap) GetEndKey

func (pmap *PartitionMap) GetEndKey(key string) string

GetEndKey returns the end key for the partition containing a key.

func (*PartitionMap) GetPartition

func (pmap *PartitionMap) GetPartition(key string) Partition

GetPartition returns the Partition for a key.

func (*PartitionMap) GetStamp

func (pmap *PartitionMap) GetStamp() time.Time

func (*PartitionMap) GetTarget

func (pmap *PartitionMap) GetTarget(key string) string

GetTarget returns a target for the specified key.

func (*PartitionMap) GetVersion

func (pmap *PartitionMap) GetVersion() string

GetVersion lazily computes a fingerprint of the partition map. This can be useful to verify that all instances of a program are using the same partition map.

func (*PartitionMap) Save

func (pmap *PartitionMap) Save(path string) error

Save stores the partition map in a file, in JSON format.

type PartitionStatsResponse

type PartitionStatsResponse struct {
	Counters map[string]int
}

type PartitionStatus

type PartitionStatus struct {
	Name     string
	Target   string
	Version  string
	Stamp    time.Time
	Counters map[string]int
	Err      error
}

func (PartitionStatus) Partitions

func (s PartitionStatus) Partitions() int

func (PartitionStatus) Total

func (s PartitionStatus) Total() int

type PartitionedService

type PartitionedService interface {
	GetPartitionMap() *PartitionMap
	GetPartitionCounters() map[string]int
	SetPartitionCounters(map[string]int)
	GetSelfTarget() string
	Scan() <-chan string
	Move(key string) error
}

Interface of a service that supports partitioning. You should provide your own Scan() and Move() methods, but it is possible to extend PartitionedServiceBase for the boilerplate methods.

type PartitionedServiceBase

type PartitionedServiceBase struct {
	// Partition map (used by the client).  Self is our target ID.
	Pmap       *PartitionMap
	SelfTarget string

	// Partition counters.
	Pcounters map[string]int
}

func (*PartitionedServiceBase) GetPartitionCounters

func (pb *PartitionedServiceBase) GetPartitionCounters() map[string]int

func (*PartitionedServiceBase) GetPartitionMap

func (pb *PartitionedServiceBase) GetPartitionMap() *PartitionMap

func (*PartitionedServiceBase) GetSelfTarget

func (pb *PartitionedServiceBase) GetSelfTarget() string

func (*PartitionedServiceBase) SetPartitionCounters

func (pb *PartitionedServiceBase) SetPartitionCounters(c map[string]int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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