cluster

package
v0.0.0-...-25da3cc Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinQueryResourceInterval = 60
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cluster

type Cluster struct {
	ClusterId    string
	Registry     *registry.Registry
	LeaderKey    string
	LeaderServer string

	Nodes map[string]*core.NodeInfo

	ExecutorInfos map[string]*core.ExecutorInfo

	Scheduler scheduler.Scheduler

	OnNodesChange        WatchChangeHandle
	OnNodeOffline        NodeOfflineHandle
	OnLeaderChange       WatchChangeHandle
	OnLeaderChangeFailed WatchFailedHandle
	// contains filtered or unexported fields
}

func NewCluster

func NewCluster(profile *config.Profile, registry *registry.Registry) *Cluster

NewCluster new cluster and reg server

func (*Cluster) AddExecutor

func (c *Cluster) AddExecutor(execInfo *core.ExecutorInfo) *core.Result

AddExecutor add executor info into executor list

func (*Cluster) AddNodeInfo

func (c *Cluster) AddNodeInfo(nodeInfo *core.NodeInfo) *core.Result

AddNodeInfo add node into node list it will query remote resource

func (*Cluster) ClusterInfo

func (c *Cluster) ClusterInfo() *core.ClusterInfo

ClusterInfo return ClusterInfo

func (*Cluster) ElectionLeader

func (c *Cluster) ElectionLeader(leaderServer string) error

electionLeader election leader role to registry server

func (*Cluster) FindExecutor

func (c *Cluster) FindExecutor(taskId string) (*core.ExecutorInfo, bool)

FindExecutor find executor info by task id

func (*Cluster) FindNode

func (c *Cluster) FindNode(endPoint string) (*core.NodeInfo, bool)

FindNode find node info by endpoint

func (*Cluster) GetLeaderInfo

func (c *Cluster) GetLeaderInfo() (string, error)

GetLeaderInfo get leader info from leader key must check is locked by leader session leader changed by watchLeaderChange

func (*Cluster) GetLeaderRpcClient

func (c *Cluster) GetLeaderRpcClient() *client.RpcClient

GetLeaderRpcClient get leader rpc client

func (*Cluster) GetLowBalanceWorker

func (c *Cluster) GetLowBalanceWorker() (*core.NodeInfo, error)

GetLowBalanceWorker get lower balance worker, if not match, it will try 3 times

func (*Cluster) GetRpcClient

func (c *Cluster) GetRpcClient(endPoint string) *client.RpcClient

GetRpcClient get rpc client with endpoint

func (*Cluster) QueryNodeResource

func (c *Cluster) QueryNodeResource(endPoint string) (*core.ResourceInfo, *core.Result)

QueryNodeResource query node resource by endpoint

func (*Cluster) RemoveRpcClient

func (c *Cluster) RemoveRpcClient(endPoint string)

RemoveRpcClient remove rpc client with endpoint

func (*Cluster) Start

func (c *Cluster) Start() error

func (*Cluster) Stop

func (c *Cluster) Stop() error

type NodeOfflineHandle

type NodeOfflineHandle func(info *core.NodeInfo)

type WatchChangeHandle

type WatchChangeHandle func()

type WatchFailedHandle

type WatchFailedHandle func()

Jump to

Keyboard shortcuts

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