prophet: github.com/infinivision/prophet Index | Files

package prophet

import "github.com/infinivision/prophet"

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

Package 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

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

func EmptyPeer Uses

func EmptyPeer(value Peer) bool

EmptyPeer returns a peer is a empty peer

func ExecuteInParallel Uses

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 Uses

func GeometricMean(input Float64Data) (float64, error)

GeometricMean gets the geometric mean for a slice of numbers

func HarmonicMean Uses

func HarmonicMean(input Float64Data) (float64, error)

HarmonicMean gets the harmonic mean for a slice of numbers

func MatchEvent Uses

func MatchEvent(event, flag int) bool

MatchEvent returns the flag has the target event

func Max Uses

func Max(input Float64Data) (max float64, err error)

Max finds the highest number in a slice

func Mean Uses

func Mean(input Float64Data) (float64, error)

Mean gets the average of a slice of numbers

func Median Uses

func Median(input Float64Data) (median float64, err error)

Median gets the median number in a slice of numbers

func Min Uses

func Min(input Float64Data) (min float64, err error)

Min finds the lowest number in a set of data

func Mode Uses

func Mode(input Float64Data) (mode []float64, err error)

Mode gets the mode of a slice of numbers

func PopulationVariance Uses

func PopulationVariance(input Float64Data) (pvar float64, err error)

PopulationVariance finds the amount of variance within a population

func SetLogger Uses

func SetLogger(l Logger)

SetLogger set the log for prophet

func StandardDeviation Uses

func StandardDeviation(input Float64Data) (sdev float64, err error)

StandardDeviation the amount of variation in the dataset

func StandardDeviationPopulation Uses

func StandardDeviationPopulation(input Float64Data) (sdev float64, err error)

StandardDeviationPopulation finds the amount of variation from the population

func Sum Uses

func Sum(input Float64Data) (sum float64, err error)

Sum adds all the numbers of a slice together

type Action Uses

type Action int

Action the action on the cluster join the cluster

type Adapter Uses

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 Uses

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 ChangePeerType Uses

type ChangePeerType byte

ChangePeerType change peer type

type Container Uses

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 Uses

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 Uses

func (req *ContainerHeartbeatReq) Init(adapter Adapter) error

Init init

func (*ContainerHeartbeatReq) Prepare Uses

func (req *ContainerHeartbeatReq) Prepare() error

Prepare prepare

type ContainerRuntime Uses

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

ContainerRuntime is the container runtime info

func (*ContainerRuntime) Clone Uses

func (cr *ContainerRuntime) Clone() *ContainerRuntime

Clone returns the container clone info

func (*ContainerRuntime) Downtime Uses

func (cr *ContainerRuntime) Downtime() time.Duration

Downtime returns the container down time

func (*ContainerRuntime) GetLabelValue Uses

func (cr *ContainerRuntime) GetLabelValue(key string) string

GetLabelValue returns label value of key

func (*ContainerRuntime) GetLocationID Uses

func (cr *ContainerRuntime) GetLocationID(keys []string) string

GetLocationID returns location id

func (*ContainerRuntime) HasNoneHeartbeat Uses

func (cr *ContainerRuntime) HasNoneHeartbeat() bool

HasNoneHeartbeat returns if received a heartbeat from the container

func (*ContainerRuntime) IsBlocked Uses

func (cr *ContainerRuntime) IsBlocked() bool

IsBlocked returns the container is blocked from balance if true.

func (*ContainerRuntime) IsUp Uses

func (cr *ContainerRuntime) IsUp() bool

IsUp returns the container is up state

func (*ContainerRuntime) LeaderScore Uses

func (cr *ContainerRuntime) LeaderScore() float64

LeaderScore returns score with leader

func (*ContainerRuntime) ReplicaScore Uses

func (cr *ContainerRuntime) ReplicaScore() float64

ReplicaScore returns score with replica

func (*ContainerRuntime) ResourceCount Uses

func (cr *ContainerRuntime) ResourceCount(kind ResourceKind) uint64

ResourceCount returns resource count by kind

func (*ContainerRuntime) ResourceScore Uses

func (cr *ContainerRuntime) ResourceScore(kind ResourceKind) float64

ResourceScore returns resource score by kind

func (*ContainerRuntime) StorageUsedBytes Uses

func (cr *ContainerRuntime) StorageUsedBytes() uint64

StorageUsedBytes returns container used storage with bytes

func (*ContainerRuntime) StorageUsedRatio Uses

func (cr *ContainerRuntime) StorageUsedRatio() int

StorageUsedRatio returns container used storage with rate

type Coordinator Uses

type Coordinator struct {
    sync.RWMutex
    // contains filtered or unexported fields
}

Coordinator resource coordinator

type Elector Uses

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 Uses

func NewElector(client *clientv3.Client, options ...ElectorOption) (Elector, error)

NewElector create a elector

type ElectorOption Uses

type ElectorOption func(*electorOptions)

ElectorOption elector option

func WithLeaderLeaseSeconds Uses

func WithLeaderLeaseSeconds(value int64) ElectorOption

WithLeaderLeaseSeconds set leader lease in seconds

func WithLockIfBecomeLeader Uses

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 Uses

func WithPrefix(value string) ElectorOption

WithPrefix set data prefix in embed etcd server

type EmbeddedEtcdCfg Uses

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 Uses

type EventNotify struct {
    Seq   uint64 `json:"seq"`
    Event int    `json:"event"`
    Value []byte `json:"value"`
}

EventNotify event notify

func (*EventNotify) ReadInitEventValues Uses

func (evt *EventNotify) ReadInitEventValues(resourceF func([]byte, uint64), containerF func([]byte))

ReadInitEventValues read all resource info

func (*EventNotify) ReadLeaderChangerValue Uses

func (evt *EventNotify) ReadLeaderChangerValue() (uint64, uint64)

ReadLeaderChangerValue returns the target resource and the new leader returns resourceid, newleaderid

type Filter Uses

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 Uses

func NewBlockFilter() Filter

NewBlockFilter returns a filter for choose resource container by block

func NewCacheFilter Uses

func NewCacheFilter(freezeCache *resourceFreezeCache) Filter

NewCacheFilter returns a filter for choose resource container by runtime cache

func NewDistinctScoreFilter Uses

func NewDistinctScoreFilter(cfg *Cfg, containers []*ContainerRuntime, source *ContainerRuntime) Filter

NewDistinctScoreFilter a filter for ensures that distinct score will not decrease.

func NewExcludedFilter Uses

func NewExcludedFilter(sources, targets map[uint64]struct{}) Filter

NewExcludedFilter returns a filter for choose resource container by excluded value

