Skip to content
Snippets Groups Projects
Commit e76b242a authored by cvictory's avatar cvictory
Browse files

Fix : when there is no invoker is available for network reason, it is the same...

Fix : when there is no invoker is available for network reason, it is the same as "No Provider Available."
parent 1024e7ae
Branches
Tags
No related merge requests found
...@@ -31,6 +31,7 @@ import ( ...@@ -31,6 +31,7 @@ import (
"github.com/apache/dubbo-go/common" "github.com/apache/dubbo-go/common"
"github.com/apache/dubbo-go/common/constant" "github.com/apache/dubbo-go/common/constant"
"github.com/apache/dubbo-go/common/extension" "github.com/apache/dubbo-go/common/extension"
"github.com/apache/dubbo-go/common/logger"
"github.com/apache/dubbo-go/protocol" "github.com/apache/dubbo-go/protocol"
) )
...@@ -119,6 +120,10 @@ func (invoker *baseClusterInvoker) doSelect(lb cluster.LoadBalance, invocation p ...@@ -119,6 +120,10 @@ func (invoker *baseClusterInvoker) doSelect(lb cluster.LoadBalance, invocation p
} }
func (invoker *baseClusterInvoker) doSelectInvoker(lb cluster.LoadBalance, invocation protocol.Invocation, invokers []protocol.Invoker, invoked []protocol.Invoker) protocol.Invoker { func (invoker *baseClusterInvoker) doSelectInvoker(lb cluster.LoadBalance, invocation protocol.Invocation, invokers []protocol.Invoker, invoked []protocol.Invoker) protocol.Invoker {
if len(invokers) == 0 {
logger.Errorf("the invokers of %s is nil. ", invocation.Invoker().GetUrl().ServiceKey())
return nil
}
if len(invokers) == 1 { if len(invokers) == 1 {
return invokers[0] return invokers[0]
} }
...@@ -133,6 +138,8 @@ func (invoker *baseClusterInvoker) doSelectInvoker(lb cluster.LoadBalance, invoc ...@@ -133,6 +138,8 @@ func (invoker *baseClusterInvoker) doSelectInvoker(lb cluster.LoadBalance, invoc
for _, invoker := range invokers { for _, invoker := range invokers {
if !invoker.IsAvailable() { if !invoker.IsAvailable() {
logger.Infof("the invoker of %s is not available, maybe some network error happened or the server is shutdown.",
invoker.GetUrl().Ip)
continue continue
} }
...@@ -144,6 +151,7 @@ func (invoker *baseClusterInvoker) doSelectInvoker(lb cluster.LoadBalance, invoc ...@@ -144,6 +151,7 @@ func (invoker *baseClusterInvoker) doSelectInvoker(lb cluster.LoadBalance, invoc
if len(reslectInvokers) > 0 { if len(reslectInvokers) > 0 {
selectedInvoker = lb.Select(reslectInvokers, invocation) selectedInvoker = lb.Select(reslectInvokers, invocation)
} else { } else {
logger.Errorf("all %d invokers is unavailable for %s.", len(invokers), selectedInvoker.GetUrl().String())
return nil return nil
} }
} }
......
...@@ -51,6 +51,7 @@ func (invoker *failoverClusterInvoker) Invoke(ctx context.Context, invocation pr ...@@ -51,6 +51,7 @@ func (invoker *failoverClusterInvoker) Invoke(ctx context.Context, invocation pr
result protocol.Result result protocol.Result
invoked []protocol.Invoker invoked []protocol.Invoker
providers []string providers []string
ivk protocol.Invoker
) )
invokers := invoker.directory.List(invocation) invokers := invoker.directory.List(invocation)
...@@ -75,7 +76,7 @@ func (invoker *failoverClusterInvoker) Invoke(ctx context.Context, invocation pr ...@@ -75,7 +76,7 @@ func (invoker *failoverClusterInvoker) Invoke(ctx context.Context, invocation pr
return &protocol.RPCResult{Err: err} return &protocol.RPCResult{Err: err}
} }
} }
ivk := invoker.doSelect(loadBalance, invocation, invokers, invoked) ivk = invoker.doSelect(loadBalance, invocation, invokers, invoked)
if ivk == nil { if ivk == nil {
continue continue
} }
...@@ -88,10 +89,17 @@ func (invoker *failoverClusterInvoker) Invoke(ctx context.Context, invocation pr ...@@ -88,10 +89,17 @@ func (invoker *failoverClusterInvoker) Invoke(ctx context.Context, invocation pr
} }
return result return result
} }
ip := common.GetLocalIp() ip := common.GetLocalIp()
invokerSvc := invoker.GetUrl().Service() invokerSvc := invoker.GetUrl().Service()
invokerUrl := invoker.directory.GetUrl() invokerUrl := invoker.directory.GetUrl()
if ivk == nil {
logger.Errorf("Failed to invoke the method %s of the service %s .No provider is available.", methodName, invokerSvc)
return &protocol.RPCResult{
Err: perrors.Errorf("Failed to invoke the method %s of the service %s .No provider is available because can't connect server.",
methodName, invokerSvc),
}
}
return &protocol.RPCResult{ return &protocol.RPCResult{
Err: perrors.Wrap(result.Error(), fmt.Sprintf("Failed to invoke the method %v in the service %v. "+ Err: perrors.Wrap(result.Error(), fmt.Sprintf("Failed to invoke the method %v in the service %v. "+
"Tried %v times of the providers %v (%v/%v)from the registry %v on the consumer %v using the dubbo version %v. "+ "Tried %v times of the providers %v (%v/%v)from the registry %v on the consumer %v using the dubbo version %v. "+
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment