优化服务发现

This commit is contained in:
boyce
2021-05-06 16:09:27 +08:00
parent 1007845e95
commit bbab004f65
5 changed files with 10 additions and 9 deletions

View File

@@ -175,6 +175,7 @@ func (cls *Cluster) serviceDiscoverySetNodeInfo (nodeInfo *NodeInfo){
}
cls.mapIdNode[nodeInfo.NodeId] = *nodeInfo
log.Debug("Discovery nodeId: %d discovery service:%+v",nodeInfo.NodeId,nodeInfo.PublicServiceList)
//已经存在连接,则不需要进行设置
if _,rpcInfoOK := cls.mapRpc[nodeInfo.NodeId];rpcInfoOK == true {
return
@@ -186,9 +187,7 @@ func (cls *Cluster) serviceDiscoverySetNodeInfo (nodeInfo *NodeInfo){
rpcInfo.client.Connect(nodeInfo.NodeId,nodeInfo.ListenAddr)
cls.mapRpc[nodeInfo.NodeId] = rpcInfo
//debug
fmt.Printf("xxxxxxxxxxxx")
fmt.Println(nodeInfo)
}
func (cls *Cluster) buildLocalRpc(){

View File

@@ -233,7 +233,7 @@ func (processor *EventProcessor) EventHandler(ev IEvent) {
func (processor *EventProcessor) pushEvent(event IEvent){
if len(processor.eventChannel)>=cap(processor.eventChannel){
log.Error("event process channel is full.")
log.Error("event process channel is full,data:%+v!",event)
return
}

View File

@@ -232,12 +232,12 @@ func startNode(args interface{}) error{
//2.初始化node
initNode(nodeId)
//3.运行集群
cluster.GetCluster().Start()
//4.运行service
//3.运行service
service.Start()
//4.运行集群
cluster.GetCluster().Start()
//5.记录进程id号
writeProcessPid(nodeId)

View File

@@ -112,7 +112,7 @@ func (agent *RpcAgent) Run() {
for {
data,err := agent.conn.ReadMsg()
if err != nil {
log.Error("read message: %v", err)
log.Error("read message: %v,remoteAddress:%s", err,agent.conn.RemoteAddr().String())
//will close tcpconn
break
}

View File

@@ -98,6 +98,8 @@ func (s *Service) SetGoRoutineNum(goroutineNum int32) bool {
func (s *Service) Start() {
s.startStatus = true
s.eventProcessor.SetEventChannel(0)
for i:=int32(0);i< s.goroutineNum;i++{
s.wg.Add(1)
go func(){