func NewHealthFilter Uses

func NewHealthFilter(cfg *Cfg) Filter

NewHealthFilter returns a filter for choose resource container by health info

func NewLabelFilter Uses

func NewLabelFilter(labels []Pair) Filter

NewLabelFilter returns label filter, if the container missing the labels, skip it.

func NewSnapshotCountFilter Uses

func NewSnapshotCountFilter(cfg *Cfg) Filter

NewSnapshotCountFilter returns snapshot filter

func NewStateFilter Uses

func NewStateFilter(cfg *Cfg) Filter

NewStateFilter returns a filter for choose resource container by state

func NewStorageThresholdFilter Uses

func NewStorageThresholdFilter(cfg *Cfg) Filter

NewStorageThresholdFilter returns a filter for choose resource container by storage rate

type Float64Data Uses

type Float64Data []float64

Float64Data is a named type for []float64 with helper methods

func (Float64Data) Get Uses

func (f Float64Data) Get(i int) float64

Get item in slice

func (Float64Data) Len Uses

func (f Float64Data) Len() int

Len returns length of slice

func (Float64Data) Less Uses

func (f Float64Data) Less(i, j int) bool

Less returns if one number is less than another

func (Float64Data) Max Uses

func (f Float64Data) Max() (float64, error)

Max returns the maximum number in the data

func (Float64Data) Mean Uses

func (f Float64Data) Mean() (float64, error)

Mean returns the mean of the data

func (Float64Data) Median Uses

func (f Float64Data) Median() (float64, error)

Median returns the median of the data

func (Float64Data) Min Uses

func (f Float64Data) Min() (float64, error)

Min returns the minimum number in the data

func (Float64Data) Mode Uses

func (f Float64Data) Mode() ([]float64, error)

Mode returns the mode of the data

func (Float64Data) Sum Uses

func (f Float64Data) Sum() (float64, error)

Sum returns the total of all the numbers in the data

func (Float64Data) Swap Uses

func (f Float64Data) Swap(i, j int)

Swap switches out two numbers in slice

type HeartbeatHandler Uses

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 InitWatcher Uses

type InitWatcher struct {
    Flag int `json:"flag"`
}

InitWatcher init watcher

type Job Uses

type Job struct {
    sync.RWMutex
    // contains filtered or unexported fields
}

Job is do for something with state

func (*Job) Cancel Uses

func (job *Job) Cancel()

Cancel cancel the job

func (*Job) GetResult Uses

func (job *Job) GetResult() interface{}

GetResult returns job result

func (*Job) IsCancelled Uses

func (job *Job) IsCancelled() bool

IsCancelled returns true if job state is Cancelled

func (*Job) IsCancelling Uses

func (job *Job) IsCancelling() bool

IsCancelling returns true if job state is Cancelling

func (*Job) IsComplete Uses

func (job *Job) IsComplete() bool

IsComplete return true means the job is complete.

func (*Job) IsFailed Uses

func (job *Job) IsFailed() bool

IsFailed returns true if job state is Failed

func (*Job) IsFinished Uses

func (job *Job) IsFinished() bool

IsFinished returns true if job state is Finished

func (*Job) IsNotComplete Uses

func (job *Job) IsNotComplete() bool

IsNotComplete return true means the job is not complete.

func (*Job) IsPending Uses

func (job *Job) IsPending() bool

IsPending returns true if job state is Pending

func (*Job) IsRunning Uses

func (job *Job) IsRunning() bool

IsRunning returns true if job state is Running

func (*Job) SetResult Uses

func (job *Job) SetResult(result interface{})

SetResult set result

type JobState Uses

type JobState int

JobState is the job state

type LocalStorage Uses

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 Uses

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 Uses

func NewLocalStore(meta Container, storage LocalStorage, pd Prophet) LocalStore

NewLocalStore returns a local store

type Logger Uses

type Logger interface {
    Info(v ...interface{})
    Infof(format string, v ...interface{})
    Debug(v ...interface{})
    Debugf(format string, v ...interface{})
    Warning(v ...interface{})
    Warningf(format string, v ...interface{})
    Error(v ...interface{})
    Errorf(format string, v ...interface{})
    Fatal(v ...interface{})
    Fatalf(format string, v ...interface{})
}

Logger logger

type MockAdapter Uses

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

MockAdapter is a mock of Adapter interface

func NewMockAdapter Uses

func NewMockAdapter(ctrl *gomock.Controller) *MockAdapter

NewMockAdapter creates a new mock instance

func (*MockAdapter) ContainerHBInterval Uses

func (m *MockAdapter) ContainerHBInterval() time.Duration

ContainerHBInterval mocks base method

func (*MockAdapter) EXPECT Uses

func (m *MockAdapter) EXPECT() *MockAdapterMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

func (*MockAdapter) FetchContainerHB Uses

func (m *MockAdapter) FetchContainerHB() *ContainerHeartbeatReq

FetchContainerHB mocks base method

func (*MockAdapter) FetchLeaderResources Uses

func (m *MockAdapter) FetchLeaderResources() []uint64

FetchLeaderResources mocks base method

func (*MockAdapter) FetchResourceHB Uses

func (m *MockAdapter) FetchResourceHB(id uint64) *ResourceHeartbeatReq

FetchResourceHB mocks base method

func (*MockAdapter) HBHandler Uses

func (m *MockAdapter) HBHandler() HeartbeatHandler

HBHandler mocks base method

func (*MockAdapter) NewContainer Uses

func (m *MockAdapter) NewContainer() Container

NewContainer mocks base method

func (*MockAdapter) NewResource Uses

func (m *MockAdapter) NewResource() Resource

NewResource mocks base method

func (*MockAdapter) ResourceHBInterval Uses

func (m *MockAdapter) ResourceHBInterval() time.Duration

ResourceHBInterval mocks base method

type MockAdapterMockRecorder Uses

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

MockAdapterMockRecorder is the mock recorder for MockAdapter

func (*MockAdapterMockRecorder) ContainerHBInterval Uses

func (mr *MockAdapterMockRecorder) ContainerHBInterval() *gomock.Call

ContainerHBInterval indicates an expected call of ContainerHBInterval

func (*MockAdapterMockRecorder) FetchContainerHB Uses

func (mr *MockAdapterMockRecorder) FetchContainerHB() *gomock.Call

FetchContainerHB indicates an expected call of FetchContainerHB

func (*MockAdapterMockRecorder) FetchLeaderResources Uses

func (mr *MockAdapterMockRecorder) FetchLeaderResources() *gomock.Call

FetchLeaderResources indicates an expected call of FetchLeaderResources

func (*MockAdapterMockRecorder) FetchResourceHB Uses

