Documentation ¶
Index ¶
- Constants
- Variables
- func ConnectAllControllerCandidates() bool
- func ConnectBeforeControllerCandidateServers() bool
- func Fatal()
- func IsController() bool
- func IsFatal() bool
- func IsRunning() bool
- func IsShutdown() bool
- func NewCandidateReconnectAndRun(candidateNodeId int32, candidateAddress string)
- func ReplicationManager()
- func Running()
- func SetNodeStatus(status int)
- func SetServerNodeRole(role int)
- func Start()
- func StartClientIO()
- func StartServerConnectionListener()
- type CandidateReconnect
- type ClientConnection
- type ClientConnectionManager
- type ClientMessageQueues
- type ClientRequestProcessor
- type Controller
- type ControllerCandidate
- type ControllerNode
- type HighAvailabilityManager
- type IOThreadRunningSignal
- type NodeStatus
- type RemoteServerNodeManager
- type ServerConnectionListener
- type ServerMessageReceiver
- type ServerNetworkManager
- type ServerNodeRole
- type ServiceChangedListener
- type ServiceInstance
- type ServiceRegistry
- func (s *ServiceRegistry) GetData() []byte
- func (s *ServiceRegistry) GetRegisterService(serviceName string) map[string][]*ServiceInstance
- func (s *ServiceRegistry) Heartbeat(serviceInstance *ServiceInstance)
- func (s *ServiceRegistry) HeartbeatCheck()
- func (s *ServiceRegistry) IsEmpty() bool
- func (s *ServiceRegistry) Register(serviceInstance *ServiceInstance)
- func (s *ServiceRegistry) UpdateData(serviceInstances []*ServiceInstance)
- type Slot
- type SlotManager
- type Slots
- type SlotsReplica
Constants ¶
const ( SlotsCount = 16384 // slot槽位的总数量 SlotsAllocationFilename = "slots_allocation" // 槽位分配存储文件的名字 SlotsReplicaAllocationFilename = "slots_replica_allocation" // 槽位分配存储文件的名字 ReplicaNodeIdsFilename = "replica_node_ids" NodeSlotsFilename = "node_slots" // 槽位分配存储文件的名字 NodeSlotsReplicasFilename = "node_slots_replicas" )
const ( DefaultConnectRetries = 3 // 默认的主动连接的重试次数 ConnectTimeout = 5000 // 连接超时时间 RetryConnectMasterNodeInterval = 1 * 60 * 1000 // 重试连接master node的时间间隔 CheckAllOtherNodesConnectInterval = 10 * 1000 // 检查跟其他所有节点的连接状态的时间间隔 AllMasterNodeConnectCheckInterval = 100 // 等待所有master节点连接过来的检查间隔 DefaultRetries = 3 // 默认的监听端口号的重试次数 )
const (
AutoRebalanceThreshold = 5 * 60
)
const (
CandidateReconnectInterval = 60
)
Variables ¶
Functions ¶
func ConnectAllControllerCandidates ¶
func ConnectAllControllerCandidates() bool
func ConnectBeforeControllerCandidateServers ¶
func ConnectBeforeControllerCandidateServers() bool
func IsController ¶
func IsController() bool
func IsShutdown ¶
func IsShutdown() bool
func SetNodeStatus ¶
func SetNodeStatus(status int)
func SetServerNodeRole ¶
func SetServerNodeRole(role int)
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 ¶
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 ControllerCandidate ¶
type ControllerCandidate struct {
// contains filtered or unexported fields
}
func GetControllerCandidateInstance ¶
func GetControllerCandidateInstance() *ControllerCandidate
type ControllerNode ¶
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 ¶
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 ¶
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 (*Slots) RemoteSlot ¶
type SlotsReplica ¶
type SlotsReplica struct {
// contains filtered or unexported fields
}
func NewSlotsReplica ¶
func NewSlotsReplica() *SlotsReplica