cluster

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2023 License: MIT Imports: 21 Imported by: 1

Documentation

Index

Constants

View Source
const (
	BUCKET_EXPIRE = 0
	BUCKET_COLD   = 1
	BUCKET_ACTIVE = 2
)
View Source
const DEP_STATUS_ACTIVATING = 2
View Source
const DEP_STATUS_ACTIVE = 1
View Source
const DEP_STATUS_POOLED = 0
View Source
const IN_DEPLOYMENT_MIGRATION = true

Variables

View Source
var (
	ErrNotActiveBucket         = errors.New("scale out failed, not in active bucket")
	BucketFlushInactiveTimeout = time.Second
)
View Source
var (
	ErrUnsupported   = errors.New("unsupported")
	ErrClusterClosed = errors.New("err cluster closed")
)
View Source
var (
	MaxBackingNodes = 5

	ErrInvalidInstance = errors.New("invalid instance")
)
View Source
var (
	ErrInsufficientDeployments = errors.New("insufficient lambda deployments")
)
View Source
var (
	ErrOutOfBound = errors.New("instance is not active")
)

Functions

func CleanUpPool

func CleanUpPool()

Types

type Bucket

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

A bucket is a view of a group

func (*Bucket) AllInstancesStats

func (b *Bucket) AllInstancesStats() types.Iterator

func (*Bucket) InstanceLen

func (b *Bucket) InstanceLen() int

types.ClusterStatus implementation

func (*Bucket) InstanceStats

func (b *Bucket) InstanceStats(idx int) types.InstanceStats

func (*Bucket) InstanceStatsFromIterator

func (b *Bucket) InstanceStatsFromIterator(iter types.Iterator) (int, types.InstanceStats)

func (*Bucket) MetaStats

func (b *Bucket) MetaStats() types.MetaStoreStats

type BucketIndex

type BucketIndex struct {
	DefaultGroupIndex
	BucketId int
}

type Cluster

type Cluster interface {
	lambdastore.InstanceManager
	lambdastore.Relocator
	metastore.ClusterManager

	Start() error
	WaitReady()
	GetPlacer() metastore.Placer
	CollectData()
	Close()
}

type DefaultGroupIndex

type DefaultGroupIndex int

func (DefaultGroupIndex) Idx

func (i DefaultGroupIndex) Idx() int

func (*DefaultGroupIndex) Next

func (*DefaultGroupIndex) NextN

type Group

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

func NewGroup

func NewGroup(num int) *Group

func (*Group) All

func (g *Group) All() []*GroupInstance

func (*Group) EndIndex

func (g *Group) EndIndex() DefaultGroupIndex

func (*Group) Expand

func (g *Group) Expand(n int) (DefaultGroupIndex, error)

func (*Group) Expire

func (g *Group) Expire(n int) error

func (*Group) Instance

func (g *Group) Instance(idx GroupIndex) *lambdastore.Instance

func (*Group) Len

func (g *Group) Len() int

func (*Group) Reserve

func (g *Group) Reserve(idx GroupIndex, d types.LambdaDeployment) *GroupInstance

func (*Group) Set

func (g *Group) Set(ins *GroupInstance)

func (*Group) StartIndex

func (g *Group) StartIndex() DefaultGroupIndex

func (*Group) SubGroup

func (g *Group) SubGroup(start GroupIndex, end GroupIndex) []*GroupInstance

func (*Group) Swap

func (g *Group) Swap(gins1 *GroupInstance, gins2 *GroupInstance)

type GroupIndex

type GroupIndex interface {
	Idx() int
}

type GroupInstance

type GroupInstance struct {
	types.LambdaDeployment
	// contains filtered or unexported fields
}

func (*GroupInstance) Idx

func (gins *GroupInstance) Idx() int

func (*GroupInstance) Instance

func (gins *GroupInstance) Instance() *lambdastore.Instance

func (*GroupInstance) IsRetired

func (gins *GroupInstance) IsRetired() bool

func (*GroupInstance) Retire

func (gins *GroupInstance) Retire() bool

type GroupInstanceEnumerator

type GroupInstanceEnumerator struct {
	mapreduce.Enumerator
}

func NewGroupInstanceEnumerator

func NewGroupInstanceEnumerator(ginstances []*GroupInstance) *GroupInstanceEnumerator

func (*GroupInstanceEnumerator) Instance

func (enum *GroupInstanceEnumerator) Instance(i int) *lambdastore.Instance