func (mr *MockAdapterMockRecorder) FetchResourceHB(id interface{}) *gomock.Call

FetchResourceHB indicates an expected call of FetchResourceHB

func (*MockAdapterMockRecorder) HBHandler Uses

func (mr *MockAdapterMockRecorder) HBHandler() *gomock.Call

HBHandler indicates an expected call of HBHandler

func (*MockAdapterMockRecorder) NewContainer Uses

func (mr *MockAdapterMockRecorder) NewContainer() *gomock.Call

NewContainer indicates an expected call of NewContainer

func (*MockAdapterMockRecorder) NewResource Uses

func (mr *MockAdapterMockRecorder) NewResource() *gomock.Call

NewResource indicates an expected call of NewResource

func (*MockAdapterMockRecorder) ResourceHBInterval Uses

func (mr *MockAdapterMockRecorder) ResourceHBInterval() *gomock.Call

ResourceHBInterval indicates an expected call of ResourceHBInterval

type MockContainer Uses

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

MockContainer is a mock of Container interface

func NewMockContainer Uses

func NewMockContainer(ctrl *gomock.Controller) *MockContainer

NewMockContainer creates a new mock instance

func (*MockContainer) ActionOnJoinCluster Uses

func (m *MockContainer) ActionOnJoinCluster() Action

ActionOnJoinCluster mocks base method

func (*MockContainer) Clone Uses

func (m *MockContainer) Clone() Container

Clone mocks base method

func (*MockContainer) EXPECT Uses

func (m *MockContainer) EXPECT() *MockContainerMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

func (*MockContainer) ID Uses

func (m *MockContainer) ID() uint64

ID mocks base method

func (*MockContainer) Labels Uses

func (m *MockContainer) Labels() []Pair

Labels mocks base method

func (*MockContainer) Marshal Uses

func (m *MockContainer) Marshal() ([]byte, error)

Marshal mocks base method

func (*MockContainer) SetID Uses

func (m *MockContainer) SetID(id uint64)

SetID mocks base method

func (*MockContainer) ShardAddr Uses

func (m *MockContainer) ShardAddr() string

ShardAddr mocks base method

func (*MockContainer) State Uses

func (m *MockContainer) State() State

State mocks base method

func (*MockContainer) Unmarshal Uses

func (m *MockContainer) Unmarshal(data []byte) error

Unmarshal mocks base method

type MockContainerMockRecorder Uses

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

MockContainerMockRecorder is the mock recorder for MockContainer

func (*MockContainerMockRecorder) ActionOnJoinCluster Uses

func (mr *MockContainerMockRecorder) ActionOnJoinCluster() *gomock.Call

ActionOnJoinCluster indicates an expected call of ActionOnJoinCluster

func (*MockContainerMockRecorder) Clone Uses

func (mr *MockContainerMockRecorder) Clone() *gomock.Call

Clone indicates an expected call of Clone

func (*MockContainerMockRecorder) ID Uses

func (mr *MockContainerMockRecorder) ID() *gomock.Call

ID indicates an expected call of ID

func (*MockContainerMockRecorder) Labels Uses

func (mr *MockContainerMockRecorder) Labels() *gomock.Call

Labels indicates an expected call of Labels

func (*MockContainerMockRecorder) Marshal Uses

func (mr *MockContainerMockRecorder) Marshal() *gomock.Call

Marshal indicates an expected call of Marshal

func (*MockContainerMockRecorder) SetID Uses

func (mr *MockContainerMockRecorder) SetID(id interface{}) *gomock.Call

SetID indicates an expected call of SetID

func (*MockContainerMockRecorder) ShardAddr Uses

func (mr *MockContainerMockRecorder) ShardAddr() *gomock.Call

ShardAddr indicates an expected call of ShardAddr

func (*MockContainerMockRecorder) State Uses

func (mr *MockContainerMockRecorder) State() *gomock.Call

State indicates an expected call of State

func (*MockContainerMockRecorder) Unmarshal Uses

func (mr *MockContainerMockRecorder) Unmarshal(data interface{}) *gomock.Call

Unmarshal indicates an expected call of Unmarshal

type MockPeerReplicaHandler Uses

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

MockPeerReplicaHandler is a mock of PeerReplicaHandler interface

func NewMockPeerReplicaHandler Uses

func NewMockPeerReplicaHandler(ctrl *gomock.Controller) *MockPeerReplicaHandler

NewMockPeerReplicaHandler creates a new mock instance

func (*MockPeerReplicaHandler) AddPeer Uses

func (m *MockPeerReplicaHandler) AddPeer(arg0 Resource, arg1 Peer)

AddPeer mocks base method

func (*MockPeerReplicaHandler) Destory Uses

func (m *MockPeerReplicaHandler) Destory(arg0 Resource)

Destory mocks base method

func (*MockPeerReplicaHandler) EXPECT Uses

func (m *MockPeerReplicaHandler) EXPECT() *MockPeerReplicaHandlerMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

func (*MockPeerReplicaHandler) Heartbeat Uses

func (m *MockPeerReplicaHandler) Heartbeat(arg0 Resource) bool

Heartbeat mocks base method

func (*MockPeerReplicaHandler) RemovePeer Uses

func (m *MockPeerReplicaHandler) RemovePeer(arg0 Resource, arg1 Peer) bool

RemovePeer mocks base method

func (*MockPeerReplicaHandler) ResourceBecomeFollower Uses

func (m *MockPeerReplicaHandler) ResourceBecomeFollower(arg0 Resource)

ResourceBecomeFollower mocks base method

func (*MockPeerReplicaHandler) ResourceBecomeLeader Uses

func (m *MockPeerReplicaHandler) ResourceBecomeLeader(arg0 Resource)

ResourceBecomeLeader mocks base method

func (*MockPeerReplicaHandler) Scale Uses

func (m *MockPeerReplicaHandler) Scale(arg0 Resource, arg1 interface{}) (bool, []*PeerReplica)

Scale mocks base method

type MockPeerReplicaHandlerMockRecorder Uses

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

MockPeerReplicaHandlerMockRecorder is the mock recorder for MockPeerReplicaHandler

func (*MockPeerReplicaHandlerMockRecorder) AddPeer Uses

func (mr *MockPeerReplicaHandlerMockRecorder) AddPeer(arg0, arg1 interface{}) *gomock.Call

AddPeer indicates an expected call of AddPeer

func (*MockPeerReplicaHandlerMockRecorder) Destory Uses

func (mr *MockPeerReplicaHandlerMockRecorder) Destory(arg0 interface{}) *gomock.Call

Destory indicates an expected call of Destory

