manager

package
v0.0.0-...-a7402c0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2023 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SlotsCount                     = 16384                      // slot槽位的总数量
	SlotsAllocationFilename        = "slots_allocation"         // 槽位分配存储文件的名字
	SlotsReplicaAllocationFilename = "slots_replica_allocation" // 槽位分配存储文件的名字
	ReplicaNodeIdsFilename         = "replica_node_ids"
	NodeSlotsFilename              = "node_slots" // 槽位分配存储文件的名字
	NodeSlotsReplicasFilename      = "node_slots_replicas"
)
View Source
const (
	DefaultConnectRetries             = 3             // 默认的主动连接的重试次数
	ConnectTimeout                    = 5000          // 连接超时时间
	RetryConnectMasterNodeInterval    = 1 * 60 * 1000 // 重试连接master node的时间间隔
	CheckAllOtherNodesConnectInterval = 10 * 1000     // 检查跟其他所有节点的连接状态的时间间隔
	AllMasterNodeConnectCheckInterval = 100           // 等待所有master节点连接过来的检查间隔
	DefaultRetries                    = 3             // 默认的监听端口号的重试次数
)
View Source
const (
	AutoRebalanceThreshold = 5 * 60
)
View Source
const (
	CandidateReconnectInterval = 60
)

Variables

View Source
var Int32HashCode = func(key int32) uint32 {
	hash := fnv.New32()
	hash.Write([]byte(fmt.Sprintf("%v", key)))
	return hash.Sum32() >> 24
}

Functions

func ConnectAllControllerCandidates

func ConnectAllControllerCandidates() bool

func ConnectBeforeControllerCandidateServers

func ConnectBeforeControllerCandidateServers() bool

func Fatal

func Fatal()

func IsController

func IsController() bool

func IsFatal

func IsFatal() bool

func IsRunning

func IsRunning() bool

func IsShutdown

func IsShutdown() bool

func NewCandidateReconnectAndRun

func NewCandidateReconnectAndRun(candidateNodeId int32, candidateAddress string)

func ReplicationManager

func ReplicationManager()

ReplicationManager Replica copy component

func Running

func Running()

func SetNodeStatus

func SetNodeStatus(status int)

func SetServerNodeRole

func SetServerNodeRole(role int)

func Start

func Start()

func StartClientIO

func StartClientIO()

func StartServerConnectionListener

func StartServerConnectionListener()

Types

type CandidateReconnect

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

CandidateReconnect The candidate node reconnects

type ClientConnection

type ClientConnection struct {
	HasReadMessage bool
	ConnectionId   string
	Conn           net.Conn
}

func NewClientConnection

func NewClientConnection(conn net.Conn) *ClientConnection

type ClientConnectionManager

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

func GetClientConnectionManagerInstance

func GetClientConnectionManagerInstance() *ClientConnectionManager

type ClientMessageQueues

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

func GetClientMessageQueuesInstance

func GetClientMessageQueuesInstance() *ClientMessageQueues

type ClientRequestProcessor

type ClientRequestProcessor struct {
}

type Controller

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

type ControllerCandidate

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

func GetControllerCandidateInstance

func GetControllerCandidateInstance() *ControllerCandidate

type ControllerNode

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

ControllerNode controller where node

func GetControllerNodeInstance

func GetControllerNodeInstance() *ControllerNode

func (*ControllerNode) IsControllerNode

func (c *ControllerNode) IsControllerNode(nodeId int32) bool

func (*ControllerNode) SetControllerNodeId

func (c *ControllerNode) SetControllerNodeId(nodeId int32)

type HighAvailabilityManager

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

HighAvailabilityManager High availability management component Scalable architecture, a controller or candidate crashed, and you added a new node, Check whether it is a controller candidate. If so, it should be automatically added to the controller candidate cluster and the cluster metadata should be automatically synchronized. If it is an ordinary node, then it is automatic to do the data rebalance, automatically do a recalculation of slot data, do a rebalancing.

func GetHighAvailabilityManagerInstance

func GetHighAvailabilityManagerInstance() *HighAvailabilityManager

type IOThreadRunningSignal

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

IOThreadRunningSignal io thread running signal

func (*IOThreadRunningSignal) IsRunning

func (i *IOThreadRunningSignal) IsRunning() bool

