Documentation ¶
Overview ¶
Package prophet is a generated GoMock package.
Package prophet is a generated GoMock package.
Package prophet is a generated GoMock package.
Package prophet is a generated GoMock package.
Package prophet is a generated GoMock package.
Index ¶
- Constants
- Variables
- func EmptyPeer(value Peer) bool
- func ExecuteInParallel(q *Queue, fn func(interface{}))
- func GeometricMean(input Float64Data) (float64, error)
- func HarmonicMean(input Float64Data) (float64, error)
- func MatchEvent(event, flag int) bool
- func Max(input Float64Data) (max float64, err error)
- func Mean(input Float64Data) (float64, error)
- func Median(input Float64Data) (median float64, err error)
- func Min(input Float64Data) (min float64, err error)
- func Mode(input Float64Data) (mode []float64, err error)
- func PopulationVariance(input Float64Data) (pvar float64, err error)
- func SetLogger(l Logger)
- func StandardDeviation(input Float64Data) (sdev float64, err error)
- func StandardDeviationPopulation(input Float64Data) (sdev float64, err error)
- func Sum(input Float64Data) (sum float64, err error)
- type Action
- type Adapter
- type Cfg
- type ChangePeerType
- type Container
- type ContainerHeartbeatReq
- type ContainerRuntime
- func (cr *ContainerRuntime) Clone() *ContainerRuntime
- func (cr *ContainerRuntime) Downtime() time.Duration
- func (cr *ContainerRuntime) GetLabelValue(key string) string
- func (cr *ContainerRuntime) GetLocationID(keys []string) string
- func (cr *ContainerRuntime) HasNoneHeartbeat() bool
- func (cr *ContainerRuntime) IsBlocked() bool
- func (cr *ContainerRuntime) IsUp() bool
- func (cr *ContainerRuntime) LeaderScore() float64
- func (cr *ContainerRuntime) ReplicaScore() float64
- func (cr *ContainerRuntime) ResourceCount(kind ResourceKind) uint64
- func (cr *ContainerRuntime) ResourceScore(kind ResourceKind) float64
- func (cr *ContainerRuntime) StorageUsedBytes() uint64
- func (cr *ContainerRuntime) StorageUsedRatio() int
- type Coordinator
- type Elector
- type ElectorOption
- type EmbeddedEtcdCfg
- type EventNotify
- type Filter
- func NewBlockFilter() Filter
- func NewCacheFilter(freezeCache *resourceFreezeCache) Filter
- func NewDistinctScoreFilter(cfg *Cfg, containers []*ContainerRuntime, source *ContainerRuntime) Filter
- func NewExcludedFilter(sources, targets map[uint64]struct{}) Filter
- func NewHealthFilter(cfg *Cfg) Filter
- func NewLabelFilter(labels []Pair) Filter
- func NewSnapshotCountFilter(cfg *Cfg) Filter
- func NewStateFilter(cfg *Cfg) Filter
- func NewStorageThresholdFilter(cfg *Cfg) Filter
- type Float64Data
- func (f Float64Data) Get(i int) float64
- func (f Float64Data) Len() int
- func (f Float64Data) Less(i, j int) bool
- func (f Float64Data) Max() (float64, error)
- func (f Float64Data) Mean() (float64, error)
- func (f Float64Data) Median() (float64, error)
- func (f Float64Data) Min() (float64, error)
- func (f Float64Data) Mode() ([]float64, error)
- func (f Float64Data) Sum() (float64, error)
- func (f Float64Data) Swap(i, j int)
- type HeartbeatHandler
- type InitWatcher
- type Job
- func (job *Job) Cancel()
- func (job *Job) GetResult() interface{}
- func (job *Job) IsCancelled() bool
- func (job *Job) IsCancelling() bool
- func (job *Job) IsComplete() bool
- func (job *Job) IsFailed() bool
- func (job *Job) IsFinished() bool
- func (job *Job) IsNotComplete() bool
- func (job *Job) IsPending() bool
- func (job *Job) IsRunning() bool
- func (job *Job) SetResult(result interface{})
- type JobState
- type LocalStorage
- type LocalStore
- type Logger
- type MockAdapter
- func (m *MockAdapter) ContainerHBInterval() time.Duration
- func (m *MockAdapter) EXPECT() *MockAdapterMockRecorder
- func (m *MockAdapter) FetchContainerHB() *ContainerHeartbeatReq
- func (m *MockAdapter) FetchLeaderResources() []uint64
- func (m *MockAdapter) FetchResourceHB(id uint64) *ResourceHeartbeatReq
- func (m *MockAdapter) HBHandler() HeartbeatHandler
- func (m *MockAdapter) NewContainer() Container
- func (m *MockAdapter) NewResource() Resource
- func (m *MockAdapter) ResourceHBInterval() time.Duration
- type MockAdapterMockRecorder
- func (mr *MockAdapterMockRecorder) ContainerHBInterval() *gomock.Call
- func (mr *MockAdapterMockRecorder) FetchContainerHB() *gomock.Call
- func (mr *MockAdapterMockRecorder) FetchLeaderResources() *gomock.Call
- func (mr *MockAdapterMockRecorder) FetchResourceHB(id interface{}) *gomock.Call
- func (mr *MockAdapterMockRecorder) HBHandler() *gomock.Call
- func (mr *MockAdapterMockRecorder) NewContainer() *gomock.Call
- func (mr *MockAdapterMockRecorder) NewResource() *gomock.Call
- func (mr *MockAdapterMockRecorder) ResourceHBInterval() *gomock.Call
- type MockContainer
- func (m *MockContainer) ActionOnJoinCluster() Action
- func (m *MockContainer) Clone() Container
- func (m *MockContainer) EXPECT() *MockContainerMockRecorder
- func (m *MockContainer) ID() uint64
- func (m *MockContainer) Labels() []Pair
- func (m *MockContainer) Marshal() ([]byte, error)
- func (m *MockContainer) SetID(id uint64)
- func (m *MockContainer) ShardAddr() string
- func (m *MockContainer) State() State
- func (m *MockContainer) Unmarshal(data []byte) error
- type MockContainerMockRecorder
- func (mr *MockContainerMockRecorder) ActionOnJoinCluster() *gomock.Call
- func (mr *MockContainerMockRecorder) Clone() *gomock.Call
- func (mr *MockContainerMockRecorder) ID() *gomock.Call
- func (mr *MockContainerMockRecorder) Labels() *gomock.Call
- func (mr *MockContainerMockRecorder) Marshal() *gomock.Call
- func (mr *MockContainerMockRecorder) SetID(id interface{}) *gomock.Call
- func (mr *MockContainerMockRecorder) ShardAddr() *gomock.Call
- func (mr *MockContainerMockRecorder) State() *gomock.Call
- func (mr *MockContainerMockRecorder) Unmarshal(data interface{}) *gomock.Call
- type MockPeerReplicaHandler
- func (m *MockPeerReplicaHandler) AddPeer(arg0 Resource, arg1 Peer)
- func (m *MockPeerReplicaHandler) Destory(arg0 Resource)
- func (m *MockPeerReplicaHandler) EXPECT() *MockPeerReplicaHandlerMockRecorder
- func (m *MockPeerReplicaHandler) Heartbeat(arg0 Resource) bool
- func (m *MockPeerReplicaHandler) RemovePeer(arg0 Resource, arg1 Peer) bool
- func (m *MockPeerReplicaHandler) ResourceBecomeFollower(arg0 Resource)
- func (m *MockPeerReplicaHandler) ResourceBecomeLeader(arg0 Resource)
- func (m *MockPeerReplicaHandler) Scale(arg0 Resource, arg1 interface{}) (bool, []*PeerReplica)
- type MockPeerReplicaHandlerMockRecorder
- func (mr *MockPeerReplicaHandlerMockRecorder) AddPeer(arg0, arg1 interface{}) *gomock.Call
- func (mr *MockPeerReplicaHandlerMockRecorder) Destory(arg0 interface{}) *gomock.Call
- func (mr *MockPeerReplicaHandlerMockRecorder) Heartbeat(arg0 interface{}) *gomock.Call
- func (mr *MockPeerReplicaHandlerMockRecorder) RemovePeer(arg0, arg1 interface{}) *gomock.Call
- func (mr *MockPeerReplicaHandlerMockRecorder) ResourceBecomeFollower(arg0 interface{}) *gomock.Call
- func (mr *MockPeerReplicaHandlerMockRecorder) ResourceBecomeLeader(arg0 interface{}) *gomock.Call
- func (mr *MockPeerReplicaHandlerMockRecorder) Scale(arg0, arg1 interface{}) *gomock.Call
- type MockProphet
- type MockProphetMockRecorder
- type MockRPC
- type MockRPCMockRecorder
- type MockResource
- func (m *MockResource) Changed(other Resource) bool
- func (m *MockResource) Clone() Resource
- func (m *MockResource) EXPECT() *MockResourceMockRecorder
- func (m *MockResource) ID() uint64
- func (m *MockResource) Labels() []Pair
- func (m *MockResource) Marshal() ([]byte, error)
- func (m *MockResource) Peers() []*Peer
- func (m *MockResource) ScaleCompleted(arg0 uint64) bool
- func (m *MockResource) SetID(id uint64)
- func (m *MockResource) SetPeers(peers []*Peer)
- func (m *MockResource) Stale(other Resource) bool
- func (m *MockResource) Unmarshal(data []byte) error
- type MockResourceMockRecorder
- func (mr *MockResourceMockRecorder) Changed(other interface{}) *gomock.Call
- func (mr *MockResourceMockRecorder) Clone() *gomock.Call
- func (mr *MockResourceMockRecorder) ID() *gomock.Call
- func (mr *MockResourceMockRecorder) Labels() *gomock.Call
- func (mr *MockResourceMockRecorder) Marshal() *gomock.Call
- func (mr *MockResourceMockRecorder) Peers() *gomock.Call
- func (mr *MockResourceMockRecorder) ScaleCompleted(arg0 interface{}) *gomock.Call
- func (mr *MockResourceMockRecorder) SetID(id interface{}) *gomock.Call
- func (mr *MockResourceMockRecorder) SetPeers(peers interface{}) *gomock.Call
- func (mr *MockResourceMockRecorder) Stale(other interface{}) *gomock.Call
- func (mr *MockResourceMockRecorder) Unmarshal(data interface{}) *gomock.Call
- type MockResourceStore
- func (m *MockResourceStore) AddReplica(arg0 *PeerReplica)
- func (m *MockResourceStore) EXPECT() *MockResourceStoreMockRecorder
- func (m *MockResourceStore) ForeachReplica(arg0 func(*PeerReplica) bool)
- func (m *MockResourceStore) GetContainerAddr(arg0 uint64) (string, error)
- func (m *MockResourceStore) GetPeerReplica(id uint64, leader bool) *PeerReplica
- func (m *MockResourceStore) GetTransport() ReplicaTransport
- func (m *MockResourceStore) HandleReplicaMsg(arg0 interface{}) interface{}
- func (m *MockResourceStore) LocalStore() LocalStore
- func (m *MockResourceStore) Meta() Container
- func (m *MockResourceStore) MustStartTask(arg0 func(context.Context)) uint64
- func (m *MockResourceStore) MustStopTask(arg0 uint64)
- func (m *MockResourceStore) RemoveReplica(id uint64)
- func (m *MockResourceStore) Start()
- type MockResourceStoreMockRecorder
- func (mr *MockResourceStoreMockRecorder) AddReplica(arg0 interface{}) *gomock.Call
- func (mr *MockResourceStoreMockRecorder) ForeachReplica(arg0 interface{}) *gomock.Call
- func (mr *MockResourceStoreMockRecorder) GetContainerAddr(arg0 interface{}) *gomock.Call
- func (mr *MockResourceStoreMockRecorder) GetPeerReplica(id, leader interface{}) *gomock.Call
- func (mr *MockResourceStoreMockRecorder) GetTransport() *gomock.Call
- func (mr *MockResourceStoreMockRecorder) HandleReplicaMsg(arg0 interface{}) *gomock.Call
- func (mr *MockResourceStoreMockRecorder) LocalStore() *gomock.Call
- func (mr *MockResourceStoreMockRecorder) Meta() *gomock.Call
- func (mr *MockResourceStoreMockRecorder) MustStartTask(arg0 interface{}) *gomock.Call
- func (mr *MockResourceStoreMockRecorder) MustStopTask(arg0 interface{}) *gomock.Call
- func (mr *MockResourceStoreMockRecorder) RemoveReplica(id interface{}) *gomock.Call
- func (mr *MockResourceStoreMockRecorder) Start() *gomock.Call
- type MockRoleChangeHandler
- type MockRoleChangeHandlerMockRecorder
- type MockSerializable
- type MockSerializableMockRecorder
- type MockcodecSerializable
- type MockcodecSerializableMockRecorder
- type Node
- type Operator
- type Option
- func ParseProphetOptions(name string) []Option
- func ParseProphetOptionsWithPath(name, path string) []Option
- func WithCountResourceReplicas(value int) Option
- func WithEmbeddedEtcd(cfg *EmbeddedEtcdCfg) Option
- func WithExternalEtcd(client *clientv3.Client) Option
- func WithLeaseTTL(leaseTTL int64) Option
- func WithLocationLabels(value []string) Option
- func WithMaxAllowContainerDownDuration(value time.Duration) Option
- func WithMaxFreezeScheduleInterval(value time.Duration) Option
- func WithMaxLimitSnapshotsCount(value uint64) Option
- func WithMaxRPCConnIdle(value time.Duration) Option
- func WithMaxRPCCons(value int) Option
- func WithMaxRPCTimeout(value time.Duration) Option
- func WithMaxRebalanceLeader(value uint64) Option
- func WithMaxRebalanceReplica(value uint64) Option
- func WithMaxScheduleInterval(value time.Duration) Option
- func WithMaxScheduleReplica(value uint64) Option
- func WithMaxScheduleRetries(value int) Option
- func WithMinAvailableStorageUsedRate(value int) Option
- func WithMinScheduleInterval(value time.Duration) Option
- func WithRPCAddr(value string) Option
- func WithRoleChangeHandler(Handler RoleChangeHandler) Option
- func WithScaleOnNewStore() Option
- func WithScheduler(value Scheduler) Option
- func WithTimeoutWaitOperatorComplete(value time.Duration) Option
- type Pair
- type Peer
- type PeerReplica
- func (pr *PeerReplica) AddPeer(peer Peer)
- func (pr *PeerReplica) ChangeLeaderTo(leader uint64, cb func(interface{}, error))
- func (pr *PeerReplica) CollectDownPeers(maxDuration time.Duration) []*PeerStats
- func (pr *PeerReplica) CollectPendingPeers() []*Peer
- func (pr *PeerReplica) Destroy()
- func (pr *PeerReplica) Do(doFunc func(error), timeout time.Duration)
- func (pr *PeerReplica) Heartbeat()
- func (pr *PeerReplica) IsLeader() bool
- func (pr *PeerReplica) Peer() *Peer
- func (pr *PeerReplica) RemovePeer(peer Peer)
- func (pr *PeerReplica) Resource() Resource
- func (pr *PeerReplica) Scale(data interface{})
- func (pr *PeerReplica) Tag() string
- type PeerReplicaHandler
- type PeerStats
- type Prophet
- type Queue
- func (q *Queue) Dispose() []interface{}
- func (q *Queue) Disposed() bool
- func (q *Queue) Empty() bool
- func (q *Queue) Get(number int64, items []interface{}) (int64, error)
- func (q *Queue) Len() int64
- func (q *Queue) Peek() (interface{}, error)
- func (q *Queue) Poll(number int64, items []interface{}, timeout time.Duration) (int64, error)
- func (q *Queue) Put(items ...interface{}) error
- func (q *Queue) PutOrUpdate(cmp func(interface{}, interface{}) bool, item interface{}) error
- type RPC
- type ReplicaTransport
- type Resource
- type ResourceHeartbeatReq
- type ResourceKind
- type ResourceRuntime
- func (res *ResourceRuntime) Clone() *ResourceRuntime
- func (res *ResourceRuntime) GetContainerIDs() map[uint64]struct{}
- func (res *ResourceRuntime) GetContainerPeer(containerID uint64) *Peer
- func (res *ResourceRuntime) GetPeer(peerID uint64) *Peer
- func (res *ResourceRuntime) GetPendingPeer(peerID uint64) *Peer
- func (res *ResourceRuntime) RemoveContainerPeer(id uint64)
- type ResourceStore
- type RoleChangeHandler
- type Runner
- func (s *Runner) AddNamedWorker(name string) (uint64, error)
- func (s *Runner) IsNamedWorkerBusy(worker string) bool
- func (s *Runner) RunCancelableTask(task func(context.Context)) (uint64, error)
- func (s *Runner) RunJob(desc string, task func() error) error
- func (s *Runner) RunJobWithNamedWorker(desc, worker string, task func() error) error
- func (s *Runner) RunJobWithNamedWorkerWithCB(desc, worker string, task func() error, cb func(*Job)) error
- func (s *Runner) RunTask(task func()) error
- func (s *Runner) Stop() error
- func (s *Runner) StopCancelableTask(id uint64) error
- type Runtime
- func (rc *Runtime) Container(id uint64) *ContainerRuntime
- func (rc *Runtime) Containers() []*ContainerRuntime
- func (rc *Runtime) RandFollowerResource(id uint64) *ResourceRuntime
- func (rc *Runtime) RandLeaderResource(id uint64) *ResourceRuntime
- func (rc *Runtime) Resource(id uint64) *ResourceRuntime
- func (rc *Runtime) ResourceContainers(target *ResourceRuntime) []*ContainerRuntime
- func (rc *Runtime) ResourceFollowerContainers(res *ResourceRuntime) []*ContainerRuntime
- func (rc *Runtime) Resources() []*ResourceRuntime
- type Scheduler
- type Selector
- type Serializable
- type State
- type Store
- type Watcher
Constants ¶
const ( // NoneAction none action NoneAction = Action(0) // ScaleOutAction all resources will received a scale operation when a new container join the cluster ScaleOutAction = Action(1) )
const ( // DefaultTimeout default timeout DefaultTimeout = time.Second * 3 // DefaultRequestTimeout default request timeout DefaultRequestTimeout = 10 * time.Second // DefaultSlowRequestTime default slow request time DefaultSlowRequestTime = time.Second * 1 )
const ( // Pending job is wait to running Pending = JobState(0) // Running job is running Running = JobState(1) // Cancelling job is cancelling Cancelling = JobState(2) // Cancelled job is cancelled Cancelled = JobState(3) // Finished job is complete Finished = JobState(4) // Failed job is failed when execute Failed = JobState(5) )
Variables ¶
var ( // ErrSchedulerExisted error with scheduler is existed ErrSchedulerExisted = errors.New("scheduler is existed") // ErrSchedulerNotFound error with scheduler is not found ErrSchedulerNotFound = errors.New("scheduler is not found") )
var ( // ErrNorLeader not leader ErrNorLeader = errors.New("Not Leader") // ErrDoTimeout timeout ErrDoTimeout = errors.New("Do Timeout") )
var ( // AddPeer add peer AddPeer = ChangePeerType(0) // RemovePeer remove peer RemovePeer = ChangePeerType(1) // ScalePeer scale peer ScalePeer = ChangePeerType(2) )
var ( // ErrDisposed is returned when an operation is performed on a disposed // queue. ErrDisposed = errors.New(`queue: disposed`) // ErrTimeout is returned when an applicable queue operation times out. ErrTimeout = errors.New(`queue: poll timed out`) // ErrEmptyQueue is returned when an non-applicable queue operation was called // due to the queue's empty item state ErrEmptyQueue = errors.New(`queue: empty queue`) )
var ( // EventInit event init EventInit = 1 << 1 // EventResourceCreated event resource created EventResourceCreated = 1 << 2 // EventResourceLeaderChanged event resource leader changed EventResourceLeaderChanged = 1 << 3 // EventResourceChaned event resource changed EventResourceChaned = 1 << 4 // EventContainerCreated event container create EventContainerCreated = 1 << 5 // EventContainerChanged event container create EventContainerChanged = 1 << 6 // EventFlagResource all resource event EventFlagResource = EventResourceCreated | EventResourceLeaderChanged | EventResourceChaned // EventFlagContainer all container event EventFlagContainer = EventContainerCreated | EventContainerChanged // EventFlagAll all event EventFlagAll = 0xffffffff )
var ( // ErrJobCancelled error job cancelled ErrJobCancelled = errors.New("Job cancelled") )
Functions ¶
func ExecuteInParallel ¶
func ExecuteInParallel(q *Queue, fn func(interface{}))
ExecuteInParallel will (in parallel) call the provided function with each item in the queue until the queue is exhausted. When the queue is exhausted execution is complete and all goroutines will be killed. This means that the queue will be disposed so cannot be used again.
func GeometricMean ¶
func GeometricMean(input Float64Data) (float64, error)
GeometricMean gets the geometric mean for a slice of numbers
func HarmonicMean ¶
func HarmonicMean(input Float64Data) (float64, error)
HarmonicMean gets the harmonic mean for a slice of numbers
func MatchEvent ¶
MatchEvent returns the flag has the target event
func Max ¶
func Max(input Float64Data) (max float64, err error)
Max finds the highest number in a slice
func Mean ¶
func Mean(input Float64Data) (float64, error)
Mean gets the average of a slice of numbers
func Median ¶
func Median(input Float64Data) (median float64, err error)
Median gets the median number in a slice of numbers
func Min ¶
func Min(input Float64Data) (min float64, err error)
Min finds the lowest number in a set of data
func Mode ¶
func Mode(input Float64Data) (mode []float64, err error)
Mode gets the mode of a slice of numbers
func PopulationVariance ¶
func PopulationVariance(input Float64Data) (pvar float64, err error)
PopulationVariance finds the amount of variance within a population
func StandardDeviation ¶
func StandardDeviation(input Float64Data) (sdev float64, err error)
StandardDeviation the amount of variation in the dataset
func StandardDeviationPopulation ¶
func StandardDeviationPopulation(input Float64Data) (sdev float64, err error)
StandardDeviationPopulation finds the amount of variation from the population
func Sum ¶
func Sum(input Float64Data) (sum float64, err error)
Sum adds all the numbers of a slice together
Types ¶
type Adapter ¶
type Adapter interface { // NewResource return a new resource NewResource() Resource // NewContainer return a new container NewContainer() Container // FetchLeaderResources fetch loacle leader resource FetchLeaderResources() []uint64 // FetchResourceHB fetch resource HB FetchResourceHB(id uint64) *ResourceHeartbeatReq // FetchContainerHB fetch container HB FetchContainerHB() *ContainerHeartbeatReq // ResourceHBInterval fetch resource HB interface ResourceHBInterval() time.Duration // ContainerHBInterval fetch container HB interface ContainerHBInterval() time.Duration // HBHandler HB hander HBHandler() HeartbeatHandler }
Adapter prophet adapter
type Cfg ¶
type Cfg struct { // RPCAddr prophet rpc addr RPCAddr string // MaxScheduleRetries maximum retry times for schedule MaxScheduleRetries int // MaxScheduleInterval maximum schedule interval per scheduler MaxScheduleInterval time.Duration // MinScheduleInterval minimum schedule interval per scheduler MinScheduleInterval time.Duration // TimeoutWaitOperatorComplete timeout for waitting teh operator complete TimeoutWaitOperatorComplete time.Duration // MaxFreezeScheduleInterval freeze the container for a while if shouldSchedule is returns false MaxFreezeScheduleInterval time.Duration // MaxAllowContainerDownDuration maximum down time of removed from replicas MaxAllowContainerDownDuration time.Duration // MaxRebalanceLeader maximum count of transfer leader operator MaxRebalanceLeader uint64 // MaxRebalanceReplica maximum count of remove|add replica operator MaxRebalanceReplica uint64 // MaxScheduleReplica maximum count of schedule replica operator MaxScheduleReplica uint64 // MaxLimitSnapshotsCount maximum count of node about snapshot MaxLimitSnapshotsCount uint64 // CountResourceReplicas replica number per resource CountResourceReplicas int // MinAvailableStorageUsedRate minimum storage used rate of container, if the rate is over this value, skip the container MinAvailableStorageUsedRate int // LocationLabels the label used for location LocationLabels []string // MaxRPCCons rpc conns MaxRPCCons int // MaxRPCConnIdle rpc conn max idle time MaxRPCConnIdle time.Duration // MaxRPCTimeout rpc max timeout MaxRPCTimeout time.Duration StorageNode bool LeaseTTL int64 Schedulers []Scheduler Handler RoleChangeHandler EnableScaleOnNewStore bool }
Cfg prophet cfg
type Container ¶
type Container interface { Serializable // ShardAddr returns address that used for communication between the resource replications ShardAddr() string // SetID update the container id SetID(id uint64) // ID returns the container id ID() uint64 // Labels returns the lable tag of the container Labels() []Pair // State returns the state of the container State() State // Clone returns the cloned value Clone() Container // ActionOnJoinCluster returns the cluster will do what when a new container join the cluster ActionOnJoinCluster() Action // Marshal returns error if marshal failed Marshal() ([]byte, error) // Unmarshal returns error if unmarshal failed Unmarshal(data []byte) error }
Container is an abstraction of the node in a distributed system. Usually a container has many resoruces
type ContainerHeartbeatReq ¶
type ContainerHeartbeatReq struct { Data []byte `json:"data"` StorageCapacity uint64 `json:"storageCapacity"` StorageAvailable uint64 `json:"storageAvailable"` LeaderCount uint64 `json:"leaderCount"` ReplicaCount uint64 `json:"replicaCount"` SendingSnapCount uint64 `json:"sendingSnapCount"` ReceivingSnapCount uint64 `json:"receivingSnapCount"` ApplyingSnapCount uint64 `json:"applyingSnapCount"` Busy bool `json:"busy"` // stop replica balance Block bool `json:"block"` // stop leader balance Container Container `json:"-"` }
ContainerHeartbeatReq container hb msg
func (*ContainerHeartbeatReq) Init ¶
func (req *ContainerHeartbeatReq) Init(adapter Adapter) error
Init init
func (*ContainerHeartbeatReq) Prepare ¶
func (req *ContainerHeartbeatReq) Prepare() error
Prepare prepare
type ContainerRuntime ¶
type ContainerRuntime struct {
// contains filtered or unexported fields
}
ContainerRuntime is the container runtime info
func (*ContainerRuntime) Clone ¶
func (cr *ContainerRuntime) Clone() *ContainerRuntime
Clone returns the container clone info
func (*ContainerRuntime) Downtime ¶
func (cr *ContainerRuntime) Downtime() time.Duration
Downtime returns the container down time
func (*ContainerRuntime) GetLabelValue ¶
func (cr *ContainerRuntime) GetLabelValue(key string) string
GetLabelValue returns label value of key
func (*ContainerRuntime) GetLocationID ¶
func (cr *ContainerRuntime) GetLocationID(keys []string) string
GetLocationID returns location id
func (*ContainerRuntime) HasNoneHeartbeat ¶
func (cr *ContainerRuntime) HasNoneHeartbeat() bool
HasNoneHeartbeat returns if received a heartbeat from the container
func (*ContainerRuntime) IsBlocked ¶
func (cr *ContainerRuntime) IsBlocked() bool
IsBlocked returns the container is blocked from balance if true.
func (*ContainerRuntime) IsUp ¶
func (cr *ContainerRuntime) IsUp() bool
IsUp returns the container is up state
func (*ContainerRuntime) LeaderScore ¶
func (cr *ContainerRuntime) LeaderScore() float64
LeaderScore returns score with leader
func (*ContainerRuntime) ReplicaScore ¶
func (cr *ContainerRuntime) ReplicaScore() float64
ReplicaScore returns score with replica
func (*ContainerRuntime) ResourceCount ¶
func (cr *ContainerRuntime) ResourceCount(kind ResourceKind) uint64
ResourceCount returns resource count by kind
func (*ContainerRuntime) ResourceScore ¶
func (cr *ContainerRuntime) ResourceScore(kind ResourceKind) float64
ResourceScore returns resource score by kind
func (*ContainerRuntime) StorageUsedBytes ¶
func (cr *ContainerRuntime) StorageUsedBytes() uint64
StorageUsedBytes returns container used storage with bytes
func (*ContainerRuntime) StorageUsedRatio ¶
func (cr *ContainerRuntime) StorageUsedRatio() int
StorageUsedRatio returns container used storage with rate
type Coordinator ¶
Coordinator resource coordinator
type Elector ¶
type Elector interface { // Stop stop elector Stop(group uint64) // CurrentLeader returns current leader CurrentLeader(group uint64) (string, error) // ElectionLoop run leader election loop, if the currentLeader is not set, only watch leader. ElectionLoop(ctx context.Context, group uint64, currentLeader string, becomeLeader, becomeFollower func()) // ChangeLeaderTo change leader from old to new ChangeLeaderTo(group uint64, oldLeader, newLeader string) error // DoIfLeader do some options and returns false if current node is not leader or some conditions check failed DoIfLeader(group uint64, node string, conditions []clientv3.Cmp, ops ...clientv3.Op) (bool, error) }
Elector a leader elector
func NewElector ¶
func NewElector(client *clientv3.Client, options ...ElectorOption) (Elector, error)
NewElector create a elector
type ElectorOption ¶
type ElectorOption func(*electorOptions)
ElectorOption elector option
func WithLeaderLeaseSeconds ¶
func WithLeaderLeaseSeconds(value int64) ElectorOption
WithLeaderLeaseSeconds set leader lease in seconds
func WithLockIfBecomeLeader ¶
func WithLockIfBecomeLeader(value bool) ElectorOption
WithLockIfBecomeLeader set lock enable flag if become leader, If true, will add a distributed lock, and will unlock on become follower, ensure that the other nodes can be changed to leaders after the previous leader has processed the role changes.
func WithPrefix ¶
func WithPrefix(value string) ElectorOption
WithPrefix set data prefix in embed etcd server
type EmbeddedEtcdCfg ¶
type EmbeddedEtcdCfg struct { Name string DataPath string Join string EmbedEtcdLog string URLsClient string URLsAdvertiseClient string URLsPeer string URLsAdvertisePeer string InitialCluster string InitialClusterState string }
EmbeddedEtcdCfg cfg for embedded etcd
type EventNotify ¶
EventNotify event notify
func (*EventNotify) ReadInitEventValues ¶
func (evt *EventNotify) ReadInitEventValues(resourceF func([]byte, uint64), containerF func([]byte))
ReadInitEventValues read all resource info
func (*EventNotify) ReadLeaderChangerValue ¶
func (evt *EventNotify) ReadLeaderChangerValue() (uint64, uint64)
ReadLeaderChangerValue returns the target resource and the new leader returns resourceid, newleaderid
type Filter ¶
type Filter interface { // FilterSource returns true means skip this container for schedule FilterSource(container *ContainerRuntime) bool // FilterTarget returns true means skip this container for schedule FilterTarget(container *ContainerRuntime) bool }
Filter is used for filter container
func NewBlockFilter ¶
func NewBlockFilter() Filter
NewBlockFilter returns a filter for choose resource container by block
func NewCacheFilter ¶
func NewCacheFilter(freezeCache *resourceFreezeCache) Filter
NewCacheFilter returns a filter for choose resource container by runtime cache
func NewDistinctScoreFilter ¶
func NewDistinctScoreFilter(cfg *Cfg, containers []*ContainerRuntime, source *ContainerRuntime) Filter
NewDistinctScoreFilter a filter for ensures that distinct score will not decrease.
func NewExcludedFilter ¶
NewExcludedFilter returns a filter for choose resource container by excluded value
func NewHealthFilter ¶
NewHealthFilter returns a filter for choose resource container by health info
func NewLabelFilter ¶
NewLabelFilter returns label filter, if the container missing the labels, skip it.
func NewSnapshotCountFilter ¶
NewSnapshotCountFilter returns snapshot filter
func NewStateFilter ¶
NewStateFilter returns a filter for choose resource container by state
func NewStorageThresholdFilter ¶
NewStorageThresholdFilter returns a filter for choose resource container by storage rate
type Float64Data ¶
type Float64Data []float64
Float64Data is a named type for []float64 with helper methods
func (Float64Data) Less ¶
func (f Float64Data) Less(i, j int) bool
Less returns if one number is less than another
func (Float64Data) Max ¶
func (f Float64Data) Max() (float64, error)
Max returns the maximum number in the data
func (Float64Data) Mean ¶
func (f Float64Data) Mean() (float64, error)
Mean returns the mean of the data
func (Float64Data) Median ¶
func (f Float64Data) Median() (float64, error)
Median returns the median of the data
func (Float64Data) Min ¶
func (f Float64Data) Min() (float64, error)
Min returns the minimum number in the data
func (Float64Data) Mode ¶
func (f Float64Data) Mode() ([]float64, error)
Mode returns the mode of the data
func (Float64Data) Sum ¶
func (f Float64Data) Sum() (float64, error)
Sum returns the total of all the numbers in the data
func (Float64Data) Swap ¶
func (f Float64Data) Swap(i, j int)
Swap switches out two numbers in slice
type HeartbeatHandler ¶
type HeartbeatHandler interface { ChangeLeader(resourceID uint64, newLeader *Peer) ChangePeer(resourceID uint64, peer *Peer, changeType ChangePeerType) ScaleResource(resourceID uint64, byContainerID uint64) }
HeartbeatHandler handle for heartbeat rsp
type Job ¶
Job is do for something with state
func (*Job) IsCancelled ¶
IsCancelled returns true if job state is Cancelled
func (*Job) IsCancelling ¶
IsCancelling returns true if job state is Cancelling
func (*Job) IsComplete ¶
IsComplete return true means the job is complete.
func (*Job) IsFinished ¶
IsFinished returns true if job state is Finished
func (*Job) IsNotComplete ¶
IsNotComplete return true means the job is not complete.
type LocalStorage ¶
type LocalStorage interface { // Get returns the key value Get(key []byte) ([]byte, error) // Set sets the key value to the local storage Set(pairs ...[]byte) error // Remove remove the key from the local storage Remove(keys ...[]byte) error // Range visit all values that start with prefix, set limit to 0 for no limit Range(prefix []byte, limit uint64, fn func(key, value []byte) bool) error }
LocalStorage is the local data storage
type LocalStore ¶
type LocalStore interface { // BootstrapCluster bootstrap the cluster, BootstrapCluster(initResources ...Resource) // MustPutResource put the resource to local MustPutResource(...Resource) // MustRemoveResource remove the res from the local MustRemoveResource(...uint64) // MustAllocID returns the new id by pd MustAllocID() uint64 // MustCountResources returns local resources count MustCountResources() int // MustLoadResources load all local resources MustLoadResources(func(value []byte) (uint64, error)) }
LocalStore the local data store
func NewLocalStore ¶
func NewLocalStore(meta Container, storage LocalStorage, pd Prophet) LocalStore
NewLocalStore returns a local store
type Logger ¶
type Logger interface { Info(v ...interface{}) Infof(format string, v ...interface{}) Debug(v ...interface{}) Debugf(format string, v ...interface{}) Warn(v ...interface{}) Warnf(format string, v ...interface{}) Error(v ...interface{}) Errorf(format string, v ...interface{}) Fatal(v ...interface{}) Fatalf(format string, v ...interface{}) }
Logger logger
type MockAdapter ¶
type MockAdapter struct {
// contains filtered or unexported fields
}
MockAdapter is a mock of Adapter interface
func NewMockAdapter ¶
func NewMockAdapter(ctrl *gomock.Controller) *MockAdapter
NewMockAdapter creates a new mock instance
func (*MockAdapter) ContainerHBInterval ¶
func (m *MockAdapter) ContainerHBInterval() time.Duration
ContainerHBInterval mocks base method
func (*MockAdapter) EXPECT ¶
func (m *MockAdapter) EXPECT() *MockAdapterMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockAdapter) FetchContainerHB ¶
func (m *MockAdapter) FetchContainerHB() *ContainerHeartbeatReq
FetchContainerHB mocks base method
func (*MockAdapter) FetchLeaderResources ¶
func (m *MockAdapter) FetchLeaderResources() []uint64
FetchLeaderResources mocks base method
func (*MockAdapter) FetchResourceHB ¶
func (m *MockAdapter) FetchResourceHB(id uint64) *ResourceHeartbeatReq
FetchResourceHB mocks base method
func (*MockAdapter) HBHandler ¶
func (m *MockAdapter) HBHandler() HeartbeatHandler
HBHandler mocks base method
func (*MockAdapter) NewContainer ¶
func (m *MockAdapter) NewContainer() Container
NewContainer mocks base method
func (*MockAdapter) NewResource ¶
func (m *MockAdapter) NewResource() Resource
NewResource mocks base method
func (*MockAdapter) ResourceHBInterval ¶
func (m *MockAdapter) ResourceHBInterval() time.Duration
ResourceHBInterval mocks base method
type MockAdapterMockRecorder ¶
type MockAdapterMockRecorder struct {
// contains filtered or unexported fields
}
MockAdapterMockRecorder is the mock recorder for MockAdapter
func (*MockAdapterMockRecorder) ContainerHBInterval ¶
func (mr *MockAdapterMockRecorder) ContainerHBInterval() *gomock.Call
ContainerHBInterval indicates an expected call of ContainerHBInterval
func (*MockAdapterMockRecorder) FetchContainerHB ¶
func (mr *MockAdapterMockRecorder) FetchContainerHB() *gomock.Call
FetchContainerHB indicates an expected call of FetchContainerHB
func (*MockAdapterMockRecorder) FetchLeaderResources ¶
func (mr *MockAdapterMockRecorder) FetchLeaderResources() *gomock.Call
FetchLeaderResources indicates an expected call of FetchLeaderResources
func (*MockAdapterMockRecorder) FetchResourceHB ¶
func (mr *MockAdapterMockRecorder) FetchResourceHB(id interface{}) *gomock.Call
FetchResourceHB indicates an expected call of FetchResourceHB
func (*MockAdapterMockRecorder) HBHandler ¶
func (mr *MockAdapterMockRecorder) HBHandler() *gomock.Call
HBHandler indicates an expected call of HBHandler
func (*MockAdapterMockRecorder) NewContainer ¶
func (mr *MockAdapterMockRecorder) NewContainer() *gomock.Call
NewContainer indicates an expected call of NewContainer
func (*MockAdapterMockRecorder) NewResource ¶
func (mr *MockAdapterMockRecorder) NewResource() *gomock.Call
NewResource indicates an expected call of NewResource
func (*MockAdapterMockRecorder) ResourceHBInterval ¶
func (mr *MockAdapterMockRecorder) ResourceHBInterval() *gomock.Call
ResourceHBInterval indicates an expected call of ResourceHBInterval
type MockContainer ¶
type MockContainer struct {
// contains filtered or unexported fields
}
MockContainer is a mock of Container interface
func NewMockContainer ¶
func NewMockContainer(ctrl *gomock.Controller) *MockContainer
NewMockContainer creates a new mock instance
func (*MockContainer) ActionOnJoinCluster ¶
func (m *MockContainer) ActionOnJoinCluster() Action
ActionOnJoinCluster mocks base method
func (*MockContainer) EXPECT ¶
func (m *MockContainer) EXPECT() *MockContainerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockContainer) Marshal ¶
func (m *MockContainer) Marshal() ([]byte, error)
Marshal mocks base method
func (*MockContainer) ShardAddr ¶
func (m *MockContainer) ShardAddr() string
ShardAddr mocks base method
func (*MockContainer) Unmarshal ¶
func (m *MockContainer) Unmarshal(data []byte) error
Unmarshal mocks base method
type MockContainerMockRecorder ¶
type MockContainerMockRecorder struct {
// contains filtered or unexported fields
}
MockContainerMockRecorder is the mock recorder for MockContainer
func (*MockContainerMockRecorder) ActionOnJoinCluster ¶
func (mr *MockContainerMockRecorder) ActionOnJoinCluster() *gomock.Call
ActionOnJoinCluster indicates an expected call of ActionOnJoinCluster
func (*MockContainerMockRecorder) Clone ¶
func (mr *MockContainerMockRecorder) Clone() *gomock.Call
Clone indicates an expected call of Clone
func (*MockContainerMockRecorder) ID ¶
func (mr *MockContainerMockRecorder) ID() *gomock.Call
ID indicates an expected call of ID
func (*MockContainerMockRecorder) Labels ¶
func (mr *MockContainerMockRecorder) Labels() *gomock.Call
Labels indicates an expected call of Labels
func (*MockContainerMockRecorder) Marshal ¶
func (mr *MockContainerMockRecorder) Marshal() *gomock.Call
Marshal indicates an expected call of Marshal
func (*MockContainerMockRecorder) SetID ¶
func (mr *MockContainerMockRecorder) SetID(id interface{}) *gomock.Call
SetID indicates an expected call of SetID
func (*MockContainerMockRecorder) ShardAddr ¶
func (mr *MockContainerMockRecorder) ShardAddr() *gomock.Call
ShardAddr indicates an expected call of ShardAddr
func (*MockContainerMockRecorder) State ¶
func (mr *MockContainerMockRecorder) State() *gomock.Call
State indicates an expected call of State
func (*MockContainerMockRecorder) Unmarshal ¶
func (mr *MockContainerMockRecorder) Unmarshal(data interface{}) *gomock.Call
Unmarshal indicates an expected call of Unmarshal
type MockPeerReplicaHandler ¶
type MockPeerReplicaHandler struct {
// contains filtered or unexported fields
}
MockPeerReplicaHandler is a mock of PeerReplicaHandler interface
func NewMockPeerReplicaHandler ¶
func NewMockPeerReplicaHandler(ctrl *gomock.Controller) *MockPeerReplicaHandler
NewMockPeerReplicaHandler creates a new mock instance
func (*MockPeerReplicaHandler) AddPeer ¶
func (m *MockPeerReplicaHandler) AddPeer(arg0 Resource, arg1 Peer)
AddPeer mocks base method
func (*MockPeerReplicaHandler) Destory ¶
func (m *MockPeerReplicaHandler) Destory(arg0 Resource)
Destory mocks base method
func (*MockPeerReplicaHandler) EXPECT ¶
func (m *MockPeerReplicaHandler) EXPECT() *MockPeerReplicaHandlerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockPeerReplicaHandler) Heartbeat ¶
func (m *MockPeerReplicaHandler) Heartbeat(arg0 Resource) bool
Heartbeat mocks base method
func (*MockPeerReplicaHandler) RemovePeer ¶
func (m *MockPeerReplicaHandler) RemovePeer(arg0 Resource, arg1 Peer) bool
RemovePeer mocks base method
func (*MockPeerReplicaHandler) ResourceBecomeFollower ¶
func (m *MockPeerReplicaHandler) ResourceBecomeFollower(arg0 Resource)
ResourceBecomeFollower mocks base method
func (*MockPeerReplicaHandler) ResourceBecomeLeader ¶
func (m *MockPeerReplicaHandler) ResourceBecomeLeader(arg0 Resource)
ResourceBecomeLeader mocks base method
func (*MockPeerReplicaHandler) Scale ¶
func (m *MockPeerReplicaHandler) Scale(arg0 Resource, arg1 interface{}) (bool, []*PeerReplica)
Scale mocks base method
type MockPeerReplicaHandlerMockRecorder ¶
type MockPeerReplicaHandlerMockRecorder struct {
// contains filtered or unexported fields
}
MockPeerReplicaHandlerMockRecorder is the mock recorder for MockPeerReplicaHandler
func (*MockPeerReplicaHandlerMockRecorder) AddPeer ¶
func (mr *MockPeerReplicaHandlerMockRecorder) AddPeer(arg0, arg1 interface{}) *gomock.Call
AddPeer indicates an expected call of AddPeer
func (*MockPeerReplicaHandlerMockRecorder) Destory ¶
func (mr *MockPeerReplicaHandlerMockRecorder) Destory(arg0 interface{}) *gomock.Call
Destory indicates an expected call of Destory
func (*MockPeerReplicaHandlerMockRecorder) Heartbeat ¶
func (mr *MockPeerReplicaHandlerMockRecorder) Heartbeat(arg0 interface{}) *gomock.Call
Heartbeat indicates an expected call of Heartbeat
func (*MockPeerReplicaHandlerMockRecorder) RemovePeer ¶
func (mr *MockPeerReplicaHandlerMockRecorder) RemovePeer(arg0, arg1 interface{}) *gomock.Call
RemovePeer indicates an expected call of RemovePeer
func (*MockPeerReplicaHandlerMockRecorder) ResourceBecomeFollower ¶
func (mr *MockPeerReplicaHandlerMockRecorder) ResourceBecomeFollower(arg0 interface{}) *gomock.Call
ResourceBecomeFollower indicates an expected call of ResourceBecomeFollower
func (*MockPeerReplicaHandlerMockRecorder) ResourceBecomeLeader ¶
func (mr *MockPeerReplicaHandlerMockRecorder) ResourceBecomeLeader(arg0 interface{}) *gomock.Call
ResourceBecomeLeader indicates an expected call of ResourceBecomeLeader
func (*MockPeerReplicaHandlerMockRecorder) Scale ¶
func (mr *MockPeerReplicaHandlerMockRecorder) Scale(arg0, arg1 interface{}) *gomock.Call
Scale indicates an expected call of Scale
type MockProphet ¶
type MockProphet struct {
// contains filtered or unexported fields
}
MockProphet is a mock of Prophet interface
func NewMockProphet ¶
func NewMockProphet(ctrl *gomock.Controller) *MockProphet
NewMockProphet creates a new mock instance
func (*MockProphet) EXPECT ¶
func (m *MockProphet) EXPECT() *MockProphetMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockProphet) GetEtcdClient ¶
func (m *MockProphet) GetEtcdClient() *clientv3.Client
GetEtcdClient mocks base method
type MockProphetMockRecorder ¶
type MockProphetMockRecorder struct {
// contains filtered or unexported fields
}
MockProphetMockRecorder is the mock recorder for MockProphet
func (*MockProphetMockRecorder) GetEtcdClient ¶
func (mr *MockProphetMockRecorder) GetEtcdClient() *gomock.Call
GetEtcdClient indicates an expected call of GetEtcdClient
func (*MockProphetMockRecorder) GetRPC ¶
func (mr *MockProphetMockRecorder) GetRPC() *gomock.Call
GetRPC indicates an expected call of GetRPC
func (*MockProphetMockRecorder) GetStore ¶
func (mr *MockProphetMockRecorder) GetStore() *gomock.Call
GetStore indicates an expected call of GetStore
func (*MockProphetMockRecorder) Start ¶
func (mr *MockProphetMockRecorder) Start() *gomock.Call
Start indicates an expected call of Start
type MockRPC ¶
type MockRPC struct {
// contains filtered or unexported fields
}
MockRPC is a mock of RPC interface
func NewMockRPC ¶
func NewMockRPC(ctrl *gomock.Controller) *MockRPC
NewMockRPC creates a new mock instance
func (*MockRPC) EXPECT ¶
func (m *MockRPC) EXPECT() *MockRPCMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockRPC) TiggerContainerHeartbeat ¶
func (m *MockRPC) TiggerContainerHeartbeat()
TiggerContainerHeartbeat mocks base method
func (*MockRPC) TiggerResourceHeartbeat ¶
TiggerResourceHeartbeat mocks base method
type MockRPCMockRecorder ¶
type MockRPCMockRecorder struct {
// contains filtered or unexported fields
}
MockRPCMockRecorder is the mock recorder for MockRPC
func (*MockRPCMockRecorder) AllocID ¶
func (mr *MockRPCMockRecorder) AllocID() *gomock.Call
AllocID indicates an expected call of AllocID
func (*MockRPCMockRecorder) AskSplit ¶
func (mr *MockRPCMockRecorder) AskSplit(res interface{}) *gomock.Call
AskSplit indicates an expected call of AskSplit
func (*MockRPCMockRecorder) TiggerContainerHeartbeat ¶
func (mr *MockRPCMockRecorder) TiggerContainerHeartbeat() *gomock.Call
TiggerContainerHeartbeat indicates an expected call of TiggerContainerHeartbeat
func (*MockRPCMockRecorder) TiggerResourceHeartbeat ¶
func (mr *MockRPCMockRecorder) TiggerResourceHeartbeat(id interface{}) *gomock.Call
TiggerResourceHeartbeat indicates an expected call of TiggerResourceHeartbeat
type MockResource ¶
type MockResource struct {
// contains filtered or unexported fields
}
MockResource is a mock of Resource interface
func NewMockResource ¶
func NewMockResource(ctrl *gomock.Controller) *MockResource
NewMockResource creates a new mock instance
func (*MockResource) Changed ¶
func (m *MockResource) Changed(other Resource) bool
Changed mocks base method
func (*MockResource) EXPECT ¶
func (m *MockResource) EXPECT() *MockResourceMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockResource) Marshal ¶
func (m *MockResource) Marshal() ([]byte, error)
Marshal mocks base method
func (*MockResource) ScaleCompleted ¶
func (m *MockResource) ScaleCompleted(arg0 uint64) bool
ScaleCompleted mocks base method
func (*MockResource) SetPeers ¶
func (m *MockResource) SetPeers(peers []*Peer)
SetPeers mocks base method
func (*MockResource) Stale ¶
func (m *MockResource) Stale(other Resource) bool
Stale mocks base method
func (*MockResource) Unmarshal ¶
func (m *MockResource) Unmarshal(data []byte) error
Unmarshal mocks base method
type MockResourceMockRecorder ¶
type MockResourceMockRecorder struct {
// contains filtered or unexported fields
}
MockResourceMockRecorder is the mock recorder for MockResource
func (*MockResourceMockRecorder) Changed ¶
func (mr *MockResourceMockRecorder) Changed(other interface{}) *gomock.Call
Changed indicates an expected call of Changed
func (*MockResourceMockRecorder) Clone ¶
func (mr *MockResourceMockRecorder) Clone() *gomock.Call
Clone indicates an expected call of Clone
func (*MockResourceMockRecorder) ID ¶
func (mr *MockResourceMockRecorder) ID() *gomock.Call
ID indicates an expected call of ID
func (*MockResourceMockRecorder) Labels ¶
func (mr *MockResourceMockRecorder) Labels() *gomock.Call
Labels indicates an expected call of Labels
func (*MockResourceMockRecorder) Marshal ¶
func (mr *MockResourceMockRecorder) Marshal() *gomock.Call
Marshal indicates an expected call of Marshal
func (*MockResourceMockRecorder) Peers ¶
func (mr *MockResourceMockRecorder) Peers() *gomock.Call
Peers indicates an expected call of Peers
func (*MockResourceMockRecorder) ScaleCompleted ¶
func (mr *MockResourceMockRecorder) ScaleCompleted(arg0 interface{}) *gomock.Call
ScaleCompleted indicates an expected call of ScaleCompleted
func (*MockResourceMockRecorder) SetID ¶
func (mr *MockResourceMockRecorder) SetID(id interface{}) *gomock.Call
SetID indicates an expected call of SetID
func (*MockResourceMockRecorder) SetPeers ¶
func (mr *MockResourceMockRecorder) SetPeers(peers interface{}) *gomock.Call
SetPeers indicates an expected call of SetPeers
func (*MockResourceMockRecorder) Stale ¶
func (mr *MockResourceMockRecorder) Stale(other interface{}) *gomock.Call
Stale indicates an expected call of Stale
func (*MockResourceMockRecorder) Unmarshal ¶
func (mr *MockResourceMockRecorder) Unmarshal(data interface{}) *gomock.Call
Unmarshal indicates an expected call of Unmarshal
type MockResourceStore ¶
type MockResourceStore struct {
// contains filtered or unexported fields
}
MockResourceStore is a mock of ResourceStore interface
func NewMockResourceStore ¶
func NewMockResourceStore(ctrl *gomock.Controller) *MockResourceStore
NewMockResourceStore creates a new mock instance
func (*MockResourceStore) AddReplica ¶
func (m *MockResourceStore) AddReplica(arg0 *PeerReplica)
AddReplica mocks base method
func (*MockResourceStore) EXPECT ¶
func (m *MockResourceStore) EXPECT() *MockResourceStoreMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockResourceStore) ForeachReplica ¶
func (m *MockResourceStore) ForeachReplica(arg0 func(*PeerReplica) bool)
ForeachReplica mocks base method
func (*MockResourceStore) GetContainerAddr ¶
func (m *MockResourceStore) GetContainerAddr(arg0 uint64) (string, error)
GetContainerAddr mocks base method
func (*MockResourceStore) GetPeerReplica ¶
func (m *MockResourceStore) GetPeerReplica(id uint64, leader bool) *PeerReplica
GetPeerReplica mocks base method
func (*MockResourceStore) GetTransport ¶
func (m *MockResourceStore) GetTransport() ReplicaTransport
GetTransport mocks base method
func (*MockResourceStore) HandleReplicaMsg ¶
func (m *MockResourceStore) HandleReplicaMsg(arg0 interface{}) interface{}
HandleReplicaMsg mocks base method
func (*MockResourceStore) LocalStore ¶
func (m *MockResourceStore) LocalStore() LocalStore
LocalStore mocks base method
func (*MockResourceStore) Meta ¶
func (m *MockResourceStore) Meta() Container
Meta mocks base method
func (*MockResourceStore) MustStartTask ¶
func (m *MockResourceStore) MustStartTask(arg0 func(context.Context)) uint64
MustStartTask mocks base method
func (*MockResourceStore) MustStopTask ¶
func (m *MockResourceStore) MustStopTask(arg0 uint64)
MustStopTask mocks base method
func (*MockResourceStore) RemoveReplica ¶
func (m *MockResourceStore) RemoveReplica(id uint64)
RemoveReplica mocks base method
type MockResourceStoreMockRecorder ¶
type MockResourceStoreMockRecorder struct {
// contains filtered or unexported fields
}
MockResourceStoreMockRecorder is the mock recorder for MockResourceStore
func (*MockResourceStoreMockRecorder) AddReplica ¶
func (mr *MockResourceStoreMockRecorder) AddReplica(arg0 interface{}) *gomock.Call
AddReplica indicates an expected call of AddReplica
func (*MockResourceStoreMockRecorder) ForeachReplica ¶
func (mr *MockResourceStoreMockRecorder) ForeachReplica(arg0 interface{}) *gomock.Call
ForeachReplica indicates an expected call of ForeachReplica
func (*MockResourceStoreMockRecorder) GetContainerAddr ¶
func (mr *MockResourceStoreMockRecorder) GetContainerAddr(arg0 interface{}) *gomock.Call
GetContainerAddr indicates an expected call of GetContainerAddr
func (*MockResourceStoreMockRecorder) GetPeerReplica ¶
func (mr *MockResourceStoreMockRecorder) GetPeerReplica(id, leader interface{}) *gomock.Call
GetPeerReplica indicates an expected call of GetPeerReplica
func (*MockResourceStoreMockRecorder) GetTransport ¶
func (mr *MockResourceStoreMockRecorder) GetTransport() *gomock.Call
GetTransport indicates an expected call of GetTransport
func (*MockResourceStoreMockRecorder) HandleReplicaMsg ¶
func (mr *MockResourceStoreMockRecorder) HandleReplicaMsg(arg0 interface{}) *gomock.Call
HandleReplicaMsg indicates an expected call of HandleReplicaMsg
func (*MockResourceStoreMockRecorder) LocalStore ¶
func (mr *MockResourceStoreMockRecorder) LocalStore() *gomock.Call
LocalStore indicates an expected call of LocalStore
func (*MockResourceStoreMockRecorder) Meta ¶
func (mr *MockResourceStoreMockRecorder) Meta() *gomock.Call
Meta indicates an expected call of Meta
func (*MockResourceStoreMockRecorder) MustStartTask ¶
func (mr *MockResourceStoreMockRecorder) MustStartTask(arg0 interface{}) *gomock.Call
MustStartTask indicates an expected call of MustStartTask
func (*MockResourceStoreMockRecorder) MustStopTask ¶
func (mr *MockResourceStoreMockRecorder) MustStopTask(arg0 interface{}) *gomock.Call
MustStopTask indicates an expected call of MustStopTask
func (*MockResourceStoreMockRecorder) RemoveReplica ¶
func (mr *MockResourceStoreMockRecorder) RemoveReplica(id interface{}) *gomock.Call
RemoveReplica indicates an expected call of RemoveReplica
func (*MockResourceStoreMockRecorder) Start ¶
func (mr *MockResourceStoreMockRecorder) Start() *gomock.Call
Start indicates an expected call of Start
type MockRoleChangeHandler ¶
type MockRoleChangeHandler struct {
// contains filtered or unexported fields
}
MockRoleChangeHandler is a mock of RoleChangeHandler interface
func NewMockRoleChangeHandler ¶
func NewMockRoleChangeHandler(ctrl *gomock.Controller) *MockRoleChangeHandler
NewMockRoleChangeHandler creates a new mock instance
func (*MockRoleChangeHandler) EXPECT ¶
func (m *MockRoleChangeHandler) EXPECT() *MockRoleChangeHandlerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockRoleChangeHandler) ProphetBecomeFollower ¶
func (m *MockRoleChangeHandler) ProphetBecomeFollower()
ProphetBecomeFollower mocks base method
func (*MockRoleChangeHandler) ProphetBecomeLeader ¶
func (m *MockRoleChangeHandler) ProphetBecomeLeader()
ProphetBecomeLeader mocks base method
type MockRoleChangeHandlerMockRecorder ¶
type MockRoleChangeHandlerMockRecorder struct {
// contains filtered or unexported fields
}
MockRoleChangeHandlerMockRecorder is the mock recorder for MockRoleChangeHandler
func (*MockRoleChangeHandlerMockRecorder) ProphetBecomeFollower ¶
func (mr *MockRoleChangeHandlerMockRecorder) ProphetBecomeFollower() *gomock.Call
ProphetBecomeFollower indicates an expected call of ProphetBecomeFollower
func (*MockRoleChangeHandlerMockRecorder) ProphetBecomeLeader ¶
func (mr *MockRoleChangeHandlerMockRecorder) ProphetBecomeLeader() *gomock.Call
ProphetBecomeLeader indicates an expected call of ProphetBecomeLeader
type MockSerializable ¶
type MockSerializable struct {
// contains filtered or unexported fields
}
MockSerializable is a mock of Serializable interface
func NewMockSerializable ¶
func NewMockSerializable(ctrl *gomock.Controller) *MockSerializable
NewMockSerializable creates a new mock instance
func (*MockSerializable) EXPECT ¶
func (m *MockSerializable) EXPECT() *MockSerializableMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
type MockSerializableMockRecorder ¶
type MockSerializableMockRecorder struct {
// contains filtered or unexported fields
}
MockSerializableMockRecorder is the mock recorder for MockSerializable
type MockcodecSerializable ¶
type MockcodecSerializable struct {
// contains filtered or unexported fields
}
MockcodecSerializable is a mock of codecSerializable interface
func NewMockcodecSerializable ¶
func NewMockcodecSerializable(ctrl *gomock.Controller) *MockcodecSerializable
NewMockcodecSerializable creates a new mock instance
func (*MockcodecSerializable) EXPECT ¶
func (m *MockcodecSerializable) EXPECT() *MockcodecSerializableMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockcodecSerializable) Init ¶
func (m *MockcodecSerializable) Init(adapter Adapter) error
Init mocks base method
func (*MockcodecSerializable) Prepare ¶
func (m *MockcodecSerializable) Prepare() error
Prepare mocks base method
type MockcodecSerializableMockRecorder ¶
type MockcodecSerializableMockRecorder struct {
// contains filtered or unexported fields
}
MockcodecSerializableMockRecorder is the mock recorder for MockcodecSerializable
func (*MockcodecSerializableMockRecorder) Init ¶
func (mr *MockcodecSerializableMockRecorder) Init(adapter interface{}) *gomock.Call
Init indicates an expected call of Init
func (*MockcodecSerializableMockRecorder) Prepare ¶
func (mr *MockcodecSerializableMockRecorder) Prepare() *gomock.Call
Prepare indicates an expected call of Prepare
type Operator ¶
type Operator interface { ResourceID() uint64 ResourceKind() ResourceKind Do(target *ResourceRuntime) (*resourceHeartbeatRsp, bool) }
Operator is an interface to scheduler resource
type Option ¶
type Option func(*options)
Option is prophet create option
func ParseProphetOptions ¶
ParseProphetOptions parse the prophet options from command line parameter
func ParseProphetOptionsWithPath ¶
ParseProphetOptionsWithPath parse the prophet options from command line parameter, using spec data path for embed etcd server
func WithCountResourceReplicas ¶
WithCountResourceReplicas replica number per resource
func WithEmbeddedEtcd ¶
func WithEmbeddedEtcd(cfg *EmbeddedEtcdCfg) Option
WithEmbeddedEtcd using embedded etcd cluster
func WithExternalEtcd ¶
WithExternalEtcd using external etcd cluster
func WithLocationLabels ¶
WithLocationLabels the label used for location
func WithMaxAllowContainerDownDuration ¶
WithMaxAllowContainerDownDuration maximum down time of removed from replicas
func WithMaxFreezeScheduleInterval ¶
WithMaxFreezeScheduleInterval freeze the container for a while if shouldSchedule is returns false
func WithMaxLimitSnapshotsCount ¶
WithMaxLimitSnapshotsCount maximum count of node about snapshot
func WithMaxRPCConnIdle ¶
WithMaxRPCConnIdle set MaxRPCConnIdle
func WithMaxRPCTimeout ¶
WithMaxRPCTimeout set MaxRPCTimeout
func WithMaxRebalanceLeader ¶
WithMaxRebalanceLeader maximum count of transfer leader operator
func WithMaxRebalanceReplica ¶
WithMaxRebalanceReplica maximum count of remove|add replica operator
func WithMaxScheduleInterval ¶
WithMaxScheduleInterval using MaxScheduleInterval maximum schedule interval per scheduler
func WithMaxScheduleReplica ¶
WithMaxScheduleReplica maximum count of schedule replica operator
func WithMaxScheduleRetries ¶
WithMaxScheduleRetries using MaxScheduleRetries maximum retry times for schedule
func WithMinAvailableStorageUsedRate ¶
WithMinAvailableStorageUsedRate minimum storage used rate of container, if the rate is over this value, skip the container
func WithMinScheduleInterval ¶
WithMinScheduleInterval using MinScheduleInterval minimum schedule interval per scheduler
func WithRoleChangeHandler ¶
func WithRoleChangeHandler(Handler RoleChangeHandler) Option
WithRoleChangeHandler using a role changed handler
func WithScaleOnNewStore ¶
func WithScaleOnNewStore() Option
WithScaleOnNewStore set EnableScaleOnNewStore
func WithTimeoutWaitOperatorComplete ¶
WithTimeoutWaitOperatorComplete timeout for waitting teh operator complete
type PeerReplica ¶
type PeerReplica struct {
// contains filtered or unexported fields
}
PeerReplica is the Resource peer replicatation. Every Resource has N replicatation in N stores.
func CreatePeerReplica ¶
func CreatePeerReplica(store ResourceStore, meta Resource, handler PeerReplicaHandler, elector Elector) (*PeerReplica, error)
CreatePeerReplica create a resource replica at current container
func NewPeerReplica ¶
func NewPeerReplica(store ResourceStore, meta Resource, peer Peer, handler PeerReplicaHandler, elector Elector) *PeerReplica
NewPeerReplica create a resource replica at current container
func (*PeerReplica) AddPeer ¶
func (pr *PeerReplica) AddPeer(peer Peer)
AddPeer add a peer to this resource
func (*PeerReplica) ChangeLeaderTo ¶
func (pr *PeerReplica) ChangeLeaderTo(leader uint64, cb func(interface{}, error))
ChangeLeaderTo change leader to new leader
func (*PeerReplica) CollectDownPeers ¶
func (pr *PeerReplica) CollectDownPeers(maxDuration time.Duration) []*PeerStats
CollectDownPeers returns the down peers
func (*PeerReplica) CollectPendingPeers ¶
func (pr *PeerReplica) CollectPendingPeers() []*Peer
CollectPendingPeers returns the pending peers
func (*PeerReplica) Destroy ¶
func (pr *PeerReplica) Destroy()
Destroy destory the resource replica from current container
func (*PeerReplica) Do ¶
func (pr *PeerReplica) Do(doFunc func(error), timeout time.Duration)
Do do something async
func (*PeerReplica) Heartbeat ¶
func (pr *PeerReplica) Heartbeat()
Heartbeat send the hb to other peers
func (*PeerReplica) IsLeader ¶
func (pr *PeerReplica) IsLeader() bool
IsLeader returns the peer replica is the leader
func (*PeerReplica) Peer ¶
func (pr *PeerReplica) Peer() *Peer
Peer returns the current peer of this resource
func (*PeerReplica) RemovePeer ¶
func (pr *PeerReplica) RemovePeer(peer Peer)
RemovePeer remove peer
type PeerReplicaHandler ¶
type PeerReplicaHandler interface { AddPeer(Resource, Peer) RemovePeer(Resource, Peer) bool Scale(Resource, interface{}) (bool, []*PeerReplica) Heartbeat(Resource) bool Destory(Resource) ResourceBecomeLeader(Resource) ResourceBecomeFollower(Resource) }
PeerReplicaHandler the interface to handle replica event message
type Prophet ¶
type Prophet interface { // Start start the prophet instance, this will start the lead election, heartbeat loop and listen requests Start() // GetStore returns the Store GetStore() Store // GetRPC returns the RPC client GetRPC() RPC // GetEtcdClient returns the internal etcd instance GetEtcdClient() *clientv3.Client }
Prophet is the distributed scheduler and coordinator
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue is the struct responsible for tracking the state of the queue.
func (*Queue) Dispose ¶
func (q *Queue) Dispose() []interface{}
Dispose will dispose of this queue and returns the items disposed. Any subsequent calls to Get or Put will return an error.
func (*Queue) Disposed ¶
Disposed returns a bool indicating if this queue has had disposed called on it.
func (*Queue) Get ¶
Get retrieves items from the queue. If there are some items in the queue, get will return a number UP TO the number passed in as a parameter. If no items are in the queue, this method will pause until items are added to the queue.
func (*Queue) Peek ¶
Peek returns a the first item in the queue by value without modifying the queue.
func (*Queue) Poll ¶
Poll retrieves items from the queue. If there are some items in the queue, Poll will return a number UP TO the number passed in as a parameter. If no items are in the queue, this method will pause until items are added to the queue or the provided timeout is reached. A non-positive timeout will block until items are added. If a timeout occurs, ErrTimeout is returned.
func (*Queue) PutOrUpdate ¶
PutOrUpdate will add the specified item to the queue, update it if exists
type RPC ¶
type RPC interface { TiggerContainerHeartbeat() TiggerResourceHeartbeat(id uint64) AllocID() (uint64, error) AskSplit(res Resource) (uint64, []uint64, error) }
RPC prophet rpc
type ReplicaTransport ¶
type ReplicaTransport interface { Start() Stop() Send(uint64, interface{}) }
ReplicaTransport transport from peers
func NewReplicaTransport ¶
func NewReplicaTransport(addr string, store ResourceStore, factory func() Resource) ReplicaTransport
NewReplicaTransport returns a replica transport to send and received message
type Resource ¶
type Resource interface { Serializable // SetID update the resource id SetID(id uint64) // ID returns the resource id ID() uint64 // Peers returns the repication peers Peers() []*Peer // SetPeers update the repication peers SetPeers(peers []*Peer) // Stale returns true if the other resource is older than current resource Stale(other Resource) bool // Changed returns true if the other resource is newer than current resource Changed(other Resource) bool // Labels returns the label pairs that determine which the resources will be scheduled to which nodes Labels() []Pair // Clone returns the cloned value Clone() Resource // ScaleCompleted returns true if the current resource has been successfully scaled according to the specified container ScaleCompleted(uint64) bool // Marshal returns error if marshal failed Marshal() ([]byte, error) // Unmarshal returns error if unmarshal failed Unmarshal(data []byte) error }
Resource is an abstraction of data shard in a distributed system. Each Resource has multiple replication and is distributed on different nodes.
type ResourceHeartbeatReq ¶
type ResourceHeartbeatReq struct { Resource Resource `json:"-"` Data []byte `json:"data"` LeaderPeer *Peer `json:"leaderPeer"` DownPeers []*PeerStats `json:"downPeers"` PendingPeers []*Peer `json:"pendingPeers"` ContainerID uint64 `json:"cid"` }
ResourceHeartbeatReq resource hb msg
func (*ResourceHeartbeatReq) Init ¶
func (req *ResourceHeartbeatReq) Init(adapter Adapter) error
Init init
func (*ResourceHeartbeatReq) Prepare ¶
func (req *ResourceHeartbeatReq) Prepare() error
Prepare prepare
type ResourceKind ¶
type ResourceKind int
ResourceKind distinguishes different kinds of resources.
const ( // LeaderKind leader LeaderKind ResourceKind = iota // ReplicaKind replication of resource ReplicaKind )
type ResourceRuntime ¶
type ResourceRuntime struct {
// contains filtered or unexported fields
}
ResourceRuntime resource runtime info
func (*ResourceRuntime) Clone ¶
func (res *ResourceRuntime) Clone() *ResourceRuntime
Clone returns a clone resource runtime
func (*ResourceRuntime) GetContainerIDs ¶
func (res *ResourceRuntime) GetContainerIDs() map[uint64]struct{}
GetContainerIDs returns all container id
func (*ResourceRuntime) GetContainerPeer ¶
func (res *ResourceRuntime) GetContainerPeer(containerID uint64) *Peer
GetContainerPeer returns the peer in the container
func (*ResourceRuntime) GetPeer ¶
func (res *ResourceRuntime) GetPeer(peerID uint64) *Peer
GetPeer return the peer
func (*ResourceRuntime) GetPendingPeer ¶
func (res *ResourceRuntime) GetPendingPeer(peerID uint64) *Peer
GetPendingPeer returns pending peer
func (*ResourceRuntime) RemoveContainerPeer ¶
func (res *ResourceRuntime) RemoveContainerPeer(id uint64)
RemoveContainerPeer remove container peer
type ResourceStore ¶
type ResourceStore interface { Start() Meta() Container GetTransport() ReplicaTransport GetContainerAddr(uint64) (string, error) HandleReplicaMsg(interface{}) interface{} ForeachReplica(func(*PeerReplica) bool) // GetPeerReplica returns a peer replicatation from the store, // when `leader` is true, only return the leader replicatation GetPeerReplica(id uint64, leader bool) *PeerReplica // AddReplica add a replicatation AddReplica(*PeerReplica) RemoveReplica(id uint64) MustStartTask(func(context.Context)) uint64 MustStopTask(uint64) LocalStore() LocalStore }
ResourceStore is a container of resources, which maintains a set of resources
func NewResourceStore ¶
func NewResourceStore(meta Container, localStore LocalStore, pd Prophet, elector Elector, handler PeerReplicaHandler, factory func() Resource, hbInterval time.Duration, workerCount uint64) ResourceStore
NewResourceStore creates a resource store
type RoleChangeHandler ¶
type RoleChangeHandler interface { ProphetBecomeLeader() ProphetBecomeFollower() }
RoleChangeHandler prophet role change handler
type Runner ¶
Runner TODO
func (*Runner) AddNamedWorker ¶
AddNamedWorker add a named worker, the named worker has uniq queue, so jobs are linear execution
func (*Runner) IsNamedWorkerBusy ¶
IsNamedWorkerBusy returns true if named queue is not empty
func (*Runner) RunCancelableTask ¶
RunCancelableTask run a task that can be cancelled Example:
err := s.RunCancelableTask(func(ctx context.Context) { select { case <-ctx.Done(): // cancelled case <-time.After(time.Second): // do something } })
if err != nil { // hanle error return }
func (*Runner) RunJobWithNamedWorker ¶
RunJobWithNamedWorker run a job in a named worker
func (*Runner) RunJobWithNamedWorkerWithCB ¶
func (s *Runner) RunJobWithNamedWorkerWithCB(desc, worker string, task func() error, cb func(*Job)) error
RunJobWithNamedWorkerWithCB run a job in a named worker
func (*Runner) Stop ¶
Stop stop all task RunTask will failure with an error Wait complete for the tasks that already in execute Cancel the tasks that is not start
func (*Runner) StopCancelableTask ¶
StopCancelableTask stop cancelable spec task
type Runtime ¶
Runtime runtime info
func (*Runtime) Container ¶
func (rc *Runtime) Container(id uint64) *ContainerRuntime
Container returns a cloned value of container runtime info
func (*Runtime) Containers ¶
func (rc *Runtime) Containers() []*ContainerRuntime
Containers returns the containers, using clone
func (*Runtime) RandFollowerResource ¶
func (rc *Runtime) RandFollowerResource(id uint64) *ResourceRuntime
RandFollowerResource returns the random follower resource
func (*Runtime) RandLeaderResource ¶
func (rc *Runtime) RandLeaderResource(id uint64) *ResourceRuntime
RandLeaderResource returns the random leader resource
func (*Runtime) Resource ¶
func (rc *Runtime) Resource(id uint64) *ResourceRuntime
Resource returns a cloned value of resource runtime info
func (*Runtime) ResourceContainers ¶
func (rc *Runtime) ResourceContainers(target *ResourceRuntime) []*ContainerRuntime
ResourceContainers returns containers that has the resource's peer
func (*Runtime) ResourceFollowerContainers ¶
func (rc *Runtime) ResourceFollowerContainers(res *ResourceRuntime) []*ContainerRuntime
ResourceFollowerContainers returns all containers for peers exclude leader
func (*Runtime) Resources ¶
func (rc *Runtime) Resources() []*ResourceRuntime
Resources returns the resources, using clone
type Scheduler ¶
type Scheduler interface { Name() string ResourceKind() ResourceKind ResourceLimit() uint64 Prepare(rt *Runtime) error Cleanup(rt *Runtime) Schedule(rt *Runtime) Operator }
Scheduler is an interface to schedule resources.
type Selector ¶
type Selector interface { SelectSource(containers []*ContainerRuntime, filters ...Filter) *ContainerRuntime SelectTarget(containers []*ContainerRuntime, filters ...Filter) *ContainerRuntime }
Selector is an interface to select source and target container to schedule.
type Store ¶
type Store interface { // PutResource puts the meta to the store PutResource(meta Resource) error // GetResource returns the spec resource GetResource(id uint64) (Resource, error) // PutContainer puts the meta to the store PutContainer(meta Container) error // GetContainer returns the spec container GetContainer(id uint64) (Container, error) // LoadResources load all resources LoadResources(limit int64, do func(Resource)) error // LoadContainers load all containers LoadContainers(limit int64, do func(Container)) error // AllocID returns the alloc id AllocID() (uint64, error) // PutBootstrapped put cluster is bootstrapped PutBootstrapped(container Container, resources ...Resource) (bool, error) // PutIfNotExists put the value at path // returns true, nil, nil if created // returns false, exists, nil if not created PutIfNotExists(path string, value []byte) (bool, []byte, error) // RemoveIfValueMatched returns true if the expect value is and the exists value are matched RemoveIfValueMatched(path string, expect []byte) (bool, error) }
Store meta store
type Watcher ¶
Watcher watcher client
func NewWatcherWithProphet ¶
NewWatcherWithProphet returns a watcher for watch
Source Files ¶
- cfg.go
- election.go
- election_option.go
- errors.go
- local.go
- log.go
- meta.go
- mock_meta.go
- mock_peer_replica.go
- mock_peer_store.go
- mock_prophet.go
- mock_prophet_rpc.go
- peer_replica.go
- peer_store.go
- peer_transport.go
- prophet.go
- prophet_coordinator.go
- prophet_etcd.go
- prophet_handler.go
- prophet_heartbeat.go
- prophet_join.go
- prophet_leader.go
- prophet_options.go
- prophet_rpc.go
- prophet_transport.go
- runtime.go
- runtime_container.go
- runtime_resource.go
- runtime_update.go
- scheduler.go
- scheduler_balancer.go
- scheduler_balancer_leader.go
- scheduler_balancer_replica.go
- scheduler_filter.go
- scheduler_op_aggregation.go
- scheduler_op_leader.go
- scheduler_op_replica.go
- scheduler_replica.go
- scheduler_replica_scale.go
- scheduler_selector.go
- store.go
- store_etcd.go
- test_infostructure.go
- util_cache.go
- util_math.go
- util_peer.go
- util_queue.go
- util_status.go
- util_task.go
- util_url.go
- watcher.go
- watcher_client.go