func (*MockPeerReplicaHandlerMockRecorder) Heartbeat Uses

func (mr *MockPeerReplicaHandlerMockRecorder) Heartbeat(arg0 interface{}) *gomock.Call

Heartbeat indicates an expected call of Heartbeat

func (*MockPeerReplicaHandlerMockRecorder) RemovePeer Uses

func (mr *MockPeerReplicaHandlerMockRecorder) RemovePeer(arg0, arg1 interface{}) *gomock.Call

RemovePeer indicates an expected call of RemovePeer

func (*MockPeerReplicaHandlerMockRecorder) ResourceBecomeFollower Uses

func (mr *MockPeerReplicaHandlerMockRecorder) ResourceBecomeFollower(arg0 interface{}) *gomock.Call

ResourceBecomeFollower indicates an expected call of ResourceBecomeFollower

func (*MockPeerReplicaHandlerMockRecorder) ResourceBecomeLeader Uses

func (mr *MockPeerReplicaHandlerMockRecorder) ResourceBecomeLeader(arg0 interface{}) *gomock.Call

ResourceBecomeLeader indicates an expected call of ResourceBecomeLeader

func (*MockPeerReplicaHandlerMockRecorder) Scale Uses

func (mr *MockPeerReplicaHandlerMockRecorder) Scale(arg0, arg1 interface{}) *gomock.Call

Scale indicates an expected call of Scale

type MockProphet Uses

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

MockProphet is a mock of Prophet interface

func NewMockProphet Uses

func NewMockProphet(ctrl *gomock.Controller) *MockProphet

NewMockProphet creates a new mock instance

func (*MockProphet) EXPECT Uses

func (m *MockProphet) EXPECT() *MockProphetMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

func (*MockProphet) GetEtcdClient Uses

func (m *MockProphet) GetEtcdClient() *clientv3.Client

GetEtcdClient mocks base method

func (*MockProphet) GetRPC Uses

func (m *MockProphet) GetRPC() RPC

GetRPC mocks base method

func (*MockProphet) GetStore Uses

func (m *MockProphet) GetStore() Store

GetStore mocks base method

func (*MockProphet) Start Uses

func (m *MockProphet) Start()

Start mocks base method

func (*MockProphet) Stop Uses

func (m *MockProphet) Stop()

Stop mocks base method

type MockProphetMockRecorder Uses

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

MockProphetMockRecorder is the mock recorder for MockProphet

func (*MockProphetMockRecorder) GetEtcdClient Uses

func (mr *MockProphetMockRecorder) GetEtcdClient() *gomock.Call

GetEtcdClient indicates an expected call of GetEtcdClient

func (*MockProphetMockRecorder) GetRPC Uses

func (mr *MockProphetMockRecorder) GetRPC() *gomock.Call

GetRPC indicates an expected call of GetRPC

func (*MockProphetMockRecorder) GetStore Uses

func (mr *MockProphetMockRecorder) GetStore() *gomock.Call

GetStore indicates an expected call of GetStore

func (*MockProphetMockRecorder) Start Uses

func (mr *MockProphetMockRecorder) Start() *gomock.Call

Start indicates an expected call of Start

func (*MockProphetMockRecorder) Stop Uses

func (mr *MockProphetMockRecorder) Stop() *gomock.Call

Stop indicates an expected call of Stop

type MockRPC Uses

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

MockRPC is a mock of RPC interface

func NewMockRPC Uses

func NewMockRPC(ctrl *gomock.Controller) *MockRPC

NewMockRPC creates a new mock instance

func (*MockRPC) AllocID Uses

func (m *MockRPC) AllocID() (uint64, error)

AllocID mocks base method

func (*MockRPC) AskSplit Uses

func (m *MockRPC) AskSplit(res Resource) (uint64, []uint64, error)

AskSplit mocks base method

func (*MockRPC) EXPECT Uses

func (m *MockRPC) EXPECT() *MockRPCMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

func (*MockRPC) TiggerContainerHeartbeat Uses

func (m *MockRPC) TiggerContainerHeartbeat()

TiggerContainerHeartbeat mocks base method

func (*MockRPC) TiggerResourceHeartbeat Uses

func (m *MockRPC) TiggerResourceHeartbeat(id uint64)

TiggerResourceHeartbeat mocks base method

type MockRPCMockRecorder Uses

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

MockRPCMockRecorder is the mock recorder for MockRPC

func (*MockRPCMockRecorder) AllocID Uses

func (mr *MockRPCMockRecorder) AllocID() *gomock.Call

AllocID indicates an expected call of AllocID

func (*MockRPCMockRecorder) AskSplit Uses

func (mr *MockRPCMockRecorder) AskSplit(res interface{}) *gomock.Call

AskSplit indicates an expected call of AskSplit

func (*MockRPCMockRecorder) TiggerContainerHeartbeat Uses

func (mr *MockRPCMockRecorder) TiggerContainerHeartbeat() *gomock.Call

TiggerContainerHeartbeat indicates an expected call of TiggerContainerHeartbeat

func (*MockRPCMockRecorder) TiggerResourceHeartbeat Uses

func (mr *MockRPCMockRecorder) TiggerResourceHeartbeat(id interface{}) *gomock.Call

TiggerResourceHeartbeat indicates an expected call of TiggerResourceHeartbeat

type MockResource Uses

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

MockResource is a mock of Resource interface

func NewMockResource Uses

func NewMockResource(ctrl *gomock.Controller) *MockResource

NewMockResource creates a new mock instance

func (*MockResource) Changed Uses

func (m *MockResource) Changed(other Resource) bool

Changed mocks base method

func (*MockResource) Clone Uses

func (m *MockResource) Clone() Resource

Clone mocks base method

func (*MockResource) EXPECT Uses

func (m *MockResource) EXPECT() *MockResourceMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

func (*MockResource) ID Uses

func (m *MockResource) ID() uint64

ID mocks base method

func (*MockResource) Labels Uses

func (m *MockResource) Labels() []Pair

Labels mocks base method

func (*MockResource) Marshal Uses

func (m *MockResource) Marshal() ([]byte, error)

Marshal mocks base method

func (*MockResource) Peers Uses

func (m *MockResource) Peers() []*Peer

Peers mocks base method

func (*MockResource) ScaleCompleted Uses

func (m *MockResource) ScaleCompleted(arg0 uint64) bool

ScaleCompleted mocks base method

func (*MockResource) SetID Uses

func (m *MockResource) SetID(id uint64)

SetID mocks base method

func (*MockResource) SetPeers Uses

func (m *MockResource) SetPeers(peers []*Peer)

SetPeers mocks base method

func (*MockResource) Stale Uses