type MovingWindow

type MovingWindow struct {
	ServerProvider
	// contains filtered or unexported fields
}

reuse window and interval should be MINUTES

func NewMovingWindow

func NewMovingWindow(server ServerProvider) *MovingWindow

func NewMovingWindowWithOptions

func NewMovingWindowWithOptions(server ServerProvider, numFuncSteps int) *MovingWindow

func (*MovingWindow) AllClustersStats

func (mw *MovingWindow) AllClustersStats() types.Iterator

func (*MovingWindow) Close

func (mw *MovingWindow) Close()

func (*MovingWindow) ClusterLen

func (mw *MovingWindow) ClusterLen() int

GroupedClusterStatus implementation

func (*MovingWindow) ClusterStats

func (mw *MovingWindow) ClusterStats(idx int) types.ClusterStats

func (*MovingWindow) ClusterStatsFromIterator

func (mw *MovingWindow) ClusterStatsFromIterator(iter types.Iterator) (int, types.ClusterStats)

func (*MovingWindow) CollectData

func (mw *MovingWindow) CollectData()

func (*MovingWindow) Daemon

func (mw *MovingWindow) Daemon()

func (*MovingWindow) DegradeCheck

func (mw *MovingWindow) DegradeCheck() int

func (*MovingWindow) ExpireCheck

func (mw *MovingWindow) ExpireCheck() int

func (*MovingWindow) GetActiveInstances

func (mw *MovingWindow) GetActiveInstances(num int) lambdastore.InstanceEnumerator

metastore.InstanceManger implementation

func (*MovingWindow) GetBackupCandidates

func (mw *MovingWindow) GetBackupCandidates() mapreduce.Iterator

func (*MovingWindow) GetCurrentBucket

func (mw *MovingWindow) GetCurrentBucket() *Bucket

func (*MovingWindow) GetDelegates

func (mw *MovingWindow) GetDelegates() []*lambdastore.Instance

func (*MovingWindow) GetPlacer

func (mw *MovingWindow) GetPlacer() metastore.Placer

func (*MovingWindow) GetSlice

func (mw *MovingWindow) GetSlice(size int) metastore.Slice

func (*MovingWindow) Instance

func (mw *MovingWindow) Instance(id uint64) *lambdastore.Instance

lambdastore.InstanceManager implementation

func (*MovingWindow) LoadCandidates

func (mw *MovingWindow) LoadCandidates(queue *lambdastore.CandidateQueue, buf []*lambdastore.Instance) int

lambdastore.CandidateProvider implementation

func (*MovingWindow) MetaStats

func (mw *MovingWindow) MetaStats() types.MetaStoreStats

func (*MovingWindow) Recycle

func (mw *MovingWindow) Recycle(ins types.LambdaDeployment) error

func (*MovingWindow) Relocate

func (mw *MovingWindow) Relocate(meta interface{}, chunkId int, cmd types.Command) (*lambdastore.Instance, error)

lambdastore.Relocator implementation

func (*MovingWindow) Rotate

func (mw *MovingWindow) Rotate() (old *Bucket, inherited int, err error)

func (*MovingWindow) Start

func (mw *MovingWindow) Start() error

func (*MovingWindow) Trigger

func (mw *MovingWindow) Trigger(event int, args ...interface{})

func (*MovingWindow) TryRelocate

func (mw *MovingWindow) TryRelocate(meta interface{}, chunkId int, cmd types.Command) (*lambdastore.Instance, bool, error)

func (*MovingWindow) WaitReady

func (mw *MovingWindow) WaitReady()

type Pool

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

func NewPool

func NewPool(numCluster int, numDeployment int) *Pool

numCluster = small number, numDeployment = large number

func (*Pool) Clear

func (s *Pool) Clear(g *Group)

func (*Pool) ClearAll

func (s *Pool) ClearAll()

func (*Pool) Deployment

func (s *Pool) Deployment(id uint64) (types.LambdaDeployment, bool)

func (*Pool) GetDestination

func (s *Pool) GetDestination(lambdaId uint64) (types.LambdaDeployment, error)

func (*Pool) GetForGroup

func (s *Pool) GetForGroup(g *Group, idx GroupIndex) *GroupInstance

Get a instance at ith position for the group. There is no border check for the index, which means the group should solely responsible for the validity of the index, and the index can be a virtual one. This operation will be blocked if no more deployment available