func (*IOThreadRunningSignal) SetIsRunning

func (i *IOThreadRunningSignal) SetIsRunning(isRunning bool)

type NodeStatus

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

NodeStatus node status

type RemoteServerNodeManager

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

func GetRemoteServerNodeManagerInstance

func GetRemoteServerNodeManagerInstance() *RemoteServerNodeManager

type ServerConnectionListener

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

type ServerMessageReceiver

type ServerMessageReceiver struct {
	RegisterRequestQueue  queue.Array[pkgrpc.RegisterRequest]
	HeartbeatRequestQueue queue.Array[pkgrpc.HeartbeatRequest]
	// contains filtered or unexported fields
}

ServerMessageReceiver Master node's message receiving component (coroutine) 1.Constantly getting the latest messages from the receiver queue of the network communication component 2.Determine the type of the message and convert the message to an object 3.Push messages to queues corresponding to different business modules 4.Provides interfaces for various business modules to get their own business messages

func GetServerMessageReceiverInstance

func GetServerMessageReceiverInstance() *ServerMessageReceiver

type ServerNetworkManager

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

func GetServerNetworkManagerInstance

func GetServerNetworkManagerInstance() *ServerNetworkManager

type ServerNodeRole

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

ServerNodeRole server node role

type ServiceChangedListener

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

type ServiceInstance

type ServiceInstance struct {
	ServiceName         string `json:"serviceName"`
	ServiceInstanceIp   string `json:"serviceInstanceIp"`
	ServiceInstancePort int32  `json:"serviceInstancePort"`
	LatestHeartbeatTime int64  `json:"latestHeartbeatTime"`
}

func NewHeartbeatToServiceInstance

func NewHeartbeatToServiceInstance(request *pkgrpc.HeartbeatRequest) *ServiceInstance

func NewRegisterToServiceInstance

func NewRegisterToServiceInstance(request *pkgrpc.RegisterRequest) *ServiceInstance

func NewServiceInstance

func NewServiceInstance(serviceName, serviceInstanceIp string, serviceInstancePort int32) *ServiceInstance

func (ServiceInstance) GetAddress

func (s ServiceInstance) GetAddress() string

func (ServiceInstance) String

func (s ServiceInstance) String() string

type ServiceRegistry

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

func NewServiceRegistry

func NewServiceRegistry(isReplica bool) *ServiceRegistry

func (*ServiceRegistry) GetData

func (s *ServiceRegistry) GetData() []byte

func (*ServiceRegistry) GetRegisterService

func (s *ServiceRegistry) GetRegisterService(serviceName string) map[string][]*ServiceInstance

func (*ServiceRegistry) Heartbeat

func (s *ServiceRegistry) Heartbeat(serviceInstance *ServiceInstance)

func (*ServiceRegistry) HeartbeatCheck

func (s *ServiceRegistry) HeartbeatCheck()

func (*ServiceRegistry) IsEmpty

func (s *ServiceRegistry) IsEmpty() bool

func (*ServiceRegistry) Register

func (s *ServiceRegistry) Register(serviceInstance *ServiceInstance)

func (*ServiceRegistry) UpdateData

func (s *ServiceRegistry) UpdateData(serviceInstances []*ServiceInstance)

type Slot

type Slot struct {
	ServiceRegistry *ServiceRegistry
	// contains filtered or unexported fields
}

func NewSlot

func NewSlot(slotNo int32, serviceRegistry *ServiceRegistry) *Slot

type SlotManager

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

func GetSlotManagerInstance

func GetSlotManagerInstance() *SlotManager

func (*SlotManager) GetSlotReplica

func (s *SlotManager) GetSlotReplica(serviceName string) *Slot

GetSlotReplica get slot replica

type Slots

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

func NewSlots

func NewSlots() *Slots

func (*Slots) GetSlot

func (s *Slots) GetSlot(slotNo int32) (*Slot, bool)

func (*Slots) PutSlot

func (s *Slots) PutSlot(slotNo int32, slot *Slot)

func (*Slots) RemoteSlot

func (s *Slots) RemoteSlot(slotNo int32)

type SlotsReplica

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

func NewSlotsReplica

func NewSlotsReplica() *SlotsReplica

Jump to

Keyboard shortcuts

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