From 0893d830ebd8ab931a5382e805be2f85c70571f7 Mon Sep 17 00:00:00 2001 From: "vito.he" Date: Fri, 6 Sep 2019 23:03:46 +0800 Subject: [PATCH 1/5] Fix:failoverbug and reties change to string type --- .gitignore | 6 ++++++ .../cluster_impl/failback_cluster_invoker.go | 11 ++++++---- .../cluster_impl/failover_cluster_invoker.go | 13 ++++++++---- cluster/cluster_impl/failover_cluster_test.go | 8 ++++---- common/constant/default.go | 16 ++++++++------- config/base_config_test.go | 20 +++++++++---------- config/method_config.go | 2 +- config/reference_config.go | 6 +++--- config/reference_config_test.go | 6 +++--- config/service_config.go | 6 +++--- config/service_config_test.go | 6 +++--- 11 files changed, 58 insertions(+), 42 deletions(-) diff --git a/.gitignore b/.gitignore index 1e651f122b..b76e94a1d6 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ *.dll *.so *.dylib +*.jar # Test binary, build with `go test -c` *.test @@ -24,3 +25,8 @@ coverage.txt logs/ .vscode/ coverage.txt + +# unit test +remoting/zookeeper/zookeeper-4unittest/ +config_center/zookeeper/zookeeper-4unittest/ +registry/zookeeper/zookeeper-4unittest/ \ No newline at end of file diff --git a/cluster/cluster_impl/failback_cluster_invoker.go b/cluster/cluster_impl/failback_cluster_invoker.go index 027461ccb7..889b168791 100644 --- a/cluster/cluster_impl/failback_cluster_invoker.go +++ b/cluster/cluster_impl/failback_cluster_invoker.go @@ -18,6 +18,7 @@ package cluster_impl import ( + "strconv" "sync" "time" ) @@ -54,15 +55,17 @@ func newFailbackClusterInvoker(directory cluster.Directory) protocol.Invoker { invoker := &failbackClusterInvoker{ baseClusterInvoker: newBaseClusterInvoker(directory), } - retriesConfig := invoker.GetUrl().GetParamInt(constant.RETRIES_KEY, constant.DEFAULT_FAILBACK_TIMES) - if retriesConfig <= 0 { - retriesConfig = constant.DEFAULT_FAILBACK_TIMES + retriesConfig := invoker.GetUrl().GetParam(constant.RETRIES_KEY, constant.DEFAULT_FAILBACK_TIMES) + retries, err := strconv.Atoi(retriesConfig) + if err != nil || retries < 0 { + retries = constant.DEFAULT_FAILBACK_TIMES_INT } + failbackTasksConfig := invoker.GetUrl().GetParamInt(constant.FAIL_BACK_TASKS_KEY, constant.DEFAULT_FAILBACK_TASKS) if failbackTasksConfig <= 0 { failbackTasksConfig = constant.DEFAULT_FAILBACK_TASKS } - invoker.maxRetries = retriesConfig + invoker.maxRetries = int64(retries) invoker.failbackTasks = failbackTasksConfig return invoker } diff --git a/cluster/cluster_impl/failover_cluster_invoker.go b/cluster/cluster_impl/failover_cluster_invoker.go index 3dd8c41dfb..c6a712a469 100644 --- a/cluster/cluster_impl/failover_cluster_invoker.go +++ b/cluster/cluster_impl/failover_cluster_invoker.go @@ -19,6 +19,7 @@ package cluster_impl import ( perrors "github.com/pkg/errors" + "strconv" ) import ( @@ -53,16 +54,20 @@ func (invoker *failoverClusterInvoker) Invoke(invocation protocol.Invocation) pr url := invokers[0].GetUrl() //get reties - retries := url.GetParamInt(constant.RETRIES_KEY, constant.DEFAULT_RETRIES) + retriesConfig := url.GetParam(constant.RETRIES_KEY, constant.DEFAULT_RETRIES) //Get the service method loadbalance config if have - if v := url.GetMethodParamInt(methodName, constant.RETRIES_KEY, 0); v != 0 { - retries = v + if v := url.GetMethodParam(methodName, constant.RETRIES_KEY, ""); len(v) != 0 { + retriesConfig = v + } + retries, err := strconv.Atoi(retriesConfig) + if err != nil || retries < 0 { + retries = constant.DEFAULT_RETRIES_INT } invoked := []protocol.Invoker{} providers := []string{} var result protocol.Result - for i := int64(0); i < retries; i++ { + for i := 0; i <= retries; i++ { //Reselect before retry to avoid a change of candidate `invokers`. //NOTE: if `invokers` changed, then `invoked` also lose accuracy. if i > 0 { diff --git a/cluster/cluster_impl/failover_cluster_test.go b/cluster/cluster_impl/failover_cluster_test.go index dc039db8de..78b799320d 100644 --- a/cluster/cluster_impl/failover_cluster_test.go +++ b/cluster/cluster_impl/failover_cluster_test.go @@ -118,14 +118,14 @@ func normalInvoke(t *testing.T, successCount int, urlParam url.Values, invocatio } func Test_FailoverInvokeSuccess(t *testing.T) { urlParams := url.Values{} - result := normalInvoke(t, 2, urlParams) + result := normalInvoke(t, 3, urlParams) assert.NoError(t, result.Error()) count = 0 } func Test_FailoverInvokeFail(t *testing.T) { urlParams := url.Values{} - result := normalInvoke(t, 3, urlParams) + result := normalInvoke(t, 4, urlParams) assert.Errorf(t, result.Error(), "error") count = 0 } @@ -133,7 +133,7 @@ func Test_FailoverInvokeFail(t *testing.T) { func Test_FailoverInvoke1(t *testing.T) { urlParams := url.Values{} urlParams.Set(constant.RETRIES_KEY, "3") - result := normalInvoke(t, 3, urlParams) + result := normalInvoke(t, 4, urlParams) assert.NoError(t, result.Error()) count = 0 } @@ -144,7 +144,7 @@ func Test_FailoverInvoke2(t *testing.T) { urlParams.Set("methods.test."+constant.RETRIES_KEY, "3") ivc := invocation.NewRPCInvocationWithOptions(invocation.WithMethodName("test")) - result := normalInvoke(t, 3, urlParams, ivc) + result := normalInvoke(t, 4, urlParams, ivc) assert.NoError(t, result.Error()) count = 0 } diff --git a/common/constant/default.go b/common/constant/default.go index d103c6aadc..541ed1d330 100644 --- a/common/constant/default.go +++ b/common/constant/default.go @@ -26,13 +26,15 @@ const ( ) const ( - DEFAULT_LOADBALANCE = "random" - DEFAULT_RETRIES = 2 - DEFAULT_PROTOCOL = "dubbo" - DEFAULT_REG_TIMEOUT = "10s" - DEFAULT_CLUSTER = "failover" - DEFAULT_FAILBACK_TIMES = 3 - DEFAULT_FAILBACK_TASKS = 100 + DEFAULT_LOADBALANCE = "random" + DEFAULT_RETRIES = "2" + DEFAULT_RETRIES_INT = 2 + DEFAULT_PROTOCOL = "dubbo" + DEFAULT_REG_TIMEOUT = "10s" + DEFAULT_CLUSTER = "failover" + DEFAULT_FAILBACK_TIMES = "3" + DEFAULT_FAILBACK_TIMES_INT = 3 + DEFAULT_FAILBACK_TASKS = 100 ) const ( diff --git a/config/base_config_test.go b/config/base_config_test.go index d07d983f64..7cb18c2c58 100644 --- a/config/base_config_test.go +++ b/config/base_config_test.go @@ -92,7 +92,7 @@ func Test_refresh(t *testing.T) { Protocol: "mock", Cluster: "failover", Loadbalance: "random", - Retries: 3, + Retries: "3", Group: "huadong_idc", Version: "1.0.0", Methods: []*MethodConfig{ @@ -100,14 +100,14 @@ func Test_refresh(t *testing.T) { InterfaceId: "MockService", InterfaceName: "com.MockService", Name: "GetUser", - Retries: 2, + Retries: "2", Loadbalance: "random", }, { InterfaceId: "MockService", InterfaceName: "com.MockService", Name: "GetUser1", - Retries: 2, + Retries: "2", Loadbalance: "random", }, }, @@ -118,9 +118,9 @@ func Test_refresh(t *testing.T) { c.SetFatherConfig(father) c.fresh() assert.Equal(t, "mock100", father.Registries["shanghai_reg1"].Protocol) - assert.Equal(t, int64(10), father.References["MockService"].Retries) + assert.Equal(t, "10", father.References["MockService"].Retries) - assert.Equal(t, int64(10), father.References["MockService"].Methods[0].Retries) + assert.Equal(t, "10", father.References["MockService"].Methods[0].Retries) assert.Equal(t, &[]bool{false}[0], father.Check) assert.Equal(t, "dubbo", father.ApplicationConfig.Name) } @@ -188,7 +188,7 @@ func Test_refreshProvider(t *testing.T) { Protocol: "mock", Cluster: "failover", Loadbalance: "random", - Retries: 3, + Retries: "3", Group: "huadong_idc", Version: "1.0.0", Methods: []*MethodConfig{ @@ -196,13 +196,13 @@ func Test_refreshProvider(t *testing.T) { InterfaceId: "MockService", InterfaceName: "com.MockService", Name: "GetUser", - Retries: 2, + Retries: "2", Loadbalance: "random", }, {InterfaceId: "MockService", InterfaceName: "com.MockService", Name: "GetUser1", - Retries: 2, + Retries: "2", Loadbalance: "random", }, }, @@ -213,9 +213,9 @@ func Test_refreshProvider(t *testing.T) { c.SetFatherConfig(father) c.fresh() assert.Equal(t, "mock100", father.Registries["shanghai_reg1"].Protocol) - assert.Equal(t, int64(10), father.Services["MockService"].Retries) + assert.Equal(t, "10", father.Services["MockService"].Retries) - assert.Equal(t, int64(10), father.Services["MockService"].Methods[0].Retries) + assert.Equal(t, "10", father.Services["MockService"].Methods[0].Retries) assert.Equal(t, "dubbo", father.ApplicationConfig.Name) assert.Equal(t, "20001", father.Protocols["jsonrpc1"].Port) } diff --git a/config/method_config.go b/config/method_config.go index 95479d1b65..560eaeaefa 100644 --- a/config/method_config.go +++ b/config/method_config.go @@ -24,7 +24,7 @@ type MethodConfig struct { InterfaceId string InterfaceName string Name string `yaml:"name" json:"name,omitempty" property:"name"` - Retries int64 `yaml:"retries" json:"retries,omitempty" property:"retries"` + Retries string `yaml:"retries" json:"retries,omitempty" property:"retries"` Loadbalance string `yaml:"loadbalance" json:"loadbalance,omitempty" property:"loadbalance"` Weight int64 `yaml:"weight" json:"weight,omitempty" property:"weight"` } diff --git a/config/reference_config.go b/config/reference_config.go index f90e3aabd3..1a318a6487 100644 --- a/config/reference_config.go +++ b/config/reference_config.go @@ -47,7 +47,7 @@ type ReferenceConfig struct { Registry string `yaml:"registry" json:"registry,omitempty" property:"registry"` Cluster string `yaml:"cluster" json:"cluster,omitempty" property:"cluster"` Loadbalance string `yaml:"loadbalance" json:"loadbalance,omitempty" property:"loadbalance"` - Retries int64 `yaml:"retries" json:"retries,omitempty" property:"retries"` + Retries string `yaml:"retries" json:"retries,omitempty" property:"retries"` Group string `yaml:"group" json:"group,omitempty" property:"group"` Version string `yaml:"version" json:"version,omitempty" property:"version"` Methods []*MethodConfig `yaml:"methods" json:"methods,omitempty" property:"methods"` @@ -154,7 +154,7 @@ func (refconfig *ReferenceConfig) getUrlMap() url.Values { urlMap.Set(constant.TIMESTAMP_KEY, strconv.FormatInt(time.Now().Unix(), 10)) urlMap.Set(constant.CLUSTER_KEY, refconfig.Cluster) urlMap.Set(constant.LOADBALANCE_KEY, refconfig.Loadbalance) - urlMap.Set(constant.RETRIES_KEY, strconv.FormatInt(refconfig.Retries, 10)) + urlMap.Set(constant.RETRIES_KEY, refconfig.Retries) urlMap.Set(constant.GROUP_KEY, refconfig.Group) urlMap.Set(constant.VERSION_KEY, refconfig.Version) urlMap.Set(constant.GENERIC_KEY, strconv.FormatBool(refconfig.Generic)) @@ -180,7 +180,7 @@ func (refconfig *ReferenceConfig) getUrlMap() url.Values { for _, v := range refconfig.Methods { urlMap.Set("methods."+v.Name+"."+constant.LOADBALANCE_KEY, v.Loadbalance) - urlMap.Set("methods."+v.Name+"."+constant.RETRIES_KEY, strconv.FormatInt(v.Retries, 10)) + urlMap.Set("methods."+v.Name+"."+constant.RETRIES_KEY, v.Retries) } return urlMap diff --git a/config/reference_config_test.go b/config/reference_config_test.go index d36fa04d74..cbe5c4cd65 100644 --- a/config/reference_config_test.go +++ b/config/reference_config_test.go @@ -90,18 +90,18 @@ func doInit() { Protocol: "mock", Cluster: "failover", Loadbalance: "random", - Retries: 3, + Retries: "3", Group: "huadong_idc", Version: "1.0.0", Methods: []*MethodConfig{ { Name: "GetUser", - Retries: 2, + Retries: "2", Loadbalance: "random", }, { Name: "GetUser1", - Retries: 2, + Retries: "2", Loadbalance: "random", }, }, diff --git a/config/service_config.go b/config/service_config.go index 8b4a7d1b22..5f08681838 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -54,7 +54,7 @@ type ServiceConfig struct { Version string `yaml:"version" json:"version,omitempty" property:"version" ` Methods []*MethodConfig `yaml:"methods" json:"methods,omitempty" property:"methods"` Warmup string `yaml:"warmup" json:"warmup,omitempty" property:"warmup"` - Retries int64 `yaml:"retries" json:"retries,omitempty" property:"retries"` + Retries string `yaml:"retries" json:"retries,omitempty" property:"retries"` Params map[string]string `yaml:"params" json:"params,omitempty" property:"params"` unexported *atomic.Bool exported *atomic.Bool @@ -160,7 +160,7 @@ func (srvconfig *ServiceConfig) getUrlMap() url.Values { urlMap.Set(constant.CLUSTER_KEY, srvconfig.Cluster) urlMap.Set(constant.LOADBALANCE_KEY, srvconfig.Loadbalance) urlMap.Set(constant.WARMUP_KEY, srvconfig.Warmup) - urlMap.Set(constant.RETRIES_KEY, strconv.FormatInt(srvconfig.Retries, 10)) + urlMap.Set(constant.RETRIES_KEY, srvconfig.Retries) urlMap.Set(constant.GROUP_KEY, srvconfig.Group) urlMap.Set(constant.VERSION_KEY, srvconfig.Version) urlMap.Set(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER)) @@ -178,7 +178,7 @@ func (srvconfig *ServiceConfig) getUrlMap() url.Values { for _, v := range srvconfig.Methods { urlMap.Set("methods."+v.Name+"."+constant.LOADBALANCE_KEY, v.Loadbalance) - urlMap.Set("methods."+v.Name+"."+constant.RETRIES_KEY, strconv.FormatInt(v.Retries, 10)) + urlMap.Set("methods."+v.Name+"."+constant.RETRIES_KEY, v.Retries) urlMap.Set("methods."+v.Name+"."+constant.WEIGHT_KEY, strconv.FormatInt(v.Weight, 10)) } diff --git a/config/service_config_test.go b/config/service_config_test.go index e111c8d110..bfbe9134fd 100644 --- a/config/service_config_test.go +++ b/config/service_config_test.go @@ -79,19 +79,19 @@ func doinit() { Registry: "shanghai_reg1,shanghai_reg2,hangzhou_reg1,hangzhou_reg2", Cluster: "failover", Loadbalance: "random", - Retries: 3, + Retries: "3", Group: "huadong_idc", Version: "1.0.0", Methods: []*MethodConfig{ { Name: "GetUser", - Retries: 2, + Retries: "2", Loadbalance: "random", Weight: 200, }, { Name: "GetUser1", - Retries: 2, + Retries: "2", Loadbalance: "random", Weight: 200, }, From 6dbad2903ec310bebce079c853a160323845b444 Mon Sep 17 00:00:00 2001 From: "vito.he" Date: Fri, 6 Sep 2019 23:16:18 +0800 Subject: [PATCH 2/5] Fix:failoverbug and reties change to string type --- .../with-configcenter-go-client/profiles/dev/client.yml | 2 +- .../with-configcenter-go-client/profiles/release/client.yml | 2 +- .../with-configcenter-go-client/profiles/test/client.yml | 2 +- .../with-configcenter-go-server/profiles/dev/server.yml | 2 +- .../with-configcenter-go-server/profiles/release/server.yml | 2 +- .../with-configcenter-go-server/profiles/test/server.yml | 2 +- examples/consul/go-client/config/client.yml | 2 +- examples/consul/go-server/config/server.yml | 2 +- examples/general/dubbo/go-client/profiles/dev/client.yml | 6 +++--- .../general/dubbo/go-client/profiles/release/client.yml | 6 +++--- examples/general/dubbo/go-client/profiles/test/client.yml | 6 +++--- examples/general/dubbo/go-server/profiles/dev/server.yml | 6 +++--- .../general/dubbo/go-server/profiles/release/server.yml | 6 +++--- examples/general/dubbo/go-server/profiles/test/server.yml | 6 +++--- examples/general/jsonrpc/go-client/profiles/dev/client.yml | 6 +++--- examples/general/jsonrpc/go-server/profiles/dev/server.yml | 6 +++--- examples/helloworld/dubbo/go-client/profiles/dev/client.yml | 2 +- examples/helloworld/dubbo/go-server/profiles/dev/server.yml | 2 +- .../dubbo/with-hystrix-go-client/profiles/dev/client.yml | 2 +- 19 files changed, 35 insertions(+), 35 deletions(-) diff --git a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/profiles/dev/client.yml b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/profiles/dev/client.yml index c8e7bd0b05..48b7b0ce95 100644 --- a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/profiles/dev/client.yml +++ b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/profiles/dev/client.yml @@ -13,7 +13,7 @@ references: cluster: "failover" methods : - name: "GetUser" - retries: 3 + retries: "3" protocol_conf: dubbo: diff --git a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/profiles/release/client.yml b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/profiles/release/client.yml index c8e7bd0b05..48b7b0ce95 100644 --- a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/profiles/release/client.yml +++ b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/profiles/release/client.yml @@ -13,7 +13,7 @@ references: cluster: "failover" methods : - name: "GetUser" - retries: 3 + retries: "3" protocol_conf: dubbo: diff --git a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/profiles/test/client.yml b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/profiles/test/client.yml index c8e7bd0b05..48b7b0ce95 100644 --- a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/profiles/test/client.yml +++ b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/profiles/test/client.yml @@ -13,7 +13,7 @@ references: cluster: "failover" methods : - name: "GetUser" - retries: 3 + retries: "3" protocol_conf: dubbo: diff --git a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/profiles/dev/server.yml b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/profiles/dev/server.yml index cdaaca4c38..219b92aebf 100644 --- a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/profiles/dev/server.yml +++ b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/profiles/dev/server.yml @@ -17,7 +17,7 @@ services: cluster: "failover" methods: - name: "GetUser" - retries: 1 + retries: "1" loadbalance: "random" protocol_conf: diff --git a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/profiles/release/server.yml b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/profiles/release/server.yml index cdaaca4c38..219b92aebf 100644 --- a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/profiles/release/server.yml +++ b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/profiles/release/server.yml @@ -17,7 +17,7 @@ services: cluster: "failover" methods: - name: "GetUser" - retries: 1 + retries: "1" loadbalance: "random" protocol_conf: diff --git a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/profiles/test/server.yml b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/profiles/test/server.yml index cdaaca4c38..219b92aebf 100644 --- a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/profiles/test/server.yml +++ b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/profiles/test/server.yml @@ -17,7 +17,7 @@ services: cluster: "failover" methods: - name: "GetUser" - retries: 1 + retries: "1" loadbalance: "random" protocol_conf: diff --git a/examples/consul/go-client/config/client.yml b/examples/consul/go-client/config/client.yml index 8a7458c384..4c0acde0d5 100644 --- a/examples/consul/go-client/config/client.yml +++ b/examples/consul/go-client/config/client.yml @@ -21,7 +21,7 @@ references: cluster: "failover" methods : - name: "SayHello" - retries: 3 + retries: "3" protocol_conf: dubbo: diff --git a/examples/consul/go-server/config/server.yml b/examples/consul/go-server/config/server.yml index c12800e68d..aa105327f8 100644 --- a/examples/consul/go-server/config/server.yml +++ b/examples/consul/go-server/config/server.yml @@ -23,7 +23,7 @@ services: cluster: "failover" methods: - name: "SayHello" - retries: 1 + retries: "1" loadbalance: "random" protocols: diff --git a/examples/general/dubbo/go-client/profiles/dev/client.yml b/examples/general/dubbo/go-client/profiles/dev/client.yml index ff69668841..4c2ad17cb3 100644 --- a/examples/general/dubbo/go-client/profiles/dev/client.yml +++ b/examples/general/dubbo/go-client/profiles/dev/client.yml @@ -39,7 +39,7 @@ references: cluster: "failover" methods : - name: "GetUser" - retries: 3 + retries: "3" "UserProvider1": registry: "hangzhouzk" protocol: "dubbo" @@ -48,7 +48,7 @@ references: cluster: "failover" methods: - name: "GetUser" - retries: 3 + retries: "3" "UserProvider2": registry: "hangzhouzk" protocol: "dubbo" @@ -58,7 +58,7 @@ references: cluster: "failover" methods: - name: "GetUser" - retries: 3 + retries: "3" protocol_conf: dubbo: diff --git a/examples/general/dubbo/go-client/profiles/release/client.yml b/examples/general/dubbo/go-client/profiles/release/client.yml index b4d897fda2..6b45f44077 100644 --- a/examples/general/dubbo/go-client/profiles/release/client.yml +++ b/examples/general/dubbo/go-client/profiles/release/client.yml @@ -39,7 +39,7 @@ references: cluster: "failover" methods : - name: "GetUser" - retries: 3 + retries: "3" "UserProvider1": registry: "hangzhouzk" protocol: "dubbo" @@ -48,7 +48,7 @@ references: cluster: "failover" methods: - name: "GetUser" - retries: 3 + retries: "3" "UserProvider2": registry: "hangzhouzk" protocol: "dubbo" @@ -58,7 +58,7 @@ references: cluster: "failover" methods: - name: "GetUser" - retries: 3 + retries: "3" protocol_conf: dubbo: diff --git a/examples/general/dubbo/go-client/profiles/test/client.yml b/examples/general/dubbo/go-client/profiles/test/client.yml index c8b5c58691..a9ebe3bb31 100644 --- a/examples/general/dubbo/go-client/profiles/test/client.yml +++ b/examples/general/dubbo/go-client/profiles/test/client.yml @@ -39,7 +39,7 @@ references: cluster: "failover" methods : - name: "GetUser" - retries: 3 + retries: "3" "UserProvider1": registry: "hangzhouzk" protocol: "dubbo" @@ -48,7 +48,7 @@ references: cluster: "failover" methods: - name: "GetUser" - retries: 3 + retries: "3" "UserProvider2": registry: "hangzhouzk" protocol: "dubbo" @@ -58,7 +58,7 @@ references: cluster: "failover" methods: - name: "GetUser" - retries: 3 + retries: "3" protocol_conf: dubbo: diff --git a/examples/general/dubbo/go-server/profiles/dev/server.yml b/examples/general/dubbo/go-server/profiles/dev/server.yml index 79c2cb2cc2..576a944754 100644 --- a/examples/general/dubbo/go-server/profiles/dev/server.yml +++ b/examples/general/dubbo/go-server/profiles/dev/server.yml @@ -38,7 +38,7 @@ services: cluster: "failover" methods: - name: "GetUser" - retries: 1 + retries: "1" loadbalance: "random" "UserProvider1": registry: "hangzhouzk" @@ -50,7 +50,7 @@ services: cluster: "failover" methods: - name: "GetUser" - retries: 1 + retries: "1" loadbalance: "random" "UserProvider2": registry: "hangzhouzk" @@ -63,7 +63,7 @@ services: cluster: "failover" methods: - name: "GetUser" - retries: 1 + retries: "1" loadbalance: "random" protocols: diff --git a/examples/general/dubbo/go-server/profiles/release/server.yml b/examples/general/dubbo/go-server/profiles/release/server.yml index 6890ed3bdb..dc3bc00276 100644 --- a/examples/general/dubbo/go-server/profiles/release/server.yml +++ b/examples/general/dubbo/go-server/profiles/release/server.yml @@ -37,7 +37,7 @@ services: cluster: "failover" methods: - name: "GetUser" - retries: 1 + retries: "1" loadbalance: "random" "UserProvider1": registry: "hangzhouzk" @@ -49,7 +49,7 @@ services: cluster: "failover" methods: - name: "GetUser" - retries: 1 + retries: "1" loadbalance: "random" "UserProvider2": registry: "hangzhouzk" @@ -62,7 +62,7 @@ services: cluster: "failover" methods: - name: "GetUser" - retries: 1 + retries: "1" loadbalance: "random" protocols: diff --git a/examples/general/dubbo/go-server/profiles/test/server.yml b/examples/general/dubbo/go-server/profiles/test/server.yml index b6dd41da44..0aab159b15 100644 --- a/examples/general/dubbo/go-server/profiles/test/server.yml +++ b/examples/general/dubbo/go-server/profiles/test/server.yml @@ -37,7 +37,7 @@ services: cluster: "failover" methods: - name: "GetUser" - retries: 1 + retries: "1" loadbalance: "random" "UserProvider1": registry: "hangzhouzk" @@ -49,7 +49,7 @@ services: cluster: "failover" methods: - name: "GetUser" - retries: 1 + retries: "1" loadbalance: "random" "UserProvider2": registry: "hangzhouzk" @@ -62,7 +62,7 @@ services: cluster: "failover" methods: - name: "GetUser" - retries: 1 + retries: "1" loadbalance: "random" protocols: diff --git a/examples/general/jsonrpc/go-client/profiles/dev/client.yml b/examples/general/jsonrpc/go-client/profiles/dev/client.yml index 788e06eecd..8d2482f1b4 100644 --- a/examples/general/jsonrpc/go-client/profiles/dev/client.yml +++ b/examples/general/jsonrpc/go-client/profiles/dev/client.yml @@ -38,7 +38,7 @@ references: cluster: "failover" methods : - name: "GetUser" - retries: 3 + retries: "3" "UserProvider1": registry: "hangzhouzk" protocol: "jsonrpc" @@ -47,7 +47,7 @@ references: cluster: "failover" methods: - name: "GetUser" - retries: 3 + retries: "3" "UserProvider2": registry: "hangzhouzk" protocol: "jsonrpc" @@ -57,4 +57,4 @@ references: cluster: "failover" methods: - name: "GetUser" - retries: 3 + retries: "3" diff --git a/examples/general/jsonrpc/go-server/profiles/dev/server.yml b/examples/general/jsonrpc/go-server/profiles/dev/server.yml index 4d74d2ef6f..10a0898b26 100644 --- a/examples/general/jsonrpc/go-server/profiles/dev/server.yml +++ b/examples/general/jsonrpc/go-server/profiles/dev/server.yml @@ -36,7 +36,7 @@ services: cluster: "failover" methods: - name: "GetUser" - retries: 1 + retries: "1" loadbalance: "random" "UserProvider1": registry: "hangzhouzk" @@ -48,7 +48,7 @@ services: cluster: "failover" methods: - name: "GetUser" - retries: 1 + retries: "1" loadbalance: "random" "UserProvider2": registry: "hangzhouzk" @@ -61,7 +61,7 @@ services: cluster: "failover" methods: - name: "GetUser" - retries: 1 + retries: "1" loadbalance: "random" protocols: diff --git a/examples/helloworld/dubbo/go-client/profiles/dev/client.yml b/examples/helloworld/dubbo/go-client/profiles/dev/client.yml index fed05b0973..226fbddd1a 100644 --- a/examples/helloworld/dubbo/go-client/profiles/dev/client.yml +++ b/examples/helloworld/dubbo/go-client/profiles/dev/client.yml @@ -34,7 +34,7 @@ references: cluster: "failover" methods : - name: "GetUser" - retries: 3 + retries: "3" protocol_conf: diff --git a/examples/helloworld/dubbo/go-server/profiles/dev/server.yml b/examples/helloworld/dubbo/go-server/profiles/dev/server.yml index be7eedeaa3..7df17934f6 100644 --- a/examples/helloworld/dubbo/go-server/profiles/dev/server.yml +++ b/examples/helloworld/dubbo/go-server/profiles/dev/server.yml @@ -28,7 +28,7 @@ services: cluster: "failover" methods: - name: "GetUser" - retries: 1 + retries: "1" loadbalance: "random" protocols: diff --git a/examples/hystrixfilter/dubbo/with-hystrix-go-client/profiles/dev/client.yml b/examples/hystrixfilter/dubbo/with-hystrix-go-client/profiles/dev/client.yml index 5b5003fb2c..4a438cc953 100644 --- a/examples/hystrixfilter/dubbo/with-hystrix-go-client/profiles/dev/client.yml +++ b/examples/hystrixfilter/dubbo/with-hystrix-go-client/profiles/dev/client.yml @@ -41,7 +41,7 @@ references: cluster: "failover" methods : - name: "GetUser" - retries: 3 + retries: "3" protocol_conf: dubbo: From d1ea35d21a39159bab26fdbb47dfb3baa9eb2b99 Mon Sep 17 00:00:00 2001 From: "vito.he" Date: Sat, 7 Sep 2019 23:16:47 +0800 Subject: [PATCH 3/5] Mod:retries in config/testdata --- config/testdata/consumer_config.yml | 2 +- config/testdata/consumer_config_with_configcenter.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/testdata/consumer_config.yml b/config/testdata/consumer_config.yml index 372873abbb..459edd9826 100644 --- a/config/testdata/consumer_config.yml +++ b/config/testdata/consumer_config.yml @@ -43,7 +43,7 @@ references: cluster: "failover" methods : - name: "GetUser" - retries: 3 + retries: "3" params: "serviceid": "soa.com.ikurento.user.UserProvider" diff --git a/config/testdata/consumer_config_with_configcenter.yml b/config/testdata/consumer_config_with_configcenter.yml index c6505e4492..69df73f51f 100644 --- a/config/testdata/consumer_config_with_configcenter.yml +++ b/config/testdata/consumer_config_with_configcenter.yml @@ -13,7 +13,7 @@ references: cluster: "failover" methods : - name: "GetUser" - retries: 3 + retries: "3" protocol_conf: dubbo: From a9770f7157d444053ad76744e478452b47b3a0b5 Mon Sep 17 00:00:00 2001 From: "vito.he" Date: Sat, 7 Sep 2019 23:24:02 +0800 Subject: [PATCH 4/5] Mod:format import --- cluster/cluster_impl/failover_cluster_invoker.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cluster/cluster_impl/failover_cluster_invoker.go b/cluster/cluster_impl/failover_cluster_invoker.go index c6a712a469..699f3d446b 100644 --- a/cluster/cluster_impl/failover_cluster_invoker.go +++ b/cluster/cluster_impl/failover_cluster_invoker.go @@ -18,10 +18,13 @@ package cluster_impl import ( - perrors "github.com/pkg/errors" "strconv" ) +import ( + perrors "github.com/pkg/errors" +) + import ( "github.com/apache/dubbo-go/cluster" "github.com/apache/dubbo-go/common/constant" From ead43d6a72e348426885ff85848bc6b3a3c0cb7e Mon Sep 17 00:00:00 2001 From: "vito.he" Date: Mon, 9 Sep 2019 10:14:44 +0800 Subject: [PATCH 5/5] Add: add error log --- cluster/cluster_impl/failback_cluster_invoker.go | 1 + cluster/cluster_impl/failover_cluster_invoker.go | 2 ++ 2 files changed, 3 insertions(+) diff --git a/cluster/cluster_impl/failback_cluster_invoker.go b/cluster/cluster_impl/failback_cluster_invoker.go index 889b168791..c8dbeda09f 100644 --- a/cluster/cluster_impl/failback_cluster_invoker.go +++ b/cluster/cluster_impl/failback_cluster_invoker.go @@ -58,6 +58,7 @@ func newFailbackClusterInvoker(directory cluster.Directory) protocol.Invoker { retriesConfig := invoker.GetUrl().GetParam(constant.RETRIES_KEY, constant.DEFAULT_FAILBACK_TIMES) retries, err := strconv.Atoi(retriesConfig) if err != nil || retries < 0 { + logger.Error("Your retries config is invalid,pls do a check. And will use the default fail back times configuration instead.") retries = constant.DEFAULT_FAILBACK_TIMES_INT } diff --git a/cluster/cluster_impl/failover_cluster_invoker.go b/cluster/cluster_impl/failover_cluster_invoker.go index 699f3d446b..70db6d4c1c 100644 --- a/cluster/cluster_impl/failover_cluster_invoker.go +++ b/cluster/cluster_impl/failover_cluster_invoker.go @@ -28,6 +28,7 @@ import ( import ( "github.com/apache/dubbo-go/cluster" "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/common/logger" "github.com/apache/dubbo-go/common/utils" "github.com/apache/dubbo-go/protocol" ) @@ -65,6 +66,7 @@ func (invoker *failoverClusterInvoker) Invoke(invocation protocol.Invocation) pr } retries, err := strconv.Atoi(retriesConfig) if err != nil || retries < 0 { + logger.Error("Your retries config is invalid,pls do a check. And will use the default retries configuration instead.") retries = constant.DEFAULT_RETRIES_INT } invoked := []protocol.Invoker{}