func (m *MockResource) Stale(other Resource) bool

Stale mocks base method

func (*MockResource) Unmarshal Uses

func (m *MockResource) Unmarshal(data []byte) error

Unmarshal mocks base method

type MockResourceMockRecorder Uses

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

MockResourceMockRecorder is the mock recorder for MockResource

func (*MockResourceMockRecorder) Changed Uses

func (mr *MockResourceMockRecorder) Changed(other interface{}) *gomock.Call

Changed indicates an expected call of Changed

func (*MockResourceMockRecorder) Clone Uses

func (mr *MockResourceMockRecorder) Clone() *gomock.Call

Clone indicates an expected call of Clone

func (*MockResourceMockRecorder) ID Uses

func (mr *MockResourceMockRecorder) ID() *gomock.Call

ID indicates an expected call of ID

func (*MockResourceMockRecorder) Labels Uses

func (mr *MockResourceMockRecorder) Labels() *gomock.Call

Labels indicates an expected call of Labels

func (*MockResourceMockRecorder) Marshal Uses

func (mr *MockResourceMockRecorder) Marshal() *gomock.Call

Marshal indicates an expected call of Marshal

func (*MockResourceMockRecorder) Peers Uses

func (mr *MockResourceMockRecorder) Peers() *gomock.Call

Peers indicates an expected call of Peers

func (*MockResourceMockRecorder) ScaleCompleted Uses

func (mr *MockResourceMockRecorder) ScaleCompleted(arg0 interface{}) *gomock.Call

ScaleCompleted indicates an expected call of ScaleCompleted

func (*MockResourceMockRecorder) SetID Uses

func (mr *MockResourceMockRecorder) SetID(id interface{}) *gomock.Call

SetID indicates an expected call of SetID

func (*MockResourceMockRecorder) SetPeers Uses

func (mr *MockResourceMockRecorder) SetPeers(peers interface{}) *gomock.Call

SetPeers indicates an expected call of SetPeers

func (*MockResourceMockRecorder) Stale Uses

func (mr *MockResourceMockRecorder) Stale(other interface{}) *gomock.Call

Stale indicates an expected call of Stale

func (*MockResourceMockRecorder) Unmarshal Uses

func (mr *MockResourceMockRecorder) Unmarshal(data interface{}) *gomock.Call

Unmarshal indicates an expected call of Unmarshal

type MockResourceStore Uses

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

MockResourceStore is a mock of ResourceStore interface

func NewMockResourceStore Uses

func NewMockResourceStore(ctrl *gomock.Controller) *MockResourceStore

NewMockResourceStore creates a new mock instance

func (*MockResourceStore) AddReplica Uses

func (m *MockResourceStore) AddReplica(arg0 *PeerReplica)

AddReplica mocks base method

func (*MockResourceStore) EXPECT Uses

func (m *MockResourceStore) EXPECT() *MockResourceStoreMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

func (*MockResourceStore) ForeachReplica Uses

func (m *MockResourceStore) ForeachReplica(arg0 func(*PeerReplica) bool)

ForeachReplica mocks base method

func (*MockResourceStore) GetContainerAddr Uses

func (m *MockResourceStore) GetContainerAddr(arg0 uint64) (string, error)

GetContainerAddr mocks base method

func (*MockResourceStore) GetPeerReplica Uses

func (m *MockResourceStore) GetPeerReplica(id uint64, leader bool) *PeerReplica

GetPeerReplica mocks base method

func (*MockResourceStore) GetTransport Uses

func (m *MockResourceStore) GetTransport() ReplicaTransport

GetTransport mocks base method

func (*MockResourceStore) HandleReplicaMsg Uses

func (m *MockResourceStore) HandleReplicaMsg(arg0 interface{}) interface{}

HandleReplicaMsg mocks base method

func (*MockResourceStore) LocalStore Uses

func (m *MockResourceStore) LocalStore() LocalStore

LocalStore mocks base method

func (*MockResourceStore) Meta Uses

func (m *MockResourceStore) Meta() Container

Meta mocks base method

func (*MockResourceStore) MustStartTask Uses

func (m *MockResourceStore) MustStartTask(arg0 func(context.Context)) uint64

MustStartTask mocks base method

func (*MockResourceStore) MustStopTask Uses

func (m *MockResourceStore) MustStopTask(arg0 uint64)

MustStopTask mocks base method

func (*MockResourceStore) RemoveReplica Uses

func (m *MockResourceStore) RemoveReplica(id uint64)

RemoveReplica mocks base method

func (*MockResourceStore) Start Uses

func (m *MockResourceStore) Start()

Start mocks base method

type MockResourceStoreMockRecorder Uses

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

MockResourceStoreMockRecorder is the mock recorder for MockResourceStore

func (*MockResourceStoreMockRecorder) AddReplica Uses

func (mr *MockResourceStoreMockRecorder) AddReplica(arg0 interface{}) *gomock.Call

AddReplica indicates an expected call of AddReplica

func (*MockResourceStoreMockRecorder) ForeachReplica Uses

func (mr *MockResourceStoreMockRecorder) ForeachReplica(arg0 interface{}) *gomock.Call

ForeachReplica indicates an expected call of ForeachReplica

func (*MockResourceStoreMockRecorder) GetContainerAddr Uses

func (mr *MockResourceStoreMockRecorder) GetContainerAddr(arg0 interface{}) *gomock.Call

GetContainerAddr indicates an expected call of GetContainerAddr

func (*MockResourceStoreMockRecorder) GetPeerReplica Uses

func (mr *MockResourceStoreMockRecorder) GetPeerReplica(id, leader interface{}) *gomock.Call

GetPeerReplica indicates an expected call of GetPeerReplica

func (*MockResourceStoreMockRecorder) GetTransport Uses

func (mr *MockResourceStoreMockRecorder) GetTransport() *gomock.Call

GetTransport indicates an expected call of GetTransport

func (*MockResourceStoreMockRecorder) HandleReplicaMsg Uses

func (mr *MockResourceStoreMockRecorder) HandleReplicaMsg(arg0 interface{}) *gomock.Call

HandleReplicaMsg indicates an expected call of HandleReplicaMsg

func (*MockResourceStoreMockRecorder) LocalStore Uses

func (mr *MockResourceStoreMockRecorder) LocalStore() *gomock.Call

LocalStore indicates an expected call of LocalStore

func (*MockResourceStoreMockRecorder) Meta Uses

func (mr *MockResourceStoreMockRecorder) Meta() *gomock.Call

Meta indicates an expected call of Meta

func (*MockResourceStoreMockRecorder) MustStartTask Uses

func (mr *MockResourceStoreMockRecorder) MustStartTask(arg0 interface{}) *gomock.Call

MustStartTask indicates an expected call of MustStartTask

func (*MockResourceStoreMockRecorder) MustStopTask Uses

func (mr *MockResourceStoreMockRecorder) MustStopTask(arg0 interface{}) *gomock.Call

MustStopTask indicates an expected call of MustStopTask

func (*MockResourceStoreMockRecorder) RemoveReplica Uses

func (mr *MockResourceStoreMockRecorder) RemoveReplica(id interface{}) *gomock.Call

RemoveReplica indicates an expected call of RemoveReplica

func (*MockResourceStoreMockRecorder) Start Uses

func (mr *MockResourceStoreMockRecorder) Start() *gomock.Call

Start indicates an expected call of Start

type MockRoleChangeHandler Uses

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

MockRoleChangeHandler is a mock of RoleChangeHandler interface

func NewMockRoleChangeHandler Uses

func NewMockRoleChangeHandler(ctrl *gomock.Controller) *MockRoleChangeHandler

NewMockRoleChangeHandler creates a new mock instance

func (*MockRoleChangeHandler) EXPECT Uses

func (m *MockRoleChangeHandler) EXPECT() *MockRoleChangeHandlerMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

func (*MockRoleChangeHandler) ProphetBecomeFollower Uses

func (m *MockRoleChangeHandler) ProphetBecomeFollower()

ProphetBecomeFollower mocks base method

func (*MockRoleChangeHandler) ProphetBecomeLeader Uses

func (m *MockRoleChangeHandler) ProphetBecomeLeader()

ProphetBecomeLeader mocks base method

type MockRoleChangeHandlerMockRecorder Uses

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

MockRoleChangeHandlerMockRecorder is the mock recorder for MockRoleChangeHandler

func (*MockRoleChangeHandlerMockRecorder) ProphetBecomeFollower Uses

func (mr *MockRoleChangeHandlerMockRecorder) ProphetBecomeFollower() *gomock.Call

ProphetBecomeFollower indicates an expected call of ProphetBecomeFollower

func (*MockRoleChangeHandlerMockRecorder) ProphetBecomeLeader Uses

func (mr *MockRoleChangeHandlerMockRecorder) ProphetBecomeLeader() *gomock.Call

ProphetBecomeLeader indicates an expected call of ProphetBecomeLeader

type MockSerializable Uses

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

MockSerializable is a mock of Serializable interface

func NewMockSerializable Uses

func NewMockSerializable(ctrl *gomock.Controller) *MockSerializable

NewMockSerializable creates a new mock instance

func (*MockSerializable) EXPECT Uses

func (m *MockSerializable) EXPECT() *MockSerializableMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

type MockSerializableMockRecorder Uses

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

MockSerializableMockRecorder is the mock recorder for MockSerializable

type MockcodecSerializable Uses

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

MockcodecSerializable is a mock of codecSerializable interface

func NewMockcodecSerializable Uses

func NewMockcodecSerializable(ctrl *gomock.Controller) *MockcodecSerializable

NewMockcodecSerializable creates a new mock instance

func (*MockcodecSerializable) EXPECT Uses

func (m *MockcodecSerializable) EXPECT() *MockcodecSerializableMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

func (*MockcodecSerializable) Init Uses

func (m *MockcodecSerializable) Init(adapter Adapter) error

Init mocks base method

func (*MockcodecSerializable) Prepare Uses

func (m *MockcodecSerializable) Prepare() error

Prepare mocks base method

type MockcodecSerializableMockRecorder Uses

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

MockcodecSerializableMockRecorder is the mock recorder for MockcodecSerializable

func (*MockcodecSerializableMockRecorder) Init Uses

func (mr *MockcodecSerializableMockRecorder) Init(adapter interface{}) *gomock.Call

Init indicates an expected call of Init

func (*MockcodecSerializableMockRecorder) Prepare Uses

func (mr *MockcodecSerializableMockRecorder) Prepare() *gomock.Call

Prepare indicates an expected call of Prepare

type Node Uses

type Node struct {
    Name string `json:"name"`
    Addr string `json:"addr"`
}

Node is prophet info

type Operator Uses

type Operator interface {
    ResourceID() uint64
    ResourceKind() ResourceKind
    Do(target *ResourceRuntime) (*resourceHeartbeatRsp, bool)
}

Operator is an interface to scheduler resource

type Option Uses

type Option func(*options)

Option is prophet create option

func ParseProphetOptions Uses

func ParseProphetOptions(name string) []Option

ParseProphetOptions parse the prophet options from command line parameter

func ParseProphetOptionsWithPath Uses

func ParseProphetOptionsWithPath(name, path string) []Option

ParseProphetOptionsWithPath parse the prophet options from command line parameter, using spec data path for embed etcd server

func WithCountResourceReplicas Uses

func WithCountResourceReplicas(value int) Option

WithCountResourceReplicas replica number per resource

func WithEmbeddedEtcd Uses

func WithEmbeddedEtcd(cfg *EmbeddedEtcdCfg) Option

WithEmbeddedEtcd using embedded etcd cluster

func WithExternalEtcd Uses

func WithExternalEtcd(client *clientv3.Client) Option

WithExternalEtcd using external etcd cluster

func WithLeaseTTL Uses

func WithLeaseTTL(leaseTTL int64) Option

WithLeaseTTL prophet leader lease ttl

func WithLocationLabels Uses

func WithLocationLabels(value []string) Option

WithLocationLabels the label used for location

func WithMaxAllowContainerDownDuration Uses

func WithMaxAllowContainerDownDuration(value time.Duration) Option

WithMaxAllowContainerDownDuration maximum down time of removed from replicas

func WithMaxFreezeScheduleInterval Uses

func WithMaxFreezeScheduleInterval(value time.Duration) Option

WithMaxFreezeScheduleInterval freeze the container for a while if shouldSchedule is returns false

func WithMaxLimitSnapshotsCount Uses

func WithMaxLimitSnapshotsCount(value uint64) Option

WithMaxLimitSnapshotsCount maximum count of node about snapshot

func WithMaxRPCConnIdle Uses

func WithMaxRPCConnIdle(value time.Duration) Option

WithMaxRPCConnIdle set MaxRPCConnIdle

func WithMaxRPCCons Uses

func WithMaxRPCCons(value int) Option

WithMaxRPCCons set MaxRPCCons

func WithMaxRPCTimeout Uses

func WithMaxRPCTimeout(value time.Duration) Option

WithMaxRPCTimeout set MaxRPCTimeout

func WithMaxRebalanceLeader Uses

func WithMaxRebalanceLeader(value uint64) Option