func (*Pool) Instance

func (s *Pool) Instance(id uint64) *lambdastore.Instance

func (*Pool) InstanceIndex

func (s *Pool) InstanceIndex(id uint64) (*GroupInstance, bool)

func (*Pool) NumActives

func (s *Pool) NumActives() int

func (*Pool) NumAvailable

func (s *Pool) NumAvailable() int

func (*Pool) Recycle

func (s *Pool) Recycle(dp types.LambdaDeployment)

Recycle lambda deployment for later use Instead of removing instance from actives, placehold a legacy instance to keep track delegate information. TODO: Relocate meta to reflect delegated placements.

func (*Pool) ReserveForGroup

func (s *Pool) ReserveForGroup(g *Group, idx GroupIndex) (*GroupInstance, error)

Reserve a deployment at ith position in the group. The group may choose to instancize it later or not. This operation will return err if no more deployment available

func (*Pool) ReserveForInstance

func (s *Pool) ReserveForInstance(insId uint64) (*GroupInstance, error)

Reserve a deployment to replace specified instance. Can be a different deployment other than the instance's for different mode.

func (*Pool) StartMigrator

func (s *Pool) StartMigrator(lambdaId uint64) (string, error)

MigrationScheduler implementations

type ServerProvider

type ServerProvider interface {
	GetServePort(uint64) int
	GetPersistCache() types.PersistCache
}

type Slice

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

func NewSlice

func NewSlice(size int, initializer SliceInitializer) *Slice

func (*Slice) GetIndex

func (s *Slice) GetIndex(idx uint64) uint64

func (*Slice) Reset

func (s *Slice) Reset(size int)

func (*Slice) Size

func (s *Slice) Size() int

type SliceInitializer

type SliceInitializer func(int) (int, int)

type StaticCluster

type StaticCluster struct {
	ServerProvider
	// contains filtered or unexported fields
}

func NewStaticCluster

func NewStaticCluster(server ServerProvider, size int) *StaticCluster

initial lambda group

func (*StaticCluster) AllInstancesStats

func (c *StaticCluster) AllInstancesStats() types.Iterator

func (*StaticCluster) Close

func (c *StaticCluster) Close()

func (*StaticCluster) CollectData

func (c *StaticCluster) CollectData()

func (*StaticCluster) GetActiveInstances

func (c *StaticCluster) GetActiveInstances(num int) lambdastore.InstanceEnumerator

metastore.InstanceManger implementation

func (*StaticCluster) GetBackupCandidates

func (c *StaticCluster) GetBackupCandidates() mapreduce.Iterator

func (*StaticCluster) GetDelegates

func (c *StaticCluster) GetDelegates() []*lambdastore.Instance

func (*StaticCluster) GetPlacer

func (c *StaticCluster) GetPlacer() metastore.Placer

func (*StaticCluster) GetSlice

func (c *StaticCluster) GetSlice(size int) metastore.Slice

func (*StaticCluster) Instance

func (c *StaticCluster) Instance(id uint64) *lambdastore.Instance

lambdastore.InstanceManager implementation

func (*StaticCluster) InstanceLen

func (c *StaticCluster) InstanceLen() int

ClusterStatus implementation

func (*StaticCluster) InstanceStats

func (c *StaticCluster) InstanceStats(idx int) types.InstanceStats

func (*StaticCluster) InstanceStatsFromIterator

func (c *StaticCluster) InstanceStatsFromIterator(iter types.Iterator) (int, types.InstanceStats)

func (*StaticCluster) MetaStats

func (c *StaticCluster) MetaStats() types.MetaStoreStats

func (*StaticCluster) Recycle

func (c *StaticCluster) Recycle(ins types.LambdaDeployment) error

func (*StaticCluster) Relocate

func (c *StaticCluster) Relocate(obj interface{}, chunk int, cmd types.Command) (*lambdastore.Instance, error)

lambdastore.Relocator implementation

func (*StaticCluster) Start

func (c *StaticCluster) Start() error

func (*StaticCluster) Trigger

func (c *StaticCluster) Trigger(event int, args ...interface{})

func (*StaticCluster) TryRelocate

func (c *StaticCluster) TryRelocate(o interface{}, chunkId int, cmd types.Command) (*lambdastore.Instance, bool, error)

func (*StaticCluster) WaitReady

func (c *StaticCluster) WaitReady()

Jump to

Keyboard shortcuts

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