prophet

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2021 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrClosed error of client closed
	ErrClosed = errors.New("client is closed")
	// ErrTimeout timeout
	ErrTimeout = errors.New("rpc timeout")
)

Functions

func StartMonitor

func StartMonitor(ctx context.Context, now func() time.Time, systimeErrHandler func())

StartMonitor calls systimeErrHandler if system time jump backward.

Types

type Client

type Client interface {
	Close() error
	AllocID() (uint64, error)
	PutContainer(container metadata.Container) error
	GetContainer(containerID uint64) (metadata.Container, error)
	ResourceHeartbeat(meta metadata.Resource, hb rpcpb.ResourceHeartbeatReq) error
	ContainerHeartbeat(hb rpcpb.ContainerHeartbeatReq) (rpcpb.ContainerHeartbeatRsp, error)
	AskSplit(res metadata.Resource) (rpcpb.SplitID, error)
	ReportSplit(left, right metadata.Resource) error
	AskBatchSplit(res metadata.Resource, count uint32) ([]rpcpb.SplitID, error)
	ReportBatchSplit(results ...metadata.Resource) error
	NewWatcher(flag uint32) (Watcher, error)
	GetResourceHeartbeatRspNotifier() (chan rpcpb.ResourceHeartbeatRsp, error)
	// AsyncAddResources add resources asynchronously. The operation add new resources meta on the
	// prophet leader cache and embed etcd. And porphet leader has a background goroutine to notify
	// all related containers to create resource replica peer at local.
	AsyncAddResources(resources ...metadata.Resource) error
	// AsyncAddResourcesWithLeastPeers same of `AsyncAddResources`, but if the number of peers successfully
	// allocated exceed the `leastPeers`, no error will be returned.
	AsyncAddResourcesWithLeastPeers(resources []metadata.Resource, leastPeers []int) error
	// AsyncRemoveResources remove resource asynchronously. The operation only update the resource state
	// on the prophet leader cache and embed etcd. The resource actual destory triggered in three ways as below:
	// a) Each cube node starts a backgroud goroutine to check all the resources state, and resource will
	//    destoryed if encounter removed state.
	// b) Resource heartbeat received a DestoryDirectly schedule command.
	// c) If received a resource removed event.
	AsyncRemoveResources(ids ...uint64) error
	// CheckResourceState returns resources state
	CheckResourceState(resources *roaring64.Bitmap) (rpcpb.CheckResourceStateRsp, error)

	// PutPlacementRule put placement rule
	PutPlacementRule(rule rpcpb.PlacementRule) error
	// GetAppliedRules returns applied rules of the resource
	GetAppliedRules(id uint64) ([]rpcpb.PlacementRule, error)

	// CreateJob create job
	CreateJob(metapb.Job) error
	// RemoveJob remove job
	RemoveJob(metapb.Job) error
	// ExecuteJob execute on job and returns the execute result
	ExecuteJob(metapb.Job, []byte) ([]byte, error)
}

Client prophet client

func NewClient

func NewClient(adapter metadata.Adapter, opts ...Option) Client

NewClient create a prophet client

type Option

type Option func(*options)

Option client option

func WithLeaderGetter

func WithLeaderGetter(value func() *metapb.Member) Option

WithLeaderGetter set a func to get a leader

func WithRPCTimeout

func WithRPCTimeout(value time.Duration) Option

WithRPCTimeout set rpc timeout

type Prophet

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()
	// GetStorage returns the storage
	GetStorage() storage.Storage
	// GetClient returns the prophet client
	GetClient() Client
	// GetLeader returns leader
	GetLeader() *metapb.Member
	// GetMember returns self
	GetMember() *member.Member
	// GetConfig returns cfg
	GetConfig() *config.Config
	// GetClusterID return cluster id
	GetClusterID() uint64
	// GetBasicCluster returns basic cluster
	GetBasicCluster() *core.BasicCluster
}

Prophet is the distributed scheduler and coordinator

func NewProphet

func NewProphet(cfg *config.Config) Prophet

NewProphet returns a prophet instance

type Watcher

type Watcher interface {
	// GetNotify returns event notify channel
	GetNotify() chan rpcpb.EventNotify
	// Close close watcher
	Close()
}

Watcher watcher

Jump to

Keyboard shortcuts

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