WithMaxRebalanceLeader maximum count of transfer leader operator

func WithMaxRebalanceReplica Uses

func WithMaxRebalanceReplica(value uint64) Option

WithMaxRebalanceReplica maximum count of remove|add replica operator

func WithMaxScheduleInterval Uses

func WithMaxScheduleInterval(value time.Duration) Option

WithMaxScheduleInterval using MaxScheduleInterval maximum schedule interval per scheduler

func WithMaxScheduleReplica Uses

func WithMaxScheduleReplica(value uint64) Option

WithMaxScheduleReplica maximum count of schedule replica operator

func WithMaxScheduleRetries Uses

func WithMaxScheduleRetries(value int) Option

WithMaxScheduleRetries using MaxScheduleRetries maximum retry times for schedule

func WithMinAvailableStorageUsedRate Uses

func WithMinAvailableStorageUsedRate(value int) Option

WithMinAvailableStorageUsedRate minimum storage used rate of container, if the rate is over this value, skip the container

func WithMinScheduleInterval Uses

func WithMinScheduleInterval(value time.Duration) Option

WithMinScheduleInterval using MinScheduleInterval minimum schedule interval per scheduler

func WithRPCAddr Uses

func WithRPCAddr(value string) Option

WithRPCAddr set rpc address

func WithRoleChangeHandler Uses

func WithRoleChangeHandler(Handler RoleChangeHandler) Option

WithRoleChangeHandler using a role changed handler

func WithScaleOnNewStore Uses

func WithScaleOnNewStore() Option

WithScaleOnNewStore set EnableScaleOnNewStore

func WithScheduler Uses

func WithScheduler(value Scheduler) Option

WithScheduler add a scheduler

func WithTimeoutWaitOperatorComplete Uses

func WithTimeoutWaitOperatorComplete(value time.Duration) Option

WithTimeoutWaitOperatorComplete timeout for waitting teh operator complete

type Pair Uses

type Pair struct {
    Key   string `json:"key"`
    Value string `json:"value"`
}

Pair key value pair

type Peer Uses

type Peer struct {
    ID          uint64 `json:"id"`
    ContainerID uint64 `json:"cid"`
}

Peer is the resource peer

func FindPeer Uses

func FindPeer(peers []*Peer, containerID uint64) (Peer, bool)

FindPeer find peer at the spec container

func (*Peer) Clone Uses

func (p *Peer) Clone() *Peer

Clone returns a clone value

type PeerReplica Uses

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

PeerReplica is the Resource peer replicatation. Every Resource has N replicatation in N stores.

func CreatePeerReplica Uses

func CreatePeerReplica(store ResourceStore, meta Resource, handler PeerReplicaHandler, elector Elector) (*PeerReplica, error)

CreatePeerReplica create a resource replica at current container

func NewPeerReplica Uses

func NewPeerReplica(store ResourceStore, meta Resource, peer Peer, handler PeerReplicaHandler, elector Elector) *PeerReplica

NewPeerReplica create a resource replica at current container

func (*PeerReplica) AddPeer Uses

func (pr *PeerReplica) AddPeer(peer Peer)

AddPeer add a peer to this resource

func (*PeerReplica) ChangeLeaderTo Uses

func (pr *PeerReplica) ChangeLeaderTo(leader uint64, cb func(interface{}, error))

ChangeLeaderTo change leader to new leader

func (*PeerReplica) CollectDownPeers Uses

func (pr *PeerReplica) CollectDownPeers(maxDuration time.Duration) []*PeerStats

CollectDownPeers returns the down peers

func (*PeerReplica) CollectPendingPeers Uses

func (pr *PeerReplica) CollectPendingPeers() []*Peer

CollectPendingPeers returns the pending peers

func (*PeerReplica) Destroy Uses

func (pr *PeerReplica) Destroy()

Destroy destory the resource replica from current container

func (*PeerReplica) Do Uses

func (pr *PeerReplica) Do(doFunc func(error), timeout time.Duration)

Do do something async

func (*PeerReplica) Heartbeat Uses

func (pr *PeerReplica) Heartbeat()

Heartbeat send the hb to other peers

func (*PeerReplica) IsLeader Uses

func (pr *PeerReplica) IsLeader() bool

IsLeader returns the peer replica is the leader

func (*PeerReplica) Peer Uses

func (pr *PeerReplica) Peer() *Peer

Peer returns the current peer of this resource

func (*PeerReplica) RemovePeer Uses

func (pr *PeerReplica) RemovePeer(peer Peer)

RemovePeer remove peer

func (*PeerReplica) Resource Uses

func (pr *PeerReplica) Resource() Resource

Resource returns the meta

func (*PeerReplica) Scale Uses

func (pr *PeerReplica) Scale(data interface{})

Scale scale this pr

func (*PeerReplica) Tag Uses

func (pr *PeerReplica) Tag() string

Tag returns the pr tag

type PeerReplicaHandler Uses

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 PeerStats Uses

type PeerStats struct {
    Peer        *Peer
    DownSeconds uint64
}

PeerStats peer stats

func (*PeerStats) Clone Uses

func (ps *PeerStats) Clone() *PeerStats

Clone returns a clone value

type Prophet Uses

type Prophet interface {
    // Start start the prophet instance, this will start the lead election, heartbeat loop and listen requests
    Start()
    // Stop stop the prophet instance
    Stop()
    // 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

func NewProphet Uses

func NewProphet(name string, adapter Adapter, opts ...Option) Prophet

NewProphet returns a prophet instance

type Queue Uses

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

Queue is the struct responsible for tracking the state of the queue.

func New Uses

func New(hint int64) *Queue

New is a constructor for a new threadsafe queue.

func (*Queue) Dispose Uses

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 Uses

func (q *Queue) Disposed() bool

Disposed returns a bool indicating if this queue has had disposed called on it.

func (*Queue) Empty Uses

func (q *Queue) Empty() bool

Empty returns a bool indicating if this bool is empty.

func (*Queue) Get Uses

func (q *Queue) Get(number int64, items []interface{}) (int64, error)

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) Len Uses

func (q *Queue) Len() int64

Len returns the number of items in this queue.

func (*Queue) Peek Uses

func (q *Queue) Peek() (interface{}, error)

Peek returns a the first item in the queue by value without modifying the queue.

func (*Queue) Poll Uses

func (q *Queue) Poll(number int64, items []interface{}, timeout time.Duration) (int64, error)

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) Put Uses

func (q *Queue) Put(items ...interface{}) error

Put will add the specified items to the queue.

func (*Queue) PutOrUpdate Uses

func (q *Queue) PutOrUpdate(cmp func(interface{}, interface{}) bool, item interface{}) error

PutOrUpdate will add the specified item to the queue, update it if exists

type RPC Uses

type RPC interface {
    TiggerContainerHeartbeat()
    TiggerResourceHeartbeat(id uint64)
    AllocID() (uint64, error)
    AskSplit(res Resource) (uint64, []uint64, error)
}

RPC prophet rpc

type ReplicaTransport Uses

type ReplicaTransport interface {
    Start()
    Stop()

    Send(uint64, interface{})
}

ReplicaTransport transport from peers

func NewReplicaTransport Uses

func NewReplicaTransport(addr string, store ResourceStore, factory func() Resource) ReplicaTransport

NewReplicaTransport returns a replica transport to send and received message

type Resource Uses

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 Uses

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 Uses

func (req *ResourceHeartbeatReq) Init(adapter Adapter) error

Init init

func (*ResourceHeartbeatReq) Prepare Uses

func (req *ResourceHeartbeatReq) Prepare() error

Prepare prepare

type ResourceKind Uses

type ResourceKind int

ResourceKind distinguishes different kinds of resources.

const (
    // LeaderKind leader
    LeaderKind ResourceKind = iota
    // ReplicaKind replication of resource
    ReplicaKind
)

type ResourceRuntime Uses

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

ResourceRuntime resource runtime info

func (*ResourceRuntime) Clone Uses

func (res *ResourceRuntime) Clone() *ResourceRuntime

Clone returns a clone resource runtime

func (*ResourceRuntime) GetContainerIDs Uses

func (res *ResourceRuntime) GetContainerIDs() map[uint64]struct{}

GetContainerIDs returns all container id

func (*ResourceRuntime) GetContainerPeer Uses

func (res *ResourceRuntime) GetContainerPeer(containerID uint64) *Peer

GetContainerPeer returns the peer in the container

func (*ResourceRuntime) GetPeer Uses

func (res *ResourceRuntime) GetPeer(peerID uint64) *Peer

GetPeer return the peer

func (*ResourceRuntime) GetPendingPeer Uses

func (res *ResourceRuntime) GetPendingPeer(peerID uint64) *Peer

GetPendingPeer returns pending peer

func (*ResourceRuntime) RemoveContainerPeer Uses

func (res *ResourceRuntime) RemoveContainerPeer(id uint64)

RemoveContainerPeer remove container peer

type ResourceStore Uses

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 Uses

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 Uses

type RoleChangeHandler interface {
    ProphetBecomeLeader()
    ProphetBecomeFollower()
}

RoleChangeHandler prophet role change handler

type Runner Uses

type Runner struct {
    sync.RWMutex
    // contains filtered or unexported fields
}

Runner TODO

func NewRunner Uses

func NewRunner() *Runner

NewRunner returns a task runner

func (*Runner) AddNamedWorker Uses

func (s *Runner) AddNamedWorker(name string) (uint64, error)

AddNamedWorker add a named worker, the named worker has uniq queue, so jobs are linear execution

func (*Runner) IsNamedWorkerBusy Uses

func (s *Runner) IsNamedWorkerBusy(worker string) bool

IsNamedWorkerBusy returns true if named queue is not empty

func (*Runner) RunCancelableTask Uses

func (s *Runner) RunCancelableTask(task func(context.Context)) (uint64, error)

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) RunJob Uses

func (s *Runner) RunJob(desc string, task func() error) error

RunJob run a job

func (*Runner) RunJobWithNamedWorker Uses

func (s *Runner) RunJobWithNamedWorker(desc, worker string, task func() error) error

RunJobWithNamedWorker run a job in a named worker

func (*Runner) RunJobWithNamedWorkerWithCB Uses

func (s *Runner) RunJobWithNamedWorkerWithCB(desc, worker string, task func() error, cb func(*Job)) error

RunJobWithNamedWorkerWithCB run a job in a named worker

func (*Runner) RunTask Uses

func (s *Runner) RunTask(task func()) error

RunTask runs a task in new goroutine

func (*Runner) Stop Uses

func (s *Runner) Stop() error

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 Uses

func (s *Runner) StopCancelableTask(id uint64) error

StopCancelableTask stop cancelable spec task

type Runtime Uses

type Runtime struct {
    sync.RWMutex
    // contains filtered or unexported fields
}

Runtime runtime info

func (*Runtime) Container Uses

func (rc *Runtime) Container(id uint64) *ContainerRuntime

Container returns a cloned value of container runtime info

func (*Runtime) Containers Uses

func (rc *Runtime) Containers() []*ContainerRuntime

Containers returns the containers, using clone

func (*Runtime) RandFollowerResource Uses

func (rc *Runtime) RandFollowerResource(id uint64) *ResourceRuntime

RandFollowerResource returns the random follower resource

func (*Runtime) RandLeaderResource Uses

func (rc *Runtime) RandLeaderResource(id uint64) *ResourceRuntime

RandLeaderResource returns the random leader resource

func (*Runtime) Resource Uses

func (rc *Runtime) Resource(id uint64) *ResourceRuntime

Resource returns a cloned value of resource runtime info

func (*Runtime) ResourceContainers Uses

func (rc *Runtime) ResourceContainers(target *ResourceRuntime) []*ContainerRuntime

ResourceContainers returns containers that has the resource's peer

func (*Runtime) ResourceFollowerContainers Uses

func (rc *Runtime) ResourceFollowerContainers(res *ResourceRuntime) []*ContainerRuntime

ResourceFollowerContainers returns all containers for peers exclude leader

func (*Runtime) Resources Uses

func (rc *Runtime) Resources() []*ResourceRuntime

Resources returns the resources, using clone

type Scheduler Uses

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 Uses

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 Serializable Uses

type Serializable interface {
}

Serializable serializable

type State Uses

type State int

State is the state

const (
    // UP is normal state
    UP  State = iota
    // Down is the unavailable state
    Down
    // Tombstone is the destory state
    Tombstone
)

type Store Uses

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 Uses

type Watcher struct {
    sync.RWMutex
    // contains filtered or unexported fields
}

Watcher watcher client

func NewWatcher Uses

func NewWatcher(addrs ...string) *Watcher

NewWatcher returns a watcher for watch

func NewWatcherWithProphet Uses

func NewWatcherWithProphet(p Prophet) *Watcher

NewWatcherWithProphet returns a watcher for watch

func (*Watcher) Stop Uses

func (w *Watcher) Stop()

Stop stop watch

func (*Watcher) Watch Uses

func (w *Watcher) Watch(flag int) chan *EventNotify

Watch watch event

Package prophet imports 34 packages (graph). Updated 2019-12-11. Refresh now. Tools for package owners.