diff --git a/.gitignore b/.gitignore index 3d70f85a59b1367114bf04a7286fbb020d6825a4..1e651f122beb2ff487b0ef897af6fa74be9bfd1d 100644 --- a/.gitignore +++ b/.gitignore @@ -17,9 +17,10 @@ coverage.txt target/ classes - -# Gopkg.lock +# go mod, go test vendor/ +coverage.txt logs/ .vscode/ +coverage.txt diff --git a/.travis.yml b/.travis.yml index a4cbb8f750991a2e7538fb666823dadd695cfcd6..ea6b2035584ba07ae7caa709f83be59cf20c730e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,10 @@ install: true script: - go fmt ./... && [[ -z `git status -s` ]] + - mkdir -p remoting/zookeeper/zookeeper-4unittest/contrib/fatjar config_center/zookeeper/zookeeper-4unittest/contrib/fatjar registry/zookeeper/zookeeper-4unittest/contrib/fatjar + - wget -P "remoting/zookeeper/zookeeper-4unittest/contrib/fatjar" https://github.com/dubbogo/resources/raw/master/zookeeper-4unitest/contrib/fatjar/zookeeper-3.4.9-fatjar.jar + - cp remoting/zookeeper/zookeeper-4unittest/contrib/fatjar/zookeeper-3.4.9-fatjar.jar config_center/zookeeper/zookeeper-4unittest/contrib/fatjar/ + - cp remoting/zookeeper/zookeeper-4unittest/contrib/fatjar/zookeeper-3.4.9-fatjar.jar registry/zookeeper/zookeeper-4unittest/contrib/fatjar/ - go mod vendor && go test ./... -coverprofile=coverage.txt -covermode=atomic after_success: diff --git a/LICENSE b/LICENSE index d80bbdaa1e12f60cc04fe2c14f97e293aff6dcd4..e76f9d9dd705daad997776153b1060f5bf8c2a1d 100644 --- a/LICENSE +++ b/LICENSE @@ -176,8 +176,6 @@ END OF TERMS AND CONDITIONS - Copyright (c) 2016 ~ 2018 Alex Stocks. - Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000000000000000000000000000000000000..a9bd809c5c43a9d88a773b5f0c421b252abf38de --- /dev/null +++ b/NOTICE @@ -0,0 +1,5 @@ +Apache Dubbo Go +Copyright 2018-2019 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). diff --git a/README.md b/README.md index b64ce4973d6df5efcb560058b857d455e6371a57..d01c5df56a4e33a6bd062c64201fc985c79077b1 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,10 @@ --- Apache Dubbo Go Implementation. + + +Apache/Dubbo-go image, licensed under [Creative Commons 3.0 Attributions license](https://creativecommons.org/licenses/by/3.0/). + ## License Apache License, Version 2.0 @@ -29,18 +33,18 @@ Finished List: - Role: Consumer, Provider - Transport: HTTP, TCP - Codec: JsonRPC v2, Hessian v2 -- Registry: ZooKeeper +- Registry: ZooKeeper/[etcd v3](https://github.com/apache/dubbo-go/pull/148)/[nacos](https://github.com/apache/dubbo-go/pull/151)/[consul](https://github.com/apache/dubbo-go/pull/121) - Configure Center: Zookeeper -- Cluster Strategy: Failover -- Load Balance: Random, RoundRobin, LeastActive -- Filter: Echo Health Check +- Cluster Strategy: Failover/[Failfast](https://github.com/apache/dubbo-go/pull/140)/[Failsafe/Failback](https://github.com/apache/dubbo-go/pull/136)/[Available](https://github.com/apache/dubbo-go/pull/155)/[Broadcast](https://github.com/apache/dubbo-go/pull/158)/[Forking](https://github.com/apache/dubbo-go/pull/161) +- Load Balance: Random/[RoundRobin](https://github.com/apache/dubbo-go/pull/66)/[LeastActive](https://github.com/apache/dubbo-go/pull/65) +- Filter: Echo Health Check/[Circuit break and service downgrade](https://github.com/apache/dubbo-go/pull/133) +- Other feature: [generic invoke](https://github.com/apache/dubbo-go/pull/122)/start check/connecting certain provider/multi-protocols/multi-registries/multi-versions/service group Working List: -- Cluster Strategy: Failfast/Failsafe/Failback/Forking - Load Balance: ConsistentHash -- Filter: TokenFilter/AccessLogFilter/CountFilter/ActiveLimitFilter/ExecuteLimitFilter/GenericFilter/TpsLimitFilter -- Registry: etcd/k8s/consul/nacos +- Filter: TokenFilter/AccessLogFilter/CountFilter/ExecuteLimitFilter/TpsLimitFilter +- Registry: k8s - Configure Center: apollo - Dynamic Configuration Center & Metadata Center (dubbo v2.7.x) - Metrics: Promethus(dubbo v2.7.x) @@ -55,7 +59,7 @@ You can know more about dubbo-go by its [roadmap](https://github.com/apache/dubb ## Document -Move [here](https://dubbogo.github.io/dubbo-go-website/) +TODO ## Quick Start diff --git a/README_CN.md b/README_CN.md index 0553527534506f21eb9bd154c034b8345298f93c..9a769a196afa87eabc88649a5315b2772a8e4fef 100644 --- a/README_CN.md +++ b/README_CN.md @@ -5,6 +5,9 @@ --- Apache Dubbo Go 璇█瀹炵幇 + + +Apache/Dubbo-go image, licensed under [Creative Commons 3.0 Attributions license](https://creativecommons.org/licenses/by/3.0/). ## 璇佷功 ## @@ -26,29 +29,29 @@ Apache License, Version 2.0 瀹炵幇鍒楄〃: -- Role: Consumer, Provider -- Transport: HTTP, TCP -- Codec: JsonRPC v2, Hessian v2 -- Registry: ZooKeeper -- Routing: Rule(dubbo v2.6.x) -- Configure Center: Zookeeper -- Cluster Strategy: Failover -- Load Balance: Random, RoundRobin, LeastActive -- Filter: Echo Health Check +- 瑙掕壊绔�: Consumer, Provider +- 浼犺緭鍗忚: HTTP, TCP +- 搴忓垪鍖栧崗璁�: JsonRPC v2, Hessian v2 +- 娉ㄥ唽涓績: ZooKeeper/[etcd v3](https://github.com/apache/dubbo-go/pull/148)/[nacos](https://github.com/apache/dubbo-go/pull/151)/[consul](https://github.com/apache/dubbo-go/pull/121) +- 閰嶇疆涓績: Zookeeper +- 闆嗙兢绛栫暐: Failover/[Failfast](https://github.com/apache/dubbo-go/pull/140)/[Failsafe/Failback](https://github.com/apache/dubbo-go/pull/136)/[Available](https://github.com/apache/dubbo-go/pull/155)/[Broadcast](https://github.com/apache/dubbo-go/pull/158)/[Forking](https://github.com/apache/dubbo-go/pull/161) +- 璐熻浇鍧囪 绛栫暐: Random/[RoundRobin](https://github.com/apache/dubbo-go/pull/66)/[LeastActive](https://github.com/apache/dubbo-go/pull/65) +- 杩囨护鍣�: Echo Health Check/[鏈嶅姟鐔旀柇&闄嶇骇](https://github.com/apache/dubbo-go/pull/133) +- 鍏朵粬鍔熻兘鏀寔: [娉涘寲璋冪敤](https://github.com/apache/dubbo-go/pull/122)/鍚姩鏃舵鏌�/鏈嶅姟鐩磋繛/澶氭湇鍔″崗璁�/澶氭敞鍐屼腑蹇�/澶氭湇鍔$増鏈�/鏈嶅姟鍒嗙粍 寮€鍙戜腑鍒楄〃: -- Cluster Strategy: Failfast/Failsafe/Failback/Forking -- Load Balance: ConsistentHash -- Filter: TokenFilter/AccessLogFilter/CountFilter/ActiveLimitFilter/ExecuteLimitFilter/GenericFilter/TpsLimitFilter -- Registry: etcd/k8s/consul/nacos -- Configure Center: apollo -- Dynamic Configuration Center & Metadata Center (dubbo v2.7.x) +- 闆嗙兢绛栫暐: Forking +- 璐熻浇鍧囪 绛栫暐: ConsistentHash +- 杩囨护鍣�: TokenFilter/AccessLogFilter/CountFilter/ExecuteLimitFilter/TpsLimitFilter +- 娉ㄥ唽涓績: k8s +- 閰嶇疆涓績: apollo +- 鍔ㄦ€侀厤缃腑蹇� & 鍏冩暟鎹腑蹇� (dubbo v2.7.x) - Metrics: Promethus(dubbo v2.7.x) 浠诲姟鍒楄〃: -- Registry: kubernetes +- 娉ㄥ唽涓績: kubernetes - Routing: istio - tracing (dubbo ecosystem) @@ -56,7 +59,7 @@ Apache License, Version 2.0 ## 鏂囨。 -绉绘[杩欓噷](https://dubbogo.github.io/dubbo-go-website/) +TODO ## 蹇€熷紑濮� ## diff --git a/cluster/cluster_impl/available_cluster.go b/cluster/cluster_impl/available_cluster.go new file mode 100644 index 0000000000000000000000000000000000000000..7e748cd938319ff437bb3fb6c7945b857d316069 --- /dev/null +++ b/cluster/cluster_impl/available_cluster.go @@ -0,0 +1,40 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package cluster_impl + +import ( + "github.com/apache/dubbo-go/cluster" + "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/protocol" +) + +type availableCluster struct{} + +const available = "available" + +func init() { + extension.SetCluster(available, NewAvailableCluster) +} + +func NewAvailableCluster() cluster.Cluster { + return &availableCluster{} +} + +func (cluser *availableCluster) Join(directory cluster.Directory) protocol.Invoker { + return NewAvailableClusterInvoker(directory) +} diff --git a/cluster/cluster_impl/available_cluster_invoker.go b/cluster/cluster_impl/available_cluster_invoker.go new file mode 100644 index 0000000000000000000000000000000000000000..c59c0702c216fe5c58d190a023322aaa00ac9c17 --- /dev/null +++ b/cluster/cluster_impl/available_cluster_invoker.go @@ -0,0 +1,61 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package cluster_impl + +import ( + "fmt" +) + +import ( + "github.com/pkg/errors" +) + +import ( + "github.com/apache/dubbo-go/cluster" + "github.com/apache/dubbo-go/protocol" +) + +type availableClusterInvoker struct { + baseClusterInvoker +} + +func NewAvailableClusterInvoker(directory cluster.Directory) protocol.Invoker { + return &availableClusterInvoker{ + baseClusterInvoker: newBaseClusterInvoker(directory), + } +} + +func (invoker *availableClusterInvoker) Invoke(invocation protocol.Invocation) protocol.Result { + invokers := invoker.directory.List(invocation) + err := invoker.checkInvokers(invokers, invocation) + if err != nil { + return &protocol.RPCResult{Err: err} + } + + err = invoker.checkWhetherDestroyed() + if err != nil { + return &protocol.RPCResult{Err: err} + } + + for _, ivk := range invokers { + if ivk.IsAvailable() { + return ivk.Invoke(invocation) + } + } + return &protocol.RPCResult{Err: errors.New(fmt.Sprintf("no provider available in %v", invokers))} +} diff --git a/cluster/cluster_impl/available_cluster_invoker_test.go b/cluster/cluster_impl/available_cluster_invoker_test.go new file mode 100644 index 0000000000000000000000000000000000000000..04032a7f24dec0e73acb15921f753921391f1515 --- /dev/null +++ b/cluster/cluster_impl/available_cluster_invoker_test.go @@ -0,0 +1,88 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package cluster_impl + +import ( + "context" + "strings" + "testing" +) + +import ( + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/assert" +) + +import ( + "github.com/apache/dubbo-go/cluster/directory" + "github.com/apache/dubbo-go/cluster/loadbalance" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/protocol" + "github.com/apache/dubbo-go/protocol/invocation" + "github.com/apache/dubbo-go/protocol/mock" +) + +var ( + availableUrl, _ = common.NewURL(context.Background(), "dubbo://192.168.1.1:20000/com.ikurento.user.UserProvider") +) + +func registerAvailable(t *testing.T, invoker *mock.MockInvoker) protocol.Invoker { + extension.SetLoadbalance("random", loadbalance.NewRandomLoadBalance) + availableCluster := NewAvailableCluster() + + invokers := []protocol.Invoker{} + invokers = append(invokers, invoker) + invoker.EXPECT().GetUrl().Return(availableUrl) + + staticDir := directory.NewStaticDirectory(invokers) + clusterInvoker := availableCluster.Join(staticDir) + return clusterInvoker +} + +func TestAvailableClusterInvokerSuccess(t *testing.T) { + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + invoker := mock.NewMockInvoker(ctrl) + clusterInvoker := registerAvailable(t, invoker) + + mockResult := &protocol.RPCResult{Rest: rest{tried: 0, success: true}} + invoker.EXPECT().IsAvailable().Return(true) + invoker.EXPECT().Invoke(gomock.Any()).Return(mockResult) + + result := clusterInvoker.Invoke(&invocation.RPCInvocation{}) + + assert.Equal(t, mockResult, result) +} + +func TestAvailableClusterInvokerNoAvail(t *testing.T) { + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + invoker := mock.NewMockInvoker(ctrl) + clusterInvoker := registerAvailable(t, invoker) + + invoker.EXPECT().IsAvailable().Return(false) + + result := clusterInvoker.Invoke(&invocation.RPCInvocation{}) + + assert.NotNil(t, result.Error()) + assert.True(t, strings.Contains(result.Error().Error(), "no provider available")) + assert.Nil(t, result.Result()) +} diff --git a/cluster/cluster_impl/base_cluster_invoker.go b/cluster/cluster_impl/base_cluster_invoker.go index 6cbed7748e496afb37f9a1e93dbc40e845c62b06..52e2156885a2e6cc3c35da75a1d0db8bcfcabec0 100644 --- a/cluster/cluster_impl/base_cluster_invoker.go +++ b/cluster/cluster_impl/base_cluster_invoker.go @@ -25,9 +25,10 @@ import ( import ( "github.com/apache/dubbo-go/cluster" "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/common/extension" "github.com/apache/dubbo-go/common/utils" "github.com/apache/dubbo-go/protocol" - "github.com/apache/dubbo-go/version" ) type baseClusterInvoker struct { @@ -65,7 +66,7 @@ func (invoker *baseClusterInvoker) checkInvokers(invokers []protocol.Invoker, in ip, _ := utils.GetLocalIP() return perrors.Errorf("Failed to invoke the method %v. No provider available for the service %v from "+ "registry %v on the consumer %v using the dubbo version %v .Please check if the providers have been started and registered.", - invocation.MethodName(), invoker.directory.GetUrl().SubURL.Key(), invoker.directory.GetUrl().String(), ip, version.Version) + invocation.MethodName(), invoker.directory.GetUrl().SubURL.Key(), invoker.directory.GetUrl().String(), ip, constant.Version) } return nil @@ -76,13 +77,13 @@ func (invoker *baseClusterInvoker) checkWhetherDestroyed() error { if invoker.destroyed.Load() { ip, _ := utils.GetLocalIP() return perrors.Errorf("Rpc cluster invoker for %v on consumer %v use dubbo version %v is now destroyed! can not invoke any more. ", - invoker.directory.GetUrl().Service(), ip, version.Version) + invoker.directory.GetUrl().Service(), ip, constant.Version) } return nil } func (invoker *baseClusterInvoker) doSelect(lb cluster.LoadBalance, invocation protocol.Invocation, invokers []protocol.Invoker, invoked []protocol.Invoker) protocol.Invoker { - //todo:ticky connect 绮樼焊杩炴帴 + //todo:sticky connect if len(invokers) == 1 { return invokers[0] } @@ -115,12 +116,24 @@ func (invoker *baseClusterInvoker) doSelect(lb cluster.LoadBalance, invocation p } func isInvoked(selectedInvoker protocol.Invoker, invoked []protocol.Invoker) bool { - if len(invoked) > 0 { - for _, i := range invoked { - if i == selectedInvoker { - return true - } + for _, i := range invoked { + if i == selectedInvoker { + return true } } return false } + +func getLoadBalance(invoker protocol.Invoker, invocation protocol.Invocation) cluster.LoadBalance { + url := invoker.GetUrl() + + methodName := invocation.MethodName() + //Get the service loadbalance config + lb := url.GetParam(constant.LOADBALANCE_KEY, constant.DEFAULT_LOADBALANCE) + + //Get the service method loadbalance config if have + if v := url.GetMethodParam(methodName, constant.LOADBALANCE_KEY, ""); len(v) > 0 { + lb = v + } + return extension.GetLoadbalance(lb) +} diff --git a/cluster/cluster_impl/broadcast_cluster.go b/cluster/cluster_impl/broadcast_cluster.go new file mode 100644 index 0000000000000000000000000000000000000000..50aae3cfab8d67570b50dcab4e53bbfad29d6d30 --- /dev/null +++ b/cluster/cluster_impl/broadcast_cluster.go @@ -0,0 +1,40 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package cluster_impl + +import ( + "github.com/apache/dubbo-go/cluster" + "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/protocol" +) + +type broadcastCluster struct{} + +const broadcast = "broadcast" + +func init() { + extension.SetCluster(broadcast, NewBroadcastCluster) +} + +func NewBroadcastCluster() cluster.Cluster { + return &broadcastCluster{} +} + +func (cluster *broadcastCluster) Join(directory cluster.Directory) protocol.Invoker { + return newBroadcastClusterInvoker(directory) +} diff --git a/cluster/cluster_impl/broadcast_cluster_invoker.go b/cluster/cluster_impl/broadcast_cluster_invoker.go new file mode 100644 index 0000000000000000000000000000000000000000..238df0acfa7fb946e38bfbfd490bce7c0bb34e60 --- /dev/null +++ b/cluster/cluster_impl/broadcast_cluster_invoker.go @@ -0,0 +1,59 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package cluster_impl + +import ( + "github.com/apache/dubbo-go/cluster" + "github.com/apache/dubbo-go/common/logger" + "github.com/apache/dubbo-go/protocol" +) + +type broadcastClusterInvoker struct { + baseClusterInvoker +} + +func newBroadcastClusterInvoker(directory cluster.Directory) protocol.Invoker { + return &broadcastClusterInvoker{ + baseClusterInvoker: newBaseClusterInvoker(directory), + } +} + +func (invoker *broadcastClusterInvoker) Invoke(invocation protocol.Invocation) protocol.Result { + invokers := invoker.directory.List(invocation) + err := invoker.checkInvokers(invokers, invocation) + if err != nil { + return &protocol.RPCResult{Err: err} + } + err = invoker.checkWhetherDestroyed() + if err != nil { + return &protocol.RPCResult{Err: err} + } + + var result protocol.Result + for _, ivk := range invokers { + result = ivk.Invoke(invocation) + if result.Error() != nil { + logger.Warnf("broadcast invoker invoke err: %v when use invoker: %v\n", result.Error(), ivk) + err = result.Error() + } + } + if err != nil { + return &protocol.RPCResult{Err: err} + } + return result +} diff --git a/cluster/cluster_impl/broadcast_cluster_invoker_test.go b/cluster/cluster_impl/broadcast_cluster_invoker_test.go new file mode 100644 index 0000000000000000000000000000000000000000..565684a8ae25c648ff77aef71d2ced0665202fe7 --- /dev/null +++ b/cluster/cluster_impl/broadcast_cluster_invoker_test.go @@ -0,0 +1,109 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package cluster_impl + +import ( + "context" + "errors" + "testing" +) + +import ( + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/assert" +) + +import ( + "github.com/apache/dubbo-go/cluster/directory" + "github.com/apache/dubbo-go/cluster/loadbalance" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/protocol" + "github.com/apache/dubbo-go/protocol/invocation" + "github.com/apache/dubbo-go/protocol/mock" +) + +var ( + broadcastUrl, _ = common.NewURL(context.TODO(), "dubbo://192.168.1.1:20000/com.ikurento.user.UserProvider") +) + +func registerBroadcast(t *testing.T, mockInvokers ...*mock.MockInvoker) protocol.Invoker { + extension.SetLoadbalance("random", loadbalance.NewRandomLoadBalance) + + invokers := []protocol.Invoker{} + for i, ivk := range mockInvokers { + invokers = append(invokers, ivk) + if i == 0 { + ivk.EXPECT().GetUrl().Return(broadcastUrl) + } + } + staticDir := directory.NewStaticDirectory(invokers) + + broadcastCluster := NewBroadcastCluster() + clusterInvoker := broadcastCluster.Join(staticDir) + return clusterInvoker +} + +func Test_BroadcastInvokeSuccess(t *testing.T) { + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + invokers := make([]*mock.MockInvoker, 0) + + mockResult := &protocol.RPCResult{Rest: rest{tried: 0, success: true}} + for i := 0; i < 3; i++ { + invoker := mock.NewMockInvoker(ctrl) + invokers = append(invokers, invoker) + invoker.EXPECT().Invoke(gomock.Any()).Return(mockResult) + } + + clusterInvoker := registerBroadcast(t, invokers...) + + result := clusterInvoker.Invoke(&invocation.RPCInvocation{}) + assert.Equal(t, mockResult, result) +} + +func Test_BroadcastInvokeFailed(t *testing.T) { + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + invokers := make([]*mock.MockInvoker, 0) + + mockResult := &protocol.RPCResult{Rest: rest{tried: 0, success: true}} + mockFailedResult := &protocol.RPCResult{Err: errors.New("just failed")} + for i := 0; i < 10; i++ { + invoker := mock.NewMockInvoker(ctrl) + invokers = append(invokers, invoker) + invoker.EXPECT().Invoke(gomock.Any()).Return(mockResult) + } + { + invoker := mock.NewMockInvoker(ctrl) + invokers = append(invokers, invoker) + invoker.EXPECT().Invoke(gomock.Any()).Return(mockFailedResult) + } + for i := 0; i < 10; i++ { + invoker := mock.NewMockInvoker(ctrl) + invokers = append(invokers, invoker) + invoker.EXPECT().Invoke(gomock.Any()).Return(mockResult) + } + + clusterInvoker := registerBroadcast(t, invokers...) + + result := clusterInvoker.Invoke(&invocation.RPCInvocation{}) + assert.Equal(t, mockFailedResult.Err, result.Error()) +} diff --git a/cluster/cluster_impl/failback_cluster.go b/cluster/cluster_impl/failback_cluster.go new file mode 100644 index 0000000000000000000000000000000000000000..de22c78e947d0b8124add721ab7ff42efebcdbe4 --- /dev/null +++ b/cluster/cluster_impl/failback_cluster.go @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cluster_impl + +import ( + "github.com/apache/dubbo-go/cluster" + "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/protocol" +) + +type failbackCluster struct{} + +const failback = "failback" + +func init() { + extension.SetCluster(failback, NewFailbackCluster) +} + +func NewFailbackCluster() cluster.Cluster { + return &failbackCluster{} +} + +func (cluster *failbackCluster) Join(directory cluster.Directory) protocol.Invoker { + return newFailbackClusterInvoker(directory) +} diff --git a/cluster/cluster_impl/failback_cluster_invoker.go b/cluster/cluster_impl/failback_cluster_invoker.go new file mode 100644 index 0000000000000000000000000000000000000000..027461ccb7f32d6383d756ac986295b6300f249c --- /dev/null +++ b/cluster/cluster_impl/failback_cluster_invoker.go @@ -0,0 +1,203 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cluster_impl + +import ( + "sync" + "time" +) + +import ( + "github.com/Workiva/go-datastructures/queue" +) + +import ( + "github.com/apache/dubbo-go/cluster" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/common/logger" + "github.com/apache/dubbo-go/protocol" +) + +/** + * When fails, record failure requests and schedule for retry on a regular interval. + * Especially useful for services of notification. + * + * <a href="http://en.wikipedia.org/wiki/Failback">Failback</a> + */ +type failbackClusterInvoker struct { + baseClusterInvoker + + once sync.Once + ticker *time.Ticker + maxRetries int64 + failbackTasks int64 + taskList *queue.Queue +} + +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 + } + 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.failbackTasks = failbackTasksConfig + return invoker +} + +func (invoker *failbackClusterInvoker) process() { + invoker.ticker = time.NewTicker(time.Second * 1) + for range invoker.ticker.C { + // check each timeout task and re-run + for { + value, err := invoker.taskList.Peek() + if err == queue.ErrDisposed { + return + } + if err == queue.ErrEmptyQueue { + break + } + + retryTask := value.(*retryTimerTask) + if time.Since(retryTask.lastT).Seconds() < 5 { + break + } + + // ignore return. the get must success. + _, err = invoker.taskList.Get(1) + if err != nil { + logger.Warnf("get task found err: %v\n", err) + break + } + + go func(retryTask *retryTimerTask) { + invoked := make([]protocol.Invoker, 0) + invoked = append(invoked, retryTask.lastInvoker) + + retryInvoker := invoker.doSelect(retryTask.loadbalance, retryTask.invocation, retryTask.invokers, invoked) + var result protocol.Result + result = retryInvoker.Invoke(retryTask.invocation) + if result.Error() != nil { + retryTask.lastInvoker = retryInvoker + invoker.checkRetry(retryTask, result.Error()) + } + }(retryTask) + + } + } +} + +func (invoker *failbackClusterInvoker) checkRetry(retryTask *retryTimerTask, err error) { + logger.Errorf("Failed retry to invoke the method %v in the service %v, wait again. The exception: %v.\n", + retryTask.invocation.MethodName(), invoker.GetUrl().Service(), err.Error()) + retryTask.retries++ + retryTask.lastT = time.Now() + if retryTask.retries > invoker.maxRetries { + logger.Errorf("Failed retry times exceed threshold (%v), We have to abandon, invocation-> %v.\n", + retryTask.retries, retryTask.invocation) + } else { + invoker.taskList.Put(retryTask) + } +} + +func (invoker *failbackClusterInvoker) Invoke(invocation protocol.Invocation) protocol.Result { + invokers := invoker.directory.List(invocation) + err := invoker.checkInvokers(invokers, invocation) + if err != nil { + logger.Errorf("Failed to invoke the method %v in the service %v, wait for retry in background. Ignored exception: %v.\n", + invocation.MethodName(), invoker.GetUrl().Service(), err) + return &protocol.RPCResult{} + } + url := invokers[0].GetUrl() + methodName := invocation.MethodName() + //Get the service loadbalance config + lb := url.GetParam(constant.LOADBALANCE_KEY, constant.DEFAULT_LOADBALANCE) + + //Get the service method loadbalance config if have + if v := url.GetMethodParam(methodName, constant.LOADBALANCE_KEY, ""); v != "" { + lb = v + } + loadbalance := extension.GetLoadbalance(lb) + + invoked := make([]protocol.Invoker, 0, len(invokers)) + var result protocol.Result + + ivk := invoker.doSelect(loadbalance, invocation, invokers, invoked) + //DO INVOKE + result = ivk.Invoke(invocation) + if result.Error() != nil { + invoker.once.Do(func() { + invoker.taskList = queue.New(invoker.failbackTasks) + go invoker.process() + }) + + taskLen := invoker.taskList.Len() + if taskLen >= invoker.failbackTasks { + logger.Warnf("tasklist is too full > %d.\n", taskLen) + return &protocol.RPCResult{} + } + + timerTask := newRetryTimerTask(loadbalance, invocation, invokers, ivk) + invoker.taskList.Put(timerTask) + + logger.Errorf("Failback to invoke the method %v in the service %v, wait for retry in background. Ignored exception: %v.\n", + methodName, url.Service(), result.Error().Error()) + // ignore + return &protocol.RPCResult{} + } + + return result +} + +func (invoker *failbackClusterInvoker) Destroy() { + invoker.baseClusterInvoker.Destroy() + + // stop ticker + if invoker.ticker != nil { + invoker.ticker.Stop() + } + + _ = invoker.taskList.Dispose() +} + +type retryTimerTask struct { + loadbalance cluster.LoadBalance + invocation protocol.Invocation + invokers []protocol.Invoker + lastInvoker protocol.Invoker + retries int64 + lastT time.Time +} + +func newRetryTimerTask(loadbalance cluster.LoadBalance, invocation protocol.Invocation, invokers []protocol.Invoker, + lastInvoker protocol.Invoker) *retryTimerTask { + return &retryTimerTask{ + loadbalance: loadbalance, + invocation: invocation, + invokers: invokers, + lastInvoker: lastInvoker, + lastT: time.Now(), + } +} diff --git a/cluster/cluster_impl/failback_cluster_test.go b/cluster/cluster_impl/failback_cluster_test.go new file mode 100644 index 0000000000000000000000000000000000000000..c94347a1251a69a10c0a4d50007ef569bd6dd996 --- /dev/null +++ b/cluster/cluster_impl/failback_cluster_test.go @@ -0,0 +1,242 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package cluster_impl + +import ( + "context" + "sync" + "testing" + "time" +) + +import ( + "github.com/golang/mock/gomock" + perrors "github.com/pkg/errors" + "github.com/stretchr/testify/assert" +) + +import ( + "github.com/apache/dubbo-go/cluster/directory" + "github.com/apache/dubbo-go/cluster/loadbalance" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/protocol" + "github.com/apache/dubbo-go/protocol/invocation" + "github.com/apache/dubbo-go/protocol/mock" +) + +var ( + failbackUrl, _ = common.NewURL(context.TODO(), "dubbo://192.168.1.1:20000/com.ikurento.user.UserProvider") +) + +// registerFailback register failbackCluster to cluster extension. +func registerFailback(t *testing.T, invoker *mock.MockInvoker) protocol.Invoker { + extension.SetLoadbalance("random", loadbalance.NewRandomLoadBalance) + failbackCluster := NewFailbackCluster() + + invokers := []protocol.Invoker{} + invokers = append(invokers, invoker) + + invoker.EXPECT().GetUrl().Return(failbackUrl) + + staticDir := directory.NewStaticDirectory(invokers) + clusterInvoker := failbackCluster.Join(staticDir) + return clusterInvoker +} + +// success firstly, failback should return origin invoke result. +func Test_FailbackSuceess(t *testing.T) { + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + invoker := mock.NewMockInvoker(ctrl) + clusterInvoker := registerFailback(t, invoker).(*failbackClusterInvoker) + + invoker.EXPECT().GetUrl().Return(failbackUrl).Times(1) + + mockResult := &protocol.RPCResult{Rest: rest{tried: 0, success: true}} + invoker.EXPECT().Invoke(gomock.Any()).Return(mockResult) + + result := clusterInvoker.Invoke(&invocation.RPCInvocation{}) + assert.Equal(t, mockResult, result) +} + +// failed firstly, success later after one retry. +func Test_FailbackRetryOneSuccess(t *testing.T) { + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + invoker := mock.NewMockInvoker(ctrl) + clusterInvoker := registerFailback(t, invoker).(*failbackClusterInvoker) + + invoker.EXPECT().GetUrl().Return(failbackUrl).AnyTimes() + + // failed at first + mockFailedResult := &protocol.RPCResult{Err: perrors.New("error")} + invoker.EXPECT().Invoke(gomock.Any()).Return(mockFailedResult) + + // success second + var wg sync.WaitGroup + wg.Add(1) + now := time.Now() + mockSuccResult := &protocol.RPCResult{Rest: rest{tried: 0, success: true}} + invoker.EXPECT().Invoke(gomock.Any()).DoAndReturn(func(invocation protocol.Invocation) protocol.Result { + delta := time.Since(now).Nanoseconds() / int64(time.Second) + assert.True(t, delta >= 5) + wg.Done() + return mockSuccResult + }) + + result := clusterInvoker.Invoke(&invocation.RPCInvocation{}) + assert.Nil(t, result.Error()) + assert.Nil(t, result.Result()) + assert.Equal(t, 0, len(result.Attachments())) + + // ensure the retry task has been executed + assert.Equal(t, int64(1), clusterInvoker.taskList.Len()) + // wait until the retry task is executed, the taskList will be empty. + wg.Wait() + assert.Equal(t, int64(0), clusterInvoker.taskList.Len()) + + invoker.EXPECT().Destroy().Return() + clusterInvoker.Destroy() + + assert.Equal(t, int64(0), clusterInvoker.taskList.Len()) +} + +// failed firstly, and failed again after ech retry time. +func Test_FailbackRetryFailed(t *testing.T) { + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + invoker := mock.NewMockInvoker(ctrl) + clusterInvoker := registerFailback(t, invoker).(*failbackClusterInvoker) + + invoker.EXPECT().GetUrl().Return(failbackUrl).AnyTimes() + + mockFailedResult := &protocol.RPCResult{Err: perrors.New("error")} + invoker.EXPECT().Invoke(gomock.Any()).Return(mockFailedResult) + + // + var wg sync.WaitGroup + retries := 2 + wg.Add(retries) + now := time.Now() + + // add retry call that eventually failed. + for i := 0; i < retries; i++ { + j := i + 1 + invoker.EXPECT().Invoke(gomock.Any()).DoAndReturn(func(invocation protocol.Invocation) protocol.Result { + delta := time.Since(now).Nanoseconds() / int64(time.Second) + assert.True(t, delta >= int64(5*j)) + wg.Done() + return mockFailedResult + }) + } + + // first call should failed. + result := clusterInvoker.Invoke(&invocation.RPCInvocation{}) + assert.Nil(t, result.Error()) + assert.Nil(t, result.Result()) + assert.Equal(t, 0, len(result.Attachments())) + + wg.Wait() + time.Sleep(time.Second) + assert.Equal(t, int64(1), clusterInvoker.taskList.Len()) + + invoker.EXPECT().Destroy().Return() + clusterInvoker.Destroy() + // after destroy, the taskList will be empty + assert.Equal(t, int64(0), clusterInvoker.taskList.Len()) +} + +// add 10 tasks but all failed firstly, and failed again with one retry. +func Test_FailbackRetryFailed10Times(t *testing.T) { + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + invoker := mock.NewMockInvoker(ctrl) + clusterInvoker := registerFailback(t, invoker).(*failbackClusterInvoker) + clusterInvoker.maxRetries = 10 + + invoker.EXPECT().GetUrl().Return(failbackUrl).AnyTimes() + + // 10 task should failed firstly. + mockFailedResult := &protocol.RPCResult{Err: perrors.New("error")} + invoker.EXPECT().Invoke(gomock.Any()).Return(mockFailedResult).Times(10) + + // 10 task should retry and failed. + var wg sync.WaitGroup + wg.Add(10) + now := time.Now() + invoker.EXPECT().Invoke(gomock.Any()).DoAndReturn(func(invocation protocol.Invocation) protocol.Result { + delta := time.Since(now).Nanoseconds() / int64(time.Second) + assert.True(t, delta >= 5) + wg.Done() + return mockFailedResult + }).Times(10) + + for i := 0; i < 10; i++ { + result := clusterInvoker.Invoke(&invocation.RPCInvocation{}) + assert.Nil(t, result.Error()) + assert.Nil(t, result.Result()) + assert.Equal(t, 0, len(result.Attachments())) + } + + wg.Wait() + time.Sleep(time.Second) // in order to ensure checkRetry have done + assert.Equal(t, int64(10), clusterInvoker.taskList.Len()) + + invoker.EXPECT().Destroy().Return() + clusterInvoker.Destroy() + + assert.Equal(t, int64(0), clusterInvoker.taskList.Len()) +} + +func Test_FailbackOutOfLimit(t *testing.T) { + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + invoker := mock.NewMockInvoker(ctrl) + clusterInvoker := registerFailback(t, invoker).(*failbackClusterInvoker) + clusterInvoker.failbackTasks = 1 + + invoker.EXPECT().GetUrl().Return(failbackUrl).AnyTimes() + + mockFailedResult := &protocol.RPCResult{Err: perrors.New("error")} + invoker.EXPECT().Invoke(gomock.Any()).Return(mockFailedResult).Times(11) + + // reached limit + result := clusterInvoker.Invoke(&invocation.RPCInvocation{}) + assert.Nil(t, result.Error()) + assert.Nil(t, result.Result()) + assert.Equal(t, 0, len(result.Attachments())) + + // all will be out of limit + for i := 0; i < 10; i++ { + result := clusterInvoker.Invoke(&invocation.RPCInvocation{}) + assert.Nil(t, result.Error()) + assert.Nil(t, result.Result()) + assert.Equal(t, 0, len(result.Attachments())) + + assert.Equal(t, int64(1), clusterInvoker.taskList.Len()) + } + + invoker.EXPECT().Destroy().Return() + clusterInvoker.Destroy() +} diff --git a/cluster/cluster_impl/failfast_cluster.go b/cluster/cluster_impl/failfast_cluster.go new file mode 100644 index 0000000000000000000000000000000000000000..6301d945626103226132b433dd21e8647f53a38b --- /dev/null +++ b/cluster/cluster_impl/failfast_cluster.go @@ -0,0 +1,40 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package cluster_impl + +import ( + "github.com/apache/dubbo-go/cluster" + "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/protocol" +) + +type failfastCluster struct{} + +const failfast = "failfast" + +func init() { + extension.SetCluster(failfast, NewFailFastCluster) +} + +func NewFailFastCluster() cluster.Cluster { + return &failfastCluster{} +} + +func (cluster *failfastCluster) Join(directory cluster.Directory) protocol.Invoker { + return newFailFastClusterInvoker(directory) +} diff --git a/cluster/cluster_impl/failfast_cluster_invoker.go b/cluster/cluster_impl/failfast_cluster_invoker.go new file mode 100644 index 0000000000000000000000000000000000000000..734ea2c6cb19bf54a338a76a10c9cfcc59d3954b --- /dev/null +++ b/cluster/cluster_impl/failfast_cluster_invoker.go @@ -0,0 +1,51 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package cluster_impl + +import ( + "github.com/apache/dubbo-go/cluster" + "github.com/apache/dubbo-go/protocol" +) + +type failfastClusterInvoker struct { + baseClusterInvoker +} + +func newFailFastClusterInvoker(directory cluster.Directory) protocol.Invoker { + return &failfastClusterInvoker{ + baseClusterInvoker: newBaseClusterInvoker(directory), + } +} + +func (invoker *failfastClusterInvoker) Invoke(invocation protocol.Invocation) protocol.Result { + invokers := invoker.directory.List(invocation) + err := invoker.checkInvokers(invokers, invocation) + if err != nil { + return &protocol.RPCResult{Err: err} + } + + loadbalance := getLoadBalance(invokers[0], invocation) + + err = invoker.checkWhetherDestroyed() + if err != nil { + return &protocol.RPCResult{Err: err} + } + + ivk := invoker.doSelect(loadbalance, invocation, invokers, nil) + return ivk.Invoke(invocation) +} diff --git a/cluster/cluster_impl/failfast_cluster_test.go b/cluster/cluster_impl/failfast_cluster_test.go new file mode 100644 index 0000000000000000000000000000000000000000..7a19e80ccda15aa13a1c4fcf250e05a6effa7f0b --- /dev/null +++ b/cluster/cluster_impl/failfast_cluster_test.go @@ -0,0 +1,97 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package cluster_impl + +import ( + "context" + "testing" +) + +import ( + "github.com/golang/mock/gomock" + perrors "github.com/pkg/errors" + "github.com/stretchr/testify/assert" +) + +import ( + "github.com/apache/dubbo-go/cluster/directory" + "github.com/apache/dubbo-go/cluster/loadbalance" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/protocol" + "github.com/apache/dubbo-go/protocol/invocation" + "github.com/apache/dubbo-go/protocol/mock" +) + +var ( + failfastUrl, _ = common.NewURL(context.TODO(), "dubbo://192.168.1.1:20000/com.ikurento.user.UserProvider") +) + +// registerFailfast register failfastCluster to cluster extension. +func registerFailfast(t *testing.T, invoker *mock.MockInvoker) protocol.Invoker { + extension.SetLoadbalance("random", loadbalance.NewRandomLoadBalance) + failfastCluster := NewFailFastCluster() + + invokers := []protocol.Invoker{} + invokers = append(invokers, invoker) + + invoker.EXPECT().GetUrl().Return(failfastUrl) + + staticDir := directory.NewStaticDirectory(invokers) + clusterInvoker := failfastCluster.Join(staticDir) + return clusterInvoker +} + +func Test_FailfastInvokeSuccess(t *testing.T) { + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + invoker := mock.NewMockInvoker(ctrl) + clusterInvoker := registerFailfast(t, invoker) + + invoker.EXPECT().GetUrl().Return(failfastUrl) + + mockResult := &protocol.RPCResult{Rest: rest{tried: 0, success: true}} + + invoker.EXPECT().Invoke(gomock.Any()).Return(mockResult) + result := clusterInvoker.Invoke(&invocation.RPCInvocation{}) + + assert.NoError(t, result.Error()) + res := result.Result().(rest) + assert.True(t, res.success) + assert.Equal(t, 0, res.tried) +} + +func Test_FailfastInvokeFail(t *testing.T) { + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + invoker := mock.NewMockInvoker(ctrl) + clusterInvoker := registerFailfast(t, invoker) + + invoker.EXPECT().GetUrl().Return(failfastUrl) + + mockResult := &protocol.RPCResult{Err: perrors.New("error")} + + invoker.EXPECT().Invoke(gomock.Any()).Return(mockResult) + result := clusterInvoker.Invoke(&invocation.RPCInvocation{}) + + assert.NotNil(t, result.Error()) + assert.Equal(t, "error", result.Error().Error()) + assert.Nil(t, result.Result()) +} diff --git a/cluster/cluster_impl/failover_cluster_invoker.go b/cluster/cluster_impl/failover_cluster_invoker.go index cd17a85e00a1d4307b3b861467051e9719345d1a..3dd8c41dfb7b7512d7c81fa6d7f8a7c35cec0dcb 100644 --- a/cluster/cluster_impl/failover_cluster_invoker.go +++ b/cluster/cluster_impl/failover_cluster_invoker.go @@ -24,10 +24,8 @@ import ( import ( "github.com/apache/dubbo-go/cluster" "github.com/apache/dubbo-go/common/constant" - "github.com/apache/dubbo-go/common/extension" "github.com/apache/dubbo-go/common/utils" "github.com/apache/dubbo-go/protocol" - "github.com/apache/dubbo-go/version" ) type failoverClusterInvoker struct { @@ -48,17 +46,11 @@ func (invoker *failoverClusterInvoker) Invoke(invocation protocol.Invocation) pr if err != nil { return &protocol.RPCResult{Err: err} } - url := invokers[0].GetUrl() - methodName := invocation.MethodName() - //Get the service loadbalance config - lb := url.GetParam(constant.LOADBALANCE_KEY, constant.DEFAULT_LOADBALANCE) + loadbalance := getLoadBalance(invokers[0], invocation) - //Get the service method loadbalance config if have - if v := url.GetMethodParam(methodName, constant.LOADBALANCE_KEY, ""); v != "" { - lb = v - } - loadbalance := extension.GetLoadbalance(lb) + methodName := invocation.MethodName() + url := invokers[0].GetUrl() //get reties retries := url.GetParamInt(constant.RETRIES_KEY, constant.DEFAULT_RETRIES) @@ -98,6 +90,6 @@ func (invoker *failoverClusterInvoker) Invoke(invocation protocol.Invocation) pr ip, _ := utils.GetLocalIP() return &protocol.RPCResult{Err: perrors.Errorf("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. Last error is %v.", - methodName, invoker.GetUrl().Service(), retries, providers, len(providers), len(invokers), invoker.directory.GetUrl(), ip, version.Version, result.Error().Error(), + methodName, invoker.GetUrl().Service(), retries, providers, len(providers), len(invokers), invoker.directory.GetUrl(), ip, constant.Version, result.Error().Error(), )} } diff --git a/cluster/cluster_impl/failsafe_cluster.go b/cluster/cluster_impl/failsafe_cluster.go new file mode 100644 index 0000000000000000000000000000000000000000..3ff97d25eae80980a90a03e71865bb8f9a63defe --- /dev/null +++ b/cluster/cluster_impl/failsafe_cluster.go @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cluster_impl + +import ( + "github.com/apache/dubbo-go/cluster" + "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/protocol" +) + +type failsafeCluster struct{} + +const failsafe = "failsafe" + +func init() { + extension.SetCluster(failsafe, NewFailsafeCluster) +} + +func NewFailsafeCluster() cluster.Cluster { + return &failsafeCluster{} +} + +func (cluster *failsafeCluster) Join(directory cluster.Directory) protocol.Invoker { + return newFailsafeClusterInvoker(directory) +} diff --git a/cluster/cluster_impl/failsafe_cluster_invoker.go b/cluster/cluster_impl/failsafe_cluster_invoker.go new file mode 100644 index 0000000000000000000000000000000000000000..b95f997fef87cf466f07c4e506e41758e7998e52 --- /dev/null +++ b/cluster/cluster_impl/failsafe_cluster_invoker.go @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cluster_impl + +import ( + "github.com/apache/dubbo-go/cluster" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/common/logger" + "github.com/apache/dubbo-go/protocol" +) + +/** + * When invoke fails, log the error message and ignore this error by returning an empty Result. + * Usually used to write audit logs and other operations + * + * <a href="http://en.wikipedia.org/wiki/Fail-safe">Fail-safe</a> + * + */ +type failsafeClusterInvoker struct { + baseClusterInvoker +} + +func newFailsafeClusterInvoker(directory cluster.Directory) protocol.Invoker { + return &failsafeClusterInvoker{ + baseClusterInvoker: newBaseClusterInvoker(directory), + } +} + +func (invoker *failsafeClusterInvoker) Invoke(invocation protocol.Invocation) protocol.Result { + invokers := invoker.directory.List(invocation) + + err := invoker.checkInvokers(invokers, invocation) + if err != nil { + return &protocol.RPCResult{} + } + + url := invokers[0].GetUrl() + methodName := invocation.MethodName() + //Get the service loadbalance config + lb := url.GetParam(constant.LOADBALANCE_KEY, constant.DEFAULT_LOADBALANCE) + //Get the service method loadbalance config if have + if v := url.GetMethodParam(methodName, constant.LOADBALANCE_KEY, ""); v != "" { + lb = v + } + loadbalance := extension.GetLoadbalance(lb) + + invoked := make([]protocol.Invoker, 0) + var result protocol.Result + + ivk := invoker.doSelect(loadbalance, invocation, invokers, invoked) + //DO INVOKE + result = ivk.Invoke(invocation) + if result.Error() != nil { + // ignore + logger.Errorf("Failsafe ignore exception: %v.\n", result.Error().Error()) + return &protocol.RPCResult{} + } + return result +} diff --git a/cluster/cluster_impl/failsafe_cluster_test.go b/cluster/cluster_impl/failsafe_cluster_test.go new file mode 100644 index 0000000000000000000000000000000000000000..9ee9d9fee31b0cb24d877ab3dc0e24fb552f5f11 --- /dev/null +++ b/cluster/cluster_impl/failsafe_cluster_test.go @@ -0,0 +1,95 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package cluster_impl + +import ( + "context" + "testing" +) + +import ( + "github.com/golang/mock/gomock" + perrors "github.com/pkg/errors" + "github.com/stretchr/testify/assert" +) + +import ( + "github.com/apache/dubbo-go/cluster/directory" + "github.com/apache/dubbo-go/cluster/loadbalance" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/protocol" + "github.com/apache/dubbo-go/protocol/invocation" + "github.com/apache/dubbo-go/protocol/mock" +) + +var ( + failsafeUrl, _ = common.NewURL(context.TODO(), "dubbo://192.168.1.1:20000/com.ikurento.user.UserProvider") +) + +// register_failsafe register failsafeCluster to cluster extension. +func register_failsafe(t *testing.T, invoker *mock.MockInvoker) protocol.Invoker { + extension.SetLoadbalance("random", loadbalance.NewRandomLoadBalance) + failsafeCluster := NewFailsafeCluster() + + invokers := []protocol.Invoker{} + invokers = append(invokers, invoker) + + invoker.EXPECT().GetUrl().Return(failbackUrl) + + staticDir := directory.NewStaticDirectory(invokers) + clusterInvoker := failsafeCluster.Join(staticDir) + return clusterInvoker +} + +func Test_FailSafeInvokeSuccess(t *testing.T) { + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + invoker := mock.NewMockInvoker(ctrl) + clusterInvoker := register_failsafe(t, invoker) + + invoker.EXPECT().GetUrl().Return(failsafeUrl) + + mockResult := &protocol.RPCResult{Rest: rest{tried: 0, success: true}} + + invoker.EXPECT().Invoke(gomock.Any()).Return(mockResult) + result := clusterInvoker.Invoke(&invocation.RPCInvocation{}) + + assert.NoError(t, result.Error()) + res := result.Result().(rest) + assert.True(t, res.success) +} + +func Test_FailSafeInvokeFail(t *testing.T) { + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + invoker := mock.NewMockInvoker(ctrl) + clusterInvoker := register_failsafe(t, invoker) + + invoker.EXPECT().GetUrl().Return(failsafeUrl) + + mockResult := &protocol.RPCResult{Err: perrors.New("error")} + + invoker.EXPECT().Invoke(gomock.Any()).Return(mockResult) + result := clusterInvoker.Invoke(&invocation.RPCInvocation{}) + + assert.NoError(t, result.Error()) + assert.Nil(t, result.Result()) +} diff --git a/cluster/cluster_impl/forking_cluster.go b/cluster/cluster_impl/forking_cluster.go new file mode 100644 index 0000000000000000000000000000000000000000..0a3c2b313ff3c4e89e592af9256fc42713419914 --- /dev/null +++ b/cluster/cluster_impl/forking_cluster.go @@ -0,0 +1,40 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package cluster_impl + +import ( + "github.com/apache/dubbo-go/cluster" + "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/protocol" +) + +type forkingCluster struct{} + +const forking = "forking" + +func init() { + extension.SetCluster(forking, NewForkingCluster) +} + +func NewForkingCluster() cluster.Cluster { + return &forkingCluster{} +} + +func (cluster *forkingCluster) Join(directory cluster.Directory) protocol.Invoker { + return newForkingClusterInvoker(directory) +} diff --git a/cluster/cluster_impl/forking_cluster_invoker.go b/cluster/cluster_impl/forking_cluster_invoker.go new file mode 100644 index 0000000000000000000000000000000000000000..d6cf2f4b89ab4f322fa758deecae90c60742ef49 --- /dev/null +++ b/cluster/cluster_impl/forking_cluster_invoker.go @@ -0,0 +1,99 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package cluster_impl + +import ( + "errors" + "fmt" + "time" +) + +import ( + "github.com/Workiva/go-datastructures/queue" +) + +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/protocol" +) + +type forkingClusterInvoker struct { + baseClusterInvoker +} + +func newForkingClusterInvoker(directory cluster.Directory) protocol.Invoker { + return &forkingClusterInvoker{ + baseClusterInvoker: newBaseClusterInvoker(directory), + } +} + +func (invoker *forkingClusterInvoker) Invoke(invocation protocol.Invocation) protocol.Result { + err := invoker.checkWhetherDestroyed() + if err != nil { + return &protocol.RPCResult{Err: err} + } + + invokers := invoker.directory.List(invocation) + err = invoker.checkInvokers(invokers, invocation) + if err != nil { + return &protocol.RPCResult{Err: err} + } + + var selected []protocol.Invoker + forks := int(invoker.GetUrl().GetParamInt(constant.FORKS_KEY, constant.DEFAULT_FORKS)) + timeouts := invoker.GetUrl().GetParamInt(constant.TIMEOUT_KEY, constant.DEFAULT_TIMEOUT) + if forks < 0 || forks > len(invokers) { + selected = invokers + } else { + selected = make([]protocol.Invoker, 0) + loadbalance := getLoadBalance(invokers[0], invocation) + for i := 0; i < forks; i++ { + ivk := invoker.doSelect(loadbalance, invocation, invokers, selected) + if ivk != nil { + selected = append(selected, ivk) + } + } + } + + resultQ := queue.New(1) + for _, ivk := range selected { + go func(k protocol.Invoker) { + result := k.Invoke(invocation) + err := resultQ.Put(result) + if err != nil { + logger.Errorf("resultQ put failed with exception: %v.\n", err) + } + }(ivk) + } + + rsps, err := resultQ.Poll(1, time.Millisecond*time.Duration(timeouts)) + if err != nil { + return &protocol.RPCResult{ + Err: errors.New(fmt.Sprintf("failed to forking invoke provider %v, but no luck to perform the invocation. Last error is: %s", selected, err.Error()))} + } + if len(rsps) == 0 { + return &protocol.RPCResult{Err: errors.New(fmt.Sprintf("failed to forking invoke provider %v, but no resp", selected))} + } + result, ok := rsps[0].(protocol.Result) + if !ok { + return &protocol.RPCResult{Err: errors.New(fmt.Sprintf("failed to forking invoke provider %v, but not legal resp", selected))} + } + return result +} diff --git a/cluster/cluster_impl/forking_cluster_test.go b/cluster/cluster_impl/forking_cluster_test.go new file mode 100644 index 0000000000000000000000000000000000000000..8603f8aedc4e28a3a4ca2f115355debc1a5ecc62 --- /dev/null +++ b/cluster/cluster_impl/forking_cluster_test.go @@ -0,0 +1,162 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package cluster_impl + +import ( + "context" + "strconv" + "sync" + "testing" + "time" +) + +import ( + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/assert" +) + +import ( + "github.com/apache/dubbo-go/cluster/directory" + "github.com/apache/dubbo-go/cluster/loadbalance" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/protocol" + "github.com/apache/dubbo-go/protocol/invocation" + "github.com/apache/dubbo-go/protocol/mock" +) + +var ( + forkingUrl, _ = common.NewURL(context.TODO(), "dubbo://192.168.1.1:20000/com.ikurento.user.UserProvider") +) + +func registerForking(t *testing.T, mockInvokers ...*mock.MockInvoker) protocol.Invoker { + extension.SetLoadbalance(loadbalance.RoundRobin, loadbalance.NewRoundRobinLoadBalance) + + invokers := []protocol.Invoker{} + for i, ivk := range mockInvokers { + invokers = append(invokers, ivk) + if i == 0 { + ivk.EXPECT().GetUrl().Return(forkingUrl) + } + } + staticDir := directory.NewStaticDirectory(invokers) + + forkingCluster := NewForkingCluster() + clusterInvoker := forkingCluster.Join(staticDir) + return clusterInvoker +} + +func Test_ForkingInvokeSuccess(t *testing.T) { + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + invokers := make([]*mock.MockInvoker, 0) + + mockResult := &protocol.RPCResult{Rest: rest{tried: 0, success: true}} + forkingUrl.AddParam(constant.FORKS_KEY, strconv.Itoa(3)) + //forkingUrl.AddParam(constant.TIMEOUT_KEY, strconv.Itoa(constant.DEFAULT_TIMEOUT)) + + var wg sync.WaitGroup + wg.Add(2) + for i := 0; i < 2; i++ { + invoker := mock.NewMockInvoker(ctrl) + invokers = append(invokers, invoker) + invoker.EXPECT().IsAvailable().Return(true).AnyTimes() + invoker.EXPECT().Invoke(gomock.Any()).DoAndReturn( + func(invocation protocol.Invocation) protocol.Result { + wg.Done() + return mockResult + }) + } + + clusterInvoker := registerForking(t, invokers...) + + result := clusterInvoker.Invoke(&invocation.RPCInvocation{}) + assert.Equal(t, mockResult, result) + wg.Wait() +} + +func Test_ForkingInvokeTimeout(t *testing.T) { + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + invokers := make([]*mock.MockInvoker, 0) + + mockResult := &protocol.RPCResult{Rest: rest{tried: 0, success: true}} + forkingUrl.AddParam(constant.FORKS_KEY, strconv.Itoa(3)) + + var wg sync.WaitGroup + wg.Add(2) + for i := 0; i < 2; i++ { + invoker := mock.NewMockInvoker(ctrl) + invokers = append(invokers, invoker) + invoker.EXPECT().IsAvailable().Return(true).AnyTimes() + invoker.EXPECT().Invoke(gomock.Any()).DoAndReturn( + func(invocation protocol.Invocation) protocol.Result { + time.Sleep(2 * time.Second) + wg.Done() + return mockResult + }) + } + + clusterInvoker := registerForking(t, invokers...) + + result := clusterInvoker.Invoke(&invocation.RPCInvocation{}) + assert.NotNil(t, result) + assert.NotNil(t, result.Error()) + wg.Wait() +} + +func Test_ForkingInvokeHalfTimeout(t *testing.T) { + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + invokers := make([]*mock.MockInvoker, 0) + + mockResult := &protocol.RPCResult{Rest: rest{tried: 0, success: true}} + forkingUrl.AddParam(constant.FORKS_KEY, strconv.Itoa(3)) + + var wg sync.WaitGroup + wg.Add(2) + for i := 0; i < 2; i++ { + invoker := mock.NewMockInvoker(ctrl) + invokers = append(invokers, invoker) + invoker.EXPECT().IsAvailable().Return(true).AnyTimes() + if i == 1 { + invoker.EXPECT().Invoke(gomock.Any()).DoAndReturn( + func(invocation protocol.Invocation) protocol.Result { + wg.Done() + return mockResult + }) + } else { + invoker.EXPECT().Invoke(gomock.Any()).DoAndReturn( + func(invocation protocol.Invocation) protocol.Result { + time.Sleep(2 * time.Second) + wg.Done() + return mockResult + }) + } + } + + clusterInvoker := registerForking(t, invokers...) + + result := clusterInvoker.Invoke(&invocation.RPCInvocation{}) + assert.Equal(t, mockResult, result) + wg.Wait() +} diff --git a/cluster/loadbalance/least_active.go b/cluster/loadbalance/least_active.go index 695ca21b0ed53dcf94907223e4c222af17311db9..39c5620f02d607bb68430e17a206a1649ee31c54 100644 --- a/cluster/loadbalance/least_active.go +++ b/cluster/loadbalance/least_active.go @@ -1,14 +1,19 @@ -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ // @author yiji@apache.org package loadbalance diff --git a/cluster/loadbalance/least_active_test.go b/cluster/loadbalance/least_active_test.go index 7663ea3ce6252dcb7ddeaea92fb6bef8d95478d5..6bc6985678d7c392ad21b49ec341c3550265f622 100644 --- a/cluster/loadbalance/least_active_test.go +++ b/cluster/loadbalance/least_active_test.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package loadbalance import ( diff --git a/cluster/loadbalance/round_robin.go b/cluster/loadbalance/round_robin.go index e173e211c3630f4d4786edc2c1a09709fd7bf0a1..075acac7cdc60086ececb7b655dee86ec5198369 100644 --- a/cluster/loadbalance/round_robin.go +++ b/cluster/loadbalance/round_robin.go @@ -1,15 +1,19 @@ -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package loadbalance diff --git a/common/constant/default.go b/common/constant/default.go index 7ab92249ad742152b385ac7f0aa6e96f37fdb00c..d103c6aadc0f76d4c4d82fedb89ea2f21f5eb7aa 100644 --- a/common/constant/default.go +++ b/common/constant/default.go @@ -26,11 +26,13 @@ const ( ) const ( - DEFAULT_LOADBALANCE = "random" - DEFAULT_RETRIES = 2 - DEFAULT_PROTOCOL = "dubbo" - DEFAULT_REG_TIMEOUT = "10s" - DEFAULT_CLUSTER = "failover" + DEFAULT_LOADBALANCE = "random" + DEFAULT_RETRIES = 2 + DEFAULT_PROTOCOL = "dubbo" + DEFAULT_REG_TIMEOUT = "10s" + DEFAULT_CLUSTER = "failover" + DEFAULT_FAILBACK_TIMES = 3 + DEFAULT_FAILBACK_TASKS = 100 ) const ( diff --git a/common/constant/key.go b/common/constant/key.go index ba86c531c95e02583a0e7e8be9da10ff622136ca..ed60c24b633fa62bbdf5b45931b286c6bbcd932b 100644 --- a/common/constant/key.go +++ b/common/constant/key.go @@ -46,6 +46,11 @@ const ( WEIGHT_KEY = "weight" WARMUP_KEY = "warmup" RETRIES_KEY = "retries" + BEAN_NAME = "bean.name" + FAIL_BACK_TASKS_KEY = "failbacktasks" + FORKS_KEY = "forks" + DEFAULT_FORKS = 2 + DEFAULT_TIMEOUT = 1000 ) const ( @@ -85,3 +90,15 @@ const ( ProviderConfigPrefix = "dubbo.provider." ConsumerConfigPrefix = "dubbo.consumer." ) + +const ( + NACOS_KEY = "nacos" + NACOS_DEFAULT_ROLETYPE = 3 + NACOS_CACHE_DIR_KEY = "cacheDir" + NACOS_LOG_DIR_KEY = "logDir" + NACOS_ENDPOINT = "endpoint" + NACOS_SERVICE_NAME_SEPARATOR = ":" + NACOS_CATEGORY_KEY = "category" + NACOS_PROTOCOL_KEY = "protocol" + NACOS_PATH_KEY = "path" +) diff --git a/version/version.go b/common/constant/version.go similarity index 98% rename from version/version.go rename to common/constant/version.go index b9a076e78cbf0c9c7b5172e1b30c84f60f250ea7..d4c6821e76894cbd82dc5fae09124263b5c6aa0f 100644 --- a/version/version.go +++ b/common/constant/version.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package version +package constant const ( Version = "2.6.0" diff --git a/common/url.go b/common/url.go index c594df235134d71d98b83c11b2f6eb9312283aae..6431ee12995a95848c6f3369c490bc5dbf07bb6b 100644 --- a/common/url.go +++ b/common/url.go @@ -27,6 +27,7 @@ import ( "net/url" "strconv" "strings" + "sync" ) import ( @@ -64,10 +65,12 @@ func (t RoleType) Role() string { } type baseUrl struct { - Protocol string - Location string // ip+port - Ip string - Port string + Protocol string + Location string // ip+port + Ip string + Port string + //url.Values is not safe map, add to avoid concurrent map read and map write error + paramsLock sync.RWMutex Params url.Values PrimitiveURL string ctx context.Context @@ -108,16 +111,19 @@ func WithParams(params url.Values) option { url.Params = params } } + func WithParamsValue(key, val string) option { return func(url *URL) { url.Params.Set(key, val) } } + func WithProtocol(proto string) option { return func(url *URL) { url.Protocol = proto } } + func WithIp(ip string) option { return func(url *URL) { url.Ip = ip @@ -141,6 +147,7 @@ func WithLocation(location string) option { url.Location = location } } + func NewURLWithOptions(opts ...option) *URL { url := &URL{} for _, opt := range opts { @@ -283,14 +290,18 @@ func (c URL) Service() string { } func (c *URL) AddParam(key string, value string) { + c.paramsLock.Lock() c.Params.Add(key, value) + c.paramsLock.Unlock() } func (c URL) GetParam(s string, d string) string { var r string - if r = c.Params.Get(s); r == "" { + c.paramsLock.RLock() + if r = c.Params.Get(s); len(r) == 0 { r = d } + c.paramsLock.RUnlock() return r } func (c URL) GetParamAndDecoded(key string) (string, error) { diff --git a/config/config_loader.go b/config/config_loader.go index 720f65f5de6b24b445b7ce07dd2daaba0a856681..c5127c8c43622e7b26c998eb54e1b1803e6575ec 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -28,7 +28,6 @@ import ( "github.com/apache/dubbo-go/common" "github.com/apache/dubbo-go/common/constant" "github.com/apache/dubbo-go/common/logger" - "github.com/apache/dubbo-go/version" ) var ( @@ -37,8 +36,8 @@ var ( maxWait = 3 ) -// loaded comsumer & provider config from xxx.yml, and log config from xxx.xml -// Namely: dubbo.comsumer.xml & dubbo.provider.xml in java dubbo +// loaded consumer & provider config from xxx.yml, and log config from xxx.xml +// Namely: dubbo.consumer.xml & dubbo.provider.xml in java dubbo func init() { var ( confConFile, confProFile string @@ -71,9 +70,8 @@ func Load() { SetConsumerService(genericService) } rpcService := GetConsumerService(key) - if rpcService == nil { - logger.Warnf("%s is not exsist!", key) + logger.Warnf("%s does not exist!", key) continue } ref.id = key @@ -94,13 +92,13 @@ func Load() { checkok = false count++ if count > maxWait { - panic(fmt.Sprintf("Failed to check the status of the service %v . No provider available for the service to the consumer use dubbo version %v", refconfig.InterfaceName, version.Version)) + panic(fmt.Sprintf("Failed to check the status of the service %v . No provider available for the service to the consumer use dubbo version %v", refconfig.InterfaceName, constant.Version)) } time.Sleep(time.Second * 1) break } if refconfig.invoker == nil { - logger.Warnf("The interface %s invoker not exsist , may you should check your interface config.", refconfig.InterfaceName) + logger.Warnf("The interface %s invoker not exist , may you should check your interface config.", refconfig.InterfaceName) } } } @@ -121,7 +119,7 @@ func Load() { for key, svs := range providerConfig.Services { rpcService := GetProviderService(key) if rpcService == nil { - logger.Warnf("%s is not exsist!", key) + logger.Warnf("%s does not exist!", key) continue } svs.id = key diff --git a/config/consumer_config.go b/config/consumer_config.go index 737339a0ad195201327eb4fac3445b18eb4bbf26..55082ffe41ad0a38ccbb6c2e788f0b609a8b4ef8 100644 --- a/config/consumer_config.go +++ b/config/consumer_config.go @@ -52,6 +52,7 @@ type ConsumerConfig struct { Registries map[string]*RegistryConfig `yaml:"registries" json:"registries,omitempty" property:"registries"` References map[string]*ReferenceConfig `yaml:"references" json:"references,omitempty" property:"references"` ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol_conf,omitempty" property:"protocol_conf"` + FilterConf interface{} `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf" ` } func (*ConsumerConfig) Prefix() string { diff --git a/config/provider_config.go b/config/provider_config.go index a504eea237dc47f66c4ed27d334ce5eea5c87d45..db8abaf73e9609b3f3ac1db68e89a3d66068659b 100644 --- a/config/provider_config.go +++ b/config/provider_config.go @@ -46,6 +46,7 @@ type ProviderConfig struct { Services map[string]*ServiceConfig `yaml:"services" json:"services,omitempty" property:"services"` Protocols map[string]*ProtocolConfig `yaml:"protocols" json:"protocols,omitempty" property:"protocols"` ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol_conf,omitempty" property:"protocol_conf" ` + FilterConf interface{} `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf" ` } func (*ProviderConfig) Prefix() string { diff --git a/config/reference_config.go b/config/reference_config.go index 67a4a3d816060475fa49182f7141aba9807849e1..f90e3aabd3a68b8dc7a7509331d301ea3a252f92 100644 --- a/config/reference_config.go +++ b/config/reference_config.go @@ -158,6 +158,7 @@ func (refconfig *ReferenceConfig) getUrlMap() url.Values { urlMap.Set(constant.GROUP_KEY, refconfig.Group) urlMap.Set(constant.VERSION_KEY, refconfig.Version) urlMap.Set(constant.GENERIC_KEY, strconv.FormatBool(refconfig.Generic)) + urlMap.Set(constant.ROLE_KEY, strconv.Itoa(common.CONSUMER)) //getty invoke async or sync urlMap.Set(constant.ASYNC_KEY, strconv.FormatBool(refconfig.async)) diff --git a/config/reference_config_test.go b/config/reference_config_test.go index 296cde65fad6017b930ef06e0045a45b4af27c86..d36fa04d7461cfb6cd4c9d2d739e9863355df077 100644 --- a/config/reference_config_test.go +++ b/config/reference_config_test.go @@ -29,6 +29,7 @@ import ( import ( "github.com/apache/dubbo-go/cluster/cluster_impl" "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" "github.com/apache/dubbo-go/common/extension" "github.com/apache/dubbo-go/protocol" ) @@ -82,6 +83,7 @@ func doInit() { "MockService": { Params: map[string]string{ "serviceid": "soa.mock", + "forks": "5", }, Registry: "shanghai_reg1,shanghai_reg2,hangzhou_reg1,hangzhou_reg2", InterfaceName: "com.MockService", @@ -190,6 +192,23 @@ func Test_Implement(t *testing.T) { consumerConfig = nil } +func Test_Forking(t *testing.T) { + doInit() + extension.SetProtocol("dubbo", GetProtocol) + extension.SetProtocol("registry", GetProtocol) + m := consumerConfig.References["MockService"] + m.Url = "dubbo://127.0.0.1:20000;registry://127.0.0.2:20000" + + for _, reference := range consumerConfig.References { + reference.Refer() + forks := int(reference.invoker.GetUrl().GetParamInt(constant.FORKS_KEY, constant.DEFAULT_FORKS)) + assert.Equal(t, 5, forks) + assert.NotNil(t, reference.pxy) + assert.NotNil(t, reference.Cluster) + } + consumerConfig = nil +} + func GetProtocol() protocol.Protocol { if regProtocol != nil { return regProtocol diff --git a/config/registry_config.go b/config/registry_config.go index 3d54c348aadd2a2f836849d12e50887c36909d31..0abdab810f3cfa835f7d1f21e395cd2a2812a051 100644 --- a/config/registry_config.go +++ b/config/registry_config.go @@ -36,9 +36,10 @@ type RegistryConfig struct { TimeoutStr string `yaml:"timeout" default:"5s" json:"timeout,omitempty" property:"timeout"` // unit: second Group string `yaml:"group" json:"group,omitempty" property:"group"` //for registry - Address string `yaml:"address" json:"address,omitempty" property:"address"` - Username string `yaml:"username" json:"username,omitempty" property:"username"` - Password string `yaml:"password" json:"password,omitempty" property:"password"` + Address string `yaml:"address" json:"address,omitempty" property:"address"` + Username string `yaml:"username" json:"username,omitempty" property:"username"` + Password string `yaml:"password" json:"password,omitempty" property:"password"` + Params map[string]string `yaml:"params" json:"params,omitempty" property:"params"` } func (*RegistryConfig) Prefix() string { @@ -109,6 +110,8 @@ func (regconfig *RegistryConfig) getUrlMap(roleType common.RoleType) url.Values urlMap.Set(constant.ROLE_KEY, strconv.Itoa(int(roleType))) urlMap.Set(constant.REGISTRY_KEY, regconfig.Protocol) urlMap.Set(constant.REGISTRY_TIMEOUT_KEY, regconfig.TimeoutStr) - + for k, v := range regconfig.Params { + urlMap.Set(k, v) + } return urlMap } diff --git a/config/service_config.go b/config/service_config.go index 76913319f6f0ac27ec36ebaa2d89db09bbd79c7c..8b4a7d1b2251be206085a54a8676944aa3158609 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -163,6 +163,7 @@ func (srvconfig *ServiceConfig) getUrlMap() url.Values { urlMap.Set(constant.RETRIES_KEY, strconv.FormatInt(srvconfig.Retries, 10)) urlMap.Set(constant.GROUP_KEY, srvconfig.Group) urlMap.Set(constant.VERSION_KEY, srvconfig.Version) + urlMap.Set(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER)) //application info urlMap.Set(constant.APPLICATION_KEY, providerConfig.ApplicationConfig.Name) urlMap.Set(constant.ORGANIZATION_KEY, providerConfig.ApplicationConfig.Organization) diff --git a/config/testdata/consumer_config.yml b/config/testdata/consumer_config.yml index 373871dccbc6c3f7272b7abcb1a9a104c8f13090..372873abbb258e03acfe8e9e00d03aa2f77fb9a9 100644 --- a/config/testdata/consumer_config.yml +++ b/config/testdata/consumer_config.yml @@ -47,6 +47,7 @@ references: params: "serviceid": "soa.com.ikurento.user.UserProvider" + "forks": 5 protocol_conf: dubbo: diff --git a/config_center/zookeeper/impl.go b/config_center/zookeeper/impl.go index ef0761efcd0d2cee47425dd5e1099200d3be6a70..f2827b2bb693fc1943116686f8056c0edaeadc99 100644 --- a/config_center/zookeeper/impl.go +++ b/config_center/zookeeper/impl.go @@ -196,7 +196,7 @@ func (r *zookeeperDynamicConfiguration) closeConfigs() { r.cltLock.Lock() defer r.cltLock.Unlock() logger.Infof("begin to close provider zk client") - // 鍏堝叧闂棫client锛屼互鍏抽棴tmp node + // Close the old client first to close the tmp node r.client.Close() r.client = nil } diff --git a/config_center/zookeeper/zookeeper-4unitest/contrib/fatjar/zookeeper-3.4.9-fatjar.jar b/config_center/zookeeper/zookeeper-4unitest/contrib/fatjar/zookeeper-3.4.9-fatjar.jar deleted file mode 100644 index 839531b8b8762a9c19e334a5cbf79314cb16f945..0000000000000000000000000000000000000000 Binary files a/config_center/zookeeper/zookeeper-4unitest/contrib/fatjar/zookeeper-3.4.9-fatjar.jar and /dev/null differ diff --git a/dubbogo.png b/dubbogo.png new file mode 100644 index 0000000000000000000000000000000000000000..2cac434091276df102c3ae405c09621b8d8926ef Binary files /dev/null and b/dubbogo.png differ diff --git a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/app/client.go b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/app/client.go index fb2e0ef7ec4cc82e681ff8d352a8f45276ccfd99..44ffbd98f691d6ffef0485bc54159662662f8b16 100644 --- a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/app/client.go +++ b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/app/client.go @@ -27,7 +27,7 @@ import ( ) import ( - "github.com/apache/dubbo-go-hessian2" + hessian "github.com/apache/dubbo-go-hessian2" ) import ( @@ -135,12 +135,12 @@ func initSignal() { case syscall.SIGHUP: // reload() default: - go time.AfterFunc(time.Duration(survivalTimeout)*time.Second, func() { + time.AfterFunc(time.Duration(survivalTimeout)*time.Second, func() { logger.Warnf("app exit now by force...") os.Exit(1) }) - // 瑕佷箞fastFailTimeout鏃堕棿鍐呮墽琛屽畬姣曚笅闈㈢殑閫昏緫鐒跺悗绋嬪簭閫€鍑猴紝瑕佷箞鎵ц涓婇潰鐨勮秴鏃跺嚱鏁扮▼搴忓己琛岄€€鍑� + // The program exits normally or timeout forcibly exits. fmt.Println("app exit now...") return } diff --git a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/app/user.go b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/app/user.go index 8140acaef621f361e5b35fa90318d73546902913..5bddf1e19f59be1b7fae917cffddfde4d362f44e 100644 --- a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/app/user.go +++ b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/app/user.go @@ -83,7 +83,7 @@ type User struct { Name string Age int32 Time time.Time - Sex Gender // 娉ㄦ剰姝ゅ锛宩ava enum Object <--> go string + Sex Gender // notice: java enum Object <--> go string } func (u User) String() string { diff --git a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/bin/load.sh b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/bin/load.sh index 07d5d15eac7b7974845e36c3807e7ec55875de65..ffa240b29d9e76761a151e7462092b86908de6f6 100644 --- a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/bin/load.sh +++ b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/bin/load.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : dubbogo app devops script -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-05-13 02:01 -# FILE : load.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + APP_NAME="APPLICATION_NAME" APP_ARGS="" diff --git a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/common/app.properties b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/common/app.properties index 6bbd6db850ceeaf5ff873fee01a3578237cbd557..e10868f4d292765c7eeb2e8bb8b1684a44f56a14 100644 --- a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/common/app.properties +++ b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/common/app.properties @@ -1,13 +1,19 @@ -# dubbogo application configure script -# ****************************************************** -# DESC : dubbogo environment variable -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:29 -# FILE : app.properties -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + export TARGET_EXEC_NAME="user_info_client" # BUILD_PACKAGE="dubbogo-examples/user-info/client/app" diff --git a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/common/build.sh b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/common/build.sh index e72418297ad2f0ac6985476b5a8d5e03b9e7584e..c9a9e87c73ef45195d6f70acccf9374ee6cb906b 100644 --- a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/common/build.sh +++ b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/common/build.sh @@ -1,13 +1,19 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:28 -# FILE : build.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. rm -rf target/ diff --git a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/linux/dev.sh b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/linux/dev.sh index 3373f01b948b708cd7bc1958c9d56a9042c60a68..eada737c8d0939d4237a6d218fc2a07efdbff381 100644 --- a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/linux/dev.sh +++ b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/linux/dev.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for dev env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2017-10-18 13:24 -# FILE : dev.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/linux/release.sh b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/linux/release.sh index 34867b8b3488778cd76a1dc7802393dcab6b0df0..10eb3d73f8760d394537b90b7aeff83ca2b243ed 100644 --- a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/linux/release.sh +++ b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/linux/release.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for release env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:34 -# FILE : test.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/linux/test.sh b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/linux/test.sh index 1bbbefd1e14e08c16deaf859e2841f4d1fe88e9c..78b650c0d49483f9f6862532afa5c483b618475a 100644 --- a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/linux/test.sh +++ b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/linux/test.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for test env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:34 -# FILE : test.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/mac/dev.sh b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/mac/dev.sh index b68ac83b6524a6713cd90c4fc5968fe64b1a9545..c8284769909e62f0142c29e3a63177bf2826593f 100644 --- a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/mac/dev.sh +++ b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/mac/dev.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for dev env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2017-10-18 13:24 -# FILE : dev.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/mac/release.sh b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/mac/release.sh index 688288b3b1b989e8af70a3674b34ea8e0668f3b4..91c2dfee79b1499b640420191174f980eac187bb 100644 --- a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/mac/release.sh +++ b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/mac/release.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for release env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:34 -# FILE : test.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/mac/test.sh b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/mac/test.sh index 56d6c11ecd6a1dc5984c74b88c10be9239e57428..a7853f5e2d51df8e3e9509621952c44bca0d1a2d 100644 --- a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/mac/test.sh +++ b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/mac/test.sh @@ -1,13 +1,19 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for test env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:34 -# FILE : test.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. set -e diff --git a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/windows/dev.sh b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/windows/dev.sh index 91cf6f23bcbecb26db798469a30529261aabbbb6..10a3866c0f4ed8e1070c4d5641259c04073df6cb 100644 --- a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/windows/dev.sh +++ b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/windows/dev.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for dev env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2017-10-18 13:24 -# FILE : dev.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/windows/release.sh b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/windows/release.sh index f317720bd53d9c9e5f8f484b6eb682c9c736af0c..21af573fa3842d47959d5726b11b81d5fff5b8df 100644 --- a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/windows/release.sh +++ b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/windows/release.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for release env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:34 -# FILE : test.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/windows/test.sh b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/windows/test.sh index 7dd2bec5260e647b57a46aaa37acc098babff068..2104da8b5909957c165eedc2f7d6866a890e9e6d 100644 --- a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/windows/test.sh +++ b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-client/assembly/windows/test.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for test env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:34 -# FILE : test.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/app/server.go b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/app/server.go index 814978566774c449e058c7f0d4e73176f5a1f57b..04c614d732d3ed39d921796050249907fbc530d5 100644 --- a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/app/server.go +++ b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/app/server.go @@ -73,12 +73,12 @@ func initSignal() { case syscall.SIGHUP: // reload() default: - go time.AfterFunc(time.Duration(float64(survivalTimeout)*float64(time.Second)), func() { + time.AfterFunc(time.Duration(float64(survivalTimeout)*float64(time.Second)), func() { logger.Warnf("app exit now by force...") os.Exit(1) }) - // 瑕佷箞fastFailTimeout鏃堕棿鍐呮墽琛屽畬姣曚笅闈㈢殑閫昏緫鐒跺悗绋嬪簭閫€鍑猴紝瑕佷箞鎵ц涓婇潰鐨勮秴鏃跺嚱鏁扮▼搴忓己琛岄€€鍑� + // The program exits normally or timeout forcibly exits. fmt.Println("provider app exit now...") return } diff --git a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/app/user.go b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/app/user.go index d0ac61e4c41e805dbcadc30238993e3946da7cd0..0e4d05766887ae41440313b49ba4dc859a09ed35 100644 --- a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/app/user.go +++ b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/app/user.go @@ -84,7 +84,7 @@ type ( Name string Age int32 Time time.Time - Sex Gender // 娉ㄦ剰姝ゅ锛宩ava enum Object <--> go string + Sex Gender // notice: java enum Object <--> go string } UserProvider struct { diff --git a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/bin/load.sh b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/bin/load.sh index 47fc5e38ded155a43c30b8cbf4d2a5ae04b58d0c..90077c2471d7d5553ddea6402c7e2c06867cba8e 100644 --- a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/bin/load.sh +++ b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/bin/load.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : dubbogo app devops script -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-05-13 02:01 -# FILE : load.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + APP_NAME="APPLICATION_NAME" APP_ARGS="" diff --git a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/common/app.properties b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/common/app.properties index dffb755b0811dd140d3f04e232f5f80ff60181df..1f0827eb512b9bcb3c2428f8e0b50d76f65743ef 100644 --- a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/common/app.properties +++ b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/common/app.properties @@ -1,13 +1,19 @@ -# dubbogo application configure script -# ****************************************************** -# DESC : application environment variable -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:29 -# FILE : app.properties -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + TARGET_EXEC_NAME="user_info_server" # BUILD_PACKAGE="dubbogo-examples/user-info/server/app" diff --git a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/common/build.sh b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/common/build.sh index 15ac904f7c265d942d7018439719af7e7391aa41..89a95ce679ca711824a2de0888686be79d96f505 100644 --- a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/common/build.sh +++ b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/common/build.sh @@ -1,13 +1,19 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:28 -# FILE : build.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. rm -rf target/ diff --git a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/linux/dev.sh b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/linux/dev.sh index 55886f09fb4873be84cfa46aae592f5f000120a4..d830ac98c2b9328791d00d5160d487b1a12b5fed 100644 --- a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/linux/dev.sh +++ b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/linux/dev.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for dev env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2018-06-24 17:32 -# FILE : dev.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/linux/release.sh b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/linux/release.sh index 9772ad9614583917d62beba2db9fcaefea63e1ed..99303800b0fbcd7f8dfea668dcf395f126fb99f6 100644 --- a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/linux/release.sh +++ b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/linux/release.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for release env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:25 -# FILE : release.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/linux/test.sh b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/linux/test.sh index 2fc4a98862bee5ef11a23e1b74058627a899181d..87144bb973095acaf8c17b0ec3bf42f643d0b95f 100644 --- a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/linux/test.sh +++ b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/linux/test.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for test env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:34 -# FILE : test.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/mac/dev.sh b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/mac/dev.sh index 5dfa78490b895ce556c809ead32b6f517a5f1450..3a7659b2d57e0e2502950d76ec6c938abf2b7513 100644 --- a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/mac/dev.sh +++ b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/mac/dev.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for dev env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2018-06-24 17:32 -# FILE : dev.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/mac/release.sh b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/mac/release.sh index 1ec21c7b511ccce9eddfac22a2374b57a7a697bf..1c4bce4bf825fe401823ec33025e004a476ccaaf 100644 --- a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/mac/release.sh +++ b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/mac/release.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for release env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:25 -# FILE : release.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/mac/test.sh b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/mac/test.sh index d34914c7dbed0e442b4accf51a3ecdf7c2984db8..69206e32fed343eb87c04190b509b16482125542 100644 --- a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/mac/test.sh +++ b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/mac/test.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for release env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:25 -# FILE : release.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/windows/dev.sh b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/windows/dev.sh index 97fbb6f698e500ad08d971b13cc1ffd00cd97803..011fb41148f205bc329118a3c75e52854c0ecfd3 100644 --- a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/windows/dev.sh +++ b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/windows/dev.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for dev env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2018-06-24 17:34 -# FILE : dev.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/windows/release.sh b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/windows/release.sh index 782cb10c7828eb277b5905f10f8dd6ad1c2d6bed..679a26a7dc77a9bc0ccbf119eac3caba252cadc9 100644 --- a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/windows/release.sh +++ b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/windows/release.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for release env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:25 -# FILE : release.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/windows/test.sh b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/windows/test.sh index 2037ddecf2545f1543d5d28be728fb0899722098..4a36de0f3a26b804601de703c62a8062bd0623f4 100644 --- a/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/windows/test.sh +++ b/examples/configcenter/zookeeper/dubbo/with-configcenter-go-server/assembly/windows/test.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for test env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:34 -# FILE : test.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/app/client.go b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/app/client.go index 642b45a9343477086300ccb78d56756fbf51a817..db76d939a1a7e2bd5ae04b5968dd5af7aaf69a2e 100644 --- a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/app/client.go +++ b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/app/client.go @@ -120,12 +120,12 @@ func initSignal() { case syscall.SIGHUP: // reload() default: - go time.AfterFunc(time.Duration(survivalTimeout)*time.Second, func() { + time.AfterFunc(time.Duration(survivalTimeout)*time.Second, func() { logger.Warnf("app exit now by force...") os.Exit(1) }) - // 瑕佷箞fastFailTimeout鏃堕棿鍐呮墽琛屽畬姣曚笅闈㈢殑閫昏緫鐒跺悗绋嬪簭閫€鍑猴紝瑕佷箞鎵ц涓婇潰鐨勮秴鏃跺嚱鏁扮▼搴忓己琛岄€€鍑� + // The program exits normally or timeout forcibly exits. fmt.Println("app exit now...") return } diff --git a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/bin/load.sh b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/bin/load.sh index 07d5d15eac7b7974845e36c3807e7ec55875de65..ffa240b29d9e76761a151e7462092b86908de6f6 100644 --- a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/bin/load.sh +++ b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/bin/load.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : dubbogo app devops script -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-05-13 02:01 -# FILE : load.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + APP_NAME="APPLICATION_NAME" APP_ARGS="" diff --git a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/common/app.properties b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/common/app.properties index 6bbd6db850ceeaf5ff873fee01a3578237cbd557..e10868f4d292765c7eeb2e8bb8b1684a44f56a14 100644 --- a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/common/app.properties +++ b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/common/app.properties @@ -1,13 +1,19 @@ -# dubbogo application configure script -# ****************************************************** -# DESC : dubbogo environment variable -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:29 -# FILE : app.properties -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + export TARGET_EXEC_NAME="user_info_client" # BUILD_PACKAGE="dubbogo-examples/user-info/client/app" diff --git a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/common/build.sh b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/common/build.sh index 06b212db6c3dcc28e5e43666284662bcb7abcae4..c9a9e87c73ef45195d6f70acccf9374ee6cb906b 100644 --- a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/common/build.sh +++ b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/common/build.sh @@ -1,13 +1,19 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:28 -# FILE : build.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. rm -rf target/ @@ -15,7 +21,7 @@ PROJECT_HOME=`pwd` TARGET_FOLDER=${PROJECT_HOME}/target/${GOOS} TARGET_SBIN_NAME=${TARGET_EXEC_NAME} -version=`cat app/version.go | grep Version | grep -v "Apache" | awk -F '=' '{print $2}' | awk -F '"' '{print $2}'` +version=`cat app/version.go | grep Version | grep -v "Apache" | awk -F '=' '{print $2}' | awk -F '"' '{print $2}'` if [[ ${GOOS} == "windows" ]]; then TARGET_SBIN_NAME=${TARGET_SBIN_NAME}.exe fi diff --git a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/linux/dev.sh b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/linux/dev.sh index 3373f01b948b708cd7bc1958c9d56a9042c60a68..eada737c8d0939d4237a6d218fc2a07efdbff381 100644 --- a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/linux/dev.sh +++ b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/linux/dev.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for dev env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2017-10-18 13:24 -# FILE : dev.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/linux/release.sh b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/linux/release.sh index 34867b8b3488778cd76a1dc7802393dcab6b0df0..10eb3d73f8760d394537b90b7aeff83ca2b243ed 100644 --- a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/linux/release.sh +++ b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/linux/release.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for release env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:34 -# FILE : test.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/linux/test.sh b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/linux/test.sh index 1bbbefd1e14e08c16deaf859e2841f4d1fe88e9c..78b650c0d49483f9f6862532afa5c483b618475a 100644 --- a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/linux/test.sh +++ b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/linux/test.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for test env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:34 -# FILE : test.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/mac/dev.sh b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/mac/dev.sh index b68ac83b6524a6713cd90c4fc5968fe64b1a9545..c8284769909e62f0142c29e3a63177bf2826593f 100644 --- a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/mac/dev.sh +++ b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/mac/dev.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for dev env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2017-10-18 13:24 -# FILE : dev.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/mac/release.sh b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/mac/release.sh index 688288b3b1b989e8af70a3674b34ea8e0668f3b4..91c2dfee79b1499b640420191174f980eac187bb 100644 --- a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/mac/release.sh +++ b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/mac/release.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for release env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:34 -# FILE : test.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/mac/test.sh b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/mac/test.sh index 56d6c11ecd6a1dc5984c74b88c10be9239e57428..a7853f5e2d51df8e3e9509621952c44bca0d1a2d 100644 --- a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/mac/test.sh +++ b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/mac/test.sh @@ -1,13 +1,19 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for test env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:34 -# FILE : test.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. set -e diff --git a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/windows/dev.sh b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/windows/dev.sh index 91cf6f23bcbecb26db798469a30529261aabbbb6..10a3866c0f4ed8e1070c4d5641259c04073df6cb 100644 --- a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/windows/dev.sh +++ b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/windows/dev.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for dev env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2017-10-18 13:24 -# FILE : dev.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/windows/release.sh b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/windows/release.sh index f317720bd53d9c9e5f8f484b6eb682c9c736af0c..21af573fa3842d47959d5726b11b81d5fff5b8df 100644 --- a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/windows/release.sh +++ b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/windows/release.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for release env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:34 -# FILE : test.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/windows/test.sh b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/windows/test.sh index 7dd2bec5260e647b57a46aaa37acc098babff068..2104da8b5909957c165eedc2f7d6866a890e9e6d 100644 --- a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/windows/test.sh +++ b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-client/assembly/windows/test.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for test env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:34 -# FILE : test.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/app/server.go b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/app/server.go index 851a97c15543961ad29784de449fe1ee56adc9c9..23cfd415533cf81b900be1982b9ceae567a845f3 100644 --- a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/app/server.go +++ b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/app/server.go @@ -62,12 +62,12 @@ func initSignal() { case syscall.SIGHUP: // reload() default: - go time.AfterFunc(time.Duration(float64(survivalTimeout)*float64(time.Second)), func() { + time.AfterFunc(time.Duration(float64(survivalTimeout)*float64(time.Second)), func() { logger.Warnf("app exit now by force...") os.Exit(1) }) - // 瑕佷箞fastFailTimeout鏃堕棿鍐呮墽琛屽畬姣曚笅闈㈢殑閫昏緫鐒跺悗绋嬪簭閫€鍑猴紝瑕佷箞鎵ц涓婇潰鐨勮秴鏃跺嚱鏁扮▼搴忓己琛岄€€鍑� + // The program exits normally or timeout forcibly exits. fmt.Println("provider app exit now...") return } diff --git a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/bin/load.sh b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/bin/load.sh index 47fc5e38ded155a43c30b8cbf4d2a5ae04b58d0c..90077c2471d7d5553ddea6402c7e2c06867cba8e 100644 --- a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/bin/load.sh +++ b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/bin/load.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : dubbogo app devops script -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-05-13 02:01 -# FILE : load.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + APP_NAME="APPLICATION_NAME" APP_ARGS="" diff --git a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/common/app.properties b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/common/app.properties index dffb755b0811dd140d3f04e232f5f80ff60181df..1f0827eb512b9bcb3c2428f8e0b50d76f65743ef 100644 --- a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/common/app.properties +++ b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/common/app.properties @@ -1,13 +1,19 @@ -# dubbogo application configure script -# ****************************************************** -# DESC : application environment variable -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:29 -# FILE : app.properties -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + TARGET_EXEC_NAME="user_info_server" # BUILD_PACKAGE="dubbogo-examples/user-info/server/app" diff --git a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/common/build.sh b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/common/build.sh index 15ac904f7c265d942d7018439719af7e7391aa41..89a95ce679ca711824a2de0888686be79d96f505 100644 --- a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/common/build.sh +++ b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/common/build.sh @@ -1,13 +1,19 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:28 -# FILE : build.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. rm -rf target/ diff --git a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/linux/dev.sh b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/linux/dev.sh index 55886f09fb4873be84cfa46aae592f5f000120a4..d830ac98c2b9328791d00d5160d487b1a12b5fed 100644 --- a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/linux/dev.sh +++ b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/linux/dev.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for dev env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2018-06-24 17:32 -# FILE : dev.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/linux/release.sh b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/linux/release.sh index 9772ad9614583917d62beba2db9fcaefea63e1ed..99303800b0fbcd7f8dfea668dcf395f126fb99f6 100644 --- a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/linux/release.sh +++ b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/linux/release.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for release env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:25 -# FILE : release.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/linux/test.sh b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/linux/test.sh index 2fc4a98862bee5ef11a23e1b74058627a899181d..87144bb973095acaf8c17b0ec3bf42f643d0b95f 100644 --- a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/linux/test.sh +++ b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/linux/test.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for test env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:34 -# FILE : test.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/mac/dev.sh b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/mac/dev.sh index 5dfa78490b895ce556c809ead32b6f517a5f1450..3a7659b2d57e0e2502950d76ec6c938abf2b7513 100644 --- a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/mac/dev.sh +++ b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/mac/dev.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for dev env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2018-06-24 17:32 -# FILE : dev.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/mac/release.sh b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/mac/release.sh index 1ec21c7b511ccce9eddfac22a2374b57a7a697bf..1c4bce4bf825fe401823ec33025e004a476ccaaf 100644 --- a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/mac/release.sh +++ b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/mac/release.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for release env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:25 -# FILE : release.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/mac/test.sh b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/mac/test.sh index d34914c7dbed0e442b4accf51a3ecdf7c2984db8..69206e32fed343eb87c04190b509b16482125542 100644 --- a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/mac/test.sh +++ b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/mac/test.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for release env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:25 -# FILE : release.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/windows/dev.sh b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/windows/dev.sh index 97fbb6f698e500ad08d971b13cc1ffd00cd97803..011fb41148f205bc329118a3c75e52854c0ecfd3 100644 --- a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/windows/dev.sh +++ b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/windows/dev.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for dev env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2018-06-24 17:34 -# FILE : dev.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/windows/release.sh b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/windows/release.sh index 782cb10c7828eb277b5905f10f8dd6ad1c2d6bed..679a26a7dc77a9bc0ccbf119eac3caba252cadc9 100644 --- a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/windows/release.sh +++ b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/windows/release.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for release env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:25 -# FILE : release.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/windows/test.sh b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/windows/test.sh index 2037ddecf2545f1543d5d28be728fb0899722098..4a36de0f3a26b804601de703c62a8062bd0623f4 100644 --- a/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/windows/test.sh +++ b/examples/configcenter/zookeeper/jsonrpc/with-configcenter-go-server/assembly/windows/test.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for test env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:34 -# FILE : test.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/consul/README.md b/examples/consul/README.md new file mode 100644 index 0000000000000000000000000000000000000000..bb475526e8c1ccc6c9cc2365caa2a06b2f69d997 --- /dev/null +++ b/examples/consul/README.md @@ -0,0 +1,44 @@ +# consul + +Examples for consul registry. Before running examples below, make sure that consul has been started. + +## requirement + +- consul +- go 1.12 +- java 8 +- maven 3.6.1 + +## go-server + +``` +$ cd examples/consul/go-server +$ export CONF_PROVIDER_FILE_PATH="config/server.yml" +$ export APP_LOG_CONF_FILE="config/log.yml" +$ go run . +``` + +## go-client + +``` +$ cd examples/consul/go-client +$ export CONF_CONSUMER_FILE_PATH="config/client.yml" +$ export APP_LOG_CONF_FILE="config/log.yml" +$ go run . +``` + +## java-server + +``` +$ cd examples/consul/java-server +$ mvn clean package +$ java -jar target/java-server-1.0.0.jar +``` + +## java-client + +``` +$ cd examples/consul/java-client +$ mvn clean package +$ java -jar target/java-client-1.0.0.jar +``` \ No newline at end of file diff --git a/examples/consul/go-client/client.go b/examples/consul/go-client/client.go new file mode 100644 index 0000000000000000000000000000000000000000..73a9bc9c3cddb7fc23cae2cd8d776bc68ef26af8 --- /dev/null +++ b/examples/consul/go-client/client.go @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package main + +import ( + "fmt" +) + +import ( + _ "github.com/apache/dubbo-go/cluster/cluster_impl" + _ "github.com/apache/dubbo-go/cluster/loadbalance" + _ "github.com/apache/dubbo-go/common/proxy/proxy_factory" + "github.com/apache/dubbo-go/config" + _ "github.com/apache/dubbo-go/filter/impl" + _ "github.com/apache/dubbo-go/protocol/dubbo" + _ "github.com/apache/dubbo-go/registry/consul" + _ "github.com/apache/dubbo-go/registry/protocol" +) + +func main() { + config.Load() + + message, err := dubboService.SayHello([]interface{}{"world"}) + if err != nil { + panic(err) + } + fmt.Println(message) +} diff --git a/examples/consul/go-client/config/client.yml b/examples/consul/go-client/config/client.yml new file mode 100644 index 0000000000000000000000000000000000000000..8a7458c384bc80b5096aa1b3496f9f1430753a07 --- /dev/null +++ b/examples/consul/go-client/config/client.yml @@ -0,0 +1,52 @@ +application_config: + organization : "ikurento.com" + name : "BDTService" + module : "dubbogo user-info client" + version : "0.0.1" + owner : "ZX" + environment : "test" + +registries : + "consul": + protocol: "consul" + timeout : "3s" + address: "127.0.0.1:8500" + username: "" + password: "" + +references: + "DubboService": + protocol : "dubbo" + interface : "dubbo.DubboService" + cluster: "failover" + methods : + - name: "SayHello" + retries: 3 + +protocol_conf: + dubbo: + reconnect_interval: 0 + connection_number: 2 + heartbeat_period: "5s" + session_timeout: "20s" + fail_fast_timeout: "5s" + pool_size: 64 + pool_ttl: 600 + getty_session_param: + compress_encoding: false + tcp_no_delay: true + tcp_keep_alive: true + keep_alive_period: "120s" + tcp_r_buf_size: 262144 + tcp_w_buf_size: 65536 + pkg_rq_size: 1024 + pkg_wq_size: 512 + tcp_read_timeout: "1s" + tcp_write_timeout: "5s" + wait_timeout: "1s" + max_msg_len: 10240 + session_name: "client" + +check: true +request_timeout : "3s" +connect_timeout : "3s" diff --git a/examples/consul/go-client/config/log.yml b/examples/consul/go-client/config/log.yml new file mode 100644 index 0000000000000000000000000000000000000000..baee0b7248484e425f88f35ab128212c931ff85e --- /dev/null +++ b/examples/consul/go-client/config/log.yml @@ -0,0 +1,28 @@ + +level: "info" +development: false +disableCaller: false +disableStacktrace: true +sampling: +encoding: "console" + +# encoder +encoderConfig: + messageKey: "message" + levelKey: "level" + timeKey: "time" + nameKey: "logger" + callerKey: "caller" + stacktraceKey: "stacktrace" + lineEnding: "" + levelEncoder: "capitalColor" + timeEncoder: "iso8601" + durationEncoder: "seconds" + callerEncoder: "short" + nameEncoder: "" + +outputPaths: + - "stderr" +errorOutputPaths: + - "stderr" +initialFields: diff --git a/examples/consul/go-client/service.go b/examples/consul/go-client/service.go new file mode 100644 index 0000000000000000000000000000000000000000..0f7cca59857f0b66e8fab51c0ec95e3adfead44a --- /dev/null +++ b/examples/consul/go-client/service.go @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package main + +import ( + "github.com/apache/dubbo-go/config" +) + +var dubboService = new(DubboService) + +func init() { + config.SetConsumerService(dubboService) +} + +type DubboService struct { + SayHello func(req interface{}) (string, error) +} + +func (s *DubboService) Reference() string { + return "DubboService" +} diff --git a/examples/consul/go-server/config/log.yml b/examples/consul/go-server/config/log.yml new file mode 100644 index 0000000000000000000000000000000000000000..baee0b7248484e425f88f35ab128212c931ff85e --- /dev/null +++ b/examples/consul/go-server/config/log.yml @@ -0,0 +1,28 @@ + +level: "info" +development: false +disableCaller: false +disableStacktrace: true +sampling: +encoding: "console" + +# encoder +encoderConfig: + messageKey: "message" + levelKey: "level" + timeKey: "time" + nameKey: "logger" + callerKey: "caller" + stacktraceKey: "stacktrace" + lineEnding: "" + levelEncoder: "capitalColor" + timeEncoder: "iso8601" + durationEncoder: "seconds" + callerEncoder: "short" + nameEncoder: "" + +outputPaths: + - "stderr" +errorOutputPaths: + - "stderr" +initialFields: diff --git a/examples/consul/go-server/config/server.yml b/examples/consul/go-server/config/server.yml new file mode 100644 index 0000000000000000000000000000000000000000..c12800e68d1c32793cb6860561f3240f196a6a78 --- /dev/null +++ b/examples/consul/go-server/config/server.yml @@ -0,0 +1,52 @@ +application_config: + organization : "ikurento.com" + name : "BDTService" + module : "dubbogo user-info server" + version : "0.0.1" + owner : "ZX" + environment : "test" + +registries : + "consul": + protocol: "consul" + timeout : "3s" + address: "127.0.0.1:8500" + username: "" + password: "" + +services: + "DubboService": + protocol : "dubbo" + interface : "dubbo.DubboService" + loadbalance: "random" + warmup: "100" + cluster: "failover" + methods: + - name: "SayHello" + retries: 1 + loadbalance: "random" + +protocols: + "dubbo1": + name: "dubbo" + port: 20000 + +protocol_conf: + dubbo: + session_number: 700 + fail_fast_timeout: "5s" + session_timeout: "20s" + getty_session_param: + compress_encoding: false + tcp_no_delay: true + tcp_keep_alive: true + keep_alive_period: "120s" + tcp_r_buf_size: 262144 + tcp_w_buf_size: 65536 + pkg_rq_size: 1024 + pkg_wq_size: 512 + tcp_read_timeout: "1s" + tcp_write_timeout: "5s" + wait_timeout: "1s" + max_msg_len: 1024 + session_name: "server" diff --git a/examples/consul/go-server/server.go b/examples/consul/go-server/server.go new file mode 100644 index 0000000000000000000000000000000000000000..798fe7c7b0632bf7d366d4bf500846fd6ced73e9 --- /dev/null +++ b/examples/consul/go-server/server.go @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package main + +import ( + "fmt" + "os" + "os/signal" + "syscall" + "time" +) + +import ( + _ "github.com/apache/dubbo-go/cluster/cluster_impl" + _ "github.com/apache/dubbo-go/cluster/loadbalance" + "github.com/apache/dubbo-go/common/logger" + _ "github.com/apache/dubbo-go/common/proxy/proxy_factory" + "github.com/apache/dubbo-go/config" + _ "github.com/apache/dubbo-go/filter/impl" + _ "github.com/apache/dubbo-go/protocol/dubbo" + _ "github.com/apache/dubbo-go/registry/consul" + _ "github.com/apache/dubbo-go/registry/protocol" +) + +var ( + survivalTimeout = int(3e9) +) + +func main() { + config.Load() + initSignal() +} + +func initSignal() { + signals := make(chan os.Signal, 1) + // It is not possible to block SIGKILL or syscall.SIGSTOP + signal.Notify(signals, os.Interrupt, os.Kill, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT) + for { + sig := <-signals + logger.Infof("get signal %s", sig.String()) + switch sig { + case syscall.SIGHUP: + // reload() + default: + go time.AfterFunc(time.Duration(float64(survivalTimeout)*float64(time.Second)), func() { + logger.Warnf("app exit now by force...") + os.Exit(1) + }) + + // The program exits normally or timeout forcibly exits. + fmt.Println("provider app exit now...") + return + } + } +} diff --git a/examples/consul/go-server/service.go b/examples/consul/go-server/service.go new file mode 100644 index 0000000000000000000000000000000000000000..7c08ec99b93ce1d383fad3e717b4fdf2da0b5d6c --- /dev/null +++ b/examples/consul/go-server/service.go @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package main + +import ( + "github.com/apache/dubbo-go/config" +) + +func init() { + config.SetProviderService(new(DubboService)) +} + +type DubboService struct{} + +func (s *DubboService) SayHello(message string) (string, error) { + return "hello " + message, nil +} + +func (s *DubboService) Reference() string { + return "DubboService" +} diff --git a/examples/consul/java-client/.gitignore b/examples/consul/java-client/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..0bbcf418ec53691d6895a6ea8eeb56a264f2b735 --- /dev/null +++ b/examples/consul/java-client/.gitignore @@ -0,0 +1,7 @@ +.idea +.gradle +*.iml +dependency-reduced-pom.xml +out/ +build/ +target/ \ No newline at end of file diff --git a/examples/consul/java-client/pom.xml b/examples/consul/java-client/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..3e54e77d492416b439c8fe441dae492eb019229a --- /dev/null +++ b/examples/consul/java-client/pom.xml @@ -0,0 +1,88 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>consul</groupId> + <artifactId>java-client</artifactId> + <version>1.0.0</version> + + <properties> + <maven.compiler.source>1.8</maven.compiler.source> + <maven.compiler.target>1.8</maven.compiler.target> + </properties> + + <dependencies> + <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + <version>1.2.17</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.apache.dubbo</groupId> + <artifactId>dubbo</artifactId> + <version>2.7.1</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>com.ecwid.consul</groupId> + <artifactId>consul-api</artifactId> + <version>1.4.2</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + <version>1.2</version> + <scope>compile</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-shade-plugin</artifactId> + <version>3.1.1</version> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>shade</goal> + </goals> + <configuration> + <transformers> + <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> + <mainClass>dubbo.client.Main</mainClass> + </transformer> + </transformers> + <filters> + <filter> + <artifact>*:*</artifact> + <excludes> + <exclude>META-INF/*.SF</exclude> + <exclude>META-INF/*.DSA</exclude> + <exclude>META-INF/*.RSA</exclude> + </excludes> + </filter> + </filters> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file diff --git a/examples/consul/java-client/src/main/java/dubbo/DubboService.java b/examples/consul/java-client/src/main/java/dubbo/DubboService.java new file mode 100644 index 0000000000000000000000000000000000000000..4eb2d8c10ae76a3f15ab2619cc369ff3564b97af --- /dev/null +++ b/examples/consul/java-client/src/main/java/dubbo/DubboService.java @@ -0,0 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package dubbo; + +public interface DubboService { + String SayHello(String message); +} diff --git a/examples/consul/java-client/src/main/java/dubbo/client/Main.java b/examples/consul/java-client/src/main/java/dubbo/client/Main.java new file mode 100644 index 0000000000000000000000000000000000000000..d9880bf2c4625dbebe0225502ebf42f98b36d896 --- /dev/null +++ b/examples/consul/java-client/src/main/java/dubbo/client/Main.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package dubbo.client; + +import org.apache.dubbo.config.ApplicationConfig; +import org.apache.dubbo.config.ReferenceConfig; +import org.apache.dubbo.config.RegistryConfig; +import dubbo.DubboService; + +public class Main { + public static void main(String[] args) { + ApplicationConfig applicationConfig = new ApplicationConfig(); + applicationConfig.setName("java-client"); + applicationConfig.setQosPort(33333); + + RegistryConfig registryConfig = new RegistryConfig(); + registryConfig.setAddress("consul://127.0.0.1:8500"); + + ReferenceConfig<DubboService> referenceConfig = new ReferenceConfig<>(); + referenceConfig.setApplication(applicationConfig); + referenceConfig.setRegistry(registryConfig); + referenceConfig.setInterface(DubboService.class); + + DubboService dubboService = referenceConfig.get(); + System.out.println(dubboService.SayHello("world")); + } +} diff --git a/examples/consul/java-client/src/main/resources/log4j.properties b/examples/consul/java-client/src/main/resources/log4j.properties new file mode 100644 index 0000000000000000000000000000000000000000..097fa4309c1811750de0164bfaf2ebf354615d57 --- /dev/null +++ b/examples/consul/java-client/src/main/resources/log4j.properties @@ -0,0 +1,4 @@ +log4j.appender.Stdout=org.apache.log4j.ConsoleAppender +log4j.appender.Stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.Stdout.layout.conversionPattern=[%p] %c | %m\n +log4j.rootLogger=INFO,Stdout \ No newline at end of file diff --git a/examples/consul/java-server/.gitignore b/examples/consul/java-server/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..0bbcf418ec53691d6895a6ea8eeb56a264f2b735 --- /dev/null +++ b/examples/consul/java-server/.gitignore @@ -0,0 +1,7 @@ +.idea +.gradle +*.iml +dependency-reduced-pom.xml +out/ +build/ +target/ \ No newline at end of file diff --git a/examples/consul/java-server/pom.xml b/examples/consul/java-server/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..07a1e5bc414a6a5d3688ff9ed2624f34d3622d59 --- /dev/null +++ b/examples/consul/java-server/pom.xml @@ -0,0 +1,89 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>consul</groupId> + <artifactId>java-server</artifactId> + <version>1.0.0</version> + + <properties> + <maven.compiler.source>1.8</maven.compiler.source> + <maven.compiler.target>1.8</maven.compiler.target> + </properties> + + <dependencies> + <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + <version>1.2.17</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.apache.dubbo</groupId> + <artifactId>dubbo</artifactId> + <version>2.7.1</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>com.ecwid.consul</groupId> + <artifactId>consul-api</artifactId> + <version>1.4.2</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + <version>1.2</version> + <scope>compile</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-shade-plugin</artifactId> + <version>3.1.1</version> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>shade</goal> + </goals> + <configuration> + <transformers> + <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> + <mainClass>dubbo.server.Main</mainClass> + </transformer> + </transformers> + <filters> + <filter> + <artifact>*:*</artifact> + <excludes> + <exclude>META-INF/*.SF</exclude> + <exclude>META-INF/*.DSA</exclude> + <exclude>META-INF/*.RSA</exclude> + </excludes> + </filter> + </filters> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file diff --git a/examples/consul/java-server/src/main/java/dubbo/DubboService.java b/examples/consul/java-server/src/main/java/dubbo/DubboService.java new file mode 100644 index 0000000000000000000000000000000000000000..de6b5b53355d72f678355de5773aeb1f00ec1751 --- /dev/null +++ b/examples/consul/java-server/src/main/java/dubbo/DubboService.java @@ -0,0 +1,5 @@ +package dubbo; + +public interface DubboService { + String SayHello(String message); +} diff --git a/examples/consul/java-server/src/main/java/dubbo/server/Impl/DubboServiceImpl.java b/examples/consul/java-server/src/main/java/dubbo/server/Impl/DubboServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..61c5e9039c1eaaad0dcebaa0c43653eb23f2f92b --- /dev/null +++ b/examples/consul/java-server/src/main/java/dubbo/server/Impl/DubboServiceImpl.java @@ -0,0 +1,11 @@ +package dubbo.server.Impl; + +import dubbo.DubboService; + +public class DubboServiceImpl implements DubboService { + + @Override + public String SayHello(String message) { + return "hello " + message; + } +} diff --git a/examples/consul/java-server/src/main/java/dubbo/server/Main.java b/examples/consul/java-server/src/main/java/dubbo/server/Main.java new file mode 100644 index 0000000000000000000000000000000000000000..91c7b0b912f4fb27e6d108d2975bcd8a6d08f4a4 --- /dev/null +++ b/examples/consul/java-server/src/main/java/dubbo/server/Main.java @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package dubbo.server; + +import org.apache.dubbo.config.ApplicationConfig; +import org.apache.dubbo.config.ProtocolConfig; +import org.apache.dubbo.config.RegistryConfig; +import org.apache.dubbo.config.ServiceConfig; +import dubbo.DubboService; +import dubbo.server.Impl.DubboServiceImpl; + +import java.io.IOException; + +public class Main { + public static void main(String[] args) throws IOException { + ApplicationConfig applicationConfig = new ApplicationConfig(); + applicationConfig.setName("java-server"); + + RegistryConfig registryConfig = new RegistryConfig(); + registryConfig.setAddress("consul://127.0.0.1:8500"); + + ProtocolConfig protocolConfig = new ProtocolConfig(); + protocolConfig.setName("dubbo"); + protocolConfig.setHost("127.0.0.1"); + protocolConfig.setPort(12345); + + ServiceConfig<DubboService> serviceConfig = new ServiceConfig<>(); + serviceConfig.setApplication(applicationConfig); + serviceConfig.setRegistry(registryConfig); + serviceConfig.setProtocol(protocolConfig); + serviceConfig.setInterface(DubboService.class); + serviceConfig.setRef(new DubboServiceImpl()); + serviceConfig.export(); + + System.in.read(); + } +} diff --git a/examples/consul/java-server/src/main/resources/log4j.properties b/examples/consul/java-server/src/main/resources/log4j.properties new file mode 100644 index 0000000000000000000000000000000000000000..097fa4309c1811750de0164bfaf2ebf354615d57 --- /dev/null +++ b/examples/consul/java-server/src/main/resources/log4j.properties @@ -0,0 +1,4 @@ +log4j.appender.Stdout=org.apache.log4j.ConsoleAppender +log4j.appender.Stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.Stdout.layout.conversionPattern=[%p] %c | %m\n +log4j.rootLogger=INFO,Stdout \ No newline at end of file diff --git a/examples/general/dubbo/go-client/app/client.go b/examples/general/dubbo/go-client/app/client.go index b7ee0e662a26251a79af13d36215cc2cb44fd794..60adad356b8a8ff843034dd8e6086a2b832c7792 100644 --- a/examples/general/dubbo/go-client/app/client.go +++ b/examples/general/dubbo/go-client/app/client.go @@ -33,7 +33,6 @@ import ( "github.com/apache/dubbo-go/common/logger" _ "github.com/apache/dubbo-go/common/proxy/proxy_factory" "github.com/apache/dubbo-go/config" - "github.com/apache/dubbo-go/protocol/dubbo" _ "github.com/apache/dubbo-go/registry/protocol" _ "github.com/apache/dubbo-go/filter/impl" @@ -64,8 +63,6 @@ func main() { test1() println("\n\ntest2") test2() - println("\n\ntest3") - test3() initSignal() } @@ -81,12 +78,12 @@ func initSignal() { case syscall.SIGHUP: // reload() default: - go time.AfterFunc(time.Duration(survivalTimeout), func() { + time.AfterFunc(time.Duration(survivalTimeout), func() { logger.Warnf("app exit now by force...") os.Exit(1) }) - // 瑕佷箞fastFailTimeout鏃堕棿鍐呮墽琛屽畬姣曚笅闈㈢殑閫昏緫鐒跺悗绋嬪簭閫€鍑猴紝瑕佷箞鎵ц涓婇潰鐨勮秴鏃跺嚱鏁扮▼搴忓己琛岄€€鍑� + // The program exits normally or timeout forcibly exits. fmt.Println("app exit now...") return } @@ -288,24 +285,3 @@ func test2() { } println("error: %v", err) } -func test3() { - var appName = "UserProviderGer" - var referenceConfig = config.ReferenceConfig{ - InterfaceName: "com.ikurento.user.UserProvider", - Cluster: "failover", - Registry: "hangzhouzk", - Protocol: dubbo.DUBBO, - Generic: true, - } - referenceConfig.GenericLoad(appName) //appName is the unique identification of RPCService - - time.Sleep(3 * time.Second) - println("\n\n\nstart to generic invoke") - resp, err := referenceConfig.GetRPCService().(*config.GenericService).Invoke([]interface{}{"GetUser", []string{"java.lang.String"}, []interface{}{"A003"}}) - if err != nil { - panic(err) - } - println("res: %v\n", resp) - println("succ!") - -} diff --git a/examples/general/dubbo/go-client/app/user.go b/examples/general/dubbo/go-client/app/user.go index affa5418a701842e890f9e2498c2ef7a769532bd..104d325d052940439da1c89c565a47520c73dd88 100644 --- a/examples/general/dubbo/go-client/app/user.go +++ b/examples/general/dubbo/go-client/app/user.go @@ -89,7 +89,7 @@ type User struct { Name string Age int32 Time time.Time - Sex Gender // 娉ㄦ剰姝ゅ锛宩ava enum Object <--> go string + Sex Gender // notice: java enum Object <--> go string } func (u User) String() string { diff --git a/examples/general/dubbo/go-client/assembly/bin/load.sh b/examples/general/dubbo/go-client/assembly/bin/load.sh index 07d5d15eac7b7974845e36c3807e7ec55875de65..ffa240b29d9e76761a151e7462092b86908de6f6 100644 --- a/examples/general/dubbo/go-client/assembly/bin/load.sh +++ b/examples/general/dubbo/go-client/assembly/bin/load.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : dubbogo app devops script -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-05-13 02:01 -# FILE : load.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + APP_NAME="APPLICATION_NAME" APP_ARGS="" diff --git a/examples/general/dubbo/go-client/assembly/common/app.properties b/examples/general/dubbo/go-client/assembly/common/app.properties index 6bbd6db850ceeaf5ff873fee01a3578237cbd557..e10868f4d292765c7eeb2e8bb8b1684a44f56a14 100644 --- a/examples/general/dubbo/go-client/assembly/common/app.properties +++ b/examples/general/dubbo/go-client/assembly/common/app.properties @@ -1,13 +1,19 @@ -# dubbogo application configure script -# ****************************************************** -# DESC : dubbogo environment variable -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:29 -# FILE : app.properties -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + export TARGET_EXEC_NAME="user_info_client" # BUILD_PACKAGE="dubbogo-examples/user-info/client/app" diff --git a/examples/general/dubbo/go-client/assembly/common/build.sh b/examples/general/dubbo/go-client/assembly/common/build.sh index e72418297ad2f0ac6985476b5a8d5e03b9e7584e..c9a9e87c73ef45195d6f70acccf9374ee6cb906b 100644 --- a/examples/general/dubbo/go-client/assembly/common/build.sh +++ b/examples/general/dubbo/go-client/assembly/common/build.sh @@ -1,13 +1,19 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:28 -# FILE : build.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. rm -rf target/ diff --git a/examples/general/dubbo/go-client/assembly/linux/dev.sh b/examples/general/dubbo/go-client/assembly/linux/dev.sh index 3373f01b948b708cd7bc1958c9d56a9042c60a68..eada737c8d0939d4237a6d218fc2a07efdbff381 100644 --- a/examples/general/dubbo/go-client/assembly/linux/dev.sh +++ b/examples/general/dubbo/go-client/assembly/linux/dev.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for dev env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2017-10-18 13:24 -# FILE : dev.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/general/dubbo/go-client/assembly/linux/release.sh b/examples/general/dubbo/go-client/assembly/linux/release.sh index 34867b8b3488778cd76a1dc7802393dcab6b0df0..10eb3d73f8760d394537b90b7aeff83ca2b243ed 100644 --- a/examples/general/dubbo/go-client/assembly/linux/release.sh +++ b/examples/general/dubbo/go-client/assembly/linux/release.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for release env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:34 -# FILE : test.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/general/dubbo/go-client/assembly/linux/test.sh b/examples/general/dubbo/go-client/assembly/linux/test.sh index 1bbbefd1e14e08c16deaf859e2841f4d1fe88e9c..78b650c0d49483f9f6862532afa5c483b618475a 100644 --- a/examples/general/dubbo/go-client/assembly/linux/test.sh +++ b/examples/general/dubbo/go-client/assembly/linux/test.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for test env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:34 -# FILE : test.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/general/dubbo/go-client/assembly/mac/dev.sh b/examples/general/dubbo/go-client/assembly/mac/dev.sh index b68ac83b6524a6713cd90c4fc5968fe64b1a9545..c8284769909e62f0142c29e3a63177bf2826593f 100644 --- a/examples/general/dubbo/go-client/assembly/mac/dev.sh +++ b/examples/general/dubbo/go-client/assembly/mac/dev.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for dev env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2017-10-18 13:24 -# FILE : dev.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/general/dubbo/go-client/assembly/mac/release.sh b/examples/general/dubbo/go-client/assembly/mac/release.sh index 688288b3b1b989e8af70a3674b34ea8e0668f3b4..91c2dfee79b1499b640420191174f980eac187bb 100644 --- a/examples/general/dubbo/go-client/assembly/mac/release.sh +++ b/examples/general/dubbo/go-client/assembly/mac/release.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for release env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:34 -# FILE : test.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/general/dubbo/go-client/assembly/mac/test.sh b/examples/general/dubbo/go-client/assembly/mac/test.sh index 56d6c11ecd6a1dc5984c74b88c10be9239e57428..a7853f5e2d51df8e3e9509621952c44bca0d1a2d 100644 --- a/examples/general/dubbo/go-client/assembly/mac/test.sh +++ b/examples/general/dubbo/go-client/assembly/mac/test.sh @@ -1,13 +1,19 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for test env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:34 -# FILE : test.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. set -e diff --git a/examples/general/dubbo/go-client/assembly/windows/dev.sh b/examples/general/dubbo/go-client/assembly/windows/dev.sh index 91cf6f23bcbecb26db798469a30529261aabbbb6..10a3866c0f4ed8e1070c4d5641259c04073df6cb 100644 --- a/examples/general/dubbo/go-client/assembly/windows/dev.sh +++ b/examples/general/dubbo/go-client/assembly/windows/dev.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for dev env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2017-10-18 13:24 -# FILE : dev.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/general/dubbo/go-client/assembly/windows/release.sh b/examples/general/dubbo/go-client/assembly/windows/release.sh index f317720bd53d9c9e5f8f484b6eb682c9c736af0c..21af573fa3842d47959d5726b11b81d5fff5b8df 100644 --- a/examples/general/dubbo/go-client/assembly/windows/release.sh +++ b/examples/general/dubbo/go-client/assembly/windows/release.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for release env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:34 -# FILE : test.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/general/dubbo/go-client/assembly/windows/test.sh b/examples/general/dubbo/go-client/assembly/windows/test.sh index 7dd2bec5260e647b57a46aaa37acc098babff068..2104da8b5909957c165eedc2f7d6866a890e9e6d 100644 --- a/examples/general/dubbo/go-client/assembly/windows/test.sh +++ b/examples/general/dubbo/go-client/assembly/windows/test.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for test env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:34 -# FILE : test.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/general/dubbo/go-server/app/app b/examples/general/dubbo/go-server/app/app deleted file mode 100755 index 43e170c50ba2e8ac2dbe6e5efa0e2bdff1b3194a..0000000000000000000000000000000000000000 Binary files a/examples/general/dubbo/go-server/app/app and /dev/null differ diff --git a/examples/general/dubbo/go-server/app/server.go b/examples/general/dubbo/go-server/app/server.go index de9c28737b43cee780494c6f0824cabac84b6595..0ffd6309c607168d75073c296eb60d21dadbca2d 100644 --- a/examples/general/dubbo/go-server/app/server.go +++ b/examples/general/dubbo/go-server/app/server.go @@ -74,12 +74,12 @@ func initSignal() { case syscall.SIGHUP: // reload() default: - go time.AfterFunc(time.Duration(survivalTimeout), func() { + time.AfterFunc(time.Duration(survivalTimeout), func() { logger.Warnf("app exit now by force...") os.Exit(1) }) - // 瑕佷箞fastFailTimeout鏃堕棿鍐呮墽琛屽畬姣曚笅闈㈢殑閫昏緫鐒跺悗绋嬪簭閫€鍑猴紝瑕佷箞鎵ц涓婇潰鐨勮秴鏃跺嚱鏁扮▼搴忓己琛岄€€鍑� + // The program exits normally or timeout forcibly exits. fmt.Println("provider app exit now...") return } diff --git a/examples/general/dubbo/go-server/app/user.go b/examples/general/dubbo/go-server/app/user.go index ce53bca080e388c2ef8bb852a4ddc7f95a232d96..e07a02e772de589bd9df85ef6e1e69fb2468d347 100644 --- a/examples/general/dubbo/go-server/app/user.go +++ b/examples/general/dubbo/go-server/app/user.go @@ -24,7 +24,7 @@ import ( ) import ( - "github.com/apache/dubbo-go-hessian2" + hessian "github.com/apache/dubbo-go-hessian2" ) type Gender hessian.JavaEnum @@ -73,7 +73,7 @@ type ( Name string Age int32 Time time.Time - Sex Gender // 娉ㄦ剰姝ゅ锛宩ava enum Object <--> go string + Sex Gender // notice: java enum Object <--> go string } ) diff --git a/examples/general/dubbo/go-server/app/user_provider.go b/examples/general/dubbo/go-server/app/user_provider.go index fdf0a3abb2ac26cc2cbfa5971db3f02b18fe0be0..87f0d85f96c9664399ab0dd22eaf4af5c742da33 100644 --- a/examples/general/dubbo/go-server/app/user_provider.go +++ b/examples/general/dubbo/go-server/app/user_provider.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package main import ( diff --git a/examples/general/dubbo/go-server/app/user_provider1.go b/examples/general/dubbo/go-server/app/user_provider1.go index 3edc816b592f9e165f149a792a9401a25c8c73c0..afc2a1d238752657e1b070979a6555b51dfb8d19 100644 --- a/examples/general/dubbo/go-server/app/user_provider1.go +++ b/examples/general/dubbo/go-server/app/user_provider1.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package main import ( diff --git a/examples/general/dubbo/go-server/app/user_provider2.go b/examples/general/dubbo/go-server/app/user_provider2.go index d28bcc33963ef73b372508e057679a5910948c25..cc19e0b5a176c186d3c593867eb90b221c01f943 100644 --- a/examples/general/dubbo/go-server/app/user_provider2.go +++ b/examples/general/dubbo/go-server/app/user_provider2.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package main import ( diff --git a/examples/general/dubbo/go-server/assembly/bin/load.sh b/examples/general/dubbo/go-server/assembly/bin/load.sh index 47fc5e38ded155a43c30b8cbf4d2a5ae04b58d0c..90077c2471d7d5553ddea6402c7e2c06867cba8e 100644 --- a/examples/general/dubbo/go-server/assembly/bin/load.sh +++ b/examples/general/dubbo/go-server/assembly/bin/load.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : dubbogo app devops script -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-05-13 02:01 -# FILE : load.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + APP_NAME="APPLICATION_NAME" APP_ARGS="" diff --git a/examples/general/dubbo/go-server/assembly/common/app.properties b/examples/general/dubbo/go-server/assembly/common/app.properties index dffb755b0811dd140d3f04e232f5f80ff60181df..1f0827eb512b9bcb3c2428f8e0b50d76f65743ef 100644 --- a/examples/general/dubbo/go-server/assembly/common/app.properties +++ b/examples/general/dubbo/go-server/assembly/common/app.properties @@ -1,13 +1,19 @@ -# dubbogo application configure script -# ****************************************************** -# DESC : application environment variable -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:29 -# FILE : app.properties -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + TARGET_EXEC_NAME="user_info_server" # BUILD_PACKAGE="dubbogo-examples/user-info/server/app" diff --git a/examples/general/dubbo/go-server/assembly/common/build.sh b/examples/general/dubbo/go-server/assembly/common/build.sh index 15ac904f7c265d942d7018439719af7e7391aa41..89a95ce679ca711824a2de0888686be79d96f505 100644 --- a/examples/general/dubbo/go-server/assembly/common/build.sh +++ b/examples/general/dubbo/go-server/assembly/common/build.sh @@ -1,13 +1,19 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:28 -# FILE : build.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. rm -rf target/ diff --git a/examples/general/dubbo/go-server/assembly/linux/dev.sh b/examples/general/dubbo/go-server/assembly/linux/dev.sh index 55886f09fb4873be84cfa46aae592f5f000120a4..d830ac98c2b9328791d00d5160d487b1a12b5fed 100644 --- a/examples/general/dubbo/go-server/assembly/linux/dev.sh +++ b/examples/general/dubbo/go-server/assembly/linux/dev.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for dev env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2018-06-24 17:32 -# FILE : dev.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/general/dubbo/go-server/assembly/linux/release.sh b/examples/general/dubbo/go-server/assembly/linux/release.sh index 9772ad9614583917d62beba2db9fcaefea63e1ed..99303800b0fbcd7f8dfea668dcf395f126fb99f6 100644 --- a/examples/general/dubbo/go-server/assembly/linux/release.sh +++ b/examples/general/dubbo/go-server/assembly/linux/release.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for release env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:25 -# FILE : release.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/general/dubbo/go-server/assembly/linux/test.sh b/examples/general/dubbo/go-server/assembly/linux/test.sh index 2fc4a98862bee5ef11a23e1b74058627a899181d..87144bb973095acaf8c17b0ec3bf42f643d0b95f 100644 --- a/examples/general/dubbo/go-server/assembly/linux/test.sh +++ b/examples/general/dubbo/go-server/assembly/linux/test.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for test env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:34 -# FILE : test.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/general/dubbo/go-server/assembly/mac/dev.sh b/examples/general/dubbo/go-server/assembly/mac/dev.sh index 5dfa78490b895ce556c809ead32b6f517a5f1450..3a7659b2d57e0e2502950d76ec6c938abf2b7513 100644 --- a/examples/general/dubbo/go-server/assembly/mac/dev.sh +++ b/examples/general/dubbo/go-server/assembly/mac/dev.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for dev env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2018-06-24 17:32 -# FILE : dev.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/general/dubbo/go-server/assembly/mac/release.sh b/examples/general/dubbo/go-server/assembly/mac/release.sh index 1ec21c7b511ccce9eddfac22a2374b57a7a697bf..1c4bce4bf825fe401823ec33025e004a476ccaaf 100644 --- a/examples/general/dubbo/go-server/assembly/mac/release.sh +++ b/examples/general/dubbo/go-server/assembly/mac/release.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for release env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:25 -# FILE : release.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/general/dubbo/go-server/assembly/mac/test.sh b/examples/general/dubbo/go-server/assembly/mac/test.sh index d34914c7dbed0e442b4accf51a3ecdf7c2984db8..69206e32fed343eb87c04190b509b16482125542 100644 --- a/examples/general/dubbo/go-server/assembly/mac/test.sh +++ b/examples/general/dubbo/go-server/assembly/mac/test.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for release env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:25 -# FILE : release.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/general/dubbo/go-server/assembly/windows/dev.sh b/examples/general/dubbo/go-server/assembly/windows/dev.sh index 97fbb6f698e500ad08d971b13cc1ffd00cd97803..011fb41148f205bc329118a3c75e52854c0ecfd3 100644 --- a/examples/general/dubbo/go-server/assembly/windows/dev.sh +++ b/examples/general/dubbo/go-server/assembly/windows/dev.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for dev env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2018-06-24 17:34 -# FILE : dev.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/general/dubbo/go-server/assembly/windows/release.sh b/examples/general/dubbo/go-server/assembly/windows/release.sh index 782cb10c7828eb277b5905f10f8dd6ad1c2d6bed..679a26a7dc77a9bc0ccbf119eac3caba252cadc9 100644 --- a/examples/general/dubbo/go-server/assembly/windows/release.sh +++ b/examples/general/dubbo/go-server/assembly/windows/release.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for release env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:25 -# FILE : release.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/general/dubbo/go-server/assembly/windows/test.sh b/examples/general/dubbo/go-server/assembly/windows/test.sh index 2037ddecf2545f1543d5d28be728fb0899722098..4a36de0f3a26b804601de703c62a8062bd0623f4 100644 --- a/examples/general/dubbo/go-server/assembly/windows/test.sh +++ b/examples/general/dubbo/go-server/assembly/windows/test.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for test env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:34 -# FILE : test.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/general/dubbo/java-client/build.sh b/examples/general/dubbo/java-client/build.sh index 1286b53ee6180d73ae325ca91228c7e0accfe0c5..c869acfb45794244767305c485ecabde1548e10c 100644 --- a/examples/general/dubbo/java-client/build.sh +++ b/examples/general/dubbo/java-client/build.sh @@ -1,8 +1,19 @@ #!/usr/bin/env bash -# ****************************************************** -# EMAIL : alexstocks@foxmail.com -# FILE : build.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. # rm src/main/resources/META-INF/spring/dubbo.consumer.xml # cp src/main/resources/META-INF/spring/dubbo-protocol.consumer.xml src/main/resources/META-INF/spring/dubbo.consumer.xml diff --git a/examples/general/dubbo/java-client/pom.xml b/examples/general/dubbo/java-client/pom.xml index c3e3464f2073220c765c2510aad124e0a80289e8..4065414ac598fb7bee7d14d625019d6534daba7f 100755 --- a/examples/general/dubbo/java-client/pom.xml +++ b/examples/general/dubbo/java-client/pom.xml @@ -1,18 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> <!-- - - Copyright 1999-2011 Alibaba Group. - - - - Licensed under the Apache License, Version 2.0 (the "License"); - - you may not use this file except in compliance with the License. - - You may obtain a copy of the License at - - - - http://www.apache.org/licenses/LICENSE-2.0 - - - - Unless required by applicable law or agreed to in writing, software - - distributed under the License is distributed on an "AS IS" BASIS, - - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - - See the License for the specific language governing permissions and - - limitations under the License. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. --> + <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> diff --git a/examples/general/dubbo/java-client/src/main/assembly/assembly.xml b/examples/general/dubbo/java-client/src/main/assembly/assembly.xml index 25235d9064e299dc9a6ff976b08b7e63aedca5d3..47757d1c93d8375c0cfe15a74be3dad09317f8da 100644 --- a/examples/general/dubbo/java-client/src/main/assembly/assembly.xml +++ b/examples/general/dubbo/java-client/src/main/assembly/assembly.xml @@ -1,18 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> <!-- - - Copyright 1999-2011 Alibaba Group. - - - - Licensed under the Apache License, Version 2.0 (the "License"); - - you may not use this file except in compliance with the License. - - You may obtain a copy of the License at - - - - http://www.apache.org/licenses/LICENSE-2.0 - - - - Unless required by applicable law or agreed to in writing, software - - distributed under the License is distributed on an "AS IS" BASIS, - - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - - See the License for the specific language governing permissions and - - limitations under the License. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. --> + <assembly> <id>assembly</id> <formats> diff --git a/examples/general/dubbo/java-client/src/main/java/com/ikurento/user/Consumer.java b/examples/general/dubbo/java-client/src/main/java/com/ikurento/user/Consumer.java index 9122a629f49cb1e5eeee1641e89fa0c91091e960..dc11dba56f5ec21f62344cd7e9a96eee5fb02486 100644 --- a/examples/general/dubbo/java-client/src/main/java/com/ikurento/user/Consumer.java +++ b/examples/general/dubbo/java-client/src/main/java/com/ikurento/user/Consumer.java @@ -1,12 +1,19 @@ -// ***************************************************** -// DESC : dubbo consumer -// AUTHOR : writtey by 鍖呭杈�(https://github.com/baozh) -// VERSION : 1.0 -// LICENCE : Apache License 2.0 -// EMAIL : alexstocks@foxmail.com -// MOD : 2016-10-19 17:03 -// FILE : Consumer.java -// ****************************************************** +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.ikurento.user; @@ -17,12 +24,12 @@ import com.alibaba.dubbo.rpc.service.EchoService; import java.util.List; public class Consumer { - //瀹氫箟涓€涓鏈夊彉閲� 锛圫pring涓姹傦級 + // Define a private variable (Required in Spring) private UserProvider userProvider; private UserProvider userProvider1; private UserProvider userProvider2; - //Spring娉ㄥ叆锛圫pring涓姹傦級 + // Spring DI (Required in Spring) public void setUserProvider(UserProvider u) { this.userProvider = u; } @@ -33,7 +40,7 @@ public class Consumer { this.userProvider2 = u; } - //鍚姩consumer鐨勫叆鍙e嚱鏁�(鍦ㄩ厤缃枃浠朵腑鎸囧畾) + // Start the entry function for consumer (Specified in the configuration file) public void start() throws Exception { System.out.println("\n\ntest"); testGetUser(); diff --git a/examples/general/dubbo/java-client/src/main/java/com/ikurento/user/Gender.java b/examples/general/dubbo/java-client/src/main/java/com/ikurento/user/Gender.java index 7bcfae3b23bf6ee2cca52cef7dc37e1c880d76a0..e606be79c9f633919132570b69e4d0a6588c9c8a 100644 --- a/examples/general/dubbo/java-client/src/main/java/com/ikurento/user/Gender.java +++ b/examples/general/dubbo/java-client/src/main/java/com/ikurento/user/Gender.java @@ -1,10 +1,22 @@ -package com.ikurento.user; +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -// https://github.com/JoeCao/dubbo_jsonrpc_example/tree/master/dubbo_server/src/main/java/com/ofpay/demo/api +package com.ikurento.user; -/** - * Created by wuwen on 15/4/7. - */ public enum Gender { MAN, WOMAN diff --git a/examples/general/dubbo/java-client/src/main/java/com/ikurento/user/User.java b/examples/general/dubbo/java-client/src/main/java/com/ikurento/user/User.java index 6966210df13a5d9bf4a6f7de262d3a72470950f0..7f228b3a657af4b6d9cd78b5f61fda021a6f633e 100644 --- a/examples/general/dubbo/java-client/src/main/java/com/ikurento/user/User.java +++ b/examples/general/dubbo/java-client/src/main/java/com/ikurento/user/User.java @@ -1,11 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.ikurento.user; -// https://github.com/JoeCao/dubbo_jsonrpc_example/tree/master/dubbo_server/src/main/java/com/ofpay/demo/api import java.util.Date; -/** - * Created by wuwen on 15/4/7. - */ public class User { private String id; diff --git a/examples/general/dubbo/java-client/src/main/java/com/ikurento/user/UserProvider.java b/examples/general/dubbo/java-client/src/main/java/com/ikurento/user/UserProvider.java index ed765d4c0c6b6b9b382666b29d90c9dd25206f8d..a330d9829aef7efff15a3d9ce004b22843890705 100644 --- a/examples/general/dubbo/java-client/src/main/java/com/ikurento/user/UserProvider.java +++ b/examples/general/dubbo/java-client/src/main/java/com/ikurento/user/UserProvider.java @@ -1,6 +1,4 @@ /* - * Copyright 1999-2011 Alibaba Group. - * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -13,8 +11,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.ikurento.user; -// https://github.com/JoeCao/dubbo_jsonrpc_example/tree/master/dubbo_server/src/main/java/com/ofpay/demo/api import java.util.List; diff --git a/examples/general/dubbo/java-client/src/main/resources/META-INF/spring/dubbo.consumer.xml b/examples/general/dubbo/java-client/src/main/resources/META-INF/spring/dubbo.consumer.xml index e7e5445a951614f599a63029f6d42508aaa4fccf..67c6264ea925bb60e38241f0a51e1ce7842b1d90 100644 --- a/examples/general/dubbo/java-client/src/main/resources/META-INF/spring/dubbo.consumer.xml +++ b/examples/general/dubbo/java-client/src/main/resources/META-INF/spring/dubbo.consumer.xml @@ -1,19 +1,19 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- - - Copyright 1999-2011 Alibaba Group. - - - - Licensed under the Apache License, Version 2.0 (the "License"); - - you may not use this file except in compliance with the License. - - You may obtain a copy of the License at - - - - http://www.apache.org/licenses/LICENSE-2.0 - - - - Unless required by applicable law or agreed to in writing, software - - distributed under the License is distributed on an "AS IS" BASIS, - - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - - See the License for the specific language governing permissions and - - limitations under the License. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. --> + + <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo" diff --git a/examples/general/dubbo/java-client/src/main/resources/META-INF/spring/service.xml b/examples/general/dubbo/java-client/src/main/resources/META-INF/spring/service.xml index db9fc3cba5a359b8835af53b81e50f8296d2e489..041d7c336558c9ea662ed2db3a3b9301c9eec4a2 100644 --- a/examples/general/dubbo/java-client/src/main/resources/META-INF/spring/service.xml +++ b/examples/general/dubbo/java-client/src/main/resources/META-INF/spring/service.xml @@ -1,19 +1,18 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- - - Copyright 1999-2011 Alibaba Group. - - - - Licensed under the Apache License, Version 2.0 (the "License"); - - you may not use this file except in compliance with the License. - - You may obtain a copy of the License at - - - - http://www.apache.org/licenses/LICENSE-2.0 - - - - Unless required by applicable law or agreed to in writing, software - - distributed under the License is distributed on an "AS IS" BASIS, - - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - - See the License for the specific language governing permissions and - - limitations under the License. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. --> + <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" diff --git a/examples/general/dubbo/java-server/build.sh b/examples/general/dubbo/java-server/build.sh index 0c197da639c1c1d9375e18c24dd73366c49deefe..7b5755be183f5b301f0963fcc4a4eace8a341574 100644 --- a/examples/general/dubbo/java-server/build.sh +++ b/examples/general/dubbo/java-server/build.sh @@ -1,8 +1,19 @@ #!/usr/bin/env bash -# ****************************************************** -# EMAIL : alexstocks@foxmail.com -# FILE : build.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. # mvn dependency:sources mvn clean package -Dmaven.test.skip diff --git a/examples/general/dubbo/java-server/pom.xml b/examples/general/dubbo/java-server/pom.xml index 975157865e59f24693d755dd20b0aac4b179a793..9b811e9f78a3db3cb742ce5870b5d68b55bd681c 100644 --- a/examples/general/dubbo/java-server/pom.xml +++ b/examples/general/dubbo/java-server/pom.xml @@ -1,4 +1,18 @@ <?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> diff --git a/examples/general/dubbo/java-server/script/debug.sh b/examples/general/dubbo/java-server/script/debug.sh index 27c5d800d846018127e762944151aa8e9ad4495d..1038cd7ff7f65a2a07ce21414732ab891aef67ff 100644 --- a/examples/general/dubbo/java-server/script/debug.sh +++ b/examples/general/dubbo/java-server/script/debug.sh @@ -1,13 +1,19 @@ -#!/us1r/bin/env bash -# ****************************************************** -# DESC : -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2017-10-09 21:52 -# FILE : to debug user info dubbo server -# ****************************************************** +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. # jdb -classpath /Users/alex/tmp/us/conf:/Users/alex/tmp/us/lib/*:/Users/alex/test/java/dubbo/2.5.4/dubbo-remoting/dubbo-remoting-api/src/main/java/ com.alibaba.dubbo.container.Main jdb -classpath /Users/alex/tmp/us/conf:/Users/alex/tmp/us/lib/* -sourcepath /Users/alex/test/java/dubbo/2.5.4/dubbo-remoting/dubbo-remoting-api/src/main/java/:/Users/alex/tmp/java-server/src/main/java com.alibaba.dubbo.container.Main diff --git a/examples/general/dubbo/java-server/src/main/assembly/assembly.xml b/examples/general/dubbo/java-server/src/main/assembly/assembly.xml index 2f01fea20f5391112cccb88c87bfe4ae1b59750a..98a2e100f18d195b8f0b44eb07080eaa9097af79 100644 --- a/examples/general/dubbo/java-server/src/main/assembly/assembly.xml +++ b/examples/general/dubbo/java-server/src/main/assembly/assembly.xml @@ -1,18 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> <!-- - - Copyright 1999-2011 Alibaba Group. - - - - Licensed under the Apache License, Version 2.0 (the "License"); - - you may not use this file except in compliance with the License. - - You may obtain a copy of the License at - - - - http://www.apache.org/licenses/LICENSE-2.0 - - - - Unless required by applicable law or agreed to in writing, software - - distributed under the License is distributed on an "AS IS" BASIS, - - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - - See the License for the specific language governing permissions and - - limitations under the License. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. --> + <assembly> <id>assembly</id> <formats> diff --git a/examples/general/dubbo/java-server/src/main/java/com/ikurento/user/Gender.java b/examples/general/dubbo/java-server/src/main/java/com/ikurento/user/Gender.java index 72c30ae8d4bae8fc71b4cb598205141b2d1d2020..e606be79c9f633919132570b69e4d0a6588c9c8a 100644 --- a/examples/general/dubbo/java-server/src/main/java/com/ikurento/user/Gender.java +++ b/examples/general/dubbo/java-server/src/main/java/com/ikurento/user/Gender.java @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.ikurento.user; public enum Gender { diff --git a/examples/general/dubbo/java-server/src/main/java/com/ikurento/user/Provider.java b/examples/general/dubbo/java-server/src/main/java/com/ikurento/user/Provider.java index 0031f5569fd5f16ded0da6e5426f78805fad4a42..dea1c342c2c31c51e27145e94e379b7be4106e29 100644 --- a/examples/general/dubbo/java-server/src/main/java/com/ikurento/user/Provider.java +++ b/examples/general/dubbo/java-server/src/main/java/com/ikurento/user/Provider.java @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.ikurento.user; import org.springframework.context.support.ClassPathXmlApplicationContext; diff --git a/examples/general/dubbo/java-server/src/main/java/com/ikurento/user/Response.java b/examples/general/dubbo/java-server/src/main/java/com/ikurento/user/Response.java index 3447e5c2537625f424b54291c53783a51922ae7b..83b423dd084fe7626bc34b356ca8c6e5b540c539 100644 --- a/examples/general/dubbo/java-server/src/main/java/com/ikurento/user/Response.java +++ b/examples/general/dubbo/java-server/src/main/java/com/ikurento/user/Response.java @@ -1,7 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.ikurento.user; import java.io.*; -//import java.util.Objects; public final class Response<T> implements Serializable { private static final long serialVersionUID = 3727205004706510648L; diff --git a/examples/general/dubbo/java-server/src/main/java/com/ikurento/user/User.java b/examples/general/dubbo/java-server/src/main/java/com/ikurento/user/User.java index eafc0fe1c0e0c7b72a0fce73b6a333668797145e..a6e76cffe9c41c3b505550a5f3b15c202a13907c 100644 --- a/examples/general/dubbo/java-server/src/main/java/com/ikurento/user/User.java +++ b/examples/general/dubbo/java-server/src/main/java/com/ikurento/user/User.java @@ -1,5 +1,21 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.ikurento.user; -// ref: https://github.com/JoeCao/dubbo_jsonrpc_example/tree/master/dubbo_server/src/main/java/com/ofpay/demo/api import java.util.Date; import java.io.Serializable; diff --git a/examples/general/dubbo/java-server/src/main/java/com/ikurento/user/UserProvider.java b/examples/general/dubbo/java-server/src/main/java/com/ikurento/user/UserProvider.java index 24567d23be662312a4750f07b605c685a8dfa5fe..60335876436ec77563b86c39066451e6cb04c71d 100644 --- a/examples/general/dubbo/java-server/src/main/java/com/ikurento/user/UserProvider.java +++ b/examples/general/dubbo/java-server/src/main/java/com/ikurento/user/UserProvider.java @@ -1,5 +1,21 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.ikurento.user; -// https://github.com/JoeCao/dubbo_jsonrpc_example/tree/master/dubbo_server/src/main/java/com/ofpay/demo/api import java.util.List; import java.util.Map; diff --git a/examples/general/dubbo/java-server/src/main/java/com/ikurento/user/UserProviderAnotherImpl.java b/examples/general/dubbo/java-server/src/main/java/com/ikurento/user/UserProviderAnotherImpl.java index d600545c5084a40f1318e47a6a1c20bfcd6d36bc..dfa46495d80d9312b0812800e5384d0bb71805e2 100644 --- a/examples/general/dubbo/java-server/src/main/java/com/ikurento/user/UserProviderAnotherImpl.java +++ b/examples/general/dubbo/java-server/src/main/java/com/ikurento/user/UserProviderAnotherImpl.java @@ -1,16 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.ikurento.user; -//ref: https://github.com/JoeCao/dubbo_jsonrpc_example/tree/master/dubbo_server/src/main/java/com/ofpay/demo/api import org.slf4j.Logger; import org.slf4j.LoggerFactory; -// import org.apache.log4j.Logger; -// import org.apache.log4j.LoggerFactory; import java.util.*; public class UserProviderAnotherImpl implements UserProvider { - // private static final Logger logger = LoggerFactory.getLogger(getClass()); // 鍙緭鍑哄埌dubbo鐨刲og(logs/server.log) - private static final Logger logger = LoggerFactory.getLogger("userLogger"); // 杈撳嚭鍒皍ser-server.log + // private static final Logger logger = LoggerFactory.getLogger(getClass()); // Only output to dubbo's log(logs/server.log) + private static final Logger logger = LoggerFactory.getLogger("userLogger"); // Output to user-server.log private Map<String, User> userMap = new HashMap<String, User>(); diff --git a/examples/general/dubbo/java-server/src/main/java/com/ikurento/user/UserProviderImpl.java b/examples/general/dubbo/java-server/src/main/java/com/ikurento/user/UserProviderImpl.java index 47a4e2d9732aa8d8d9279d47af5bb4fb3db37195..e2068f92350ae1cd2e4c75cd16aad5f2d9d52994 100644 --- a/examples/general/dubbo/java-server/src/main/java/com/ikurento/user/UserProviderImpl.java +++ b/examples/general/dubbo/java-server/src/main/java/com/ikurento/user/UserProviderImpl.java @@ -1,6 +1,21 @@ -package com.ikurento.user; +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -// ref: https://github.com/JoeCao/dubbo_jsonrpc_example/tree/master/dubbo_server/src/main/java/com/ofpay/demo/api +package com.ikurento.user; import java.util.HashMap; import java.util.List; @@ -8,14 +23,12 @@ import java.util.ArrayList; import java.util.Map; import java.util.Iterator; -// import org.apache.log4j.Logger; -// import org.apache.log4j.LoggerFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class UserProviderImpl implements UserProvider { - // private static final Logger logger = LoggerFactory.getLogger(getClass()); // 鍙緭鍑哄埌dubbo鐨刲og(logs/server.log) - private static final Logger LOG = LoggerFactory.getLogger("UserLogger"); // 杈撳嚭鍒皍ser-server.log + // private static final Logger logger = LoggerFactory.getLogger(getClass()); // Only output to dubbo's log(logs/server.log) + private static final Logger LOG = LoggerFactory.getLogger("UserLogger"); // Output to user-server.log Map<String, User> userMap = new HashMap<String, User>(); public UserProviderImpl() { diff --git a/examples/general/dubbo/java-server/src/main/resources/META-INF/spring/dubbo.provider.xml b/examples/general/dubbo/java-server/src/main/resources/META-INF/spring/dubbo.provider.xml index f8dd13a833e6095485d0504e21cec272a3c9a288..4ebe64b937bfcccf0ee97c948c76329272a9cca5 100644 --- a/examples/general/dubbo/java-server/src/main/resources/META-INF/spring/dubbo.provider.xml +++ b/examples/general/dubbo/java-server/src/main/resources/META-INF/spring/dubbo.provider.xml @@ -1,19 +1,18 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- - - Copyright 1999-2011 Alibaba Group. - - - - Licensed under the Apache License, Version 2.0 (the "License"); - - you may not use this file except in compliance with the License. - - You may obtain a copy of the License at - - - - http://www.apache.org/licenses/LICENSE-2.0 - - - - Unless required by applicable law or agreed to in writing, software - - distributed under the License is distributed on an "AS IS" BASIS, - - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - - See the License for the specific language governing permissions and - - limitations under the License. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. --> + <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo" diff --git a/examples/general/jsonrpc/go-client/app/client.go b/examples/general/jsonrpc/go-client/app/client.go index b781f860bc41cdc616f8836499d584056c29af43..c281794df9778f1ff9d834eaa4c1bdc819320309 100644 --- a/examples/general/jsonrpc/go-client/app/client.go +++ b/examples/general/jsonrpc/go-client/app/client.go @@ -73,12 +73,12 @@ func initSignal() { case syscall.SIGHUP: // reload() default: - go time.AfterFunc(time.Duration(survivalTimeout), func() { + time.AfterFunc(time.Duration(survivalTimeout), func() { logger.Warnf("app exit now by force...") os.Exit(1) }) - // 瑕佷箞fastFailTimeout鏃堕棿鍐呮墽琛屽畬姣曚笅闈㈢殑閫昏緫鐒跺悗绋嬪簭閫€鍑猴紝瑕佷箞鎵ц涓婇潰鐨勮秴鏃跺嚱鏁扮▼搴忓己琛岄€€鍑� + // The program exits normally or timeout forcibly exits. fmt.Println("app exit now...") return } diff --git a/examples/general/jsonrpc/go-client/assembly/bin/load.sh b/examples/general/jsonrpc/go-client/assembly/bin/load.sh index 07d5d15eac7b7974845e36c3807e7ec55875de65..ffa240b29d9e76761a151e7462092b86908de6f6 100644 --- a/examples/general/jsonrpc/go-client/assembly/bin/load.sh +++ b/examples/general/jsonrpc/go-client/assembly/bin/load.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : dubbogo app devops script -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-05-13 02:01 -# FILE : load.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + APP_NAME="APPLICATION_NAME" APP_ARGS="" diff --git a/examples/general/jsonrpc/go-client/assembly/common/app.properties b/examples/general/jsonrpc/go-client/assembly/common/app.properties index 6bbd6db850ceeaf5ff873fee01a3578237cbd557..e10868f4d292765c7eeb2e8bb8b1684a44f56a14 100644 --- a/examples/general/jsonrpc/go-client/assembly/common/app.properties +++ b/examples/general/jsonrpc/go-client/assembly/common/app.properties @@ -1,13 +1,19 @@ -# dubbogo application configure script -# ****************************************************** -# DESC : dubbogo environment variable -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:29 -# FILE : app.properties -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + export TARGET_EXEC_NAME="user_info_client" # BUILD_PACKAGE="dubbogo-examples/user-info/client/app" diff --git a/examples/general/jsonrpc/go-client/assembly/common/build.sh b/examples/general/jsonrpc/go-client/assembly/common/build.sh index 06b212db6c3dcc28e5e43666284662bcb7abcae4..583edd7d9967c8a9f384c2fbba730c0729df8cee 100644 --- a/examples/general/jsonrpc/go-client/assembly/common/build.sh +++ b/examples/general/jsonrpc/go-client/assembly/common/build.sh @@ -1,13 +1,19 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:28 -# FILE : build.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. rm -rf target/ diff --git a/examples/general/jsonrpc/go-client/assembly/linux/dev.sh b/examples/general/jsonrpc/go-client/assembly/linux/dev.sh index 3373f01b948b708cd7bc1958c9d56a9042c60a68..eada737c8d0939d4237a6d218fc2a07efdbff381 100644 --- a/examples/general/jsonrpc/go-client/assembly/linux/dev.sh +++ b/examples/general/jsonrpc/go-client/assembly/linux/dev.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for dev env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2017-10-18 13:24 -# FILE : dev.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/general/jsonrpc/go-client/assembly/linux/release.sh b/examples/general/jsonrpc/go-client/assembly/linux/release.sh index 34867b8b3488778cd76a1dc7802393dcab6b0df0..10eb3d73f8760d394537b90b7aeff83ca2b243ed 100644 --- a/examples/general/jsonrpc/go-client/assembly/linux/release.sh +++ b/examples/general/jsonrpc/go-client/assembly/linux/release.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for release env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:34 -# FILE : test.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/general/jsonrpc/go-client/assembly/linux/test.sh b/examples/general/jsonrpc/go-client/assembly/linux/test.sh index 1bbbefd1e14e08c16deaf859e2841f4d1fe88e9c..78b650c0d49483f9f6862532afa5c483b618475a 100644 --- a/examples/general/jsonrpc/go-client/assembly/linux/test.sh +++ b/examples/general/jsonrpc/go-client/assembly/linux/test.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for test env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:34 -# FILE : test.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/general/jsonrpc/go-client/assembly/mac/dev.sh b/examples/general/jsonrpc/go-client/assembly/mac/dev.sh index b68ac83b6524a6713cd90c4fc5968fe64b1a9545..c8284769909e62f0142c29e3a63177bf2826593f 100644 --- a/examples/general/jsonrpc/go-client/assembly/mac/dev.sh +++ b/examples/general/jsonrpc/go-client/assembly/mac/dev.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for dev env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2017-10-18 13:24 -# FILE : dev.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/general/jsonrpc/go-client/assembly/mac/release.sh b/examples/general/jsonrpc/go-client/assembly/mac/release.sh index 688288b3b1b989e8af70a3674b34ea8e0668f3b4..91c2dfee79b1499b640420191174f980eac187bb 100644 --- a/examples/general/jsonrpc/go-client/assembly/mac/release.sh +++ b/examples/general/jsonrpc/go-client/assembly/mac/release.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for release env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:34 -# FILE : test.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/general/jsonrpc/go-client/assembly/mac/test.sh b/examples/general/jsonrpc/go-client/assembly/mac/test.sh index 56d6c11ecd6a1dc5984c74b88c10be9239e57428..a7853f5e2d51df8e3e9509621952c44bca0d1a2d 100644 --- a/examples/general/jsonrpc/go-client/assembly/mac/test.sh +++ b/examples/general/jsonrpc/go-client/assembly/mac/test.sh @@ -1,13 +1,19 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for test env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:34 -# FILE : test.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. set -e diff --git a/examples/general/jsonrpc/go-client/assembly/windows/dev.sh b/examples/general/jsonrpc/go-client/assembly/windows/dev.sh index 91cf6f23bcbecb26db798469a30529261aabbbb6..10a3866c0f4ed8e1070c4d5641259c04073df6cb 100644 --- a/examples/general/jsonrpc/go-client/assembly/windows/dev.sh +++ b/examples/general/jsonrpc/go-client/assembly/windows/dev.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for dev env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2017-10-18 13:24 -# FILE : dev.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/general/jsonrpc/go-client/assembly/windows/release.sh b/examples/general/jsonrpc/go-client/assembly/windows/release.sh index f317720bd53d9c9e5f8f484b6eb682c9c736af0c..21af573fa3842d47959d5726b11b81d5fff5b8df 100644 --- a/examples/general/jsonrpc/go-client/assembly/windows/release.sh +++ b/examples/general/jsonrpc/go-client/assembly/windows/release.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for release env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:34 -# FILE : test.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/general/jsonrpc/go-client/assembly/windows/test.sh b/examples/general/jsonrpc/go-client/assembly/windows/test.sh index 7dd2bec5260e647b57a46aaa37acc098babff068..2104da8b5909957c165eedc2f7d6866a890e9e6d 100644 --- a/examples/general/jsonrpc/go-client/assembly/windows/test.sh +++ b/examples/general/jsonrpc/go-client/assembly/windows/test.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for test env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:34 -# FILE : test.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/general/jsonrpc/go-server/app/server.go b/examples/general/jsonrpc/go-server/app/server.go index 231082b5b4accbbb9aa78b2241416f0c8014c5ef..de4aaed0bd56a112633ff9c4aba1c79d21b49920 100644 --- a/examples/general/jsonrpc/go-server/app/server.go +++ b/examples/general/jsonrpc/go-server/app/server.go @@ -64,12 +64,12 @@ func initSignal() { case syscall.SIGHUP: // reload() default: - go time.AfterFunc(time.Duration(survivalTimeout), func() { + time.AfterFunc(time.Duration(survivalTimeout), func() { logger.Warnf("app exit now by force...") os.Exit(1) }) - // 瑕佷箞fastFailTimeout鏃堕棿鍐呮墽琛屽畬姣曚笅闈㈢殑閫昏緫鐒跺悗绋嬪簭閫€鍑猴紝瑕佷箞鎵ц涓婇潰鐨勮秴鏃跺嚱鏁扮▼搴忓己琛岄€€鍑� + // The program exits normally or timeout forcibly exits. fmt.Println("provider app exit now...") return } diff --git a/examples/general/jsonrpc/go-server/assembly/bin/load.sh b/examples/general/jsonrpc/go-server/assembly/bin/load.sh index 47fc5e38ded155a43c30b8cbf4d2a5ae04b58d0c..90077c2471d7d5553ddea6402c7e2c06867cba8e 100644 --- a/examples/general/jsonrpc/go-server/assembly/bin/load.sh +++ b/examples/general/jsonrpc/go-server/assembly/bin/load.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : dubbogo app devops script -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-05-13 02:01 -# FILE : load.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + APP_NAME="APPLICATION_NAME" APP_ARGS="" diff --git a/examples/general/jsonrpc/go-server/assembly/common/app.properties b/examples/general/jsonrpc/go-server/assembly/common/app.properties index dffb755b0811dd140d3f04e232f5f80ff60181df..1f0827eb512b9bcb3c2428f8e0b50d76f65743ef 100644 --- a/examples/general/jsonrpc/go-server/assembly/common/app.properties +++ b/examples/general/jsonrpc/go-server/assembly/common/app.properties @@ -1,13 +1,19 @@ -# dubbogo application configure script -# ****************************************************** -# DESC : application environment variable -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:29 -# FILE : app.properties -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + TARGET_EXEC_NAME="user_info_server" # BUILD_PACKAGE="dubbogo-examples/user-info/server/app" diff --git a/examples/general/jsonrpc/go-server/assembly/common/build.sh b/examples/general/jsonrpc/go-server/assembly/common/build.sh index 15ac904f7c265d942d7018439719af7e7391aa41..89a95ce679ca711824a2de0888686be79d96f505 100644 --- a/examples/general/jsonrpc/go-server/assembly/common/build.sh +++ b/examples/general/jsonrpc/go-server/assembly/common/build.sh @@ -1,13 +1,19 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:28 -# FILE : build.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. rm -rf target/ diff --git a/examples/general/jsonrpc/go-server/assembly/linux/dev.sh b/examples/general/jsonrpc/go-server/assembly/linux/dev.sh index 55886f09fb4873be84cfa46aae592f5f000120a4..d830ac98c2b9328791d00d5160d487b1a12b5fed 100644 --- a/examples/general/jsonrpc/go-server/assembly/linux/dev.sh +++ b/examples/general/jsonrpc/go-server/assembly/linux/dev.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for dev env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2018-06-24 17:32 -# FILE : dev.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/general/jsonrpc/go-server/assembly/linux/release.sh b/examples/general/jsonrpc/go-server/assembly/linux/release.sh index 9772ad9614583917d62beba2db9fcaefea63e1ed..99303800b0fbcd7f8dfea668dcf395f126fb99f6 100644 --- a/examples/general/jsonrpc/go-server/assembly/linux/release.sh +++ b/examples/general/jsonrpc/go-server/assembly/linux/release.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for release env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:25 -# FILE : release.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/general/jsonrpc/go-server/assembly/linux/test.sh b/examples/general/jsonrpc/go-server/assembly/linux/test.sh index 2fc4a98862bee5ef11a23e1b74058627a899181d..87144bb973095acaf8c17b0ec3bf42f643d0b95f 100644 --- a/examples/general/jsonrpc/go-server/assembly/linux/test.sh +++ b/examples/general/jsonrpc/go-server/assembly/linux/test.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for test env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:34 -# FILE : test.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/general/jsonrpc/go-server/assembly/mac/dev.sh b/examples/general/jsonrpc/go-server/assembly/mac/dev.sh index 5dfa78490b895ce556c809ead32b6f517a5f1450..3a7659b2d57e0e2502950d76ec6c938abf2b7513 100644 --- a/examples/general/jsonrpc/go-server/assembly/mac/dev.sh +++ b/examples/general/jsonrpc/go-server/assembly/mac/dev.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for dev env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2018-06-24 17:32 -# FILE : dev.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/general/jsonrpc/go-server/assembly/mac/release.sh b/examples/general/jsonrpc/go-server/assembly/mac/release.sh index 1ec21c7b511ccce9eddfac22a2374b57a7a697bf..1c4bce4bf825fe401823ec33025e004a476ccaaf 100644 --- a/examples/general/jsonrpc/go-server/assembly/mac/release.sh +++ b/examples/general/jsonrpc/go-server/assembly/mac/release.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for release env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:25 -# FILE : release.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/general/jsonrpc/go-server/assembly/mac/test.sh b/examples/general/jsonrpc/go-server/assembly/mac/test.sh index d34914c7dbed0e442b4accf51a3ecdf7c2984db8..69206e32fed343eb87c04190b509b16482125542 100644 --- a/examples/general/jsonrpc/go-server/assembly/mac/test.sh +++ b/examples/general/jsonrpc/go-server/assembly/mac/test.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for release env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:25 -# FILE : release.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/general/jsonrpc/go-server/assembly/windows/dev.sh b/examples/general/jsonrpc/go-server/assembly/windows/dev.sh index 97fbb6f698e500ad08d971b13cc1ffd00cd97803..011fb41148f205bc329118a3c75e52854c0ecfd3 100644 --- a/examples/general/jsonrpc/go-server/assembly/windows/dev.sh +++ b/examples/general/jsonrpc/go-server/assembly/windows/dev.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for dev env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2018-06-24 17:34 -# FILE : dev.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/general/jsonrpc/go-server/assembly/windows/release.sh b/examples/general/jsonrpc/go-server/assembly/windows/release.sh index 782cb10c7828eb277b5905f10f8dd6ad1c2d6bed..679a26a7dc77a9bc0ccbf119eac3caba252cadc9 100644 --- a/examples/general/jsonrpc/go-server/assembly/windows/release.sh +++ b/examples/general/jsonrpc/go-server/assembly/windows/release.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for release env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:25 -# FILE : release.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/general/jsonrpc/go-server/assembly/windows/test.sh b/examples/general/jsonrpc/go-server/assembly/windows/test.sh index 2037ddecf2545f1543d5d28be728fb0899722098..4a36de0f3a26b804601de703c62a8062bd0623f4 100644 --- a/examples/general/jsonrpc/go-server/assembly/windows/test.sh +++ b/examples/general/jsonrpc/go-server/assembly/windows/test.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for test env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:34 -# FILE : test.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/general/jsonrpc/java-client/build.sh b/examples/general/jsonrpc/java-client/build.sh index 1286b53ee6180d73ae325ca91228c7e0accfe0c5..c869acfb45794244767305c485ecabde1548e10c 100644 --- a/examples/general/jsonrpc/java-client/build.sh +++ b/examples/general/jsonrpc/java-client/build.sh @@ -1,8 +1,19 @@ #!/usr/bin/env bash -# ****************************************************** -# EMAIL : alexstocks@foxmail.com -# FILE : build.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. # rm src/main/resources/META-INF/spring/dubbo.consumer.xml # cp src/main/resources/META-INF/spring/dubbo-protocol.consumer.xml src/main/resources/META-INF/spring/dubbo.consumer.xml diff --git a/examples/general/jsonrpc/java-client/pom.xml b/examples/general/jsonrpc/java-client/pom.xml index 79a8a7e11b3c00fa151aa2dc728320a874304bff..445b92450a440c3525676f1f945f4728f8f7c7db 100644 --- a/examples/general/jsonrpc/java-client/pom.xml +++ b/examples/general/jsonrpc/java-client/pom.xml @@ -1,18 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> <!-- - - Copyright 1999-2011 Alibaba Group. - - - - Licensed under the Apache License, Version 2.0 (the "License"); - - you may not use this file except in compliance with the License. - - You may obtain a copy of the License at - - - - http://www.apache.org/licenses/LICENSE-2.0 - - - - Unless required by applicable law or agreed to in writing, software - - distributed under the License is distributed on an "AS IS" BASIS, - - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - - See the License for the specific language governing permissions and - - limitations under the License. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. --> + <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> diff --git a/examples/general/jsonrpc/java-client/src/main/assembly/assembly.xml b/examples/general/jsonrpc/java-client/src/main/assembly/assembly.xml index 25235d9064e299dc9a6ff976b08b7e63aedca5d3..47757d1c93d8375c0cfe15a74be3dad09317f8da 100644 --- a/examples/general/jsonrpc/java-client/src/main/assembly/assembly.xml +++ b/examples/general/jsonrpc/java-client/src/main/assembly/assembly.xml @@ -1,18 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> <!-- - - Copyright 1999-2011 Alibaba Group. - - - - Licensed under the Apache License, Version 2.0 (the "License"); - - you may not use this file except in compliance with the License. - - You may obtain a copy of the License at - - - - http://www.apache.org/licenses/LICENSE-2.0 - - - - Unless required by applicable law or agreed to in writing, software - - distributed under the License is distributed on an "AS IS" BASIS, - - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - - See the License for the specific language governing permissions and - - limitations under the License. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. --> + <assembly> <id>assembly</id> <formats> diff --git a/examples/general/jsonrpc/java-client/src/main/java/com/ikurento/user/Consumer.java b/examples/general/jsonrpc/java-client/src/main/java/com/ikurento/user/Consumer.java index 2c7b27b5e6a494420a57d6614a8f76017fccbea7..cca9559cd8c3501d8d23132eaa682ecbe3e7be29 100644 --- a/examples/general/jsonrpc/java-client/src/main/java/com/ikurento/user/Consumer.java +++ b/examples/general/jsonrpc/java-client/src/main/java/com/ikurento/user/Consumer.java @@ -1,12 +1,19 @@ -// ***************************************************** -// DESC : dubbo consumer -// AUTHOR : writtey by 鍖呭杈�(https://github.com/baozh) -// VERSION : 1.0 -// LICENCE : Apache License 2.0 -// EMAIL : alexstocks@foxmail.com -// MOD : 2016-10-19 17:03 -// FILE : Consumer.java -// ****************************************************** +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.ikurento.user; @@ -17,12 +24,12 @@ import com.alibaba.dubbo.rpc.service.EchoService; import java.util.List; public class Consumer { - //瀹氫箟涓€涓鏈夊彉閲� 锛圫pring涓姹傦級 + // Define a private variable (Required in Spring) private UserProvider userProvider; private UserProvider userProvider1; private UserProvider userProvider2; - //Spring娉ㄥ叆锛圫pring涓姹傦級 + // Spring DI (Required in Spring) public void setUserProvider(UserProvider u) { this.userProvider = u; } @@ -33,7 +40,7 @@ public class Consumer { this.userProvider2 = u; } - //鍚姩consumer鐨勫叆鍙e嚱鏁�(鍦ㄩ厤缃枃浠朵腑鎸囧畾) + // Start the entry function for consumer (Specified in the configuration file) public void start() throws Exception { System.out.println("\n\ntest"); testGetUser(); diff --git a/examples/general/jsonrpc/java-client/src/main/java/com/ikurento/user/Gender.java b/examples/general/jsonrpc/java-client/src/main/java/com/ikurento/user/Gender.java index 7bcfae3b23bf6ee2cca52cef7dc37e1c880d76a0..e606be79c9f633919132570b69e4d0a6588c9c8a 100644 --- a/examples/general/jsonrpc/java-client/src/main/java/com/ikurento/user/Gender.java +++ b/examples/general/jsonrpc/java-client/src/main/java/com/ikurento/user/Gender.java @@ -1,10 +1,22 @@ -package com.ikurento.user; +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -// https://github.com/JoeCao/dubbo_jsonrpc_example/tree/master/dubbo_server/src/main/java/com/ofpay/demo/api +package com.ikurento.user; -/** - * Created by wuwen on 15/4/7. - */ public enum Gender { MAN, WOMAN diff --git a/examples/general/jsonrpc/java-client/src/main/java/com/ikurento/user/User.java b/examples/general/jsonrpc/java-client/src/main/java/com/ikurento/user/User.java index 6966210df13a5d9bf4a6f7de262d3a72470950f0..7f228b3a657af4b6d9cd78b5f61fda021a6f633e 100644 --- a/examples/general/jsonrpc/java-client/src/main/java/com/ikurento/user/User.java +++ b/examples/general/jsonrpc/java-client/src/main/java/com/ikurento/user/User.java @@ -1,11 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.ikurento.user; -// https://github.com/JoeCao/dubbo_jsonrpc_example/tree/master/dubbo_server/src/main/java/com/ofpay/demo/api import java.util.Date; -/** - * Created by wuwen on 15/4/7. - */ public class User { private String id; diff --git a/examples/general/jsonrpc/java-client/src/main/java/com/ikurento/user/UserProvider.java b/examples/general/jsonrpc/java-client/src/main/java/com/ikurento/user/UserProvider.java index 93e7aadf02a869163f41a8f3dda84d2ebf18a475..55185778e9e3af6ebcad21570b6e70916690d18f 100644 --- a/examples/general/jsonrpc/java-client/src/main/java/com/ikurento/user/UserProvider.java +++ b/examples/general/jsonrpc/java-client/src/main/java/com/ikurento/user/UserProvider.java @@ -1,6 +1,4 @@ /* - * Copyright 1999-2011 Alibaba Group. - * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -13,8 +11,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.ikurento.user; -// https://github.com/JoeCao/dubbo_jsonrpc_example/tree/master/dubbo_server/src/main/java/com/ofpay/demo/api import java.util.List; diff --git a/examples/general/jsonrpc/java-client/src/main/resources/META-INF/spring/dubbo.consumer.xml b/examples/general/jsonrpc/java-client/src/main/resources/META-INF/spring/dubbo.consumer.xml index da21e8a359c003983ebea3269d4f2dfd255e3b29..ea4fcc4f56298f85e54b4445c0edd9a1818c4b78 100644 --- a/examples/general/jsonrpc/java-client/src/main/resources/META-INF/spring/dubbo.consumer.xml +++ b/examples/general/jsonrpc/java-client/src/main/resources/META-INF/spring/dubbo.consumer.xml @@ -1,19 +1,18 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- - - Copyright 1999-2011 Alibaba Group. - - - - Licensed under the Apache License, Version 2.0 (the "License"); - - you may not use this file except in compliance with the License. - - You may obtain a copy of the License at - - - - http://www.apache.org/licenses/LICENSE-2.0 - - - - Unless required by applicable law or agreed to in writing, software - - distributed under the License is distributed on an "AS IS" BASIS, - - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - - See the License for the specific language governing permissions and - - limitations under the License. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. --> + <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo" diff --git a/examples/general/jsonrpc/java-client/src/main/resources/META-INF/spring/service.xml b/examples/general/jsonrpc/java-client/src/main/resources/META-INF/spring/service.xml index db9fc3cba5a359b8835af53b81e50f8296d2e489..854d5135a5065f58ec1fdf32c215ca516bd4aee9 100644 --- a/examples/general/jsonrpc/java-client/src/main/resources/META-INF/spring/service.xml +++ b/examples/general/jsonrpc/java-client/src/main/resources/META-INF/spring/service.xml @@ -1,18 +1,16 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- - - Copyright 1999-2011 Alibaba Group. - - - - Licensed under the Apache License, Version 2.0 (the "License"); - - you may not use this file except in compliance with the License. - - You may obtain a copy of the License at - - - - http://www.apache.org/licenses/LICENSE-2.0 - - - - Unless required by applicable law or agreed to in writing, software - - distributed under the License is distributed on an "AS IS" BASIS, - - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - - See the License for the specific language governing permissions and - - limitations under the License. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. --> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" diff --git a/examples/general/jsonrpc/java-server/build.sh b/examples/general/jsonrpc/java-server/build.sh index 0c197da639c1c1d9375e18c24dd73366c49deefe..7b5755be183f5b301f0963fcc4a4eace8a341574 100644 --- a/examples/general/jsonrpc/java-server/build.sh +++ b/examples/general/jsonrpc/java-server/build.sh @@ -1,8 +1,19 @@ #!/usr/bin/env bash -# ****************************************************** -# EMAIL : alexstocks@foxmail.com -# FILE : build.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. # mvn dependency:sources mvn clean package -Dmaven.test.skip diff --git a/examples/general/jsonrpc/java-server/pom.xml b/examples/general/jsonrpc/java-server/pom.xml index 975157865e59f24693d755dd20b0aac4b179a793..9b811e9f78a3db3cb742ce5870b5d68b55bd681c 100644 --- a/examples/general/jsonrpc/java-server/pom.xml +++ b/examples/general/jsonrpc/java-server/pom.xml @@ -1,4 +1,18 @@ <?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> diff --git a/examples/general/jsonrpc/java-server/script/debug.sh b/examples/general/jsonrpc/java-server/script/debug.sh index 27c5d800d846018127e762944151aa8e9ad4495d..1038cd7ff7f65a2a07ce21414732ab891aef67ff 100644 --- a/examples/general/jsonrpc/java-server/script/debug.sh +++ b/examples/general/jsonrpc/java-server/script/debug.sh @@ -1,13 +1,19 @@ -#!/us1r/bin/env bash -# ****************************************************** -# DESC : -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2017-10-09 21:52 -# FILE : to debug user info dubbo server -# ****************************************************** +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. # jdb -classpath /Users/alex/tmp/us/conf:/Users/alex/tmp/us/lib/*:/Users/alex/test/java/dubbo/2.5.4/dubbo-remoting/dubbo-remoting-api/src/main/java/ com.alibaba.dubbo.container.Main jdb -classpath /Users/alex/tmp/us/conf:/Users/alex/tmp/us/lib/* -sourcepath /Users/alex/test/java/dubbo/2.5.4/dubbo-remoting/dubbo-remoting-api/src/main/java/:/Users/alex/tmp/java-server/src/main/java com.alibaba.dubbo.container.Main diff --git a/examples/general/jsonrpc/java-server/src/main/assembly/assembly.xml b/examples/general/jsonrpc/java-server/src/main/assembly/assembly.xml index 2f01fea20f5391112cccb88c87bfe4ae1b59750a..98a2e100f18d195b8f0b44eb07080eaa9097af79 100644 --- a/examples/general/jsonrpc/java-server/src/main/assembly/assembly.xml +++ b/examples/general/jsonrpc/java-server/src/main/assembly/assembly.xml @@ -1,18 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> <!-- - - Copyright 1999-2011 Alibaba Group. - - - - Licensed under the Apache License, Version 2.0 (the "License"); - - you may not use this file except in compliance with the License. - - You may obtain a copy of the License at - - - - http://www.apache.org/licenses/LICENSE-2.0 - - - - Unless required by applicable law or agreed to in writing, software - - distributed under the License is distributed on an "AS IS" BASIS, - - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - - See the License for the specific language governing permissions and - - limitations under the License. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. --> + <assembly> <id>assembly</id> <formats> diff --git a/examples/general/jsonrpc/java-server/src/main/java/com/ikurento/user/Gender.java b/examples/general/jsonrpc/java-server/src/main/java/com/ikurento/user/Gender.java index 72c30ae8d4bae8fc71b4cb598205141b2d1d2020..e606be79c9f633919132570b69e4d0a6588c9c8a 100644 --- a/examples/general/jsonrpc/java-server/src/main/java/com/ikurento/user/Gender.java +++ b/examples/general/jsonrpc/java-server/src/main/java/com/ikurento/user/Gender.java @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.ikurento.user; public enum Gender { diff --git a/examples/general/jsonrpc/java-server/src/main/java/com/ikurento/user/Provider.java b/examples/general/jsonrpc/java-server/src/main/java/com/ikurento/user/Provider.java index 0031f5569fd5f16ded0da6e5426f78805fad4a42..dea1c342c2c31c51e27145e94e379b7be4106e29 100644 --- a/examples/general/jsonrpc/java-server/src/main/java/com/ikurento/user/Provider.java +++ b/examples/general/jsonrpc/java-server/src/main/java/com/ikurento/user/Provider.java @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.ikurento.user; import org.springframework.context.support.ClassPathXmlApplicationContext; diff --git a/examples/general/jsonrpc/java-server/src/main/java/com/ikurento/user/Response.java b/examples/general/jsonrpc/java-server/src/main/java/com/ikurento/user/Response.java index 3447e5c2537625f424b54291c53783a51922ae7b..83b423dd084fe7626bc34b356ca8c6e5b540c539 100644 --- a/examples/general/jsonrpc/java-server/src/main/java/com/ikurento/user/Response.java +++ b/examples/general/jsonrpc/java-server/src/main/java/com/ikurento/user/Response.java @@ -1,7 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.ikurento.user; import java.io.*; -//import java.util.Objects; public final class Response<T> implements Serializable { private static final long serialVersionUID = 3727205004706510648L; diff --git a/examples/general/jsonrpc/java-server/src/main/java/com/ikurento/user/User.java b/examples/general/jsonrpc/java-server/src/main/java/com/ikurento/user/User.java index eafc0fe1c0e0c7b72a0fce73b6a333668797145e..a6e76cffe9c41c3b505550a5f3b15c202a13907c 100644 --- a/examples/general/jsonrpc/java-server/src/main/java/com/ikurento/user/User.java +++ b/examples/general/jsonrpc/java-server/src/main/java/com/ikurento/user/User.java @@ -1,5 +1,21 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.ikurento.user; -// ref: https://github.com/JoeCao/dubbo_jsonrpc_example/tree/master/dubbo_server/src/main/java/com/ofpay/demo/api import java.util.Date; import java.io.Serializable; diff --git a/examples/general/jsonrpc/java-server/src/main/java/com/ikurento/user/UserProvider.java b/examples/general/jsonrpc/java-server/src/main/java/com/ikurento/user/UserProvider.java index a74b2222018988e13b29f5d3b74cee00815ec40e..2958a1adeec491147c69667868642df2334b9abe 100644 --- a/examples/general/jsonrpc/java-server/src/main/java/com/ikurento/user/UserProvider.java +++ b/examples/general/jsonrpc/java-server/src/main/java/com/ikurento/user/UserProvider.java @@ -1,5 +1,21 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.ikurento.user; -// https://github.com/JoeCao/dubbo_jsonrpc_example/tree/master/dubbo_server/src/main/java/com/ofpay/demo/api import java.util.List; import java.util.Map; diff --git a/examples/general/jsonrpc/java-server/src/main/java/com/ikurento/user/UserProviderAnotherImpl.java b/examples/general/jsonrpc/java-server/src/main/java/com/ikurento/user/UserProviderAnotherImpl.java index 753a6f89a5f60e0f4884711d4c3b79e52ed2f094..299feb7bed37d3b2a62a548e04480a4d3d4c1647 100644 --- a/examples/general/jsonrpc/java-server/src/main/java/com/ikurento/user/UserProviderAnotherImpl.java +++ b/examples/general/jsonrpc/java-server/src/main/java/com/ikurento/user/UserProviderAnotherImpl.java @@ -1,16 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.ikurento.user; -//ref: https://github.com/JoeCao/dubbo_jsonrpc_example/tree/master/dubbo_server/src/main/java/com/ofpay/demo/api import org.slf4j.Logger; import org.slf4j.LoggerFactory; -// import org.apache.log4j.Logger; -// import org.apache.log4j.LoggerFactory; import java.util.*; public class UserProviderAnotherImpl implements UserProvider { - // private static final Logger logger = LoggerFactory.getLogger(getClass()); // 鍙緭鍑哄埌dubbo鐨刲og(logs/server.log) - private static final Logger logger = LoggerFactory.getLogger("userLogger"); // 杈撳嚭鍒皍ser-server.log + // private static final Logger logger = LoggerFactory.getLogger(getClass()); // Only output to dubbo's log(logs/server.log) + private static final Logger logger = LoggerFactory.getLogger("userLogger"); // Output to user-server.log private Map<String, User> userMap = new HashMap<String, User>(); diff --git a/examples/general/jsonrpc/java-server/src/main/java/com/ikurento/user/UserProviderImpl.java b/examples/general/jsonrpc/java-server/src/main/java/com/ikurento/user/UserProviderImpl.java index 960c678cf76cf4bafb3de9d5ce2a587b61aa1bac..ac6c229bb47c76f8a1d2a53672295a8cc3f4919b 100644 --- a/examples/general/jsonrpc/java-server/src/main/java/com/ikurento/user/UserProviderImpl.java +++ b/examples/general/jsonrpc/java-server/src/main/java/com/ikurento/user/UserProviderImpl.java @@ -1,6 +1,21 @@ -package com.ikurento.user; +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -// ref: https://github.com/JoeCao/dubbo_jsonrpc_example/tree/master/dubbo_server/src/main/java/com/ofpay/demo/api +package com.ikurento.user; import java.util.HashMap; import java.util.List; @@ -14,8 +29,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class UserProviderImpl implements UserProvider { - // private static final Logger logger = LoggerFactory.getLogger(getClass()); // 鍙緭鍑哄埌dubbo鐨刲og(logs/server.log) - private static final Logger LOG = LoggerFactory.getLogger("UserLogger"); // 杈撳嚭鍒皍ser-server.log + // private static final Logger logger = LoggerFactory.getLogger(getClass()); // Only output to dubbo's log(logs/server.log) + private static final Logger LOG = LoggerFactory.getLogger("UserLogger"); // Output to user-server.log Map<String, User> userMap = new HashMap<String, User>(); public UserProviderImpl() { diff --git a/examples/general/jsonrpc/java-server/src/main/resources/META-INF/spring/dubbo.provider.xml b/examples/general/jsonrpc/java-server/src/main/resources/META-INF/spring/dubbo.provider.xml index 6eb03bc94bbf34b23b6df890b7c70568466ffad8..f9ebc0805150ecb2e904782462697c4a86ed8a26 100644 --- a/examples/general/jsonrpc/java-server/src/main/resources/META-INF/spring/dubbo.provider.xml +++ b/examples/general/jsonrpc/java-server/src/main/resources/META-INF/spring/dubbo.provider.xml @@ -1,19 +1,18 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- - - Copyright 1999-2011 Alibaba Group. - - - - Licensed under the Apache License, Version 2.0 (the "License"); - - you may not use this file except in compliance with the License. - - You may obtain a copy of the License at - - - - http://www.apache.org/licenses/LICENSE-2.0 - - - - Unless required by applicable law or agreed to in writing, software - - distributed under the License is distributed on an "AS IS" BASIS, - - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - - See the License for the specific language governing permissions and - - limitations under the License. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. --> + <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo" diff --git a/examples/generic/go-client/app/client.go b/examples/generic/go-client/app/client.go new file mode 100644 index 0000000000000000000000000000000000000000..8d5a1bc5fa6cb186fcf456d385f8dad16b750ea3 --- /dev/null +++ b/examples/generic/go-client/app/client.go @@ -0,0 +1,100 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package main + +import ( + "fmt" + "time" +) + +import ( + _ "github.com/apache/dubbo-go/common/proxy/proxy_factory" + "github.com/apache/dubbo-go/config" + "github.com/apache/dubbo-go/protocol/dubbo" + _ "github.com/apache/dubbo-go/registry/protocol" + + _ "github.com/apache/dubbo-go/filter/impl" + + _ "github.com/apache/dubbo-go/cluster/cluster_impl" + _ "github.com/apache/dubbo-go/cluster/loadbalance" + _ "github.com/apache/dubbo-go/registry/zookeeper" +) + +var ( + survivalTimeout int = 10e9 +) + +// they are necessary: +// export CONF_CONSUMER_FILE_PATH="xxx" +// export APP_LOG_CONF_FILE="xxx" +func main() { + println("\n\ntest") + test() + println("\n\ntest2") + test2() + +} +func test() { + var appName = "UserProviderGer" + var referenceConfig = config.ReferenceConfig{ + InterfaceName: "com.ikurento.user.UserProvider", + Cluster: "failover", + Registry: "hangzhouzk", + Protocol: dubbo.DUBBO, + Generic: true, + } + referenceConfig.GenericLoad(appName) //appName is the unique identification of RPCService + + time.Sleep(3 * time.Second) + println("\n\n\nstart to generic invoke") + resp, err := referenceConfig.GetRPCService().(*config.GenericService).Invoke([]interface{}{"GetUser", []string{"java.lang.String"}, []interface{}{"A003"}}) + if err != nil { + panic(err) + } + fmt.Printf("res: %+v\n", resp) + println("succ!") + +} +func test2() { + var appName = "UserProviderGer" + var referenceConfig = config.ReferenceConfig{ + InterfaceName: "com.ikurento.user.UserProvider", + Cluster: "failover", + Registry: "hangzhouzk", + Protocol: dubbo.DUBBO, + Generic: true, + } + referenceConfig.GenericLoad(appName) //appName is the unique identification of RPCService + + time.Sleep(3 * time.Second) + println("\n\n\nstart to generic invoke") + user := User{ + Id: "3213", + Name: "panty", + Age: 25, + Time: time.Now(), + Sex: Gender(MAN), + } + resp, err := referenceConfig.GetRPCService().(*config.GenericService).Invoke([]interface{}{"queryUser", []string{"com.ikurento.user.User"}, []interface{}{user}}) + if err != nil { + panic(err) + } + fmt.Printf("res: %+v\n", resp) + println("succ!") + +} diff --git a/examples/generic/go-client/app/user.go b/examples/generic/go-client/app/user.go new file mode 100644 index 0000000000000000000000000000000000000000..9b226e24456e850f1b31fc0501e04d573cec35fd --- /dev/null +++ b/examples/generic/go-client/app/user.go @@ -0,0 +1,57 @@ +package main + +import ( + "strconv" + "time" +) +import ( + hessian "github.com/apache/dubbo-go-hessian2" +) + +type Gender hessian.JavaEnum + +const ( + MAN hessian.JavaEnum = iota + WOMAN +) + +var genderName = map[hessian.JavaEnum]string{ + MAN: "MAN", + WOMAN: "WOMAN", +} + +var genderValue = map[string]hessian.JavaEnum{ + "MAN": MAN, + "WOMAN": WOMAN, +} + +func (g Gender) JavaClassName() string { + return "com.ikurento.user.Gender" +} + +func (g Gender) String() string { + s, ok := genderName[hessian.JavaEnum(g)] + if ok { + return s + } + + return strconv.Itoa(int(g)) +} + +func (g Gender) EnumValue(s string) hessian.JavaEnum { + v, ok := genderValue[s] + if ok { + return v + } + + return hessian.InvalidJavaEnum +} + +type User struct { + // !!! Cannot define lowercase names of variable + Id string + Name string + Age int32 + Time time.Time + Sex Gender // 娉ㄦ剰姝ゅ锛宩ava enum Object <--> go string +} diff --git a/examples/generic/go-client/assembly/bin/load.sh b/examples/generic/go-client/assembly/bin/load.sh new file mode 100644 index 0000000000000000000000000000000000000000..176a202ab8810701ac8208db0ab764f2e215d71d --- /dev/null +++ b/examples/generic/go-client/assembly/bin/load.sh @@ -0,0 +1,202 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +APP_NAME="APPLICATION_NAME" +APP_ARGS="" +SLEEP_INTERVAL=5 +MAX_LIFETIME=4000 + +PROJECT_HOME="" +OS_NAME=`uname` +if [[ ${OS_NAME} != "Windows" ]]; then + PROJECT_HOME=`pwd` + PROJECT_HOME=${PROJECT_HOME}"/" +else + APP_NAME="APPLICATION_NAME.exe" +fi + +export CONF_CONSUMER_FILE_PATH=${PROJECT_HOME}"TARGET_CONF_FILE" +export APP_LOG_CONF_FILE=${PROJECT_HOME}"TARGET_LOG_CONF_FILE" +# export GOTRACEBACK=system +# export GODEBUG=gctrace=1 + +usage() { + echo "Usage: $0 start [conf suffix]" + echo " $0 stop" + echo " $0 term" + echo " $0 restart" + echo " $0 list" + echo " $0 monitor" + echo " $0 crontab" + exit +} + +start() { + arg=$1 + if [ "$arg" = "" ];then + echo "No registry type! Default client.yml!" + else + export CONF_CONSUMER_FILE_PATH=${CONF_CONSUMER_FILE_PATH//\.yml/\_$arg\.yml} + fi + if [ ! -f "${CONF_CONSUMER_FILE_PATH}" ];then + echo $CONF_CONSUMER_FILE_PATH" is not existing!" + return + fi + APP_LOG_PATH=${PROJECT_HOME}"logs/" + mkdir -p ${APP_LOG_PATH} + APP_BIN=${PROJECT_HOME}sbin/${APP_NAME} + chmod u+x ${APP_BIN} + # CMD="nohup ${APP_BIN} ${APP_ARGS} >>${APP_NAME}.nohup.out 2>&1 &" + CMD="${APP_BIN}" + eval ${CMD} + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}'` + if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $1}'` + fi + CUR=`date +%FT%T` + if [ "${PID}" != "" ]; then + for p in ${PID} + do + echo "start ${APP_NAME} ( pid =" ${p} ") at " ${CUR} + done + fi +} + +stop() { + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}'` + if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $1}'` + fi + if [ "${PID}" != "" ]; + then + for ps in ${PID} + do + echo "kill -SIGINT ${APP_NAME} ( pid =" ${ps} ")" + kill -2 ${ps} + done + fi +} + + +term() { + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}'` + if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $1}'` + fi + if [ "${PID}" != "" ]; + then + for ps in ${PID} + do + echo "kill -9 ${APP_NAME} ( pid =" ${ps} ")" + kill -9 ${ps} + done + fi +} + +list() { + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{printf("%s,%s,%s,%s\n", $1, $2, $9, $10)}'` + if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{printf("%s,%s,%s,%s,%s\n", $1, $4, $6, $7, $8)}'` + fi + + if [ "${PID}" != "" ]; then + echo "list ${APP_NAME}" + + if [[ ${OS_NAME} == "Linux" || ${OS_NAME} == "Darwin" ]]; then + echo "index: user, pid, start, duration" + else + echo "index: PID, WINPID, UID, STIME, COMMAND" + fi + idx=0 + for ps in ${PID} + do + echo "${idx}: ${ps}" + ((idx ++)) + done + fi +} + +monitor() { + idx=0 + while true; do + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}'` + if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $1}'` + fi + if [[ "${PID}" == "" ]]; then + start + idx=0 + fi + + ((LIFE=idx*${SLEEP_INTERVAL})) + echo "${APP_NAME} ( pid = " ${PID} ") has been working in normal state for " $LIFE " seconds." + ((idx ++)) + sleep ${SLEEP_INTERVAL} + done +} + +crontab() { + idx=0 + while true; do + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}'` + if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $1}'` + fi + if [[ "${PID}" == "" ]]; then + start + idx=0 + fi + + ((LIFE=idx*${SLEEP_INTERVAL})) + echo "${APP_NAME} ( pid = " ${PID} ") has been working in normal state for " $LIFE " seconds." + ((idx ++)) + sleep ${SLEEP_INTERVAL} + if [[ ${LIFE} -gt ${MAX_LIFETIME} ]]; then + kill -9 ${PID} + fi + done +} + +opt=$1 +case C"$opt" in + Cstart) + start $2 + ;; + Cstop) + stop + ;; + Cterm) + term + ;; + Crestart) + term + start $2 + ;; + Clist) + list + ;; + Cmonitor) + monitor + ;; + Ccrontab) + crontab + ;; + C*) + usage + ;; +esac + diff --git a/examples/generic/go-client/assembly/common/app.properties b/examples/generic/go-client/assembly/common/app.properties new file mode 100644 index 0000000000000000000000000000000000000000..97eee47429e978927a03c3fb2876b3d40bfa4269 --- /dev/null +++ b/examples/generic/go-client/assembly/common/app.properties @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +export TARGET_EXEC_NAME="user_info_client" +# BUILD_PACKAGE="dubbogo-examples/user-info/client/app" +export BUILD_PACKAGE="app" + +export TARGET_CONF_FILE="conf/client.yml" +export TARGET_LOG_CONF_FILE="conf/log.yml" diff --git a/examples/generic/go-client/assembly/common/build.sh b/examples/generic/go-client/assembly/common/build.sh new file mode 100644 index 0000000000000000000000000000000000000000..0f0b22f5f42a01fffa48efa4cae5d953fb44d7ed --- /dev/null +++ b/examples/generic/go-client/assembly/common/build.sh @@ -0,0 +1,84 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +rm -rf target/ + +PROJECT_HOME=`pwd` +TARGET_FOLDER=${PROJECT_HOME}/target/${GOOS} + +TARGET_SBIN_NAME=${TARGET_EXEC_NAME} +version=`cat app/version.go | grep Version | grep -v "Apache" | awk -F '=' '{print $2}' | awk -F '"' '{print $2}'` +if [[ ${GOOS} == "windows" ]]; then + TARGET_SBIN_NAME=${TARGET_SBIN_NAME}.exe +fi +TARGET_NAME=${TARGET_FOLDER}/${TARGET_SBIN_NAME} +if [[ $PROFILE == "dev" || $PROFILE == "test" ]]; then + # GFLAGS=-gcflags "-N -l" -race -x -v # -x浼氭妸go build鐨勮缁嗚繃绋嬭緭鍑� + # GFLAGS=-gcflags "-N -l" -race -v + # GFLAGS="-gcflags \"-N -l\" -v" + cd ${BUILD_PACKAGE} && GOOS=$GOOS GOARCH=$GOARCH go build -gcflags "-N -l" -x -v -i -o ${TARGET_NAME} && cd - +else + # -s鍘绘帀绗﹀彿琛紙鐒跺悗panic鏃跺€欑殑stack trace灏辨病鏈変换浣曟枃浠跺悕/琛屽彿淇℃伅浜嗭紝杩欎釜绛変环浜庢櫘閫欳/C++绋嬪簭琚玸trip鐨勬晥鏋滐級锛� + # -w鍘绘帀DWARF璋冭瘯淇℃伅锛屽緱鍒扮殑绋嬪簭灏变笉鑳界敤gdb璋冭瘯浜嗐€�-s鍜�-w涔熷彲浠ュ垎寮€浣跨敤锛屼竴鑸潵璇村鏋滀笉鎵撶畻鐢╣db璋冭瘯锛� + # -w鍩烘湰娌″暐鎹熷け銆�-s鐨勬崯澶卞氨鏈夌偣澶т簡銆� + cd ${BUILD_PACKAGE} && GOOS=$GOOS GOARCH=$GOARCH go build -ldflags "-w" -x -v -i -o ${TARGET_NAME} && cd - +fi + +TAR_NAME=${TARGET_EXEC_NAME}-${version}-`date "+%Y%m%d-%H%M"`-${PROFILE} + +mkdir -p ${TARGET_FOLDER}/${TAR_NAME} + +SBIN_DIR=${TARGET_FOLDER}/${TAR_NAME}/sbin +BIN_DIR=${TARGET_FOLDER}/${TAR_NAME} +CONF_DIR=${TARGET_FOLDER}/${TAR_NAME}/conf + +mkdir -p ${SBIN_DIR} +mkdir -p ${CONF_DIR} + +mv ${TARGET_NAME} ${SBIN_DIR} +cp -r assembly/bin ${BIN_DIR} +cd ${BIN_DIR}/bin/ && mv load.sh load_${TARGET_EXEC_NAME}.sh && cd - + +platform=$(uname) +# modify APPLICATION_NAME +if [ ${platform} == "Darwin" ]; then + sed -i "" "s~APPLICATION_NAME~${TARGET_EXEC_NAME}~g" ${BIN_DIR}/bin/* +else + sed -i "s~APPLICATION_NAME~${TARGET_EXEC_NAME}~g" ${BIN_DIR}/bin/* +fi + +# modify TARGET_CONF_FILE +if [ ${platform} == "Darwin" ]; then + sed -i "" "s~TARGET_CONF_FILE~${TARGET_CONF_FILE}~g" ${BIN_DIR}/bin/* +else + sed -i "s~TARGET_CONF_FILE~${TARGET_CONF_FILE}~g" ${BIN_DIR}/bin/* +fi + +# modify TARGET_LOG_CONF_FILE +if [ ${platform} == "Darwin" ]; then + sed -i "" "s~TARGET_LOG_CONF_FILE~${TARGET_LOG_CONF_FILE}~g" ${BIN_DIR}/bin/* +else + sed -i "s~TARGET_LOG_CONF_FILE~${TARGET_LOG_CONF_FILE}~g" ${BIN_DIR}/bin/* +fi + +cp -r profiles/${PROFILE}/* ${CONF_DIR} + +cd ${TARGET_FOLDER} + +tar czf ${TAR_NAME}.tar.gz ${TAR_NAME}/* + diff --git a/examples/generic/go-client/assembly/linux/dev.sh b/examples/generic/go-client/assembly/linux/dev.sh new file mode 100644 index 0000000000000000000000000000000000000000..4f659a7c383853b45b7d80d516c10e0c51e6cede --- /dev/null +++ b/examples/generic/go-client/assembly/linux/dev.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +set -e + +export GOOS=linux +export GOARCH=amd64 + +export PROFILE="dev" + +PROJECT_HOME=`pwd` + +if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then + . ${PROJECT_HOME}/assembly/common/app.properties +fi + + +if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then + sh ${PROJECT_HOME}/assembly/common/build.sh +fi diff --git a/examples/generic/go-client/assembly/linux/release.sh b/examples/generic/go-client/assembly/linux/release.sh new file mode 100644 index 0000000000000000000000000000000000000000..10eb3d73f8760d394537b90b7aeff83ca2b243ed --- /dev/null +++ b/examples/generic/go-client/assembly/linux/release.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + + +set -e + +export GOOS=linux +export GOARCH=amd64 + +export PROFILE="release" +export PROJECT_HOME=`pwd` + +if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then + . ${PROJECT_HOME}/assembly/common/app.properties +fi + + +if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then + sh ${PROJECT_HOME}/assembly/common/build.sh +fi diff --git a/examples/generic/go-client/assembly/linux/test.sh b/examples/generic/go-client/assembly/linux/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..78b650c0d49483f9f6862532afa5c483b618475a --- /dev/null +++ b/examples/generic/go-client/assembly/linux/test.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + + +set -e + +export GOOS=linux +export GOARCH=amd64 + +export PROFILE="test" +export PROJECT_HOME=`pwd` + +if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then + . ${PROJECT_HOME}/assembly/common/app.properties +fi + + +if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then + sh ${PROJECT_HOME}/assembly/common/build.sh +fi diff --git a/examples/generic/go-client/assembly/mac/dev.sh b/examples/generic/go-client/assembly/mac/dev.sh new file mode 100644 index 0000000000000000000000000000000000000000..0d21ec4aab54676837e0a909467cbf56f6bfc275 --- /dev/null +++ b/examples/generic/go-client/assembly/mac/dev.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +set -e + +export GOOS=darwin +export GOARCH=amd64 + +export PROFILE="dev" + +export PROJECT_HOME=`pwd` + +if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then + . ${PROJECT_HOME}/assembly/common/app.properties +fi + + +if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then + sh ${PROJECT_HOME}/assembly/common/build.sh +fi diff --git a/examples/generic/go-client/assembly/mac/release.sh b/examples/generic/go-client/assembly/mac/release.sh new file mode 100644 index 0000000000000000000000000000000000000000..91c2dfee79b1499b640420191174f980eac187bb --- /dev/null +++ b/examples/generic/go-client/assembly/mac/release.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + + +set -e + +export GOOS=darwin +export GOARCH=amd64 + +export PROFILE="release" +export PROJECT_HOME=`pwd` + +if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then + . ${PROJECT_HOME}/assembly/common/app.properties +fi + +if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then + sh ${PROJECT_HOME}/assembly/common/build.sh +fi diff --git a/examples/generic/go-client/assembly/mac/test.sh b/examples/generic/go-client/assembly/mac/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..2fac89d0f6b9feb95b79359b38078135f15d90e3 --- /dev/null +++ b/examples/generic/go-client/assembly/mac/test.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + + +set -e + +export GOOS=darwin +export GOARCH=amd64 + +export PROFILE="test" +export PROJECT_HOME=`pwd` + +if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then + . ${PROJECT_HOME}/assembly/common/app.properties +fi + + +if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then + sh ${PROJECT_HOME}/assembly/common/build.sh +fi diff --git a/examples/generic/go-client/assembly/windows/dev.sh b/examples/generic/go-client/assembly/windows/dev.sh new file mode 100644 index 0000000000000000000000000000000000000000..10a3866c0f4ed8e1070c4d5641259c04073df6cb --- /dev/null +++ b/examples/generic/go-client/assembly/windows/dev.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + + +set -e + +export GOOS=linux +export GOARCH=amd64 + +export PROFILE="dev" +PROJECT_HOME=`pwd` + +if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then + . ${PROJECT_HOME}/assembly/common/app.properties +fi + +if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then + sh ${PROJECT_HOME}/assembly/common/build.sh +fi diff --git a/examples/generic/go-client/assembly/windows/release.sh b/examples/generic/go-client/assembly/windows/release.sh new file mode 100644 index 0000000000000000000000000000000000000000..21af573fa3842d47959d5726b11b81d5fff5b8df --- /dev/null +++ b/examples/generic/go-client/assembly/windows/release.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + + +set -e + +export GOOS=windows +export GOARCH=amd64 + +export PROFILE="release" +export PROJECT_HOME=`pwd` + +if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then + . ${PROJECT_HOME}/assembly/common/app.properties +fi + +if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then + sh ${PROJECT_HOME}/assembly/common/build.sh +fi diff --git a/examples/generic/go-client/assembly/windows/test.sh b/examples/generic/go-client/assembly/windows/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..2104da8b5909957c165eedc2f7d6866a890e9e6d --- /dev/null +++ b/examples/generic/go-client/assembly/windows/test.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + + +set -e + +export GOOS=windows +export GOARCH=amd64 + +export PROFILE="test" +export PROJECT_HOME=`pwd` + +if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then + . ${PROJECT_HOME}/assembly/common/app.properties +fi + +if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then + sh ${PROJECT_HOME}/assembly/common/build.sh +fi diff --git a/examples/generic/go-client/profiles/dev/client.yml b/examples/generic/go-client/profiles/dev/client.yml new file mode 100644 index 0000000000000000000000000000000000000000..f4e3180aa88cbbdffd519d70b3cc83b2e2b6674a --- /dev/null +++ b/examples/generic/go-client/profiles/dev/client.yml @@ -0,0 +1,55 @@ +# dubbo client yaml configure file + + +check: true +# client +request_timeout : "3s" +# connect timeout +connect_timeout : "3s" + +# application config +application_config: + organization : "ikurento.com" + name : "BDTService" + module : "dubbogo genric client" + version : "0.0.1" + owner : "ZX" + environment : "dev" + +registries : + "hangzhouzk": + protocol: "zookeeper" + timeout : "3s" + address: "127.0.0.1:2181" + username: "" + password: "" + "shanghaizk": + protocol: "zookeeper" + timeout : "3s" + address: "127.0.0.1:2182" + username: "" + password: "" + +references: + +protocol_conf: + dubbo: + reconnect_interval: 0 + connection_number: 2 + heartbeat_period: "5s" + session_timeout: "20s" + pool_size: 64 + pool_ttl: 600 + getty_session_param: + compress_encoding: false + tcp_no_delay: true + tcp_keep_alive: true + keep_alive_period: "120s" + tcp_r_buf_size: 262144 + tcp_w_buf_size: 65536 + pkg_wq_size: 512 + tcp_read_timeout: "1s" + tcp_write_timeout: "5s" + wait_timeout: "1s" + max_msg_len: 10240 + session_name: "client" diff --git a/examples/generic/go-client/profiles/dev/log.yml b/examples/generic/go-client/profiles/dev/log.yml new file mode 100644 index 0000000000000000000000000000000000000000..59fa4279ad85272c4c49d532beaf23b74d00f58a --- /dev/null +++ b/examples/generic/go-client/profiles/dev/log.yml @@ -0,0 +1,28 @@ + +level: "debug" +development: true +disableCaller: false +disableStacktrace: false +sampling: +encoding: "console" + +# encoder +encoderConfig: + messageKey: "message" + levelKey: "level" + timeKey: "time" + nameKey: "logger" + callerKey: "caller" + stacktraceKey: "stacktrace" + lineEnding: "" + levelEncoder: "capitalColor" + timeEncoder: "iso8601" + durationEncoder: "seconds" + callerEncoder: "short" + nameEncoder: "" + +outputPaths: + - "stderr" +errorOutputPaths: + - "stderr" +initialFields: diff --git a/examples/generic/go-client/profiles/release/client.yml b/examples/generic/go-client/profiles/release/client.yml new file mode 100644 index 0000000000000000000000000000000000000000..5a21bca6c93336a8888b55a6a7e81f9240c709a5 --- /dev/null +++ b/examples/generic/go-client/profiles/release/client.yml @@ -0,0 +1,55 @@ +# dubbo client yaml configure file + + +check: true +# client +request_timeout : "3s" +# connect timeout +connect_timeout : "3s" + +# application config +application_config: + organization : "ikurento.com" + name : "BDTService" + module : "dubbogo generic client" + version : "0.0.1" + owner : "ZX" + environment : "release" + +registries : + "hangzhouzk": + protocol: "zookeeper" + timeout : "3s" + address: "127.0.0.1:2181" + username: "" + password: "" + "shanghaizk": + protocol: "zookeeper" + timeout : "3s" + address: "127.0.0.1:2182" + username: "" + password: "" + +references: + +protocol_conf: + dubbo: + reconnect_interval: 0 + connection_number: 2 + heartbeat_period: "5s" + session_timeout: "20s" + pool_size: 64 + pool_ttl: 600 + getty_session_param: + compress_encoding: false + tcp_no_delay: true + tcp_keep_alive: true + keep_alive_period: "120s" + tcp_r_buf_size: 262144 + tcp_w_buf_size: 65536 + pkg_wq_size: 512 + tcp_read_timeout: "1s" + tcp_write_timeout: "5s" + wait_timeout: "1s" + max_msg_len: 10240 + session_name: "client" diff --git a/examples/generic/go-client/profiles/release/log.yml b/examples/generic/go-client/profiles/release/log.yml new file mode 100644 index 0000000000000000000000000000000000000000..e0514be020eedf594d99d112183cdd5ce199e46d --- /dev/null +++ b/examples/generic/go-client/profiles/release/log.yml @@ -0,0 +1,28 @@ + +level: "warn" +development: true +disableCaller: true +disableStacktrace: true +sampling: +encoding: "console" + +# encoder +encoderConfig: + messageKey: "message" + levelKey: "level" + timeKey: "time" + nameKey: "logger" + callerKey: "caller" + stacktraceKey: "stacktrace" + lineEnding: "" + levelEncoder: "capitalColor" + timeEncoder: "iso8601" + durationEncoder: "seconds" + callerEncoder: "short" + nameEncoder: "" + +outputPaths: + - "stderr" +errorOutputPaths: + - "stderr" +initialFields: diff --git a/examples/generic/go-client/profiles/test/client.yml b/examples/generic/go-client/profiles/test/client.yml new file mode 100644 index 0000000000000000000000000000000000000000..7442c64c71abf47db9c15d85c6bcd2ced8057e46 --- /dev/null +++ b/examples/generic/go-client/profiles/test/client.yml @@ -0,0 +1,55 @@ +# dubbo client yaml configure file + + +check: true +# client +request_timeout : "3s" +# connect timeout +connect_timeout : "3s" + +# application config +application_config: + organization : "ikurento.com" + name : "BDTService" + module : "dubbogo user-info client" + version : "0.0.1" + owner : "ZX" + environment : "test" + +registries : + "hangzhouzk": + protocol: "zookeeper" + timeout : "3s" + address: "127.0.0.1:2181" + username: "" + password: "" + "shanghaizk": + protocol: "zookeeper" + timeout : "3s" + address: "127.0.0.1:2182" + username: "" + password: "" + +references: + +protocol_conf: + dubbo: + reconnect_interval: 0 + connection_number: 2 + heartbeat_period: "5s" + session_timeout: "20s" + pool_size: 64 + pool_ttl: 600 + getty_session_param: + compress_encoding: false + tcp_no_delay: true + tcp_keep_alive: true + keep_alive_period: "120s" + tcp_r_buf_size: 262144 + tcp_w_buf_size: 65536 + pkg_wq_size: 512 + tcp_read_timeout: "1s" + tcp_write_timeout: "5s" + wait_timeout: "1s" + max_msg_len: 10240 + session_name: "client" diff --git a/examples/generic/go-client/profiles/test/log.yml b/examples/generic/go-client/profiles/test/log.yml new file mode 100644 index 0000000000000000000000000000000000000000..baee0b7248484e425f88f35ab128212c931ff85e --- /dev/null +++ b/examples/generic/go-client/profiles/test/log.yml @@ -0,0 +1,28 @@ + +level: "info" +development: false +disableCaller: false +disableStacktrace: true +sampling: +encoding: "console" + +# encoder +encoderConfig: + messageKey: "message" + levelKey: "level" + timeKey: "time" + nameKey: "logger" + callerKey: "caller" + stacktraceKey: "stacktrace" + lineEnding: "" + levelEncoder: "capitalColor" + timeEncoder: "iso8601" + durationEncoder: "seconds" + callerEncoder: "short" + nameEncoder: "" + +outputPaths: + - "stderr" +errorOutputPaths: + - "stderr" +initialFields: diff --git a/examples/generic/java-server/build.sh b/examples/generic/java-server/build.sh new file mode 100644 index 0000000000000000000000000000000000000000..7b5755be183f5b301f0963fcc4a4eace8a341574 --- /dev/null +++ b/examples/generic/java-server/build.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# mvn dependency:sources +mvn clean package -Dmaven.test.skip +# mvn -X clean compile package -DskipTests=true diff --git a/examples/generic/java-server/pom.xml b/examples/generic/java-server/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..9b811e9f78a3db3cb742ce5870b5d68b55bd681c --- /dev/null +++ b/examples/generic/java-server/pom.xml @@ -0,0 +1,195 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>com.ikurento</groupId> + <artifactId>user-info-server</artifactId> + <packaging>jar</packaging> + <version>0.2.0</version> + <description>The demo provider module of dubbo project</description> + <properties> + <skip_maven_deploy>false</skip_maven_deploy> + + <dubbo-version>2.6.5</dubbo-version> + <dubbo-jsonrpc-version>1.0.1</dubbo-jsonrpc-version> + </properties> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>com.alibaba</groupId> + <artifactId>dubbo-dependencies-bom</artifactId> + <version>${dubbo-version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + + <dependencies> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <version>1.7.25</version> + </dependency> + + <dependency> + <groupId>com.alibaba</groupId> + <artifactId>dubbo</artifactId> + <version>${dubbo-version}</version> + <exclusions> + </exclusions> + </dependency> + + <dependency> + <groupId>io.netty</groupId> + <artifactId>netty-all</artifactId> + </dependency> + <dependency> + <groupId>org.apache.curator</groupId> + <artifactId>curator-framework</artifactId> + <version>2.12.0</version> + </dependency> + + <dependency> + <groupId>com.qianmi</groupId> + <artifactId>dubbo-rpc-jsonrpc</artifactId> + <version>${dubbo-jsonrpc-version}</version> + <exclusions> + <exclusion> + <groupId>org.springframework</groupId> + <artifactId>spring</artifactId> + </exclusion> + </exclusions> + </dependency> + + <dependency> + <groupId>org.mortbay.jetty</groupId> + <artifactId>jetty</artifactId> + <version>6.1.26</version> + </dependency> + + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-core</artifactId> + <version>2.9.9</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-databind</artifactId> + <version>2.9.9</version> + </dependency> + + <dependency> + <groupId>com.github.sgroschupf</groupId> + <artifactId>zkclient</artifactId> + <version>0.1</version> + <exclusions> + <exclusion> + <artifactId>org.apache.zookeeper</artifactId> + <groupId>zookeeper</groupId> + </exclusion> + </exclusions> + </dependency> + + <dependency> + <groupId>org.apache.zookeeper</groupId> + <artifactId>zookeeper</artifactId> + <version>3.4.14</version> + </dependency> + + </dependencies> + + <repositories> + <repository> + <id>nexus-aliyu</id> + <url>http://maven.aliyun.com/nexus/content/groups/public</url> + <releases> + <enabled>true</enabled> + </releases> + <snapshots> + <enabled>false</enabled> + </snapshots> + </repository> + </repositories> + <pluginRepositories> + <pluginRepository> + <id>nexus-aliyu</id> + <url>http://maven.aliyun.com/nexus/content/groups/public</url> + <releases> + <enabled>true</enabled> + </releases> + <snapshots> + <enabled>false</enabled> + </snapshots> + </pluginRepository> + </pluginRepositories> + + + <build> + + <plugins> + <plugin> + <artifactId>maven-dependency-plugin</artifactId> + <executions> + <execution> + <id>unpack</id> + <phase>package</phase> + <goals> + <goal>unpack</goal> + </goals> + <configuration> + <artifactItems> + <artifactItem> + <groupId>com.alibaba</groupId> + <artifactId>dubbo</artifactId> + <version>${dubbo-version}</version> + <outputDirectory>${project.build.directory}/dubbo</outputDirectory> + <includes>META-INF/assembly/**</includes> + </artifactItem> + </artifactItems> + </configuration> + </execution> + </executions> + </plugin> + + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <executions> + <execution> + <id>make-assembly</id> + <phase>package</phase> + <goals> + <goal>single</goal> + </goals> + <configuration> + <descriptors> + <descriptor>src/main/assembly/assembly.xml</descriptor> + </descriptors> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + + +</project> + + diff --git a/examples/generic/java-server/script/debug.sh b/examples/generic/java-server/script/debug.sh new file mode 100644 index 0000000000000000000000000000000000000000..1038cd7ff7f65a2a07ce21414732ab891aef67ff --- /dev/null +++ b/examples/generic/java-server/script/debug.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# jdb -classpath /Users/alex/tmp/us/conf:/Users/alex/tmp/us/lib/*:/Users/alex/test/java/dubbo/2.5.4/dubbo-remoting/dubbo-remoting-api/src/main/java/ com.alibaba.dubbo.container.Main +jdb -classpath /Users/alex/tmp/us/conf:/Users/alex/tmp/us/lib/* -sourcepath /Users/alex/test/java/dubbo/2.5.4/dubbo-remoting/dubbo-remoting-api/src/main/java/:/Users/alex/tmp/java-server/src/main/java com.alibaba.dubbo.container.Main +# jdb stop at com.alibaba.dubbo.remoting.exchange.codec.ExchangeCodec:76 +# run + diff --git a/examples/generic/java-server/src/main/assembly/assembly.xml b/examples/generic/java-server/src/main/assembly/assembly.xml new file mode 100644 index 0000000000000000000000000000000000000000..98a2e100f18d195b8f0b44eb07080eaa9097af79 --- /dev/null +++ b/examples/generic/java-server/src/main/assembly/assembly.xml @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<assembly> + <id>assembly</id> + <formats> + <format>tar.gz</format> + </formats> + <includeBaseDirectory>true</includeBaseDirectory> + <fileSets> + <fileSet> + <directory>${project.build.directory}/dubbo/META-INF/assembly/bin</directory> + <outputDirectory>bin</outputDirectory> + <fileMode>0755</fileMode> + <directoryMode>0755</directoryMode> + </fileSet> + <fileSet> + <directory>src/main/assembly/conf</directory> + <includes> + <include>dubbo.properties</include> + <include>log4j.*</include> + </includes> + <outputDirectory>conf</outputDirectory> + <fileMode>0644</fileMode> + <directoryMode>0755</directoryMode> + </fileSet> + </fileSets> + <dependencySets> + <dependencySet> + <outputDirectory>lib</outputDirectory> + </dependencySet> + </dependencySets> +</assembly> \ No newline at end of file diff --git a/examples/generic/java-server/src/main/assembly/conf/dubbo.properties b/examples/generic/java-server/src/main/assembly/conf/dubbo.properties new file mode 100644 index 0000000000000000000000000000000000000000..2826f31303717256725b02a79e1698043709d2f3 --- /dev/null +++ b/examples/generic/java-server/src/main/assembly/conf/dubbo.properties @@ -0,0 +1,14 @@ +### dubbo娉ㄥ唽涓績閰嶇疆 ## +dubbo.container = log4j,spring +dubbo.application.name = user-info-server +dubbo.application.environment = product +dubbo.application.owner = AlexStocks +dubbo.registry.address = 127.0.0.1:2181 +dubbo.registry.protocol = zookeeper +dubbo.consumer.timeout = 10000 +dubbo.provider.timeout = 10000 +dubbo.protocol.name = dubbo +dubbo.protocol.port = 10000 + +dubbo.log4j.file = logs/dubbo.log +dubbo.log4j.level = INFO diff --git a/examples/generic/java-server/src/main/assembly/conf/log4j.properties b/examples/generic/java-server/src/main/assembly/conf/log4j.properties new file mode 100644 index 0000000000000000000000000000000000000000..13c80493329261ea677de77624b363bf99c82652 --- /dev/null +++ b/examples/generic/java-server/src/main/assembly/conf/log4j.properties @@ -0,0 +1,20 @@ +## Logger configure file for myproject +log.dir=logs/ +datestamp=yyyy-MM-dd/HH:mm:ss.SSS + +log4j.rootLogger=DEBUG, file, console + +log4j.appender.file=org.apache.log4j.DailyRollingFileAppender +log4j.appender.file.threshold=DEBUG +log4j.appender.file.File=${log.dir}/log4j.log +log4j.appender.file.DatePattern=-yyyyMMddHH +log4j.appender.file.ImmediateFlush=true +log4j.appender.file.Append=true +log4j.appender.file.layout=org.apache.log4j.PatternLayout +log4j.appender.file.layout.ConversionPattern=%d{${datestamp}} %5p: %l - %m%n + +log4j.appender.console=org.apache.log4j.ConsoleAppender +log4j.appender.console.Threshold=DEBUG +log4j.appender.console.layout=org.apache.log4j.PatternLayout +log4j.appender.console.layout.ConversionPattern=%d{${datestamp}} %5p: %l - %m%n + diff --git a/examples/generic/java-server/src/main/java/com/ikurento/user/Gender.java b/examples/generic/java-server/src/main/java/com/ikurento/user/Gender.java new file mode 100644 index 0000000000000000000000000000000000000000..e606be79c9f633919132570b69e4d0a6588c9c8a --- /dev/null +++ b/examples/generic/java-server/src/main/java/com/ikurento/user/Gender.java @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.ikurento.user; + +public enum Gender { + MAN, + WOMAN +} diff --git a/examples/generic/java-server/src/main/java/com/ikurento/user/Provider.java b/examples/generic/java-server/src/main/java/com/ikurento/user/Provider.java new file mode 100644 index 0000000000000000000000000000000000000000..0031f5569fd5f16ded0da6e5426f78805fad4a42 --- /dev/null +++ b/examples/generic/java-server/src/main/java/com/ikurento/user/Provider.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.ikurento.user; + +import org.springframework.context.support.ClassPathXmlApplicationContext; + +public class Provider { + + /** + * To get ipv6 address to work, add + * System.setProperty("java.net.preferIPv6Addresses", "true"); + * before running your application. + */ + public static void main(String[] args) throws Exception { + ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"META-INF/spring/dubbo.provider.xml"}); + context.start(); + System.in.read(); // press any key to exit + } +} diff --git a/examples/generic/java-server/src/main/java/com/ikurento/user/Response.java b/examples/generic/java-server/src/main/java/com/ikurento/user/Response.java new file mode 100644 index 0000000000000000000000000000000000000000..83b423dd084fe7626bc34b356ca8c6e5b540c539 --- /dev/null +++ b/examples/generic/java-server/src/main/java/com/ikurento/user/Response.java @@ -0,0 +1,92 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.ikurento.user; + +import java.io.*; + +public final class Response<T> implements Serializable { + private static final long serialVersionUID = 3727205004706510648L; + public static final Integer OK = 200; + public static final Integer ERR = 500; + private Integer Status; + private String Err; + private T Data; + + public Response() { + } + + public static <T> Response<T> ok() { + Response r = new Response(); + r.Status = OK; + return r; + } + + public static <T> Response<T> ok(Object Data) { + Response r = new Response(); + r.Status = OK; + r.Data = Data; + return r; + } + + public static <T> Response<T> notOk(String Err) { + Response r = new Response(); + r.Status = ERR; + r.Err = Err; + return r; + } + + public static <T> Response<T> notOk(Integer Status, String Err) { + Response r = new Response(); + r.Status = Status; + r.Err = Err; + return r; + } + +// public Boolean isSuccess() { +// return Objects.equals(this.Status, OK); +// } + + public Integer getStatus() { + return this.Status; + } + + public void setStatus(Integer Status) { + this.Status = Status; + } + + public String getErr() { + return this.Err; + } + + public void setErr(String Err) { + this.Err = Err; + } + + public T getData() { + return this.Data; + } + + public void setData(T Data) { + this.Status = OK; + this.Data = Data; + } + + public String toString() { + return "Response{Status=" + this.Status + ", Err='" + this.Err + '\'' + ", Data=" + this.Data + '}'; + } +} \ No newline at end of file diff --git a/examples/generic/java-server/src/main/java/com/ikurento/user/User.java b/examples/generic/java-server/src/main/java/com/ikurento/user/User.java new file mode 100644 index 0000000000000000000000000000000000000000..a6e76cffe9c41c3b505550a5f3b15c202a13907c --- /dev/null +++ b/examples/generic/java-server/src/main/java/com/ikurento/user/User.java @@ -0,0 +1,95 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.ikurento.user; + +import java.util.Date; +import java.io.Serializable; + +public class User implements Serializable { + + private String id; + + private String name; + + private int age; + + private Date time = new Date(); + + private Gender sex = Gender.MAN; + + public User() { + } + + public User(String id, String name, int age) { + this.id = id; + this.name = name; + this.age = age; + } + + public User(String id, String name, int age, Date time, Gender sex) { + this.id = id; + this.name = name; + this.age = age; + this.time = time; + this.sex = sex; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + public Date getTime() { + return time; + } + + public void setTime(Date time) { + this.time = time; + } + + public Gender getSex() { + return sex; + } + + public void setSex(Gender sex) { + this.sex = sex; + } + + public String toString() { + return "User{id:" + id + ", name:" + name + ", age:" + age + ", time:" + time + ", gender:" + sex + "}"; + } +} diff --git a/examples/generic/java-server/src/main/java/com/ikurento/user/UserProvider.java b/examples/generic/java-server/src/main/java/com/ikurento/user/UserProvider.java new file mode 100644 index 0000000000000000000000000000000000000000..60335876436ec77563b86c39066451e6cb04c71d --- /dev/null +++ b/examples/generic/java-server/src/main/java/com/ikurento/user/UserProvider.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.ikurento.user; + +import java.util.List; +import java.util.Map; + +public interface UserProvider { + + boolean isLimit(Gender gender, String name); + + User GetUser(String userId); // the first alpha is Upper case to compatible with golang. + + List<User> GetUsers(List<String> userIdList); + + void GetUser3(); + + User GetUser0(String userId, String name); + + User GetErr(String userId) throws Exception; + + Map<String, User> GetUserMap(List<String> userIdList); + + User getUser(int usercode); + + User queryUser(User user); + + Map<String, User> queryAll(); + + int Calc(int a,int b); + + Response<Integer> Sum(int a, int b); +} diff --git a/examples/generic/java-server/src/main/java/com/ikurento/user/UserProviderAnotherImpl.java b/examples/generic/java-server/src/main/java/com/ikurento/user/UserProviderAnotherImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..05611fc9a8de061543982261697a25f4cac0d98f --- /dev/null +++ b/examples/generic/java-server/src/main/java/com/ikurento/user/UserProviderAnotherImpl.java @@ -0,0 +1,137 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.ikurento.user; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +// import org.apache.log4j.Logger; +// import org.apache.log4j.LoggerFactory; + +import java.util.*; + +public class UserProviderAnotherImpl implements UserProvider { + // private static final Logger logger = LoggerFactory.getLogger(getClass()); // 鍙緭鍑哄埌dubbo鐨刲og(logs/server.log) + private static final Logger logger = LoggerFactory.getLogger("userLogger"); // 杈撳嚭鍒皍ser-server.log + + private Map<String, User> userMap = new HashMap<String, User>(); + + public UserProviderAnotherImpl() { + // userMap.put("001", new User("001", "other-zhangsan", 18, new Date(1998-1900, 1, 2, 3, 4, 5), Gender.MAN)); + userMap.put("001", new User("001", "other-zhangsan", 18, new Date(0x12345678), Gender.MAN)); + userMap.put("002", new User("002", "other-lisi", 20, new Date(1996-1900, 1, 2, 3, 4, 5), Gender.MAN)); + userMap.put("003", new User("003", "other-lily", 23, new Date(1993-1900, 1, 2, 3, 4, 5), Gender.WOMAN)); + userMap.put("004", new User("004", "other-lisa", 32, new Date(1985-1900, 1, 2, 3, 4, 5), Gender.WOMAN)); + } + + public boolean isLimit(Gender gender, String name) { + logger.info(String.format("input gender=%sand name=%s", gender, name)); + return Gender.MAN == gender; + } + + public User GetUser(String userId) { + logger.info("input userId = " + userId); + return new User(userId, "Joe", 48); + } + + public User GetUser0(String userId, String name) { + return new User(userId, name, 48); + } + public void GetUser3() { + } + public User GetErr(String userId) throws Exception { + throw new Exception("exception"); + } + public List<User> GetUsers(ArrayList<String> userIdList) { + Iterator it = userIdList.iterator(); + List<User> userList = new ArrayList<User>(); + logger.warn("@userIdList size:" + userIdList.size()); + + while(it.hasNext()) { + String id = (String)(it.next()); + logger.info("GetUsers(@uid:" + id + ")"); + if (userMap.containsKey(id)) { + userList.add(userMap.get(id)); + logger.info("id:" + id + ", user:" + userMap.get(id)); + } + } + + return userList; + } + + public Map<String, User> GetUserMap(List<String> userIdList) { + Iterator it = userIdList.iterator(); + Map<String, User> map = new HashMap<String, User>(); + logger.warn("@userIdList size:" + userIdList.size()); + + while(it.hasNext()) { + String id = (String)(it.next()); + logger.info("GetUsers(@uid:" + id + ")"); + if (userMap.containsKey(id)) { + map.put(id, userMap.get(id)); + logger.info("id:" + id + ", user:" + userMap.get(id)); + } + } + + return map; + } + + public List<User> GetUsers(List<String> userIdList) { + Iterator it = userIdList.iterator(); + List<User> userList = new ArrayList<User>(); + logger.warn("@userIdList size:" + userIdList.size()); + + while(it.hasNext()) { + String id = (String)(it.next()); + logger.info("GetUsers(@uid:" + id + ")"); + if (userMap.containsKey(id)) { + userList.add(userMap.get(id)); + logger.info("id:" + id + ", user:" + userMap.get(id)); + } + } + + return userList; + } + + // @Override + public User getUser(int userCode) { + logger.info("input userCode = " + userCode); + return new User(String.valueOf(userCode), "userCode get", 48); + } + + public User queryUser(User user) { + logger.info("input user = " + user); + return new User(user.getId(), "get:" + user.getName(), user.getAge() + 18); + } + + public Map<String, User> queryAll() { + logger.info("input"); + Map<String, User> map = new HashMap<String, User>(); + map.put("001", new User("001", "Joe", 18)); + map.put("002", new User("002", "Wen", 20)); + + return map; + } + + public int Calc(int a,int b) { + return a + b + 100; + } + + public Response<Integer> Sum(int a,int b) { + return Response.ok(a+b); + } +} diff --git a/examples/generic/java-server/src/main/java/com/ikurento/user/UserProviderImpl.java b/examples/generic/java-server/src/main/java/com/ikurento/user/UserProviderImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..1984d169aac651e2d8534e789810d4c910e48152 --- /dev/null +++ b/examples/generic/java-server/src/main/java/com/ikurento/user/UserProviderImpl.java @@ -0,0 +1,115 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.ikurento.user; + +import java.util.HashMap; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.Iterator; + +// import org.apache.log4j.Logger; +// import org.apache.log4j.LoggerFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class UserProviderImpl implements UserProvider { + // private static final Logger logger = LoggerFactory.getLogger(getClass()); // 鍙緭鍑哄埌dubbo鐨刲og(logs/server.log) + private static final Logger LOG = LoggerFactory.getLogger("UserLogger"); // 杈撳嚭鍒皍ser-server.log + Map<String, User> userMap = new HashMap<String, User>(); + + public UserProviderImpl() { + userMap.put("A001", new User("A001", "demo-zhangsan", 18)); + userMap.put("A002", new User("A002", "demo-lisi", 20)); + userMap.put("A003", new User("A003", "demo-lily", 23)); + userMap.put("A004", new User("A004", "demo-lisa", 32)); + } + + public boolean isLimit(Gender gender, String name) { + return Gender.WOMAN == gender; + } + + public User GetUser(String userId) { + return new User(userId, "zhangsan", 18); + } + public User GetErr(String userId) throws Exception { + throw new Exception("exception"); + } + public User GetUser0(String userId, String name) { + return new User(userId, name, 18); + } + + public List<User> GetUsers(List<String> userIdList) { + Iterator it = userIdList.iterator(); + List<User> userList = new ArrayList<User>(); + LOG.warn("@userIdList size:" + userIdList.size()); + + while(it.hasNext()) { + String id = (String)(it.next()); + LOG.info("GetUsers(@uid:" + id + ")"); + if (userMap.containsKey(id)) { + userList.add(userMap.get(id)); + LOG.info("id:" + id + ", user:" + userMap.get(id)); + } + } + + return userList; + } + + public void GetUser3() { + } + + public Map<String, User> GetUserMap(List<String> userIdList) { + Iterator it = userIdList.iterator(); + Map<String, User> map = new HashMap<String, User>(); + LOG.warn("@userIdList size:" + userIdList.size()); + + while(it.hasNext()) { + String id = (String)(it.next()); + LOG.info("GetUsers(@uid:" + id + ")"); + if (userMap.containsKey(id)) { + map.put(id, userMap.get(id)); + LOG.info("id:" + id + ", user:" + userMap.get(id)); + } + } + + return map; + } + + public User queryUser(User user) { + return new User(user.getId(), "hello:" +user.getName(), user.getAge() + 18); + } + + public Map<String, User> queryAll() { + return userMap; + } + + + public User getUser(int userCode) { + return new User(String.valueOf(userCode), "userCode get", 48); + } + + + public int Calc(int a,int b) { + return a + b; + } + + public Response<Integer> Sum(int a,int b) { + return Response.ok(a+b); + } +} diff --git a/examples/generic/java-server/src/main/resources/META-INF/spring/dubbo.provider.xml b/examples/generic/java-server/src/main/resources/META-INF/spring/dubbo.provider.xml new file mode 100644 index 0000000000000000000000000000000000000000..4ebe64b937bfcccf0ee97c948c76329272a9cca5 --- /dev/null +++ b/examples/generic/java-server/src/main/resources/META-INF/spring/dubbo.provider.xml @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:dubbo="http://code.alibabatech.com/schema/dubbo" + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd + http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd"> + + <!-- 搴旂敤鍚� --> + <dubbo:application name="user-info-server"/> + <!-- 杩炴帴鍒板摢涓湰鍦版敞鍐屼腑蹇� --> + <dubbo:registry id="ikurento" address="zookeeper://127.0.0.1:2181" /> + <dubbo:registry id="ikurento2" address="zookeeper://127.0.0.1:2182" /> + <!-- 鐢╠ubbo鍗忚鍦�20880绔彛鏆撮湶鏈嶅姟 --> + <!-- dubbo:protocol host="127.0.0.1" / --> + <dubbo:protocol id="dubbo" name="dubbo" host="127.0.0.1" port="20010" /> + <dubbo:protocol id="jsonrpc" name="jsonrpc" host="127.0.0.1" port="10010" /> + <!-- 澹版槑闇€瑕佹毚闇茬殑鏈嶅姟鎺ュ彛 --> + <dubbo:service id="aaa" registry="ikurento" timeout="3000" interface="com.ikurento.user.UserProvider" ref="demoService"/> + <dubbo:service id="bbb" registry="ikurento" timeout="3000" interface="com.ikurento.user.UserProvider" ref="otherService" version="2.0"/> + <dubbo:service id="ccc" registry="ikurento" timeout="3000" interface="com.ikurento.user.UserProvider" ref="otherService" group="as" version="2.0"/> + + <bean id="demoService" class="com.ikurento.user.UserProviderImpl" /> + <bean id="otherService" class="com.ikurento.user.UserProviderAnotherImpl"/> + +</beans> diff --git a/examples/generic/java-server/src/main/resources/log4j.properties b/examples/generic/java-server/src/main/resources/log4j.properties new file mode 100644 index 0000000000000000000000000000000000000000..13c80493329261ea677de77624b363bf99c82652 --- /dev/null +++ b/examples/generic/java-server/src/main/resources/log4j.properties @@ -0,0 +1,20 @@ +## Logger configure file for myproject +log.dir=logs/ +datestamp=yyyy-MM-dd/HH:mm:ss.SSS + +log4j.rootLogger=DEBUG, file, console + +log4j.appender.file=org.apache.log4j.DailyRollingFileAppender +log4j.appender.file.threshold=DEBUG +log4j.appender.file.File=${log.dir}/log4j.log +log4j.appender.file.DatePattern=-yyyyMMddHH +log4j.appender.file.ImmediateFlush=true +log4j.appender.file.Append=true +log4j.appender.file.layout=org.apache.log4j.PatternLayout +log4j.appender.file.layout.ConversionPattern=%d{${datestamp}} %5p: %l - %m%n + +log4j.appender.console=org.apache.log4j.ConsoleAppender +log4j.appender.console.Threshold=DEBUG +log4j.appender.console.layout=org.apache.log4j.PatternLayout +log4j.appender.console.layout.ConversionPattern=%d{${datestamp}} %5p: %l - %m%n + diff --git a/examples/helloworld/dubbo/go-client/assembly/bin/load.sh b/examples/helloworld/dubbo/go-client/assembly/bin/load.sh index 07d5d15eac7b7974845e36c3807e7ec55875de65..176a202ab8810701ac8208db0ab764f2e215d71d 100644 --- a/examples/helloworld/dubbo/go-client/assembly/bin/load.sh +++ b/examples/helloworld/dubbo/go-client/assembly/bin/load.sh @@ -1,13 +1,19 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : dubbogo app devops script -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-05-13 02:01 -# FILE : load.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. APP_NAME="APPLICATION_NAME" APP_ARGS="" diff --git a/examples/helloworld/dubbo/go-client/assembly/common/app.properties b/examples/helloworld/dubbo/go-client/assembly/common/app.properties index 6bbd6db850ceeaf5ff873fee01a3578237cbd557..97eee47429e978927a03c3fb2876b3d40bfa4269 100644 --- a/examples/helloworld/dubbo/go-client/assembly/common/app.properties +++ b/examples/helloworld/dubbo/go-client/assembly/common/app.properties @@ -1,13 +1,20 @@ -# dubbogo application configure script -# ****************************************************** -# DESC : dubbogo environment variable -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:29 -# FILE : app.properties -# ****************************************************** +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + export TARGET_EXEC_NAME="user_info_client" # BUILD_PACKAGE="dubbogo-examples/user-info/client/app" diff --git a/examples/helloworld/dubbo/go-client/assembly/common/build.sh b/examples/helloworld/dubbo/go-client/assembly/common/build.sh index e72418297ad2f0ac6985476b5a8d5e03b9e7584e..0f0b22f5f42a01fffa48efa4cae5d953fb44d7ed 100644 --- a/examples/helloworld/dubbo/go-client/assembly/common/build.sh +++ b/examples/helloworld/dubbo/go-client/assembly/common/build.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:28 -# FILE : build.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + rm -rf target/ diff --git a/examples/helloworld/dubbo/go-client/assembly/linux/dev.sh b/examples/helloworld/dubbo/go-client/assembly/linux/dev.sh index 3373f01b948b708cd7bc1958c9d56a9042c60a68..eada737c8d0939d4237a6d218fc2a07efdbff381 100644 --- a/examples/helloworld/dubbo/go-client/assembly/linux/dev.sh +++ b/examples/helloworld/dubbo/go-client/assembly/linux/dev.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for dev env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2017-10-18 13:24 -# FILE : dev.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/helloworld/dubbo/go-client/assembly/linux/release.sh b/examples/helloworld/dubbo/go-client/assembly/linux/release.sh index 34867b8b3488778cd76a1dc7802393dcab6b0df0..13b19f48a8ccb448041feb636fa6b3cc4c9997a7 100644 --- a/examples/helloworld/dubbo/go-client/assembly/linux/release.sh +++ b/examples/helloworld/dubbo/go-client/assembly/linux/release.sh @@ -1,13 +1,19 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for release env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:34 -# FILE : test.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. set -e diff --git a/examples/helloworld/dubbo/go-client/assembly/linux/test.sh b/examples/helloworld/dubbo/go-client/assembly/linux/test.sh index 1bbbefd1e14e08c16deaf859e2841f4d1fe88e9c..c6c31b3b7985d3b91fdeab39c2cd9954968fb227 100644 --- a/examples/helloworld/dubbo/go-client/assembly/linux/test.sh +++ b/examples/helloworld/dubbo/go-client/assembly/linux/test.sh @@ -1,13 +1,19 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for test env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:34 -# FILE : test.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. set -e diff --git a/examples/helloworld/dubbo/go-client/assembly/mac/dev.sh b/examples/helloworld/dubbo/go-client/assembly/mac/dev.sh index b68ac83b6524a6713cd90c4fc5968fe64b1a9545..c8284769909e62f0142c29e3a63177bf2826593f 100644 --- a/examples/helloworld/dubbo/go-client/assembly/mac/dev.sh +++ b/examples/helloworld/dubbo/go-client/assembly/mac/dev.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for dev env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2017-10-18 13:24 -# FILE : dev.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/helloworld/dubbo/go-client/assembly/mac/release.sh b/examples/helloworld/dubbo/go-client/assembly/mac/release.sh index 688288b3b1b989e8af70a3674b34ea8e0668f3b4..91c2dfee79b1499b640420191174f980eac187bb 100644 --- a/examples/helloworld/dubbo/go-client/assembly/mac/release.sh +++ b/examples/helloworld/dubbo/go-client/assembly/mac/release.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for release env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:34 -# FILE : test.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/helloworld/dubbo/go-client/assembly/mac/test.sh b/examples/helloworld/dubbo/go-client/assembly/mac/test.sh index 56d6c11ecd6a1dc5984c74b88c10be9239e57428..a7853f5e2d51df8e3e9509621952c44bca0d1a2d 100644 --- a/examples/helloworld/dubbo/go-client/assembly/mac/test.sh +++ b/examples/helloworld/dubbo/go-client/assembly/mac/test.sh @@ -1,13 +1,19 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for test env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:34 -# FILE : test.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. set -e diff --git a/examples/helloworld/dubbo/go-client/assembly/windows/dev.sh b/examples/helloworld/dubbo/go-client/assembly/windows/dev.sh index 91cf6f23bcbecb26db798469a30529261aabbbb6..10a3866c0f4ed8e1070c4d5641259c04073df6cb 100644 --- a/examples/helloworld/dubbo/go-client/assembly/windows/dev.sh +++ b/examples/helloworld/dubbo/go-client/assembly/windows/dev.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for dev env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2017-10-18 13:24 -# FILE : dev.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/helloworld/dubbo/go-client/assembly/windows/release.sh b/examples/helloworld/dubbo/go-client/assembly/windows/release.sh index f317720bd53d9c9e5f8f484b6eb682c9c736af0c..21af573fa3842d47959d5726b11b81d5fff5b8df 100644 --- a/examples/helloworld/dubbo/go-client/assembly/windows/release.sh +++ b/examples/helloworld/dubbo/go-client/assembly/windows/release.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for release env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:34 -# FILE : test.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/helloworld/dubbo/go-client/assembly/windows/test.sh b/examples/helloworld/dubbo/go-client/assembly/windows/test.sh index 7dd2bec5260e647b57a46aaa37acc098babff068..2104da8b5909957c165eedc2f7d6866a890e9e6d 100644 --- a/examples/helloworld/dubbo/go-client/assembly/windows/test.sh +++ b/examples/helloworld/dubbo/go-client/assembly/windows/test.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for test env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:34 -# FILE : test.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/helloworld/dubbo/go-server/app/server.go b/examples/helloworld/dubbo/go-server/app/server.go index 29f2ad57ead58c09614ccf5f7098c77612085449..dc3a40f14f43e8dce616b3cd79a5a6b6fde38580 100644 --- a/examples/helloworld/dubbo/go-server/app/server.go +++ b/examples/helloworld/dubbo/go-server/app/server.go @@ -64,12 +64,12 @@ func initSignal() { case syscall.SIGHUP: // reload() default: - go time.AfterFunc(time.Duration(survivalTimeout), func() { + time.AfterFunc(time.Duration(survivalTimeout), func() { logger.Warnf("app exit now by force...") os.Exit(1) }) - // 瑕佷箞fastFailTimeout鏃堕棿鍐呮墽琛屽畬姣曚笅闈㈢殑閫昏緫鐒跺悗绋嬪簭閫€鍑猴紝瑕佷箞鎵ц涓婇潰鐨勮秴鏃跺嚱鏁扮▼搴忓己琛岄€€鍑� + // The program exits normally or timeout forcibly exits. fmt.Println("provider app exit now...") return } diff --git a/examples/helloworld/dubbo/go-server/assembly/bin/load.sh b/examples/helloworld/dubbo/go-server/assembly/bin/load.sh index 47fc5e38ded155a43c30b8cbf4d2a5ae04b58d0c..2e127ac652ec2b418d74efa1abfd159250cb44d1 100644 --- a/examples/helloworld/dubbo/go-server/assembly/bin/load.sh +++ b/examples/helloworld/dubbo/go-server/assembly/bin/load.sh @@ -1,13 +1,19 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : dubbogo app devops script -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-05-13 02:01 -# FILE : load.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. APP_NAME="APPLICATION_NAME" APP_ARGS="" diff --git a/examples/helloworld/dubbo/go-server/assembly/common/app.properties b/examples/helloworld/dubbo/go-server/assembly/common/app.properties index dffb755b0811dd140d3f04e232f5f80ff60181df..1f0827eb512b9bcb3c2428f8e0b50d76f65743ef 100644 --- a/examples/helloworld/dubbo/go-server/assembly/common/app.properties +++ b/examples/helloworld/dubbo/go-server/assembly/common/app.properties @@ -1,13 +1,19 @@ -# dubbogo application configure script -# ****************************************************** -# DESC : application environment variable -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:29 -# FILE : app.properties -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + TARGET_EXEC_NAME="user_info_server" # BUILD_PACKAGE="dubbogo-examples/user-info/server/app" diff --git a/examples/helloworld/dubbo/go-server/assembly/common/build.sh b/examples/helloworld/dubbo/go-server/assembly/common/build.sh index 15ac904f7c265d942d7018439719af7e7391aa41..89a95ce679ca711824a2de0888686be79d96f505 100644 --- a/examples/helloworld/dubbo/go-server/assembly/common/build.sh +++ b/examples/helloworld/dubbo/go-server/assembly/common/build.sh @@ -1,13 +1,19 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:28 -# FILE : build.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. rm -rf target/ diff --git a/examples/helloworld/dubbo/go-server/assembly/linux/dev.sh b/examples/helloworld/dubbo/go-server/assembly/linux/dev.sh index 55886f09fb4873be84cfa46aae592f5f000120a4..d830ac98c2b9328791d00d5160d487b1a12b5fed 100644 --- a/examples/helloworld/dubbo/go-server/assembly/linux/dev.sh +++ b/examples/helloworld/dubbo/go-server/assembly/linux/dev.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for dev env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2018-06-24 17:32 -# FILE : dev.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/helloworld/dubbo/go-server/assembly/linux/release.sh b/examples/helloworld/dubbo/go-server/assembly/linux/release.sh index 9772ad9614583917d62beba2db9fcaefea63e1ed..99303800b0fbcd7f8dfea668dcf395f126fb99f6 100644 --- a/examples/helloworld/dubbo/go-server/assembly/linux/release.sh +++ b/examples/helloworld/dubbo/go-server/assembly/linux/release.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for release env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:25 -# FILE : release.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/helloworld/dubbo/go-server/assembly/linux/test.sh b/examples/helloworld/dubbo/go-server/assembly/linux/test.sh index 2fc4a98862bee5ef11a23e1b74058627a899181d..87144bb973095acaf8c17b0ec3bf42f643d0b95f 100644 --- a/examples/helloworld/dubbo/go-server/assembly/linux/test.sh +++ b/examples/helloworld/dubbo/go-server/assembly/linux/test.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for test env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:34 -# FILE : test.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/helloworld/dubbo/go-server/assembly/mac/dev.sh b/examples/helloworld/dubbo/go-server/assembly/mac/dev.sh index 5dfa78490b895ce556c809ead32b6f517a5f1450..3a7659b2d57e0e2502950d76ec6c938abf2b7513 100644 --- a/examples/helloworld/dubbo/go-server/assembly/mac/dev.sh +++ b/examples/helloworld/dubbo/go-server/assembly/mac/dev.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for dev env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2018-06-24 17:32 -# FILE : dev.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/helloworld/dubbo/go-server/assembly/mac/release.sh b/examples/helloworld/dubbo/go-server/assembly/mac/release.sh index 1ec21c7b511ccce9eddfac22a2374b57a7a697bf..1c4bce4bf825fe401823ec33025e004a476ccaaf 100644 --- a/examples/helloworld/dubbo/go-server/assembly/mac/release.sh +++ b/examples/helloworld/dubbo/go-server/assembly/mac/release.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for release env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:25 -# FILE : release.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/helloworld/dubbo/go-server/assembly/mac/test.sh b/examples/helloworld/dubbo/go-server/assembly/mac/test.sh index d34914c7dbed0e442b4accf51a3ecdf7c2984db8..69206e32fed343eb87c04190b509b16482125542 100644 --- a/examples/helloworld/dubbo/go-server/assembly/mac/test.sh +++ b/examples/helloworld/dubbo/go-server/assembly/mac/test.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for release env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:25 -# FILE : release.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/helloworld/dubbo/go-server/assembly/windows/dev.sh b/examples/helloworld/dubbo/go-server/assembly/windows/dev.sh index 97fbb6f698e500ad08d971b13cc1ffd00cd97803..011fb41148f205bc329118a3c75e52854c0ecfd3 100644 --- a/examples/helloworld/dubbo/go-server/assembly/windows/dev.sh +++ b/examples/helloworld/dubbo/go-server/assembly/windows/dev.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for dev env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2018-06-24 17:34 -# FILE : dev.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/helloworld/dubbo/go-server/assembly/windows/release.sh b/examples/helloworld/dubbo/go-server/assembly/windows/release.sh index 782cb10c7828eb277b5905f10f8dd6ad1c2d6bed..679a26a7dc77a9bc0ccbf119eac3caba252cadc9 100644 --- a/examples/helloworld/dubbo/go-server/assembly/windows/release.sh +++ b/examples/helloworld/dubbo/go-server/assembly/windows/release.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for release env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:25 -# FILE : release.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/helloworld/dubbo/go-server/assembly/windows/test.sh b/examples/helloworld/dubbo/go-server/assembly/windows/test.sh index 2037ddecf2545f1543d5d28be728fb0899722098..4a36de0f3a26b804601de703c62a8062bd0623f4 100644 --- a/examples/helloworld/dubbo/go-server/assembly/windows/test.sh +++ b/examples/helloworld/dubbo/go-server/assembly/windows/test.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash -# ****************************************************** -# DESC : build script for test env -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2016-07-12 16:34 -# FILE : test.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e diff --git a/examples/helloworld/dubbo/java-server/build.sh b/examples/helloworld/dubbo/java-server/build.sh index 0c197da639c1c1d9375e18c24dd73366c49deefe..7b5755be183f5b301f0963fcc4a4eace8a341574 100644 --- a/examples/helloworld/dubbo/java-server/build.sh +++ b/examples/helloworld/dubbo/java-server/build.sh @@ -1,8 +1,19 @@ #!/usr/bin/env bash -# ****************************************************** -# EMAIL : alexstocks@foxmail.com -# FILE : build.sh -# ****************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. # mvn dependency:sources mvn clean package -Dmaven.test.skip diff --git a/examples/helloworld/dubbo/java-server/pom.xml b/examples/helloworld/dubbo/java-server/pom.xml index 975157865e59f24693d755dd20b0aac4b179a793..8c1322860245e874e06ee33584cb6b4d08a68058 100644 --- a/examples/helloworld/dubbo/java-server/pom.xml +++ b/examples/helloworld/dubbo/java-server/pom.xml @@ -1,4 +1,19 @@ <?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> diff --git a/examples/helloworld/dubbo/java-server/script/debug.sh b/examples/helloworld/dubbo/java-server/script/debug.sh index 27c5d800d846018127e762944151aa8e9ad4495d..851957ade66f7eb492f9be278bf0b6f98eed729a 100644 --- a/examples/helloworld/dubbo/java-server/script/debug.sh +++ b/examples/helloworld/dubbo/java-server/script/debug.sh @@ -1,13 +1,20 @@ -#!/us1r/bin/env bash -# ****************************************************** -# DESC : -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2017-10-09 21:52 -# FILE : to debug user info dubbo server -# ****************************************************** +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # jdb -classpath /Users/alex/tmp/us/conf:/Users/alex/tmp/us/lib/*:/Users/alex/test/java/dubbo/2.5.4/dubbo-remoting/dubbo-remoting-api/src/main/java/ com.alibaba.dubbo.container.Main jdb -classpath /Users/alex/tmp/us/conf:/Users/alex/tmp/us/lib/* -sourcepath /Users/alex/test/java/dubbo/2.5.4/dubbo-remoting/dubbo-remoting-api/src/main/java/:/Users/alex/tmp/java-server/src/main/java com.alibaba.dubbo.container.Main diff --git a/examples/helloworld/dubbo/java-server/src/main/assembly/assembly.xml b/examples/helloworld/dubbo/java-server/src/main/assembly/assembly.xml index 2f01fea20f5391112cccb88c87bfe4ae1b59750a..98a2e100f18d195b8f0b44eb07080eaa9097af79 100644 --- a/examples/helloworld/dubbo/java-server/src/main/assembly/assembly.xml +++ b/examples/helloworld/dubbo/java-server/src/main/assembly/assembly.xml @@ -1,18 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> <!-- - - Copyright 1999-2011 Alibaba Group. - - - - Licensed under the Apache License, Version 2.0 (the "License"); - - you may not use this file except in compliance with the License. - - You may obtain a copy of the License at - - - - http://www.apache.org/licenses/LICENSE-2.0 - - - - Unless required by applicable law or agreed to in writing, software - - distributed under the License is distributed on an "AS IS" BASIS, - - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - - See the License for the specific language governing permissions and - - limitations under the License. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. --> + <assembly> <id>assembly</id> <formats> diff --git a/examples/helloworld/dubbo/java-server/src/main/java/com/ikurento/user/User.java b/examples/helloworld/dubbo/java-server/src/main/java/com/ikurento/user/User.java index 06f3f18f0a8ae940000fae3155e448c3181a0054..fd2cafb31f3cc976ffc70e58eb9e393d771a1b2a 100644 --- a/examples/helloworld/dubbo/java-server/src/main/java/com/ikurento/user/User.java +++ b/examples/helloworld/dubbo/java-server/src/main/java/com/ikurento/user/User.java @@ -1,5 +1,21 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.ikurento.user; -// ref: https://github.com/JoeCao/dubbo_jsonrpc_example/tree/master/dubbo_server/src/main/java/com/ofpay/demo/api import java.util.Date; import java.io.Serializable; diff --git a/examples/helloworld/dubbo/java-server/src/main/java/com/ikurento/user/UserProvider.java b/examples/helloworld/dubbo/java-server/src/main/java/com/ikurento/user/UserProvider.java index f3301cd642ca58a57ac5e2041ec5f958d383b7fb..b1eeab82f6d2bda7e3e6bac7be220e249f72f6ba 100644 --- a/examples/helloworld/dubbo/java-server/src/main/java/com/ikurento/user/UserProvider.java +++ b/examples/helloworld/dubbo/java-server/src/main/java/com/ikurento/user/UserProvider.java @@ -1,6 +1,21 @@ -package com.ikurento.user; -// https://github.com/JoeCao/dubbo_jsonrpc_example/tree/master/dubbo_server/src/main/java/com/ofpay/demo/api +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.ikurento.user; public interface UserProvider { diff --git a/examples/helloworld/dubbo/java-server/src/main/java/com/ikurento/user/UserProviderImpl.java b/examples/helloworld/dubbo/java-server/src/main/java/com/ikurento/user/UserProviderImpl.java index ddbccab37bbe2cc59b584e59ef317d5bdaeae32d..0d66c430052ac5a8aa3c914b9c9f0a4ab116d46a 100644 --- a/examples/helloworld/dubbo/java-server/src/main/java/com/ikurento/user/UserProviderImpl.java +++ b/examples/helloworld/dubbo/java-server/src/main/java/com/ikurento/user/UserProviderImpl.java @@ -1,12 +1,27 @@ -package com.ikurento.user; +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -// ref: https://github.com/JoeCao/dubbo_jsonrpc_example/tree/master/dubbo_server/src/main/java/com/ofpay/demo/api +package com.ikurento.user; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class UserProviderImpl implements UserProvider { - private static final Logger LOG = LoggerFactory.getLogger("UserLogger"); // 杈撳嚭鍒皍ser-server.log + private static final Logger LOG = LoggerFactory.getLogger("UserLogger"); //Output to user-server.log public User GetUser(String userId) { return new User(userId, "zhangsan", 18); diff --git a/examples/helloworld/dubbo/java-server/src/main/resources/META-INF/spring/dubbo.provider.xml b/examples/helloworld/dubbo/java-server/src/main/resources/META-INF/spring/dubbo.provider.xml index fe23e1f3e91d841c30534c82d8d69e6628f6b528..edd01dc870b3bb16ffd7525387e994ea11da9b8e 100644 --- a/examples/helloworld/dubbo/java-server/src/main/resources/META-INF/spring/dubbo.provider.xml +++ b/examples/helloworld/dubbo/java-server/src/main/resources/META-INF/spring/dubbo.provider.xml @@ -1,19 +1,18 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- - - Copyright 1999-2011 Alibaba Group. - - - - Licensed under the Apache License, Version 2.0 (the "License"); - - you may not use this file except in compliance with the License. - - You may obtain a copy of the License at - - - - http://www.apache.org/licenses/LICENSE-2.0 - - - - Unless required by applicable law or agreed to in writing, software - - distributed under the License is distributed on an "AS IS" BASIS, - - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - - See the License for the specific language governing permissions and - - limitations under the License. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. --> + <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo" diff --git a/examples/hystrixfilter/dubbo/with-hystrix-go-client/app/client.go b/examples/hystrixfilter/dubbo/with-hystrix-go-client/app/client.go new file mode 100644 index 0000000000000000000000000000000000000000..0d8d7d2ffd6b7ea5db3831b55fa4dc45ace302c5 --- /dev/null +++ b/examples/hystrixfilter/dubbo/with-hystrix-go-client/app/client.go @@ -0,0 +1,130 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package main + +import ( + "context" + "fmt" + "os" + "os/signal" + "syscall" + "time" +) + +import ( + "github.com/apache/dubbo-go-hessian2" +) + +import ( + "github.com/apache/dubbo-go/common/logger" + _ "github.com/apache/dubbo-go/common/proxy/proxy_factory" + "github.com/apache/dubbo-go/config" + _ "github.com/apache/dubbo-go/protocol/dubbo" + _ "github.com/apache/dubbo-go/registry/protocol" + + _ "github.com/apache/dubbo-go/filter/impl" + + _ "github.com/apache/dubbo-go/cluster/cluster_impl" + _ "github.com/apache/dubbo-go/cluster/loadbalance" + _ "github.com/apache/dubbo-go/registry/zookeeper" +) + +var ( + survivalTimeout int = 10e9 +) + +// they are necessary: +// export CONF_CONSUMER_FILE_PATH="xxx" +// export APP_LOG_CONF_FILE="xxx" +func main() { + + hessian.RegisterJavaEnum(Gender(MAN)) + hessian.RegisterJavaEnum(Gender(WOMAN)) + hessian.RegisterPOJO(&User{}) + getUserChan := make(chan string, 32) + getErrChan := make(chan string, 32) + getUser1Chan := make(chan string, 32) + + config.Load() + logger.Debugf("[Start to test GetUser]") + for i := 0; i < 32; i++ { + go func() { + user := &User{} + err := userProvider.GetUser(context.TODO(), []interface{}{"A003"}, user) + getUserChan <- fmt.Sprintf("Result: %s ; Error: %v", user.Name, err) + }() + } + time.Sleep(time.Second * 4) + + logger.Debugf("[Start to test GetErr, without error whitelist]") + for i := 0; i < 32; i++ { + go func() { + user := &User{} + err := userProvider.GetErr(context.TODO(), []interface{}{"A003"}, user) + getErrChan <- fmt.Sprintf("Result: %s ; Error: %v", user.Name, err) + }() + } + time.Sleep(time.Second * 4) + + logger.Debugf("[Start to test illegal method GetUser1, with error whitelist]") + for i := 0; i < 32; i++ { + go func() { + user := &User{} + err := userProvider.GetUser1(context.TODO(), []interface{}{"A003"}, user) + getUser1Chan <- fmt.Sprintf("Result: %s ; Error: %v", user.Name, err) + }() + } + time.Sleep(time.Second * 4) + for i := 1; i < 32; i++ { + resGot := <-getUserChan + logger.Infof("[GetUser] %v", resGot) + } + for i := 1; i < 32; i++ { + resGot := <-getErrChan + logger.Infof("[GetErr] %v", resGot) + } + for i := 1; i < 32; i++ { + resGot := <-getUser1Chan + logger.Infof("[GetUser1] %v", resGot) + } + //initSignal() +} + +func initSignal() { + signals := make(chan os.Signal, 1) + // It is not possible to block SIGKILL or syscall.SIGSTOP + signal.Notify(signals, os.Interrupt, os.Kill, syscall.SIGHUP, + syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT) + for { + sig := <-signals + logger.Infof("get signal %s", sig.String()) + switch sig { + case syscall.SIGHUP: + // reload() + default: + go time.AfterFunc(time.Duration(survivalTimeout)*time.Second, func() { + logger.Warnf("app exit now by force...") + os.Exit(1) + }) + + // 瑕佷箞fastFailTimeout鏃堕棿鍐呮墽琛屽畬姣曚笅闈㈢殑閫昏緫鐒跺悗绋嬪簭閫€鍑猴紝瑕佷箞鎵ц涓婇潰鐨勮秴鏃跺嚱鏁扮▼搴忓己琛岄€€鍑� + fmt.Println("app exit now...") + return + } + } +} diff --git a/examples/hystrixfilter/dubbo/with-hystrix-go-client/app/example_fallback_filter.go b/examples/hystrixfilter/dubbo/with-hystrix-go-client/app/example_fallback_filter.go new file mode 100644 index 0000000000000000000000000000000000000000..0e86988fd787e0df941b62ad038746b412baf314 --- /dev/null +++ b/examples/hystrixfilter/dubbo/with-hystrix-go-client/app/example_fallback_filter.go @@ -0,0 +1,80 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package main + +import ( + "time" +) + +import ( + "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/common/logger" + "github.com/apache/dubbo-go/filter" + "github.com/apache/dubbo-go/filter/impl" + "github.com/apache/dubbo-go/protocol" +) + +const ( + EXAMPLE_FALLBACK_FILTER = "example_fallback" +) + +//This is an example filter that handles result from hystrix filter +//Define your filters and write your service downgrade strategy like this +//TODO: Maybe a base fallback filter can be offered +type ExampleFallbackFilter struct { +} + +func GetExampleFallbackFilter() filter.Filter { + return &ExampleFallbackFilter{} +} + +//The name should be the same as in your config +//Put the filter in front of hystrix filter +func init() { + extension.SetFilter(EXAMPLE_FALLBACK_FILTER, GetExampleFallbackFilter) +} + +func (ff *ExampleFallbackFilter) Invoke(invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { + return invoker.Invoke(invocation) + +} +func (ff *ExampleFallbackFilter) OnResponse(result protocol.Result, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { + if err := result.Error(); err != nil { + hystrixError, ok := err.(*impl.HystrixFilterError) + if ok { + if hystrixError.FailByHystrix() { + logger.Debugf("[Example fallback filter]%s get error caused by %s", invocation.MethodName(), hystrixError.Error()) + //Handle the error caused by Hystrix, including circuit breaking, concurrency limit and timeout + //The detailed error source can be got through hystrixError.Error() + //In this example we return a mock result under this circumstance + res := User{ + "MockID", + "MockName", + 55, + time.Now(), + Gender(MAN), + } + *(invocation.Reply().(*User)) = res + result.SetResult(&res) + result.SetError(nil) + } + } + } + //If the error is not caused by hystrix, the result doesn't come from hystrix filter or there's no error, + //we just return it here. + return result +} diff --git a/examples/hystrixfilter/dubbo/with-hystrix-go-client/app/user.go b/examples/hystrixfilter/dubbo/with-hystrix-go-client/app/user.go new file mode 100644 index 0000000000000000000000000000000000000000..affa5418a701842e890f9e2498c2ef7a769532bd --- /dev/null +++ b/examples/hystrixfilter/dubbo/with-hystrix-go-client/app/user.go @@ -0,0 +1,149 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package main + +import ( + "context" + "fmt" + "strconv" + "time" +) + +import ( + hessian "github.com/apache/dubbo-go-hessian2" +) + +import ( + "github.com/apache/dubbo-go/config" +) + +type Gender hessian.JavaEnum + +var ( + userProvider = new(UserProvider) + userProvider1 = new(UserProvider1) + userProvider2 = new(UserProvider2) +) + +func init() { + config.SetConsumerService(userProvider) + config.SetConsumerService(userProvider1) + config.SetConsumerService(userProvider2) +} + +const ( + MAN hessian.JavaEnum = iota + WOMAN +) + +var genderName = map[hessian.JavaEnum]string{ + MAN: "MAN", + WOMAN: "WOMAN", +} + +var genderValue = map[string]hessian.JavaEnum{ + "MAN": MAN, + "WOMAN": WOMAN, +} + +func (g Gender) JavaClassName() string { + return "com.ikurento.user.Gender" +} + +func (g Gender) String() string { + s, ok := genderName[hessian.JavaEnum(g)] + if ok { + return s + } + + return strconv.Itoa(int(g)) +} + +func (g Gender) EnumValue(s string) hessian.JavaEnum { + v, ok := genderValue[s] + if ok { + return v + } + + return hessian.InvalidJavaEnum +} + +type User struct { + // !!! Cannot define lowercase names of variable + Id string + Name string + Age int32 + Time time.Time + Sex Gender // 娉ㄦ剰姝ゅ锛宩ava enum Object <--> go string +} + +func (u User) String() string { + return fmt.Sprintf( + "User{Id:%s, Name:%s, Age:%d, Time:%s, Sex:%s}", + u.Id, u.Name, u.Age, u.Time, u.Sex, + ) +} + +func (User) JavaClassName() string { + return "com.ikurento.user.User" +} + +type UserProvider struct { + GetUsers func(req []interface{}) ([]interface{}, error) + GetErr func(ctx context.Context, req []interface{}, rsp *User) error + GetUser func(ctx context.Context, req []interface{}, rsp *User) error + GetUser0 func(id string, name string) (User, error) + GetUser1 func(ctx context.Context, req []interface{}, rsp *User) error + GetUser2 func(ctx context.Context, req []interface{}, rsp *User) error `dubbo:"getUser"` + GetUser3 func() error + Echo func(ctx context.Context, req interface{}) (interface{}, error) // Echo represent EchoFilter will be used +} + +func (u *UserProvider) Reference() string { + return "UserProvider" +} + +type UserProvider1 struct { + GetUsers func(req []interface{}) ([]interface{}, error) + GetErr func(ctx context.Context, req []interface{}, rsp *User) error + GetUser func(ctx context.Context, req []interface{}, rsp *User) error + GetUser0 func(id string, name string) (User, error) + GetUser1 func(ctx context.Context, req []interface{}, rsp *User) error + GetUser2 func(ctx context.Context, req []interface{}, rsp *User) error `dubbo:"getUser"` + GetUser3 func() error + Echo func(ctx context.Context, req interface{}) (interface{}, error) // Echo represent EchoFilter will be used +} + +func (u *UserProvider1) Reference() string { + return "UserProvider1" +} + +type UserProvider2 struct { + GetUsers func(req []interface{}) ([]interface{}, error) + GetErr func(ctx context.Context, req []interface{}, rsp *User) error + GetUser func(ctx context.Context, req []interface{}, rsp *User) error + GetUser0 func(id string, name string) (User, error) + GetUser1 func(ctx context.Context, req []interface{}, rsp *User) error + GetUser2 func(ctx context.Context, req []interface{}, rsp *User) error `dubbo:"getUser"` + GetUser3 func() error + Echo func(ctx context.Context, req interface{}) (interface{}, error) // Echo represent EchoFilter will be used +} + +func (u *UserProvider2) Reference() string { + return "UserProvider2" +} diff --git a/examples/hystrixfilter/dubbo/with-hystrix-go-client/app/version.go b/examples/hystrixfilter/dubbo/with-hystrix-go-client/app/version.go new file mode 100644 index 0000000000000000000000000000000000000000..c6138584f1ddeab3a4927774f44f9e78a8f08da7 --- /dev/null +++ b/examples/hystrixfilter/dubbo/with-hystrix-go-client/app/version.go @@ -0,0 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package main + +var ( + Version = "2.6.0" +) diff --git a/examples/hystrixfilter/dubbo/with-hystrix-go-client/assembly/bin/load.sh b/examples/hystrixfilter/dubbo/with-hystrix-go-client/assembly/bin/load.sh new file mode 100644 index 0000000000000000000000000000000000000000..ffa240b29d9e76761a151e7462092b86908de6f6 --- /dev/null +++ b/examples/hystrixfilter/dubbo/with-hystrix-go-client/assembly/bin/load.sh @@ -0,0 +1,203 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +APP_NAME="APPLICATION_NAME" +APP_ARGS="" +SLEEP_INTERVAL=5 +MAX_LIFETIME=4000 + +PROJECT_HOME="" +OS_NAME=`uname` +if [[ ${OS_NAME} != "Windows" ]]; then + PROJECT_HOME=`pwd` + PROJECT_HOME=${PROJECT_HOME}"/" +else + APP_NAME="APPLICATION_NAME.exe" +fi + +export CONF_CONSUMER_FILE_PATH=${PROJECT_HOME}"TARGET_CONF_FILE" +export APP_LOG_CONF_FILE=${PROJECT_HOME}"TARGET_LOG_CONF_FILE" +# export GOTRACEBACK=system +# export GODEBUG=gctrace=1 + +usage() { + echo "Usage: $0 start [conf suffix]" + echo " $0 stop" + echo " $0 term" + echo " $0 restart" + echo " $0 list" + echo " $0 monitor" + echo " $0 crontab" + exit +} + +start() { + arg=$1 + if [ "$arg" = "" ];then + echo "No registry type! Default client.yml!" + else + export CONF_CONSUMER_FILE_PATH=${CONF_CONSUMER_FILE_PATH//\.yml/\_$arg\.yml} + fi + if [ ! -f "${CONF_CONSUMER_FILE_PATH}" ];then + echo $CONF_CONSUMER_FILE_PATH" is not existing!" + return + fi + APP_LOG_PATH=${PROJECT_HOME}"logs/" + mkdir -p ${APP_LOG_PATH} + APP_BIN=${PROJECT_HOME}sbin/${APP_NAME} + chmod u+x ${APP_BIN} + # CMD="nohup ${APP_BIN} ${APP_ARGS} >>${APP_NAME}.nohup.out 2>&1 &" + CMD="${APP_BIN}" + eval ${CMD} + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}'` + if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $1}'` + fi + CUR=`date +%FT%T` + if [ "${PID}" != "" ]; then + for p in ${PID} + do + echo "start ${APP_NAME} ( pid =" ${p} ") at " ${CUR} + done + fi +} + +stop() { + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}'` + if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $1}'` + fi + if [ "${PID}" != "" ]; + then + for ps in ${PID} + do + echo "kill -SIGINT ${APP_NAME} ( pid =" ${ps} ")" + kill -2 ${ps} + done + fi +} + + +term() { + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}'` + if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $1}'` + fi + if [ "${PID}" != "" ]; + then + for ps in ${PID} + do + echo "kill -9 ${APP_NAME} ( pid =" ${ps} ")" + kill -9 ${ps} + done + fi +} + +list() { + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{printf("%s,%s,%s,%s\n", $1, $2, $9, $10)}'` + if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{printf("%s,%s,%s,%s,%s\n", $1, $4, $6, $7, $8)}'` + fi + + if [ "${PID}" != "" ]; then + echo "list ${APP_NAME}" + + if [[ ${OS_NAME} == "Linux" || ${OS_NAME} == "Darwin" ]]; then + echo "index: user, pid, start, duration" + else + echo "index: PID, WINPID, UID, STIME, COMMAND" + fi + idx=0 + for ps in ${PID} + do + echo "${idx}: ${ps}" + ((idx ++)) + done + fi +} + +monitor() { + idx=0 + while true; do + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}'` + if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $1}'` + fi + if [[ "${PID}" == "" ]]; then + start + idx=0 + fi + + ((LIFE=idx*${SLEEP_INTERVAL})) + echo "${APP_NAME} ( pid = " ${PID} ") has been working in normal state for " $LIFE " seconds." + ((idx ++)) + sleep ${SLEEP_INTERVAL} + done +} + +crontab() { + idx=0 + while true; do + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}'` + if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $1}'` + fi + if [[ "${PID}" == "" ]]; then + start + idx=0 + fi + + ((LIFE=idx*${SLEEP_INTERVAL})) + echo "${APP_NAME} ( pid = " ${PID} ") has been working in normal state for " $LIFE " seconds." + ((idx ++)) + sleep ${SLEEP_INTERVAL} + if [[ ${LIFE} -gt ${MAX_LIFETIME} ]]; then + kill -9 ${PID} + fi + done +} + +opt=$1 +case C"$opt" in + Cstart) + start $2 + ;; + Cstop) + stop + ;; + Cterm) + term + ;; + Crestart) + term + start $2 + ;; + Clist) + list + ;; + Cmonitor) + monitor + ;; + Ccrontab) + crontab + ;; + C*) + usage + ;; +esac + diff --git a/examples/hystrixfilter/dubbo/with-hystrix-go-client/assembly/common/app.properties b/examples/hystrixfilter/dubbo/with-hystrix-go-client/assembly/common/app.properties new file mode 100644 index 0000000000000000000000000000000000000000..e10868f4d292765c7eeb2e8bb8b1684a44f56a14 --- /dev/null +++ b/examples/hystrixfilter/dubbo/with-hystrix-go-client/assembly/common/app.properties @@ -0,0 +1,23 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +export TARGET_EXEC_NAME="user_info_client" +# BUILD_PACKAGE="dubbogo-examples/user-info/client/app" +export BUILD_PACKAGE="app" + +export TARGET_CONF_FILE="conf/client.yml" +export TARGET_LOG_CONF_FILE="conf/log.yml" diff --git a/examples/hystrixfilter/dubbo/with-hystrix-go-client/assembly/common/build.sh b/examples/hystrixfilter/dubbo/with-hystrix-go-client/assembly/common/build.sh new file mode 100644 index 0000000000000000000000000000000000000000..c9a9e87c73ef45195d6f70acccf9374ee6cb906b --- /dev/null +++ b/examples/hystrixfilter/dubbo/with-hystrix-go-client/assembly/common/build.sh @@ -0,0 +1,83 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +rm -rf target/ + +PROJECT_HOME=`pwd` +TARGET_FOLDER=${PROJECT_HOME}/target/${GOOS} + +TARGET_SBIN_NAME=${TARGET_EXEC_NAME} +version=`cat app/version.go | grep Version | grep -v "Apache" | awk -F '=' '{print $2}' | awk -F '"' '{print $2}'` +if [[ ${GOOS} == "windows" ]]; then + TARGET_SBIN_NAME=${TARGET_SBIN_NAME}.exe +fi +TARGET_NAME=${TARGET_FOLDER}/${TARGET_SBIN_NAME} +if [[ $PROFILE == "dev" || $PROFILE == "test" ]]; then + # GFLAGS=-gcflags "-N -l" -race -x -v # -x浼氭妸go build鐨勮缁嗚繃绋嬭緭鍑� + # GFLAGS=-gcflags "-N -l" -race -v + # GFLAGS="-gcflags \"-N -l\" -v" + cd ${BUILD_PACKAGE} && GOOS=$GOOS GOARCH=$GOARCH go build -gcflags "-N -l" -x -v -i -o ${TARGET_NAME} && cd - +else + # -s鍘绘帀绗﹀彿琛紙鐒跺悗panic鏃跺€欑殑stack trace灏辨病鏈変换浣曟枃浠跺悕/琛屽彿淇℃伅浜嗭紝杩欎釜绛変环浜庢櫘閫欳/C++绋嬪簭琚玸trip鐨勬晥鏋滐級锛� + # -w鍘绘帀DWARF璋冭瘯淇℃伅锛屽緱鍒扮殑绋嬪簭灏变笉鑳界敤gdb璋冭瘯浜嗐€�-s鍜�-w涔熷彲浠ュ垎寮€浣跨敤锛屼竴鑸潵璇村鏋滀笉鎵撶畻鐢╣db璋冭瘯锛� + # -w鍩烘湰娌″暐鎹熷け銆�-s鐨勬崯澶卞氨鏈夌偣澶т簡銆� + cd ${BUILD_PACKAGE} && GOOS=$GOOS GOARCH=$GOARCH go build -ldflags "-w" -x -v -i -o ${TARGET_NAME} && cd - +fi + +TAR_NAME=${TARGET_EXEC_NAME}-${version}-`date "+%Y%m%d-%H%M"`-${PROFILE} + +mkdir -p ${TARGET_FOLDER}/${TAR_NAME} + +SBIN_DIR=${TARGET_FOLDER}/${TAR_NAME}/sbin +BIN_DIR=${TARGET_FOLDER}/${TAR_NAME} +CONF_DIR=${TARGET_FOLDER}/${TAR_NAME}/conf + +mkdir -p ${SBIN_DIR} +mkdir -p ${CONF_DIR} + +mv ${TARGET_NAME} ${SBIN_DIR} +cp -r assembly/bin ${BIN_DIR} +cd ${BIN_DIR}/bin/ && mv load.sh load_${TARGET_EXEC_NAME}.sh && cd - + +platform=$(uname) +# modify APPLICATION_NAME +if [ ${platform} == "Darwin" ]; then + sed -i "" "s~APPLICATION_NAME~${TARGET_EXEC_NAME}~g" ${BIN_DIR}/bin/* +else + sed -i "s~APPLICATION_NAME~${TARGET_EXEC_NAME}~g" ${BIN_DIR}/bin/* +fi + +# modify TARGET_CONF_FILE +if [ ${platform} == "Darwin" ]; then + sed -i "" "s~TARGET_CONF_FILE~${TARGET_CONF_FILE}~g" ${BIN_DIR}/bin/* +else + sed -i "s~TARGET_CONF_FILE~${TARGET_CONF_FILE}~g" ${BIN_DIR}/bin/* +fi + +# modify TARGET_LOG_CONF_FILE +if [ ${platform} == "Darwin" ]; then + sed -i "" "s~TARGET_LOG_CONF_FILE~${TARGET_LOG_CONF_FILE}~g" ${BIN_DIR}/bin/* +else + sed -i "s~TARGET_LOG_CONF_FILE~${TARGET_LOG_CONF_FILE}~g" ${BIN_DIR}/bin/* +fi + +cp -r profiles/${PROFILE}/* ${CONF_DIR} + +cd ${TARGET_FOLDER} + +tar czf ${TAR_NAME}.tar.gz ${TAR_NAME}/* + diff --git a/examples/hystrixfilter/dubbo/with-hystrix-go-client/assembly/linux/dev.sh b/examples/hystrixfilter/dubbo/with-hystrix-go-client/assembly/linux/dev.sh new file mode 100644 index 0000000000000000000000000000000000000000..eada737c8d0939d4237a6d218fc2a07efdbff381 --- /dev/null +++ b/examples/hystrixfilter/dubbo/with-hystrix-go-client/assembly/linux/dev.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + + +set -e + +export GOOS=linux +export GOARCH=amd64 + +export PROFILE="dev" + +PROJECT_HOME=`pwd` + +if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then + . ${PROJECT_HOME}/assembly/common/app.properties +fi + + +if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then + sh ${PROJECT_HOME}/assembly/common/build.sh +fi diff --git a/examples/hystrixfilter/dubbo/with-hystrix-go-client/assembly/linux/release.sh b/examples/hystrixfilter/dubbo/with-hystrix-go-client/assembly/linux/release.sh new file mode 100644 index 0000000000000000000000000000000000000000..10eb3d73f8760d394537b90b7aeff83ca2b243ed --- /dev/null +++ b/examples/hystrixfilter/dubbo/with-hystrix-go-client/assembly/linux/release.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + + +set -e + +export GOOS=linux +export GOARCH=amd64 + +export PROFILE="release" +export PROJECT_HOME=`pwd` + +if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then + . ${PROJECT_HOME}/assembly/common/app.properties +fi + + +if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then + sh ${PROJECT_HOME}/assembly/common/build.sh +fi diff --git a/examples/hystrixfilter/dubbo/with-hystrix-go-client/assembly/linux/test.sh b/examples/hystrixfilter/dubbo/with-hystrix-go-client/assembly/linux/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..78b650c0d49483f9f6862532afa5c483b618475a --- /dev/null +++ b/examples/hystrixfilter/dubbo/with-hystrix-go-client/assembly/linux/test.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + + +set -e + +export GOOS=linux +export GOARCH=amd64 + +export PROFILE="test" +export PROJECT_HOME=`pwd` + +if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then + . ${PROJECT_HOME}/assembly/common/app.properties +fi + + +if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then + sh ${PROJECT_HOME}/assembly/common/build.sh +fi diff --git a/examples/hystrixfilter/dubbo/with-hystrix-go-client/assembly/mac/dev.sh b/examples/hystrixfilter/dubbo/with-hystrix-go-client/assembly/mac/dev.sh new file mode 100644 index 0000000000000000000000000000000000000000..c8284769909e62f0142c29e3a63177bf2826593f --- /dev/null +++ b/examples/hystrixfilter/dubbo/with-hystrix-go-client/assembly/mac/dev.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + + +set -e + +export GOOS=darwin +export GOARCH=amd64 + +export PROFILE="dev" + +export PROJECT_HOME=`pwd` + +if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then + . ${PROJECT_HOME}/assembly/common/app.properties +fi + + +if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then + sh ${PROJECT_HOME}/assembly/common/build.sh +fi diff --git a/examples/hystrixfilter/dubbo/with-hystrix-go-client/assembly/mac/release.sh b/examples/hystrixfilter/dubbo/with-hystrix-go-client/assembly/mac/release.sh new file mode 100644 index 0000000000000000000000000000000000000000..91c2dfee79b1499b640420191174f980eac187bb --- /dev/null +++ b/examples/hystrixfilter/dubbo/with-hystrix-go-client/assembly/mac/release.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + + +set -e + +export GOOS=darwin +export GOARCH=amd64 + +export PROFILE="release" +export PROJECT_HOME=`pwd` + +if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then + . ${PROJECT_HOME}/assembly/common/app.properties +fi + +if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then + sh ${PROJECT_HOME}/assembly/common/build.sh +fi diff --git a/examples/hystrixfilter/dubbo/with-hystrix-go-client/assembly/mac/test.sh b/examples/hystrixfilter/dubbo/with-hystrix-go-client/assembly/mac/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a7853f5e2d51df8e3e9509621952c44bca0d1a2d --- /dev/null +++ b/examples/hystrixfilter/dubbo/with-hystrix-go-client/assembly/mac/test.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +set -e + +export GOOS=darwin +export GOARCH=amd64 + +export PROFILE="test" +export PROJECT_HOME=`pwd` + +if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then + . ${PROJECT_HOME}/assembly/common/app.properties +fi + + +if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then + sh ${PROJECT_HOME}/assembly/common/build.sh +fi diff --git a/examples/hystrixfilter/dubbo/with-hystrix-go-client/assembly/windows/dev.sh b/examples/hystrixfilter/dubbo/with-hystrix-go-client/assembly/windows/dev.sh new file mode 100644 index 0000000000000000000000000000000000000000..10a3866c0f4ed8e1070c4d5641259c04073df6cb --- /dev/null +++ b/examples/hystrixfilter/dubbo/with-hystrix-go-client/assembly/windows/dev.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + + +set -e + +export GOOS=linux +export GOARCH=amd64 + +export PROFILE="dev" +PROJECT_HOME=`pwd` + +if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then + . ${PROJECT_HOME}/assembly/common/app.properties +fi + +if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then + sh ${PROJECT_HOME}/assembly/common/build.sh +fi diff --git a/examples/hystrixfilter/dubbo/with-hystrix-go-client/assembly/windows/release.sh b/examples/hystrixfilter/dubbo/with-hystrix-go-client/assembly/windows/release.sh new file mode 100644 index 0000000000000000000000000000000000000000..21af573fa3842d47959d5726b11b81d5fff5b8df --- /dev/null +++ b/examples/hystrixfilter/dubbo/with-hystrix-go-client/assembly/windows/release.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + + +set -e + +export GOOS=windows +export GOARCH=amd64 + +export PROFILE="release" +export PROJECT_HOME=`pwd` + +if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then + . ${PROJECT_HOME}/assembly/common/app.properties +fi + +if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then + sh ${PROJECT_HOME}/assembly/common/build.sh +fi diff --git a/examples/hystrixfilter/dubbo/with-hystrix-go-client/assembly/windows/test.sh b/examples/hystrixfilter/dubbo/with-hystrix-go-client/assembly/windows/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..2104da8b5909957c165eedc2f7d6866a890e9e6d --- /dev/null +++ b/examples/hystrixfilter/dubbo/with-hystrix-go-client/assembly/windows/test.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + + +set -e + +export GOOS=windows +export GOARCH=amd64 + +export PROFILE="test" +export PROJECT_HOME=`pwd` + +if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then + . ${PROJECT_HOME}/assembly/common/app.properties +fi + +if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then + sh ${PROJECT_HOME}/assembly/common/build.sh +fi 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 new file mode 100644 index 0000000000000000000000000000000000000000..5b5003fb2cabde05e7d99e738afd584a635355bd --- /dev/null +++ b/examples/hystrixfilter/dubbo/with-hystrix-go-client/profiles/dev/client.yml @@ -0,0 +1,98 @@ +# dubbo client yaml configure file + + +check: true +# client +request_timeout : "3s" +# connect timeout +connect_timeout : "3s" + +# application config +application_config: + organization : "ikurento.com" + name : "BDTService" + module : "dubbogo user-info client" + version : "0.0.1" + owner : "ZX" + environment : "dev" + +registries : + "hangzhouzk": + # 瀵瑰簲java閰嶇疆涓璦ddress灞炴€х殑zookeeper <dubbo:registry address="zookeeper://127.0.0.1:2181"/> + protocol: "zookeeper" + timeout : "3s" + address: "127.0.0.1:2181" + username: "" + password: "" + "shanghaizk": + protocol: "zookeeper" + timeout : "3s" + address: "127.0.0.1:2182" + username: "" + password: "" + +references: + "UserProvider": + # 鍙互鎸囧畾澶氫釜registry锛屼娇鐢ㄩ€楀彿闅斿紑;涓嶆寚瀹氶粯璁ゅ悜鎵€鏈夋敞鍐屼腑蹇冩敞鍐� + registry: "hangzhouzk" + filter: "example_fallback,hystrix_consumer" + protocol : "dubbo" + interface : "com.ikurento.user.UserProvider" + cluster: "failover" + methods : + - name: "GetUser" + retries: 3 + +protocol_conf: + dubbo: + reconnect_interval: 0 + connection_number: 2 + heartbeat_period: "5s" + session_timeout: "20s" + fail_fast_timeout: "5s" + pool_size: 64 + pool_ttl: 600 + getty_session_param: + compress_encoding: false + tcp_no_delay: true + tcp_keep_alive: true + keep_alive_period: "120s" + tcp_r_buf_size: 262144 + tcp_w_buf_size: 65536 + pkg_rq_size: 1024 + pkg_wq_size: 512 + tcp_read_timeout: "1s" + tcp_write_timeout: "5s" + wait_timeout: "1s" + max_msg_len: 10240 + session_name: "client" + +filter_conf: + hystrix: + configs: + "Default": + timeout : 1000 + max_concurrent_requests : 25 + sleep_window : 5000 + error_percent_threshold : 50 + request_volume_threshold: 20 + "userp": + timeout: 2000 + max_concurrent_requests: 512 + sleep_window: 4000 + error_percent_threshold: 35 + request_volume_threshold: 6 + "userp_m": + timeout : 1200 + max_concurrent_requests : 512 + sleep_window : 6000 + error_percent_threshold : 60 + request_volume_threshold: 16 + error_whitelist: [".*exception.*"] + default: "Default" + services: + "com.ikurento.user.UserProvider": + service_config: "userp" + methods: + "GetUser": "userp_m" + "GetUser1": "userp_m" \ No newline at end of file diff --git a/examples/hystrixfilter/dubbo/with-hystrix-go-client/profiles/dev/log.yml b/examples/hystrixfilter/dubbo/with-hystrix-go-client/profiles/dev/log.yml new file mode 100644 index 0000000000000000000000000000000000000000..3ed242d290148743b198e32c5823ad9aae233e8b --- /dev/null +++ b/examples/hystrixfilter/dubbo/with-hystrix-go-client/profiles/dev/log.yml @@ -0,0 +1,28 @@ + +level: "debug" +development: true +disableCaller: false +disableStacktrace: false +sampling: +encoding: "console" + +# encoder +encoderConfig: + messageKey: "message" + levelKey: "level" + timeKey: "time" + nameKey: "logger" + callerKey: "caller" + stacktraceKey: "stacktrace" + lineEnding: "" + levelEncoder: "capitalColor" + timeEncoder: "iso8601" + durationEncoder: "seconds" + callerEncoder: "short" + nameEncoder: "" + +outputPaths: + - "stderr" +errorOutputPaths: + - "stderr" +initialFields: diff --git a/examples/hystrixfilter/dubbo/with-hystrix-go-client/profiles/release/client.yml b/examples/hystrixfilter/dubbo/with-hystrix-go-client/profiles/release/client.yml new file mode 100644 index 0000000000000000000000000000000000000000..9263f2d01ff5288144876eb14c08060bdb165974 --- /dev/null +++ b/examples/hystrixfilter/dubbo/with-hystrix-go-client/profiles/release/client.yml @@ -0,0 +1,98 @@ +# dubbo client yaml configure file + + +check: true +# client +request_timeout : "3s" +# connect timeout +connect_timeout : "3s" + +# application config +application_config: + organization : "ikurento.com" + name : "BDTService" + module : "dubbogo user-info client" + version : "0.0.1" + owner : "ZX" + environment : "release" + +registries : + "hangzhouzk": + protocol: "zookeeper" + timeout : "3s" + address: "127.0.0.1:2181" + username: "" + password: "" + "shanghaizk": + protocol: "zookeeper" + timeout : "3s" + address: "127.0.0.1:2182" + username: "" + password: "" + +references: + "UserProvider": + # 鍙互鎸囧畾澶氫釜registry锛屼娇鐢ㄩ€楀彿闅斿紑;涓嶆寚瀹氶粯璁ゅ悜鎵€鏈夋敞鍐屼腑蹇冩敞鍐� + registry: "hangzhouzk" + filter: "example_fallback,hystrix_consumer" + protocol : "dubbo" +# version: "2.0" +# group: "as" + interface : "com.ikurento.user.UserProvider" + cluster: "failover" + methods : + - name: "GetUser" + retries: 3 + +protocol_conf: + dubbo: + reconnect_interval: 0 + connection_number: 2 + heartbeat_period: "5s" + session_timeout: "20s" + fail_fast_timeout: "5s" + pool_size: 64 + pool_ttl: 600 + getty_session_param: + compress_encoding: false + tcp_no_delay: true + tcp_keep_alive: true + keep_alive_period: "120s" + tcp_r_buf_size: 262144 + tcp_w_buf_size: 65536 + pkg_rq_size: 1024 + pkg_wq_size: 512 + tcp_read_timeout: "1s" + tcp_write_timeout: "5s" + wait_timeout: "1s" + max_msg_len: 10240 + session_name: "client" + +filter_conf: + hystrix: + configs: + "Default": + timeout : 1000 + max_concurrent_requests : 10 + sleep_window : 5000 + error_percent_threshold : 50 + request_volume_threshold: 20 + "userp": + timeout: 1200 + max_concurrent_requests: 8 + sleep_window: 4000 + error_percent_threshold: 45 + request_volume_threshold: 15 + "userp_m": + timeout : 1200 + max_concurrent_requests : 12 + sleep_window : 6000 + error_percent_threshold : 60 + request_volume_threshold: 30 + fallback: "exampleFallback" + default: "Default" + services: + "com.ikurento.user.UserProvider": + service_config: "userp" + methods: + "GetUser": "userp_m" diff --git a/examples/hystrixfilter/dubbo/with-hystrix-go-client/profiles/release/log.yml b/examples/hystrixfilter/dubbo/with-hystrix-go-client/profiles/release/log.yml new file mode 100644 index 0000000000000000000000000000000000000000..d8606247b8479ac5054fd2ef70a0af4bca85c4c4 --- /dev/null +++ b/examples/hystrixfilter/dubbo/with-hystrix-go-client/profiles/release/log.yml @@ -0,0 +1,28 @@ + +level: "warn" +development: true +disableCaller: true +disableStacktrace: true +sampling: +encoding: "console" + +# encoder +encoderConfig: + messageKey: "message" + levelKey: "level" + timeKey: "time" + nameKey: "logger" + callerKey: "caller" + stacktraceKey: "stacktrace" + lineEnding: "" + levelEncoder: "capitalColor" + timeEncoder: "iso8601" + durationEncoder: "seconds" + callerEncoder: "short" + nameEncoder: "" + +outputPaths: + - "stderr" +errorOutputPaths: + - "stderr" +initialFields: diff --git a/examples/hystrixfilter/dubbo/with-hystrix-go-client/profiles/test/client.yml b/examples/hystrixfilter/dubbo/with-hystrix-go-client/profiles/test/client.yml new file mode 100644 index 0000000000000000000000000000000000000000..048703b6bb130fbd26f5be88650e950f70355a24 --- /dev/null +++ b/examples/hystrixfilter/dubbo/with-hystrix-go-client/profiles/test/client.yml @@ -0,0 +1,99 @@ +# dubbo client yaml configure file + + +check: true +# client +request_timeout : "3s" +# connect timeout +connect_timeout : "3s" + +# application config +application_config: + organization : "ikurento.com" + name : "BDTService" + module : "dubbogo user-info client" + version : "0.0.1" + owner : "ZX" + environment : "test" + +registries : + "hangzhouzk": + protocol: "zookeeper" + timeout : "3s" + address: "127.0.0.1:2181" + username: "" + password: "" + "shanghaizk": + protocol: "zookeeper" + timeout : "3s" + address: "127.0.0.1:2182" + username: "" + password: "" + +references: + "UserProvider": + # 鍙互鎸囧畾澶氫釜registry锛屼娇鐢ㄩ€楀彿闅斿紑;涓嶆寚瀹氶粯璁ゅ悜鎵€鏈夋敞鍐屼腑蹇冩敞鍐� + registry: "hangzhouzk" + filter: "example_fallback,hystrix_consumer" + protocol : "dubbo" +# version: "2.0" +# group: "as" + interface : "com.ikurento.user.UserProvider" + cluster: "failover" + methods : + - name: "GetUser" + retries: 3 + +protocol_conf: + dubbo: + reconnect_interval: 0 + connection_number: 2 + heartbeat_period: "5s" + session_timeout: "20s" + fail_fast_timeout: "5s" + pool_size: 64 + pool_ttl: 600 + getty_session_param: + compress_encoding: false + tcp_no_delay: true + tcp_keep_alive: true + keep_alive_period: "120s" + tcp_r_buf_size: 262144 + tcp_w_buf_size: 65536 + pkg_rq_size: 1024 + pkg_wq_size: 512 + tcp_read_timeout: "1s" + tcp_write_timeout: "5s" + wait_timeout: "1s" + max_msg_len: 10240 + session_name: "client" + +filter_conf: + hystrix: + configs: + "Default": + timeout : 1000 + max_concurrent_requests : 25 + sleep_window : 5000 + error_percent_threshold : 50 + request_volume_threshold: 20 + "userp": + timeout: 2000 + max_concurrent_requests: 512 + sleep_window: 4000 + error_percent_threshold: 35 + request_volume_threshold: 6 + "userp_m": + timeout : 1200 + max_concurrent_requests : 512 + sleep_window : 6000 + error_percent_threshold : 60 + request_volume_threshold: 16 + error_whitelist: [".*exception.*"] + default: "Default" + services: + "com.ikurento.user.UserProvider": + service_config: "userp" + methods: + "GetUser": "userp_m" + "GetUser1": "userp_m" \ No newline at end of file diff --git a/examples/hystrixfilter/dubbo/with-hystrix-go-client/profiles/test/log.yml b/examples/hystrixfilter/dubbo/with-hystrix-go-client/profiles/test/log.yml new file mode 100644 index 0000000000000000000000000000000000000000..f93d3c7fccadec845059460befb2e0b1076881e2 --- /dev/null +++ b/examples/hystrixfilter/dubbo/with-hystrix-go-client/profiles/test/log.yml @@ -0,0 +1,28 @@ + +level: "info" +development: false +disableCaller: false +disableStacktrace: true +sampling: +encoding: "console" + +# encoder +encoderConfig: + messageKey: "message" + levelKey: "level" + timeKey: "time" + nameKey: "logger" + callerKey: "caller" + stacktraceKey: "stacktrace" + lineEnding: "" + levelEncoder: "capitalColor" + timeEncoder: "iso8601" + durationEncoder: "seconds" + callerEncoder: "short" + nameEncoder: "" + +outputPaths: + - "stderr" +errorOutputPaths: + - "stderr" +initialFields: diff --git a/filter/impl/active_filter.go b/filter/impl/active_filter.go index 435bfe7488c520b14d770aea01b3c3baf4950056..d7dad74cf3f5ccadf39372335bc1efb22f497523 100644 --- a/filter/impl/active_filter.go +++ b/filter/impl/active_filter.go @@ -1,14 +1,19 @@ -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ // @author yiji@apache.org package impl diff --git a/filter/impl/generic_filter.go b/filter/impl/generic_filter.go index 12cb4c7fa59ac4f1f7c1466f385ea9e9b59567b5..35aadb11a444bda56109e238b17267f71ec2606b 100644 --- a/filter/impl/generic_filter.go +++ b/filter/impl/generic_filter.go @@ -83,11 +83,7 @@ func struct2MapAll(obj interface{}) interface{} { if t.Kind() == reflect.Struct { result := make(map[string]interface{}, t.NumField()) for i := 0; i < t.NumField(); i++ { - if v.Field(i).Kind() == reflect.Struct { - if v.Field(i).CanInterface() { - setInMap(result, t.Field(i), struct2MapAll(v.Field(i).Interface())) - } - } else if v.Field(i).Kind() == reflect.Slice { + if v.Field(i).Kind() == reflect.Struct || v.Field(i).Kind() == reflect.Slice || v.Field(i).Kind() == reflect.Map { if v.Field(i).CanInterface() { setInMap(result, t.Field(i), struct2MapAll(v.Field(i).Interface())) } @@ -106,6 +102,18 @@ func struct2MapAll(obj interface{}) interface{} { newTemps = append(newTemps, newTemp) } return newTemps + } else if t.Kind() == reflect.Map { + var newTempMap = make(map[string]interface{}, v.Len()) + iter := v.MapRange() + for iter.Next() { + mapK := iter.Key().String() + if !iter.Value().CanInterface() { + continue + } + mapV := iter.Value().Interface() + newTempMap[mapK] = struct2MapAll(mapV) + } + return newTempMap } else { return obj } diff --git a/filter/impl/generic_filter_test.go b/filter/impl/generic_filter_test.go index a71a9db95759a143186fe9a1a4fb0c861c8949e8..9797c40df1f57017241675013620a53320e475ad 100644 --- a/filter/impl/generic_filter_test.go +++ b/filter/impl/generic_filter_test.go @@ -87,3 +87,35 @@ func Test_struct2MapAll_Slice(t *testing.T) { assert.Equal(t, reflect.Slice, reflect.TypeOf(m["caCa"]).Kind()) assert.Equal(t, reflect.Map, reflect.TypeOf(m["caCa"].([]interface{})[0].(map[string]interface{})["xxYy"]).Kind()) } +func Test_struct2MapAll_Map(t *testing.T) { + var testData struct { + AaAa string + Baba map[string]interface{} + CaCa map[string]string + DdDd map[string]interface{} + } + testData.AaAa = "aaaa" + testData.Baba = make(map[string]interface{}) + testData.CaCa = make(map[string]string) + testData.DdDd = nil + + testData.Baba["kk"] = 1 + var structData struct { + Str string + } + structData.Str = "str" + testData.Baba["struct"] = structData + testData.Baba["nil"] = nil + testData.CaCa["k1"] = "v1" + testData.CaCa["kv2"] = "v2" + m := struct2MapAll(testData) + + assert.Equal(t, reflect.Map, reflect.TypeOf(m).Kind()) + assert.Equal(t, reflect.String, reflect.TypeOf(m.(map[string]interface{})["aaAa"]).Kind()) + assert.Equal(t, reflect.Map, reflect.TypeOf(m.(map[string]interface{})["baba"]).Kind()) + assert.Equal(t, reflect.Map, reflect.TypeOf(m.(map[string]interface{})["baba"].(map[string]interface{})["struct"]).Kind()) + assert.Equal(t, "str", m.(map[string]interface{})["baba"].(map[string]interface{})["struct"].(map[string]interface{})["str"]) + assert.Equal(t, nil, m.(map[string]interface{})["baba"].(map[string]interface{})["nil"]) + assert.Equal(t, reflect.Map, reflect.TypeOf(m.(map[string]interface{})["caCa"]).Kind()) + assert.Equal(t, reflect.Map, reflect.TypeOf(m.(map[string]interface{})["ddDd"]).Kind()) +} diff --git a/filter/impl/hystrix_filter.go b/filter/impl/hystrix_filter.go new file mode 100644 index 0000000000000000000000000000000000000000..3fd9f87168616b69d5ec72460767890d6956c154 --- /dev/null +++ b/filter/impl/hystrix_filter.go @@ -0,0 +1,269 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package impl + +import ( + "fmt" + "regexp" + "sync" +) +import ( + "github.com/afex/hystrix-go/hystrix" + perrors "github.com/pkg/errors" + "gopkg.in/yaml.v2" +) +import ( + "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/common/logger" + "github.com/apache/dubbo-go/config" + "github.com/apache/dubbo-go/filter" + "github.com/apache/dubbo-go/protocol" +) + +const ( + HYSTRIX_CONSUMER = "hystrix_consumer" + HYSTRIX_PROVIDER = "hystrix_provider" + HYSTRIX = "hystrix" +) + +var ( + confConsumer = &HystrixFilterConfig{} + confProvider = &HystrixFilterConfig{} + configLoadMutex = sync.RWMutex{} + consumerConfigOnce sync.Once + providerConfigOnce sync.Once +) + +//The filter in the server end of dubbo-go can't get the invoke result for now, +//this filter ONLY works in CLIENT end (consumer side) temporarily +//Only after the callService logic is integrated into the filter chain of server end can this filter be used, +//which will be done soon +func init() { + extension.SetFilter(HYSTRIX_CONSUMER, GetHystrixFilterConsumer) + extension.SetFilter(HYSTRIX_PROVIDER, GetHystrixFilterProvider) +} + +type HystrixFilterError struct { + err error + failByHystrix bool +} + +func (hfError *HystrixFilterError) Error() string { + return hfError.err.Error() +} + +func (hfError *HystrixFilterError) FailByHystrix() bool { + return hfError.failByHystrix +} +func NewHystrixFilterError(err error, failByHystrix bool) error { + return &HystrixFilterError{ + err: err, + failByHystrix: failByHystrix, + } +} + +type HystrixFilter struct { + COrP bool //true for consumer + res map[string][]*regexp.Regexp + ifNewMap sync.Map +} + +func (hf *HystrixFilter) Invoke(invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { + + cmdName := fmt.Sprintf("%s&method=%s", invoker.GetUrl().Key(), invocation.MethodName()) + + // Do the configuration if the circuit breaker is created for the first time + if _, load := hf.ifNewMap.LoadOrStore(cmdName, true); !load { + configLoadMutex.Lock() + filterConf := getConfig(invoker.GetUrl().Service(), invocation.MethodName(), hf.COrP) + for _, ptn := range filterConf.Error { + reg, err := regexp.Compile(ptn) + if err != nil { + logger.Warnf("[Hystrix Filter]Errors occurred parsing error omit regexp: %s, %v", ptn, err) + } else { + if hf.res == nil { + hf.res = make(map[string][]*regexp.Regexp) + } + hf.res[invocation.MethodName()] = append(hf.res[invocation.MethodName()], reg) + } + } + hystrix.ConfigureCommand(cmdName, hystrix.CommandConfig{ + Timeout: filterConf.Timeout, + MaxConcurrentRequests: filterConf.MaxConcurrentRequests, + SleepWindow: filterConf.SleepWindow, + ErrorPercentThreshold: filterConf.ErrorPercentThreshold, + RequestVolumeThreshold: filterConf.RequestVolumeThreshold, + }) + configLoadMutex.Unlock() + } + configLoadMutex.RLock() + _, _, err := hystrix.GetCircuit(cmdName) + configLoadMutex.RUnlock() + if err != nil { + logger.Errorf("[Hystrix Filter]Errors occurred getting circuit for %s , will invoke without hystrix, error is: ", cmdName, err) + return invoker.Invoke(invocation) + } + logger.Infof("[Hystrix Filter]Using hystrix filter: %s", cmdName) + var result protocol.Result + _ = hystrix.Do(cmdName, func() error { + result = invoker.Invoke(invocation) + err := result.Error() + if err != nil { + result.SetError(NewHystrixFilterError(err, false)) + for _, reg := range hf.res[invocation.MethodName()] { + if reg.MatchString(err.Error()) { + logger.Debugf("[Hystrix Filter]Error in invocation but omitted in circuit breaker: %v; %s", err, cmdName) + return nil + } + } + } + return err + }, func(err error) error { + //Return error and if it is caused by hystrix logic, so that it can be handled by previous filters. + _, ok := err.(hystrix.CircuitError) + logger.Debugf("[Hystrix Filter]Hystrix health check counted, error is: %v, failed by hystrix: %v; %s", err, ok, cmdName) + result = &protocol.RPCResult{} + result.SetResult(nil) + result.SetError(NewHystrixFilterError(err, ok)) + return err + }) + return result +} + +func (hf *HystrixFilter) OnResponse(result protocol.Result, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { + return result +} +func GetHystrixFilterConsumer() filter.Filter { + //When first called, load the config in + consumerConfigOnce.Do(func() { + if err := initHystrixConfigConsumer(); err != nil { + logger.Warnf("[Hystrix Filter]Config load failed for consumer, error is: %v , will use default", err) + } + }) + return &HystrixFilter{COrP: true} +} + +func GetHystrixFilterProvider() filter.Filter { + providerConfigOnce.Do(func() { + if err := initHystrixConfigProvider(); err != nil { + logger.Warnf("[Hystrix Filter]Config load failed for provider, error is: %v , will use default", err) + } + }) + return &HystrixFilter{COrP: false} +} + +func getConfig(service string, method string, cOrP bool) CommandConfigWithError { + //Find method level config + var conf *HystrixFilterConfig + if cOrP { + conf = confConsumer + } else { + conf = confProvider + } + getConf := conf.Configs[conf.Services[service].Methods[method]] + if getConf != nil { + logger.Infof("[Hystrix Filter]Found method-level config for %s - %s", service, method) + return *getConf + } + //Find service level config + getConf = conf.Configs[conf.Services[service].ServiceConfig] + if getConf != nil { + logger.Infof("[Hystrix Filter]Found service-level config for %s - %s", service, method) + return *getConf + } + //Find default config + getConf = conf.Configs[conf.Default] + if getConf != nil { + logger.Infof("[Hystrix Filter]Found global default config for %s - %s", service, method) + return *getConf + } + getConf = &CommandConfigWithError{} + logger.Infof("[Hystrix Filter]No config found for %s - %s, using default", service, method) + return *getConf + +} + +func initHystrixConfigConsumer() error { + if config.GetConsumerConfig().FilterConf == nil { + return perrors.Errorf("no config for hystrix") + } + filterConfig := config.GetConsumerConfig().FilterConf.(map[interface{}]interface{})[HYSTRIX] + if filterConfig == nil { + return perrors.Errorf("no config for hystrix") + } + hystrixConfByte, err := yaml.Marshal(filterConfig) + if err != nil { + return err + } + err = yaml.Unmarshal(hystrixConfByte, confConsumer) + if err != nil { + return err + } + return nil +} +func initHystrixConfigProvider() error { + if config.GetProviderConfig().FilterConf == nil { + return perrors.Errorf("no config for hystrix") + } + filterConfig := config.GetConsumerConfig().FilterConf.(map[interface{}]interface{})[HYSTRIX] + if filterConfig == nil { + return perrors.Errorf("no config for hystrix") + } + hystrixConfByte, err := yaml.Marshal(filterConfig) + if err != nil { + return err + } + err = yaml.Unmarshal(hystrixConfByte, confProvider) + if err != nil { + return err + } + return nil +} + +//For sake of dynamic config +//func RefreshHystrix() error { +// conf = &HystrixFilterConfig{} +// hystrix.Flush() +// return initHystrixConfig() +//} + +type CommandConfigWithError struct { + Timeout int `yaml:"timeout"` + MaxConcurrentRequests int `yaml:"max_concurrent_requests"` + RequestVolumeThreshold int `yaml:"request_volume_threshold"` + SleepWindow int `yaml:"sleep_window"` + ErrorPercentThreshold int `yaml:"error_percent_threshold"` + Error []string `yaml:"error_whitelist"` +} + +//Config: +//- Timeout: how long to wait for command to complete, in milliseconds +//- MaxConcurrentRequests: how many commands of the same type can run at the same time +//- RequestVolumeThreshold: the minimum number of requests needed before a circuit can be tripped due to health +//- SleepWindow: how long, in milliseconds, to wait after a circuit opens before testing for recovery +//- ErrorPercentThreshold: it causes circuits to open once the rolling measure of errors exceeds this percent of requests +//See hystrix doc + +type HystrixFilterConfig struct { + Configs map[string]*CommandConfigWithError + Default string + Services map[string]ServiceHystrixConfig +} +type ServiceHystrixConfig struct { + ServiceConfig string `yaml:"service_config"` + Methods map[string]string +} diff --git a/filter/impl/hystrix_filter_test.go b/filter/impl/hystrix_filter_test.go new file mode 100644 index 0000000000000000000000000000000000000000..d3a5183ede25d8a325bb1c73020edddd2ffbc638 --- /dev/null +++ b/filter/impl/hystrix_filter_test.go @@ -0,0 +1,217 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package impl + +import ( + "regexp" + "testing" +) +import ( + "github.com/afex/hystrix-go/hystrix" + "github.com/pkg/errors" + "github.com/stretchr/testify/assert" +) +import ( + "github.com/apache/dubbo-go/protocol" + "github.com/apache/dubbo-go/protocol/invocation" +) + +func init() { + mockInitHystrixConfig() +} + +func TestNewHystrixFilterError(t *testing.T) { + get := NewHystrixFilterError(errors.New("test"), true) + assert.True(t, get.(*HystrixFilterError).FailByHystrix()) + assert.Equal(t, "test", get.Error()) +} + +func mockInitHystrixConfig() { + //Mock config + confConsumer = &HystrixFilterConfig{ + make(map[string]*CommandConfigWithError), + "Default", + make(map[string]ServiceHystrixConfig), + } + confConsumer.Configs["Default"] = &CommandConfigWithError{ + Timeout: 1000, + MaxConcurrentRequests: 600, + RequestVolumeThreshold: 5, + SleepWindow: 5000, + ErrorPercentThreshold: 5, + Error: nil, + } + confConsumer.Configs["userp"] = &CommandConfigWithError{ + Timeout: 2000, + MaxConcurrentRequests: 64, + RequestVolumeThreshold: 15, + SleepWindow: 4000, + ErrorPercentThreshold: 45, + Error: nil, + } + confConsumer.Configs["userp_m"] = &CommandConfigWithError{ + Timeout: 1200, + MaxConcurrentRequests: 64, + RequestVolumeThreshold: 5, + SleepWindow: 6000, + ErrorPercentThreshold: 60, + Error: []string{ + "exception", + }, + } + confConsumer.Services["com.ikurento.user.UserProvider"] = ServiceHystrixConfig{ + "userp", + map[string]string{ + "GetUser": "userp_m", + }, + } + +} + +func TestGetHystrixFilter(t *testing.T) { + filterGot := GetHystrixFilterConsumer() + assert.NotNil(t, filterGot) +} + +func TestGetConfig_1(t *testing.T) { + mockInitHystrixConfig() + configGot := getConfig("com.ikurento.user.UserProvider", "GetUser", true) + assert.NotNil(t, configGot) + assert.Equal(t, 1200, configGot.Timeout) + assert.Equal(t, 64, configGot.MaxConcurrentRequests) + assert.Equal(t, 6000, configGot.SleepWindow) + assert.Equal(t, 60, configGot.ErrorPercentThreshold) + assert.Equal(t, 5, configGot.RequestVolumeThreshold) +} + +func TestGetConfig_2(t *testing.T) { + mockInitHystrixConfig() + configGot := getConfig("com.ikurento.user.UserProvider", "GetUser0", true) + assert.NotNil(t, configGot) + assert.Equal(t, 2000, configGot.Timeout) + assert.Equal(t, 64, configGot.MaxConcurrentRequests) + assert.Equal(t, 4000, configGot.SleepWindow) + assert.Equal(t, 45, configGot.ErrorPercentThreshold) + assert.Equal(t, 15, configGot.RequestVolumeThreshold) +} + +func TestGetConfig_3(t *testing.T) { + mockInitHystrixConfig() + //This should use default + configGot := getConfig("Mock.Service", "GetMock", true) + assert.NotNil(t, configGot) + assert.Equal(t, 1000, configGot.Timeout) + assert.Equal(t, 600, configGot.MaxConcurrentRequests) + assert.Equal(t, 5000, configGot.SleepWindow) + assert.Equal(t, 5, configGot.ErrorPercentThreshold) + assert.Equal(t, 5, configGot.RequestVolumeThreshold) +} + +type testMockSuccessInvoker struct { + protocol.BaseInvoker +} + +func (iv *testMockSuccessInvoker) Invoke(invocation protocol.Invocation) protocol.Result { + return &protocol.RPCResult{ + Rest: "Sucess", + Err: nil, + } +} + +type testMockFailInvoker struct { + protocol.BaseInvoker +} + +func (iv *testMockFailInvoker) Invoke(invocation protocol.Invocation) protocol.Result { + return &protocol.RPCResult{ + Err: errors.Errorf("exception"), + } +} + +func TestHystrixFilter_Invoke_Success(t *testing.T) { + hf := &HystrixFilter{} + result := hf.Invoke(&testMockSuccessInvoker{}, &invocation.RPCInvocation{}) + assert.NotNil(t, result) + assert.NoError(t, result.Error()) + assert.NotNil(t, result.Result()) +} + +func TestHystrixFilter_Invoke_Fail(t *testing.T) { + hf := &HystrixFilter{} + result := hf.Invoke(&testMockFailInvoker{}, &invocation.RPCInvocation{}) + assert.NotNil(t, result) + assert.Error(t, result.Error()) +} + +func TestHystricFilter_Invoke_CircuitBreak(t *testing.T) { + mockInitHystrixConfig() + hystrix.Flush() + hf := &HystrixFilter{COrP: true} + resChan := make(chan protocol.Result, 50) + for i := 0; i < 50; i++ { + go func() { + result := hf.Invoke(&testMockFailInvoker{}, &invocation.RPCInvocation{}) + resChan <- result + }() + } + //This can not always pass the test when on travis due to concurrency, you can uncomment the code below and test it locally + + //var lastRest bool + //for i := 0; i < 50; i++ { + // lastRest = (<-resChan).Error().(*HystrixFilterError).FailByHystrix() + //} + //Normally the last result should be true, which means the circuit has been opened + // + //assert.True(t, lastRest) + +} + +func TestHystricFilter_Invoke_CircuitBreak_Omit_Exception(t *testing.T) { + mockInitHystrixConfig() + hystrix.Flush() + reg, _ := regexp.Compile(".*exception.*") + regs := []*regexp.Regexp{reg} + hf := &HystrixFilter{res: map[string][]*regexp.Regexp{"": regs}, COrP: true} + resChan := make(chan protocol.Result, 50) + for i := 0; i < 50; i++ { + go func() { + result := hf.Invoke(&testMockFailInvoker{}, &invocation.RPCInvocation{}) + resChan <- result + }() + } + //This can not always pass the test when on travis due to concurrency, you can uncomment the code below and test it locally + + //time.Sleep(time.Second * 6) + //var lastRest bool + //for i := 0; i < 50; i++ { + // lastRest = (<-resChan).Error().(*HystrixFilterError).FailByHystrix() + //} + // + //assert.False(t, lastRest) + +} + +func TestGetHystrixFilterConsumer(t *testing.T) { + get := GetHystrixFilterConsumer() + assert.NotNil(t, get) + assert.True(t, get.(*HystrixFilter).COrP) +} +func TestGetHystrixFilterProvider(t *testing.T) { + get := GetHystrixFilterProvider() + assert.NotNil(t, get) + assert.False(t, get.(*HystrixFilter).COrP) +} diff --git a/go.mod b/go.mod index 3dece6c19bacf8954f6eaebfd8ee9a0ed83d877f..20a8fc836788b1b30ca0368574f65f3b54d94d3a 100644 --- a/go.mod +++ b/go.mod @@ -1,15 +1,49 @@ module github.com/apache/dubbo-go require ( + github.com/Workiva/go-datastructures v1.0.50 + github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5 + github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190802083043-4cd0c391755e // indirect github.com/apache/dubbo-go-hessian2 v1.2.5-0.20190731020727-1697039810c8 - github.com/davecgh/go-spew v1.1.1 // indirect + github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23 // indirect + github.com/coreos/bbolt v1.3.3 // indirect + github.com/coreos/etcd v3.3.13+incompatible + github.com/coreos/go-semver v0.3.0 // indirect + github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f // indirect + github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect github.com/dubbogo/getty v1.2.2 github.com/dubbogo/gost v1.1.1 + github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239 // indirect + github.com/go-errors/errors v1.0.1 // indirect + github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6 // indirect + github.com/golang/mock v1.3.1 + github.com/google/btree v1.0.0 // indirect + github.com/grpc-ecosystem/go-grpc-middleware v1.0.0 // indirect + github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect + github.com/grpc-ecosystem/grpc-gateway v1.9.5 // indirect + github.com/hashicorp/consul v1.5.3 + github.com/hashicorp/consul/api v1.1.0 + github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869 // indirect + github.com/jonboulle/clockwork v0.1.0 // indirect + github.com/lestrrat/go-envload v0.0.0-20180220120943-6ed08b54a570 // indirect + github.com/lestrrat/go-file-rotatelogs v0.0.0-20180223000712-d3151e2a480f // indirect + github.com/lestrrat/go-strftime v0.0.0-20180220042222-ba3bf9c1d042 // indirect github.com/magiconair/properties v1.8.1 + github.com/nacos-group/nacos-sdk-go v0.0.0-20190723125407-0242d42e3dbb github.com/pkg/errors v0.8.1 + github.com/prometheus/client_golang v1.1.0 // indirect github.com/samuel/go-zookeeper v0.0.0-20180130194729-c4fab1ac1bec + github.com/smartystreets/goconvey v0.0.0-20190710185942-9d28bd7c0945 // indirect + github.com/soheilhy/cmux v0.1.4 // indirect github.com/stretchr/testify v1.3.0 + github.com/tebeka/strftime v0.1.3 // indirect + github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 // indirect + github.com/toolkits/concurrent v0.0.0-20150624120057-a4371d70e3e3 // indirect + github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect + go.etcd.io/bbolt v1.3.3 // indirect + go.etcd.io/etcd v3.3.13+incompatible go.uber.org/atomic v1.4.0 go.uber.org/zap v1.10.0 + google.golang.org/grpc v1.22.1 gopkg.in/yaml.v2 v2.2.2 ) diff --git a/go.sum b/go.sum index 7718fce852388f9fa896b891924a0662de6c157f..4c6eb9b2553042914b00f2cd121277804b896a57 100644 --- a/go.sum +++ b/go.sum @@ -1,42 +1,572 @@ +cloud.google.com/go v0.26.0 h1:e0WKqKTd5BnrG8aKH3J3h+QvEIQtSUcf2n5UZ5ZgLtQ= +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/Azure/azure-sdk-for-go v16.0.0+incompatible h1:gr1qKY/Ll72VjFTZmaBwRK1yQHAxCnV25ekOKroc9ws= +github.com/Azure/azure-sdk-for-go v16.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= +github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 h1:w+iIsaOQNcT7OZ575w+acHgRric5iCyQh+xv+KJ4HB8= +github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= +github.com/Azure/go-autorest v10.7.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= +github.com/Azure/go-autorest v10.15.3+incompatible h1:nhKI/bvazIs3C3TFGoSqKY6hZ8f5od5mb5/UcS6HVIY= +github.com/Azure/go-autorest v10.15.3+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/DataDog/datadog-go v2.2.0+incompatible h1:V5BKkxACZLjzHjSgBbr2gvLA2Ae49yhc6CSY7MLy5k4= +github.com/DataDog/datadog-go v2.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= +github.com/Jeffail/gabs v1.1.0 h1:kw5zCcl9tlJNHTDme7qbi21fDHZmXrnjMoXos3Jw/NI= +github.com/Jeffail/gabs v1.1.0/go.mod h1:6xMvQMK4k33lb7GUUpaAPh6nKMmemQeg5d4gn7/bOXc= +github.com/Microsoft/go-winio v0.4.3 h1:M3NHMuPgMSUPdE5epwNUHlRPSVzHs8HpRTrVXhR0myo= +github.com/Microsoft/go-winio v0.4.3/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA= +github.com/NYTimes/gziphandler v1.0.1 h1:iLrQrdwjDd52kHDA5op2UBJFjmOb9g+7scBan4RN8F0= +github.com/NYTimes/gziphandler v1.0.1/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= +github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw= +github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk= +github.com/SAP/go-hdb v0.12.0 h1:5hBQZ2jjyZ268qjDmoDZJuCyLzR6oRLI60eYzmTW9m4= +github.com/SAP/go-hdb v0.12.0/go.mod h1:etBT+FAi1t5k3K3tf5vQTnosgYmhDkRi8jEnQqCnxF0= +github.com/SermoDigital/jose v0.0.0-20180104203859-803625baeddc h1:LkkwnbY+S8WmwkWq1SVyRWMH9nYWO1P5XN3OD1tts/w= +github.com/SermoDigital/jose v0.0.0-20180104203859-803625baeddc/go.mod h1:ARgCUhI1MHQH+ONky/PAtmVHQrP5JlGY0F3poXOp/fA= +github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 h1:fLjPD/aNc3UIOA6tDi6QXUemppXK3P9BI7mr2hd6gx8= +github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= +github.com/Workiva/go-datastructures v1.0.50 h1:slDmfW6KCHcC7U+LP3DDBbm4fqTwZGn1beOFPfGaLvo= +github.com/Workiva/go-datastructures v1.0.50/go.mod h1:Z+F2Rca0qCsVYDS8z7bAGm8f3UkzuWYS/oBZz5a7VVA= +github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5 h1:rFw4nCn9iMW+Vajsk51NtYIcwSTkXr+JGrMd36kTDJw= +github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= +github.com/abdullin/seq v0.0.0-20160510034733-d5467c17e7af h1:DBNMBMuMiWYu0b+8KMJuWmfCkcxl09JwdlqwDZZ6U14= +github.com/abdullin/seq v0.0.0-20160510034733-d5467c17e7af/go.mod h1:5Jv4cbFiHJMsVxt52+i0Ha45fjshj6wxYr1r19tB9bw= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190802083043-4cd0c391755e h1:MSuLXx/mveDbpDNhVrcWTMeV4lbYWKcyO4rH+jAxmX0= +github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190802083043-4cd0c391755e/go.mod h1:myCDvQSzCW+wB1WAlocEru4wMGJxy+vlxHdhegi1CDQ= +github.com/aliyun/aliyun-oss-go-sdk v0.0.0-20190307165228-86c17b95fcd5/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8= github.com/apache/dubbo-go-hessian2 v1.2.5-0.20190731020727-1697039810c8 h1:7zJlM+8bpCAUhv03TZnXkT4MLlLWng1s7An8CLuN73E= github.com/apache/dubbo-go-hessian2 v1.2.5-0.20190731020727-1697039810c8/go.mod h1:LWnndnrFXZmJLAzoyNAPNHSIJ1KOHVkTSsHgC3YYWlo= -github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e h1:QEF07wC0T1rKkctt1RINW/+RMTVmiwxETico2l3gxJA= +github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= +github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da h1:8GUt8eRujhVEGZFFEjBj46YV4rDjvGrNxb0KMWYkL2I= +github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= +github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878 h1:EFSB7Zo9Eg91v7MJPVsifUysc/wPdN+NOnVe6bWbdBM= +github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878/go.mod h1:3AMJUQhVx52RsWOnlkpikZr01T/yAVN2gn0861vByNg= +github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310 h1:BUAU3CGlLvorLI26FmByPp2eC2qla6E1Tw+scpcg/to= +github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/asaskevich/govalidator v0.0.0-20180319081651-7d2e70ef918f h1:/8NcnxL60YFll4ehCwibKotx0BR9v2ND40fomga8qDs= +github.com/asaskevich/govalidator v0.0.0-20180319081651-7d2e70ef918f/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= +github.com/aws/aws-sdk-go v1.15.24 h1:xLAdTA/ore6xdPAljzZRed7IGqQgC+nY+ERS5vaj4Ro= +github.com/aws/aws-sdk-go v1.15.24/go.mod h1:mFuSZ37Z9YOHbQEwBWztmVzqXrEkub65tZoCYDt7FT0= +github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f/go.mod h1:AuiFmCCPBSrqvVMvuqFuk0qogytodnVFVSN5CeJB8Gc= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= +github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932 h1:mXoPYz/Ul5HYEDvkta6I8/rnYM5gSdSV2tJ6XbZuEtY= +github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932/go.mod h1:NOuUCSz6Q9T7+igc/hlvDOUdtWKryOrtFyIVABv/p7k= +github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY= +github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4= +github.com/boltdb/bolt v1.3.1 h1:JQmyP4ZBrce+ZQu0dY660FMfatumYDLun9hBCUVIkF4= +github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps= +github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23 h1:D21IyuvjDCshj1/qq+pCNd3VZOAEI9jy6Bi131YlXgI= +github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s= +github.com/cenkalti/backoff v2.1.1+incompatible h1:tKJnvO2kl0zmb/jA5UKAt4VoEVw1qxKWjE/Bpp46npY= +github.com/cenkalti/backoff v2.1.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= +github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible h1:C29Ae4G5GtYyYMm1aztcyj/J5ckgJm2zwdDajFbx1NY= +github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= +github.com/circonus-labs/circonusllhist v0.1.3 h1:TJH+oke8D16535+jHExHj4nQvzlZrj7ug5D7I/orNUA= +github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/containerd/continuity v0.0.0-20181203112020-004b46473808 h1:4BX8f882bXEDKfWIf0wa8HRvpnBoPszJJXL+TVbBw4M= +github.com/containerd/continuity v0.0.0-20181203112020-004b46473808/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= +github.com/coredns/coredns v1.1.2 h1:bAFHrSsBeTeRG5W3Nf2su3lUGw7Npw2UKeCJm/3A638= +github.com/coredns/coredns v1.1.2/go.mod h1:zASH/MVDgR6XZTbxvOnsZfffS+31vg6Ackf/wo1+AM0= +github.com/coreos/bbolt v1.3.3 h1:n6AiVyVRKQFNb6mJlwESEvvLoDyiTzXX7ORAUlkeBdY= +github.com/coreos/bbolt v1.3.3/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= +github.com/coreos/etcd v3.3.13+incompatible h1:8F3hqu9fGYLBifCmRCJsicFqDx/D68Rt3q1JMazcgBQ= +github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= +github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM= +github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f h1:JOrtw2xFKzlg+cbHpyrpLDmnN1HqhBfnX7WDiW7eG2c= +github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f h1:lBNOc5arjvs8E5mO2tbpBpLoyyu8B6e44T7hJy6potg= +github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/denisenkom/go-mssqldb v0.0.0-20180620032804-94c9c97e8c9f h1:JtRnQbMXb3TcSIm1j452zI45lPMiAQ0puF8iK5EnY9M= +github.com/denisenkom/go-mssqldb v0.0.0-20180620032804-94c9c97e8c9f/go.mod h1:xN/JuLBIz4bjkxNmByTiV1IbhfnYb6oo99phBn4Eqhc= +github.com/denverdino/aliyungo v0.0.0-20170926055100-d3308649c661 h1:lrWnAyy/F72MbxIxFUzKmcMCdt9Oi8RzpAxzTNQHD7o= +github.com/denverdino/aliyungo v0.0.0-20170926055100-d3308649c661/go.mod h1:dV8lFg6daOBZbT6/BDGIz6Y3WFGn8juu6G+CQ6LHtl0= +github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= +github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= +github.com/digitalocean/godo v1.1.1/go.mod h1:h6faOIcZ8lWIwNQ+DN7b3CgX4Kwby5T+nbpNqkUIozU= +github.com/digitalocean/godo v1.10.0 h1:uW1/FcvZE/hoixnJcnlmIUvTVNdZCLjRLzmDtRi1xXY= +github.com/digitalocean/godo v1.10.0/go.mod h1:h6faOIcZ8lWIwNQ+DN7b3CgX4Kwby5T+nbpNqkUIozU= +github.com/docker/go-connections v0.3.0 h1:3lOnM9cSzgGwx8VfK/NGOW5fLQ0GjIlCkaktF+n1M6o= +github.com/docker/go-connections v0.3.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= +github.com/docker/go-units v0.3.3 h1:Xk8S3Xj5sLGlG5g67hJmYMmUgXv5N4PhkjJHHqrwnTk= +github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dubbogo/getty v1.2.2 h1:qDC9WXjxcs5NPvWZz2ruVKBKr2r1Jjm6i0Sq//CQwbE= github.com/dubbogo/getty v1.2.2/go.mod h1:K4b3MkGLf7T+lMgQNFgpg0dI1Wvv1PTisFs1Psf86kU= github.com/dubbogo/gost v1.1.1 h1:JCM7vx5edPIjDA5ovJTuzEEXuw2t7xLyrlgi2mi5jHI= github.com/dubbogo/gost v1.1.1/go.mod h1:R7wZm1DrmrKGr50mBZVcg6C9ekG8aL5hP+sgWcIDwQg= +github.com/duosecurity/duo_api_golang v0.0.0-20190308151101-6c680f768e74 h1:2MIhn2R6oXQbgW5yHfS+d6YqyMfXiu2L55rFZC4UD/M= +github.com/duosecurity/duo_api_golang v0.0.0-20190308151101-6c680f768e74/go.mod h1:UqXY1lYT/ERa4OEAywUqdok1T4RCRdArkhic1Opuavo= +github.com/elazarl/go-bindata-assetfs v0.0.0-20160803192304-e1a2a7ec64b0 h1:ZoRgc53qJCfSLimXqJDrmBhnt5GChDsExMCK7t48o0Y= +github.com/elazarl/go-bindata-assetfs v0.0.0-20160803192304-e1a2a7ec64b0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4= +github.com/envoyproxy/go-control-plane v0.8.0 h1:uE6Fp4fOcAJdc1wTQXLJ+SYistkbG1dNoi6Zs1+Ybvk= +github.com/envoyproxy/go-control-plane v0.8.0/go.mod h1:GSSbY9P1neVhdY7G4wu+IK1rk/dqhiCC/4ExuWJZVuk= +github.com/envoyproxy/protoc-gen-validate v0.0.14 h1:YBW6/cKy9prEGRYLnaGa4IDhzxZhRCtKsax8srGKDnM= +github.com/envoyproxy/protoc-gen-validate v0.0.14/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239 h1:Ghm4eQYC0nEPnSJdVkTrXpu9KtoVCSo1hg7mtI7G9KU= +github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239/go.mod h1:Gdwt2ce0yfBxPvZrHkprdPPTTS3N5rwmLE8T22KBXlw= +github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= +github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/fatih/structs v0.0.0-20180123065059-ebf56d35bba7 h1:bGT+Ub6bpzHl7AAYQhBrZ5nYTAH2SF/848WducU0Ao4= +github.com/fatih/structs v0.0.0-20180123065059-ebf56d35bba7/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/go-errors/errors v1.0.1 h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6w= +github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= +github.com/go-ini/ini v1.25.4 h1:Mujh4R/dH6YL8bxuISne3xX2+qcQ9p0IxKAP6ExWoUo= +github.com/go-ini/ini v1.25.4/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-ldap/ldap v3.0.2+incompatible h1:kD5HQcAzlQ7yrhfn+h+MSABeAy/jAJhvIJ/QDllP44g= +github.com/go-ldap/ldap v3.0.2+incompatible/go.mod h1:qfd9rJvER9Q0/D/Sqn1DfHRoBp40uXYvFoEVrNEPqRc= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-ole/go-ole v1.2.1 h1:2lOsA72HgjxAuMlKpFiCbHTvu44PIVkZ5hqm3RSdI/E= +github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8= +github.com/go-sql-driver/mysql v0.0.0-20180618115901-749ddf1598b4 h1:1LlmVz15APoKz9dnm5j2ePptburJlwEH+/v/pUuoxck= +github.com/go-sql-driver/mysql v0.0.0-20180618115901-749ddf1598b4/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/go-test/deep v1.0.2 h1:onZX1rnHT3Wv6cqNgYyFOOlgVKJrksuCMCRvJStbMYw= +github.com/go-test/deep v1.0.2/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= +github.com/gocql/gocql v0.0.0-20180617115710-e06f8c1bcd78 h1:G7iRamCffNivybfZvsJjtk3k2qHa73xW+OysVkukcGk= +github.com/gocql/gocql v0.0.0-20180617115710-e06f8c1bcd78/go.mod h1:4Fw1eo5iaEhDUs8XyuhSVCVy52Jq3L+/3GJgYkwc+/0= +github.com/gogo/googleapis v1.1.0 h1:kFkMAZBNAn4j7K0GiZr8cRYzejq68VbheufiV3YuyFI= +github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE= +github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= +github.com/goji/httpauth v0.0.0-20160601135302-2da839ab0f4d/go.mod h1:nnjvkQ9ptGaCkuDUx6wNykzzlUixGxvkme+H/lnzb+A= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6 h1:ZgQEtGgCBiWRM39fZuwSd1LwSqqSW0hOdXCYYDX0R3I= +github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.3.1 h1:qGJ6qTW+x6xX/my+8YUVl4WNpX9B7+/l2tRsHGZ7f2s= +github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/snappy v0.0.0-20170215233205-553a64147049/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY= +github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= +github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135 h1:zLTLjkaOFEFIOxY5BWLFLwh+cL8vOBW4XJ2aqLE/Tf0= +github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= +github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= +github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/googleapis/gnostic v0.2.0 h1:l6N3VoaVzTncYYW+9yOz2LJJammFZGBO13sqgEhpy9g= +github.com/googleapis/gnostic v0.2.0/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= +github.com/gophercloud/gophercloud v0.0.0-20180828235145-f29afc2cceca h1:wobTb8SE189AuxzEKClyYxiI4nUGWlpVtl13eLiFlOE= +github.com/gophercloud/gophercloud v0.0.0-20180828235145-f29afc2cceca/go.mod h1:3WdhXV3rUYy9p6AUW8d94kr+HS62Y4VL9mBnFxsD8q4= +github.com/gopherjs/gopherjs v0.0.0-20180825215210-0210a2f0f73c/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/gotestyourself/gotestyourself v2.2.0+incompatible h1:AQwinXlbQR2HvPjQZOmDhRqsv5mZf+Jb1RnSLxcqZcI= +github.com/gotestyourself/gotestyourself v2.2.0+incompatible/go.mod h1:zZKM6oeNM8k+FRljX1mnzVYeS8wiGgQyvST1/GafPbY= +github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 h1:pdN6V1QBWetyv/0+wjACpqVH+eVULgEjkurDLq3goeM= +github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= +github.com/grpc-ecosystem/go-grpc-middleware v1.0.0 h1:Iju5GlWwrvL6UBg4zJJt3btmonfrMlCDdsejg4CZE7c= +github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= +github.com/grpc-ecosystem/grpc-gateway v1.9.5 h1:UImYN5qQ8tuGpGE16ZmjvcTtTw24zw1QAp/SlnNrZhI= +github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= +github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed h1:5upAirOpQc1Q53c0bnx2ufif5kANL7bfZWcc6VJWJd8= +github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed/go.mod h1:tMWxXQ9wFIaZeTI9F+hmhFiGpFmhOHzyShyFUhRm0H4= +github.com/hashicorp/consul v1.5.3 h1:EmTWRf/cuqZk6Ug9tgFUVE9xNgJPpmBvJwJMvm+agSk= +github.com/hashicorp/consul v1.5.3/go.mod h1:61E2GJCPEP3oq8La7sfDdWGQ66+Zbxzw5ecOdFD7xIE= +github.com/hashicorp/consul/api v1.1.0 h1:BNQPM9ytxj6jbjjdRPioQ94T6YXriSopn0i8COv6SRA= +github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= +github.com/hashicorp/consul/sdk v0.1.1 h1:LnuDWGNsoajlhGyHJvuWW6FVqRl8JOTPqS6CPTsYjhY= +github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= +github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= +github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-bexpr v0.1.0 h1:hA/9CWGPsQ6YZXvPvizD+VEEjBG4V6Un0Qcyav5ghK4= +github.com/hashicorp/go-bexpr v0.1.0/go.mod h1:ANbpTX1oAql27TZkKVeW8p1w8NTdnyzPe/0qqPCKohU= +github.com/hashicorp/go-checkpoint v0.0.0-20171009173528-1545e56e46de/go.mod h1:xIwEieBHERyEvaeKF/TcHh1Hu+lxPM+n2vT1+g9I4m4= +github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-cleanhttp v0.5.1 h1:dH3aiDG9Jvb5r5+bYHsikaOUIpcM0xvgMXVoDkXMzJM= +github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-discover v0.0.0-20190403160810-22221edb15cd h1:SynRxs8h2h7lLSA5py5a3WWkYpImhREtju0CuRd97wc= +github.com/hashicorp/go-discover v0.0.0-20190403160810-22221edb15cd/go.mod h1:ueUgD9BeIocT7QNuvxSyJyPAM9dfifBcaWmeybb67OY= +github.com/hashicorp/go-hclog v0.9.1 h1:9PZfAcVEvez4yhLH2TBU64/h/z4xlFI80cWXRrxuKuM= +github.com/hashicorp/go-hclog v0.9.1/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= +github.com/hashicorp/go-immutable-radix v1.0.0 h1:AKDB1HM5PWEA7i4nhcpwOrO2byshxBjXVn/J/3+z5/0= +github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-memdb v0.0.0-20180223233045-1289e7fffe71 h1:yxxFgVz31vFoKKTtRUNbXLNe4GFnbLKqg+0N7yG42L8= +github.com/hashicorp/go-memdb v0.0.0-20180223233045-1289e7fffe71/go.mod h1:kbfItVoBJwCfKXDXN4YoAXjxcFVZ7MRrJzyTX6H4giE= +github.com/hashicorp/go-msgpack v0.5.3 h1:zKjpN5BK/P5lMYrLmBHdBULWbJ0XpYR+7NGzqkZzoD4= +github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= +github.com/hashicorp/go-msgpack v0.5.5 h1:i9R9JSrqIz0QVLz3sz+i3YJdT7TTSLcfLLzJi9aZTuI= +github.com/hashicorp/go-msgpack v0.5.5/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= +github.com/hashicorp/go-multierror v1.0.0 h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uPribsnS6o= +github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hashicorp/go-plugin v0.0.0-20180331002553-e8d22c780116 h1:Y4V/yReWjQo/Ngyc0w6C3EKXKincp4YgvXeo8lI4LrI= +github.com/hashicorp/go-plugin v0.0.0-20180331002553-e8d22c780116/go.mod h1:JSqWYsict+jzcj0+xElxyrBQRPNoiWQuddnxArJ7XHQ= +github.com/hashicorp/go-raftchunking v0.6.1 h1:moEnaG3gcwsWNyIBJoD5PCByE+Ewkqxh6N05CT+MbwA= +github.com/hashicorp/go-raftchunking v0.6.1/go.mod h1:cGlg3JtDy7qy6c/3Bu660Mic1JF+7lWqIwCFSb08fX0= +github.com/hashicorp/go-retryablehttp v0.5.3 h1:QlWt0KvWT0lq8MFppF9tsJGF+ynG7ztc2KIPhzRGk7s= +github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= +github.com/hashicorp/go-rootcerts v1.0.0 h1:Rqb66Oo1X/eSV1x66xbDccZjhJigjg0+e82kpwzSwCI= +github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= +github.com/hashicorp/go-sockaddr v1.0.0 h1:GeH6tui99pF4NJgfnhp+L6+FfobzVW3Ah46sLo0ICXs= +github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= +github.com/hashicorp/go-syslog v1.0.0 h1:KaodqZuhUoZereWVIYmpUgZysurB1kBLX2j0MwMrUAE= +github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= +github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE= +github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-version v0.0.0-20170202080759-03c5bf6be031 h1:c3Xdf5fTpk+hqhxqCO+ymqjfUXV9+GZqNgTtlnVzDos= +github.com/hashicorp/go-version v0.0.0-20170202080759-03c5bf6be031/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= +github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/hcl v0.0.0-20180906183839-65a6292f0157 h1:PJ+K03hio6ADVjEc6lFu5r866o67xEEMQ73CFdI6R2U= +github.com/hashicorp/hcl v0.0.0-20180906183839-65a6292f0157/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/hashicorp/hil v0.0.0-20160711231837-1e86c6b523c5 h1:uk280DXEbQiCOZgCOI3elFSeNxf8YIZiNsbr2pQLYD0= +github.com/hashicorp/hil v0.0.0-20160711231837-1e86c6b523c5/go.mod h1:KHvg/R2/dPtaePb16oW4qIyzkMxXOL38xjRN64adsts= +github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= +github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= +github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= +github.com/hashicorp/mdns v1.0.1 h1:XFSOubp8KWB+Jd2PDyaX5xUd5bhSP/+pTDZVDMzZJM8= +github.com/hashicorp/mdns v1.0.1/go.mod h1:4gW7WsVCke5TE7EPeYliwHlRUyBtfCwuFwuMg2DmyNY= +github.com/hashicorp/memberlist v0.1.3 h1:EmmoJme1matNzb+hMpDuR/0sbJSUisxyqBGG676r31M= +github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= +github.com/hashicorp/memberlist v0.1.4 h1:gkyML/r71w3FL8gUi74Vk76avkj/9lYAY9lvg0OcoGs= +github.com/hashicorp/memberlist v0.1.4/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= +github.com/hashicorp/net-rpc-msgpackrpc v0.0.0-20151116020338-a14192a58a69 h1:lc3c72qGlIMDqQpQH82Y4vaglRMMFdJbziYWriR4UcE= +github.com/hashicorp/net-rpc-msgpackrpc v0.0.0-20151116020338-a14192a58a69/go.mod h1:/z+jUGRBlwVpUZfjute9jWaF6/HuhjuFQuL1YXzVD1Q= +github.com/hashicorp/raft v1.1.1 h1:HJr7UE1x/JrJSc9Oy6aDBHtNHUUBHjcQjTgvUVihoZs= +github.com/hashicorp/raft v1.1.1/go.mod h1:vPAJM8Asw6u8LxC3eJCUZmRP/E4QmUGE1R7g7k8sG/8= +github.com/hashicorp/raft-boltdb v0.0.0-20171010151810-6e5ba93211ea h1:xykPFhrBAS2J0VBzVa5e80b5ZtYuNQtgXjN40qBZlD4= +github.com/hashicorp/raft-boltdb v0.0.0-20171010151810-6e5ba93211ea/go.mod h1:pNv7Wc3ycL6F5oOWn+tPGo2gWD4a5X+yp/ntwdKLjRk= +github.com/hashicorp/serf v0.8.2 h1:YZ7UKsJv+hKjqGVUUbtE3HNj79Eln2oQ75tniF6iPt0= +github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= +github.com/hashicorp/vault v0.10.3 h1:3Hf6mwC4rggOq6ViWSoJ2yfk1oBS5ed58LLcP33gmEg= +github.com/hashicorp/vault v0.10.3/go.mod h1:KfSyffbKxoVyspOdlaGVjIuwLobi07qD1bAbosPMpP0= +github.com/hashicorp/vault-plugin-secrets-kv v0.0.0-20190318174639-195e0e9d07f1 h1:7IvvWArBoSjStPohKqHj3ksXNjcyPsyXYDIhCQw6Vtg= +github.com/hashicorp/vault-plugin-secrets-kv v0.0.0-20190318174639-195e0e9d07f1/go.mod h1:VJHHT2SC1tAPrfENQeBhLlb5FbZoKZM+oC/ROmEftz0= +github.com/hashicorp/vic v1.5.1-0.20190403131502-bbfe86ec9443 h1:O/pT5C1Q3mVXMyuqg7yuAWUg/jMZR1/0QTzTRdNR6Uw= +github.com/hashicorp/vic v1.5.1-0.20190403131502-bbfe86ec9443/go.mod h1:bEpDU35nTu0ey1EXjwNwPjI9xErAsoOCmcMb9GKvyxo= +github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d h1:kJCB4vdITiW1eC1vq2e6IsrXKrZit1bv/TDYFGMp4BQ= +github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/imdario/mergo v0.3.6 h1:xTNEAn+kxVO7dTZGu0CegyqKZmoWFI0rF8UxjlB2d28= +github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= +github.com/jarcoal/httpmock v0.0.0-20180424175123-9c70cfe4a1da h1:FjHUJJ7oBW4G/9j1KzlHaXL09LyMVM9rupS39lncbXk= +github.com/jarcoal/httpmock v0.0.0-20180424175123-9c70cfe4a1da/go.mod h1:ks+b9deReOc7jgqp+e7LuFiCBH6Rm5hL32cLcEAArb4= +github.com/jefferai/jsonx v0.0.0-20160721235117-9cc31c3135ee h1:AQ/QmCk6x8ECPpf2pkPtA4lyncEEBbs8VFnVXPYKhIs= +github.com/jefferai/jsonx v0.0.0-20160721235117-9cc31c3135ee/go.mod h1:N0t2vlmpe8nyZB5ouIbJQPDSR+mH6oe7xHB9VZHSUzM= +github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869 h1:IPJ3dvxmJ4uczJe5YQdrYB16oTJlGSC/OyZDqUk9xX4= +github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869/go.mod h1:cJ6Cj7dQo+O6GJNiMx+Pa94qKj+TG8ONdKHgMNIyyag= +github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= +github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM= +github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= +github.com/jonboulle/clockwork v0.1.0 h1:VKV+ZcuP6l3yW9doeqz6ziZGgcynBVQO+obU0+0hcPo= +github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= +github.com/joyent/triton-go v0.0.0-20180628001255-830d2b111e62 h1:JHCT6xuyPUrbbgAPE/3dqlvUKzRHMNuTBKKUb6OeR/k= +github.com/joyent/triton-go v0.0.0-20180628001255-830d2b111e62/go.mod h1:U+RSyWxWd04xTqnuOQxnai7XGS2PrPY2cfGoDKtMHjA= +github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.7 h1:KfgG9LzI+pYjr4xvmz/5H4FXjokeP+rlHLhv3iH62Fo= +github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= +github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= +github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/keybase/go-crypto v0.0.0-20180614160407-5114a9a81e1b h1:VE6r2OwP5gj+Z9aCkSKl3MlmnZbfMAjhvR5T7abKHEo= +github.com/keybase/go-crypto v0.0.0-20180614160407-5114a9a81e1b/go.mod h1:ghbZscTyKdM07+Fw3KSi0hcJm+AlEUWj8QLlPtijN/M= +github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/lestrrat/go-envload v0.0.0-20180220120943-6ed08b54a570 h1:0iQektZGS248WXmGIYOwRXSQhD4qn3icjMpuxwO7qlo= +github.com/lestrrat/go-envload v0.0.0-20180220120943-6ed08b54a570/go.mod h1:BLt8L9ld7wVsvEWQbuLrUZnCMnUmLZ+CGDzKtclrTlE= +github.com/lestrrat/go-file-rotatelogs v0.0.0-20180223000712-d3151e2a480f h1:sgUSP4zdTUZYZgAGGtN5Lxk92rK+JUFOwf+FT99EEI4= +github.com/lestrrat/go-file-rotatelogs v0.0.0-20180223000712-d3151e2a480f/go.mod h1:UGmTpUd3rjbtfIpwAPrcfmGf/Z1HS95TATB+m57TPB8= +github.com/lestrrat/go-strftime v0.0.0-20180220042222-ba3bf9c1d042 h1:Bvq8AziQ5jFF4BHGAEDSqwPW1NJS3XshxbRCxtjFAZc= +github.com/lestrrat/go-strftime v0.0.0-20180220042222-ba3bf9c1d042/go.mod h1:TPpsiPUEh0zFL1Snz4crhMlBe60PYxRHr5oFF3rRYg0= +github.com/lib/pq v0.0.0-20180523175426-90697d60dd84 h1:it29sI2IM490luSc3RAhp5WuCYnc6RtbfLVAB7nmC5M= +github.com/lib/pq v0.0.0-20180523175426-90697d60dd84/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4= +github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-isatty v0.0.3 h1:ns/ykhmWi7G9O+8a448SecJU3nSMBXJfqQkl0upE1jI= +github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/miekg/dns v1.0.14 h1:9jZdLNd/P4+SfEJ0TNyxYpsK8N4GtfylBLqtbYN1sbA= +github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= +github.com/mitchellh/cli v1.0.0 h1:iGBIsUe3+HZ/AD/Vd7DErOt5sU9fa8Uj7A2s1aggv1Y= +github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= +github.com/mitchellh/copystructure v1.0.0 h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMKeZ+mmkFQ= +github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= +github.com/mitchellh/go-homedir v1.0.0 h1:vKb8ShqSby24Yrqr/yDYkuFz8d0WUjys40rvnGC8aR0= +github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-testing-interface v1.0.0 h1:fzU/JVNcaqHQEcVFAKeR41fkiLdIPrefOvVG1VZ96U0= +github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= +github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= +github.com/mitchellh/hashstructure v0.0.0-20170609045927-2bca23e0e452 h1:hOY53G+kBFhbYFpRVxHl5eS7laP6B1+Cq+Z9Dry1iMU= +github.com/mitchellh/hashstructure v0.0.0-20170609045927-2bca23e0e452/go.mod h1:QjSHrPWS+BGUVBYkbTZWEnOh3G1DutKwClXU/ABz6AQ= +github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= +github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= +github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/mitchellh/reflectwalk v1.0.1 h1:FVzMWA5RllMAKIdUSC8mdWo3XtwoecrH79BY70sEEpE= +github.com/mitchellh/reflectwalk v1.0.1/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/nacos-group/nacos-sdk-go v0.0.0-20190723125407-0242d42e3dbb h1:lbmvw8r9W55w+aQgWn35W1nuleRIECMoqUrmwAOAvoI= +github.com/nacos-group/nacos-sdk-go v0.0.0-20190723125407-0242d42e3dbb/go.mod h1:CEkSvEpoveoYjA81m4HNeYQ0sge0LFGKSEqO3JKHllo= +github.com/nicolai86/scaleway-sdk v1.10.2-0.20180628010248-798f60e20bb2 h1:BQ1HW7hr4IVovMwWg0E0PYcyW8CzqDcVmaew9cujU4s= +github.com/nicolai86/scaleway-sdk v1.10.2-0.20180628010248-798f60e20bb2/go.mod h1:TLb2Sg7HQcgGdloNxkrmtgDNR9uVYF3lfdFIN4Ro6Sk= +github.com/oklog/run v0.0.0-20180308005104-6934b124db28 h1:Hbr3fbVPXea52oPQeP7KLSxP52g6SFaNY1IqAmUyEW0= +github.com/oklog/run v0.0.0-20180308005104-6934b124db28/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= +github.com/onsi/gomega v1.4.2/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/opencontainers/go-digest v1.0.0-rc1 h1:WzifXhOVOEOuFYOJAW6aQqW0TooG2iki3E3Ii+WN7gQ= +github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= +github.com/opencontainers/image-spec v1.0.1 h1:JMemWkRwHx4Zj+fVxWoMCFm/8sYGGrUVojFA6h/TRcI= +github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= +github.com/opencontainers/runc v0.1.1 h1:GlxAyO6x8rfZYN9Tt0Kti5a/cP41iuiO2yYT0IJGY8Y= +github.com/opencontainers/runc v0.1.1/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= +github.com/ory/dockertest v3.3.4+incompatible h1:VrpM6Gqg7CrPm3bL4Wm1skO+zFWLbh7/Xb5kGEbJRh8= +github.com/ory/dockertest v3.3.4+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs= +github.com/packethost/packngo v0.1.1-0.20180711074735-b9cb5096f54c h1:vwpFWvAO8DeIZfFeqASzZfsxuWPno9ncAebBEP0N3uE= +github.com/packethost/packngo v0.1.1-0.20180711074735-b9cb5096f54c/go.mod h1:otzZQXgoO96RTzDB/Hycg0qZcXZsWJGJRSXbmEIJ+4M= +github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c h1:Lgl0gzECD8GnQ5QCWA8o6BtfL6mDH5rQgM4/fX3avOs= +github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= +github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/patrickmn/go-cache v0.0.0-20180527043350-9f6ff22cfff8 h1:BR6MM54q4W9pn0SySwg6yctZtBKlTdUq6a+b0kArBnE= +github.com/patrickmn/go-cache v0.0.0-20180527043350-9f6ff22cfff8/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= +github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI= +github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/posener/complete v1.1.1 h1:ccV59UEOTzVDnDUEFdT95ZzHVZ+5+158q8+SJb2QV5w= +github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v0.9.2/go.mod h1:OsXs2jCmiKlQ1lTBmv21f2mNfw4xf/QclQDMrYNZzcM= +github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= +github.com/prometheus/client_golang v1.1.0 h1:BQ53HtBmfOitExawJ6LokA4x8ov/z0SYYb0+HxJfRI8= +github.com/prometheus/client_golang v1.1.0/go.mod h1:I1FGZT9+L76gKKOs5djB6ezCbFQP1xR9D75/vuwEF3g= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90 h1:S/YWwWx/RA8rT8tKFRuGUZhuA90OyIBpPCXkcbwU8DE= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/common v0.0.0-20181126121408-4724e9255275/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= +github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.6.0 h1:kRhiuYSXR3+uv2IbVbZhUxK5zVD/2pp3Gd2PpvPkpEo= +github.com/prometheus/common v0.6.0/go.mod h1:eBmuwkDJBwy6iBfxCBob6t6dR6ENT/y+J+Zk0j9GMYc= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/procfs v0.0.3 h1:CTwfnzjQ+8dS6MhHHu4YswVAD99sL2wjPqP+VkURmKE= +github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ= +github.com/renier/xmlrpc v0.0.0-20170708154548-ce4a1a486c03 h1:Wdi9nwnhFNAlseAOekn6B5G/+GMtks9UKbvRU/CMM/o= +github.com/renier/xmlrpc v0.0.0-20170708154548-ce4a1a486c03/go.mod h1:gRAiPF5C5Nd0eyyRdqIu9qTiFSoZzpTq727b5B8fkkU= +github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= +github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/ryanuber/go-glob v0.0.0-20170128012129-256dc444b735 h1:7YvPJVmEeFHR1Tj9sZEYsmarJEQfMVYpd/Vyy/A8dqE= +github.com/ryanuber/go-glob v0.0.0-20170128012129-256dc444b735/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= github.com/samuel/go-zookeeper v0.0.0-20180130194729-c4fab1ac1bec h1:6ncX5ko6B9LntYM0YBRXkiSaZMmLYeZ/NWcmeB43mMY= github.com/samuel/go-zookeeper v0.0.0-20180130194729-c4fab1ac1bec/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= +github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= +github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= +github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I= +github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= +github.com/shirou/gopsutil v0.0.0-20181107111621-48177ef5f880 h1:1Ge4j/3uB2rxzPWD3TC+daeCw+w91z8UCUL/7WH5gn8= +github.com/shirou/gopsutil v0.0.0-20181107111621-48177ef5f880/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= +github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 h1:udFKJ0aHUL60LboW/A+DfgoHVedieIzIXE8uylPue0U= +github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc= +github.com/sirupsen/logrus v1.0.6/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= +github.com/sirupsen/logrus v1.2.0 h1:juTguoYk5qI21pwyTXY3B3Y5cOTH3ZUyZCg1v/mihuo= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/smartystreets/assertions v0.0.0-20180820201707-7c9eb446e3cf/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/goconvey v0.0.0-20180222194500-ef6db91d284a/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s= +github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a h1:pa8hGb/2YqsZKovtsgrwcDH1RZhVbTKCjLp47XpqCDs= +github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= +github.com/smartystreets/goconvey v0.0.0-20190710185942-9d28bd7c0945 h1:N8Bg45zpk/UcpNGnfJt2y/3lRWASHNTUET8owPYCgYI= +github.com/smartystreets/goconvey v0.0.0-20190710185942-9d28bd7c0945/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= +github.com/softlayer/softlayer-go v0.0.0-20180806151055-260589d94c7d h1:bVQRCxQvfjNUeRqaY/uT0tFuvuFY0ulgnczuR684Xic= +github.com/softlayer/softlayer-go v0.0.0-20180806151055-260589d94c7d/go.mod h1:Cw4GTlQccdRGSEf6KiMju767x0NEHE0YIVPJSaXjlsw= +github.com/soheilhy/cmux v0.1.4 h1:0HKaf1o97UwFjHH9o5XsHUOF+tqmdA7KEzXLpiyaw0E= +github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= +github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= +github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/tebeka/strftime v0.1.3 h1:5HQXOqWKYRFfNyBMNVc9z5+QzuBtIXy03psIhtdJYto= +github.com/tebeka/strftime v0.1.3/go.mod h1:7wJm3dZlpr4l/oVK0t1HYIc4rMzQ2XJlOMIUJUJH6XQ= +github.com/tent/http-link-go v0.0.0-20130702225549-ac974c61c2f9/go.mod h1:RHkNRtSLfOK7qBTHaeSX1D6BNpI3qw7NTxsmNr4RvN8= +github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 h1:LnC5Kc/wtumK+WB441p7ynQJzVuNRJiqddSIE3IlSEQ= +github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= +github.com/toolkits/concurrent v0.0.0-20150624120057-a4371d70e3e3 h1:kF/7m/ZU+0D4Jj5eZ41Zm3IH/J8OElK1Qtd7tVKAwLk= +github.com/toolkits/concurrent v0.0.0-20150624120057-a4371d70e3e3/go.mod h1:QDlpd3qS71vYtakd2hmdpqhJ9nwv6mD6A30bQ1BPBFE= +github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926 h1:G3dpKMzFDjgEh2q1Z7zUUtKa8ViPtH+ocF0bE0g00O8= +github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= +github.com/vmware/govmomi v0.18.0 h1:f7QxSmP7meCtoAmiKZogvVbLInT+CZx6Px6K5rYsJZo= +github.com/vmware/govmomi v0.18.0/go.mod h1:URlwyTFZX72RmxtxuaFL2Uj3fD1JTvZdx59bHWk6aFU= +github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8= +github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= +go.etcd.io/bbolt v1.3.3 h1:MUGmc65QhB3pIlaQ5bB4LwqSj6GIonVJXpZiaKNyaKk= +go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.etcd.io/etcd v3.3.13+incompatible h1:jCejD5EMnlGxFvcGRyEV4VGlENZc7oPQX6o0t7n3xbw= +go.etcd.io/etcd v3.3.13+incompatible/go.mod h1:yaeTdrJi5lOmYerz05bd8+V7KubZs8YSFZfzsF9A6aI= go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/zap v1.10.0 h1:ORx85nbTijNz8ljznvCMR1ZBIPKFn3jQrag10X2AsuM= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/net v0.0.0-20190320064053-1272bf9dcd53 h1:kcXqo9vE6fsZY5X5Rd7R1l7fTgnWaDCVmln65REefiE= +golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c h1:Vj5n4GlwjmQteupaxJ9+0FNOmBrHfq7vN4btdGoDZgI= +golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190320064053-1272bf9dcd53/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= +golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190613194153-d28f0bde5980 h1:dfGZHvZk057jK2MCeWus/TowKpJ8y4AmooUzdBSR9GU= +golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/oauth2 v0.0.0-20170807180024-9a379c6b3e95/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be h1:vEDujvNQGv4jgYKudGeI/+DAX4Jffq6hpD55MmoEvKs= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190508220229-2d0786266e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190523142557-0e01d883c5c5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190801041406-cbf593c0f2f3 h1:4y9KwBHBgBNwDbtu44R5o1fdOCQUEXhbk/P4A9WmJq0= +golang.org/x/sys v0.0.0-20190801041406-cbf593c0f2f3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 h1:SvFZT6jyqRaOeXpc5h/JSfZenJ2O330aBsf7JfSUXmQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +google.golang.org/api v0.0.0-20180829000535-087779f1d2c9 h1:z1TeLUmxf9ws9KLICfmX+KGXTs+rjm+aGWzfsv7MZ9w= +google.golang.org/api v0.0.0-20180829000535-087779f1d2c9/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= +google.golang.org/appengine v1.1.0 h1:igQkv0AAhEIvTEpD5LIpAfav2eeVO9HBTjvKHVJPRSs= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0NQvRW8DG4Yk3Q6T9cu9RcFQDu1tc= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.19.1/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.22.1 h1:/7cs52RnTJmD43s3uxzlq2U7nqVTd/37viQwMrMNlOM= +google.golang.org/grpc v1.22.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d h1:TxyelI5cVkbREznMhfzycHdkp5cLA7DpE+GKjSslYhM= +gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d/go.mod h1:cuepJuh7vyXfUyUwEgHQXw849cJrilpS5NeIjOWESAw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKWaSkCsqBpgog8nAV2xsGOxlo= +gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= +gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= +gopkg.in/ini.v1 v1.42.0 h1:7N3gPTt50s8GuLortA00n8AqRTk75qOP98+mTPpgzRk= +gopkg.in/ini.v1 v1.42.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/mgo.v2 v2.0.0-20160818020120-3f83fa500528 h1:/saqWwm73dLmuzbNhe92F0QsZ/KiFND+esHco2v1hiY= +gopkg.in/mgo.v2 v2.0.0-20160818020120-3f83fa500528/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= +gopkg.in/ory-am/dockertest.v3 v3.3.4 h1:oen8RiwxVNxtQ1pRoV4e4jqh6UjNsOuIZ1NXns6jdcw= +gopkg.in/ory-am/dockertest.v3 v3.3.4/go.mod h1:s9mmoLkaGeAh97qygnNj4xWkiN7e1SKekYC6CovU+ek= +gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= +gopkg.in/square/go-jose.v2 v2.3.1 h1:SK5KegNXmKmqE342YYN2qPHEnUYeoMiXXl1poUlI+o4= +gopkg.in/square/go-jose.v2 v2.3.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= +gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +istio.io/gogo-genproto v0.0.0-20190124151557-6d926a6e6feb/go.mod h1:eIDJ6jNk/IeJz6ODSksHl5Aiczy5JUq6vFhJWI5OtiI= +k8s.io/api v0.0.0-20180806132203-61b11ee65332/go.mod h1:iuAfoD4hCxJ8Onx9kaTIt30j7jUFS00AXQi6QMi99vA= +k8s.io/api v0.0.0-20190325185214-7544f9db76f6 h1:9MWtbqhwTyDvF4cS1qAhxDb9Mi8taXiAu+5nEacl7gY= +k8s.io/api v0.0.0-20190325185214-7544f9db76f6/go.mod h1:iuAfoD4hCxJ8Onx9kaTIt30j7jUFS00AXQi6QMi99vA= +k8s.io/apimachinery v0.0.0-20180821005732-488889b0007f/go.mod h1:ccL7Eh7zubPUSh9A3USN90/OzHNSVN6zxzde07TDCL0= +k8s.io/apimachinery v0.0.0-20190223001710-c182ff3b9841 h1:Q4RZrHNtlC/mSdC1sTrcZ5RchC/9vxLVj57pWiCBKv4= +k8s.io/apimachinery v0.0.0-20190223001710-c182ff3b9841/go.mod h1:ccL7Eh7zubPUSh9A3USN90/OzHNSVN6zxzde07TDCL0= +k8s.io/client-go v8.0.0+incompatible h1:tTI4hRmb1DRMl4fG6Vclfdi6nTM82oIrTT7HfitmxC4= +k8s.io/client-go v8.0.0+incompatible/go.mod h1:7vJpHMYJwNQCWgzmNV+VYUl1zCObLyodBc8nIyt8L5s= diff --git a/protocol/RpcStatus.go b/protocol/RpcStatus.go index b9f3e6ecb18583034e310471164773bebe689cd9..78796b6beaf24dac33d7e0210703a9027f9fe568 100644 --- a/protocol/RpcStatus.go +++ b/protocol/RpcStatus.go @@ -1,14 +1,19 @@ -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ // @author yiji@apache.org package protocol diff --git a/protocol/dubbo/listener.go b/protocol/dubbo/listener.go index 14d83ae1dde836161fe0832af2b06144b6f3c883..60432ee0350f7bac345cd1fd8bb1e85e0880bf0e 100644 --- a/protocol/dubbo/listener.go +++ b/protocol/dubbo/listener.go @@ -89,6 +89,7 @@ func (h *RpcClientHandler) OnMessage(session getty.Session, pkg interface{}) { if p.Err != nil { logger.Errorf("rpc heartbeat response{error: %#v}", p.Err) } + h.conn.pool.rpcClient.removePendingResponse(SequenceType(p.Header.ID)) return } logger.Debugf("get rpc response{header: %#v, body: %#v}", p.Header, p.Body) diff --git a/protocol/dubbo/readwriter.go b/protocol/dubbo/readwriter.go index b8822311ef83776c62a13a0ea468a185fb94cabf..8c6c8a5a53af4df9a89eae5db5752eb07f3aa446 100644 --- a/protocol/dubbo/readwriter.go +++ b/protocol/dubbo/readwriter.go @@ -23,10 +23,11 @@ import ( ) import ( - "github.com/apache/dubbo-go-hessian2" + hessian "github.com/apache/dubbo-go-hessian2" "github.com/dubbogo/getty" perrors "github.com/pkg/errors" ) + import ( "github.com/apache/dubbo-go/common" "github.com/apache/dubbo-go/common/constant" diff --git a/protocol/invoker.go b/protocol/invoker.go index fe6aab848caceed50fc3db3e657ce87c45eac2ed..f5d41a09ad2778c12c7e5e68167a4d0acc9e3f4c 100644 --- a/protocol/invoker.go +++ b/protocol/invoker.go @@ -22,6 +22,7 @@ import ( "github.com/apache/dubbo-go/common/logger" ) +//go:generate mockgen -source invoker.go -destination mock/mock_invoker.go -self_package github.com/apache/dubbo-go/protocol/mock --package mock Invoker // Extension - Invoker type Invoker interface { common.Node diff --git a/protocol/jsonrpc/http.go b/protocol/jsonrpc/http.go index 46e2da06b77c070cf15ff6ee6b4781c453022747..b64a3a344e95164b8f49556cdc155bf34642a83b 100644 --- a/protocol/jsonrpc/http.go +++ b/protocol/jsonrpc/http.go @@ -146,7 +146,6 @@ func (c *HTTPClient) Call(ctx context.Context, service common.URL, req *Request, // !!The high level of complexity and the likelihood that the fasthttp client has not been extensively used // in production means that you would need to expect a very large benefit to justify the adoption of fasthttp today. -// from: http://big-elephants.com/2016-12/fasthttp-client/ func (c *HTTPClient) Do(addr, path string, httpHeader http.Header, body []byte) ([]byte, error) { u := url.URL{Host: strings.TrimSuffix(addr, ":"), Path: path} httpReq, err := http.NewRequest("POST", u.String(), bytes.NewBuffer(body)) diff --git a/protocol/mock/mock_invoker.go b/protocol/mock/mock_invoker.go new file mode 100644 index 0000000000000000000000000000000000000000..557dafa277e95c39d0b960436ac10ba8842c9186 --- /dev/null +++ b/protocol/mock/mock_invoker.go @@ -0,0 +1,87 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: invoker.go + +// Package mock is a generated GoMock package. +package mock + +import ( + "reflect" +) + +import ( + "github.com/golang/mock/gomock" +) + +import ( + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/protocol" +) + +// MockInvoker is a mock of Invoker interface +type MockInvoker struct { + ctrl *gomock.Controller + recorder *MockInvokerMockRecorder +} + +// MockInvokerMockRecorder is the mock recorder for MockInvoker +type MockInvokerMockRecorder struct { + mock *MockInvoker +} + +// NewMockInvoker creates a new mock instance +func NewMockInvoker(ctrl *gomock.Controller) *MockInvoker { + mock := &MockInvoker{ctrl: ctrl} + mock.recorder = &MockInvokerMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use +func (m *MockInvoker) EXPECT() *MockInvokerMockRecorder { + return m.recorder +} + +// GetUrl mocks base method +func (m *MockInvoker) GetUrl() common.URL { + ret := m.ctrl.Call(m, "GetUrl") + ret0, _ := ret[0].(common.URL) + return ret0 +} + +// GetUrl indicates an expected call of GetUrl +func (mr *MockInvokerMockRecorder) GetUrl() *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUrl", reflect.TypeOf((*MockInvoker)(nil).GetUrl)) +} + +// IsAvailable mocks base method +func (m *MockInvoker) IsAvailable() bool { + ret := m.ctrl.Call(m, "IsAvailable") + ret0, _ := ret[0].(bool) + return ret0 +} + +// IsAvailable indicates an expected call of IsAvailable +func (mr *MockInvokerMockRecorder) IsAvailable() *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsAvailable", reflect.TypeOf((*MockInvoker)(nil).IsAvailable)) +} + +// Destroy mocks base method +func (m *MockInvoker) Destroy() { + m.ctrl.Call(m, "Destroy") +} + +// Destroy indicates an expected call of Destroy +func (mr *MockInvokerMockRecorder) Destroy() *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Destroy", reflect.TypeOf((*MockInvoker)(nil).Destroy)) +} + +// Invoke mocks base method +func (m *MockInvoker) Invoke(arg0 protocol.Invocation) protocol.Result { + ret := m.ctrl.Call(m, "Invoke", arg0) + ret0, _ := ret[0].(protocol.Result) + return ret0 +} + +// Invoke indicates an expected call of Invoke +func (mr *MockInvokerMockRecorder) Invoke(arg0 interface{}) *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Invoke", reflect.TypeOf((*MockInvoker)(nil).Invoke), arg0) +} diff --git a/protocol/protocolwrapper/protocol_filter_wrapper_test.go b/protocol/protocolwrapper/protocol_filter_wrapper_test.go index 8a332490f71ead601d151fe5e27390eadcc1cbd8..98bd206325ffd38a325b667f7f0bc2684bbf626f 100644 --- a/protocol/protocolwrapper/protocol_filter_wrapper_test.go +++ b/protocol/protocolwrapper/protocol_filter_wrapper_test.go @@ -30,7 +30,9 @@ import ( "github.com/apache/dubbo-go/common" "github.com/apache/dubbo-go/common/constant" "github.com/apache/dubbo-go/common/extension" - "github.com/apache/dubbo-go/filter/impl" + "github.com/apache/dubbo-go/common/logger" + "github.com/apache/dubbo-go/filter" + //"github.com/apache/dubbo-go/filter/impl" "github.com/apache/dubbo-go/protocol" ) @@ -40,7 +42,7 @@ func TestProtocolFilterWrapper_Export(t *testing.T) { u := common.NewURLWithOptions( common.WithParams(url.Values{}), - common.WithParamsValue(constant.SERVICE_FILTER_KEY, impl.ECHO)) + common.WithParamsValue(constant.SERVICE_FILTER_KEY, "echo")) exporter := filtProto.Export(protocol.NewBaseInvoker(*u)) _, ok := exporter.GetInvoker().(*FilterInvoker) assert.True(t, ok) @@ -52,8 +54,35 @@ func TestProtocolFilterWrapper_Refer(t *testing.T) { u := common.NewURLWithOptions( common.WithParams(url.Values{}), - common.WithParamsValue(constant.REFERENCE_FILTER_KEY, impl.ECHO)) + common.WithParamsValue(constant.REFERENCE_FILTER_KEY, "echo")) invoker := filtProto.Refer(*u) _, ok := invoker.(*FilterInvoker) assert.True(t, ok) } + +//the same as echo filter, for test +func init() { + extension.SetFilter("echo", GetFilter) +} + +type EchoFilterForTest struct{} + +func (ef *EchoFilterForTest) Invoke(invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { + logger.Infof("invoking echo filter.") + logger.Debugf("%v,%v", invocation.MethodName(), len(invocation.Arguments())) + if invocation.MethodName() == constant.ECHO && len(invocation.Arguments()) == 1 { + return &protocol.RPCResult{ + Rest: invocation.Arguments()[0], + } + } + + return invoker.Invoke(invocation) +} + +func (ef *EchoFilterForTest) OnResponse(result protocol.Result, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { + return result +} + +func GetFilter() filter.Filter { + return &EchoFilterForTest{} +} diff --git a/registry/consul/listener.go b/registry/consul/listener.go new file mode 100644 index 0000000000000000000000000000000000000000..b047a4c08c9f6c809ed3dca8bd0d06ceaa576cae --- /dev/null +++ b/registry/consul/listener.go @@ -0,0 +1,206 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package consul + +import ( + "sync" +) + +import ( + consul "github.com/hashicorp/consul/api" + "github.com/hashicorp/consul/api/watch" + perrors "github.com/pkg/errors" +) + +import ( + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/logger" + "github.com/apache/dubbo-go/registry" + "github.com/apache/dubbo-go/remoting" +) + +// Consul listener wraps the consul watcher, to +// listen the service information change in consul +// registry. +type consulListener struct { + // Registry url. + registryUrl common.URL + + // Consumer url. + consumerUrl common.URL + + // Consul watcher. + plan *watch.Plan + + // Most recent service urls return by + // watcher. + urls []common.URL + + // All service information changes will + // be wrapped into ServiceEvent, and be + // sent into eventCh. Then listener's + // Next method will get event from eventCh, + // and return to upstream. + eventCh chan *registry.ServiceEvent + + // All errors, happening in the listening + // period, will be caught and send into + // errCh. Then listener's Next method will + // get error from errCh, and return to + // upstream. + errCh chan error + + // Done field represents whether consul + // listener has been closed. When closing + // listener, this field will be closed, + // and will notify consul watcher to close. + done chan struct{} + + // After listener notifies consul watcher + // to close, listener will call wg.wait to + // make sure that consul watcher is closed + // before the listener closes. + wg sync.WaitGroup +} + +func newConsulListener(registryUrl common.URL, consumerUrl common.URL) (*consulListener, error) { + params := make(map[string]interface{}, 8) + params["type"] = "service" + params["service"] = consumerUrl.Service() + params["tag"] = "dubbo" + params["passingonly"] = true + plan, err := watch.Parse(params) + if err != nil { + return nil, err + } + + listener := &consulListener{ + registryUrl: registryUrl, + consumerUrl: consumerUrl, + plan: plan, + urls: make([]common.URL, 0, 8), + eventCh: make(chan *registry.ServiceEvent, 32), + errCh: make(chan error, 32), + done: make(chan struct{}), + } + + // Set handler to consul watcher, and + // make watcher begin to watch service + // information change. + listener.plan.Handler = listener.handler + listener.wg.Add(1) + go listener.run() + return listener, nil +} + +// Wrap the consul watcher run api. There are three +// conditions that will finish the run: +// - close done +// - call plan.Stop +// - close eventCh and errCh +// If run meets first two conditions, it will close +// gracefully. However, if run meets the last condition, +// run will close with panic, so use recover to cover +// this case. +func (l *consulListener) run() { + defer func() { + p := recover() + if p != nil { + logger.Warnf("consul listener finish with panic %v", p) + } + l.wg.Done() + }() + + for { + select { + case <-l.done: + return + default: + err := l.plan.Run(l.registryUrl.Location) + if err != nil { + l.errCh <- err + } + } + } +} + +func (l *consulListener) handler(idx uint64, raw interface{}) { + var ( + service *consul.ServiceEntry + event *registry.ServiceEvent + url common.URL + ok bool + err error + ) + + services, ok := raw.([]*consul.ServiceEntry) + if !ok { + err = perrors.New("handler get non ServiceEntry type parameter") + l.errCh <- err + return + } + newUrls := make([]common.URL, 0, 8) + events := make([]*registry.ServiceEvent, 0, 8) + + for _, service = range services { + url, err = retrieveURL(service) + if err != nil { + l.errCh <- err + return + } + newUrls = append(newUrls, url) + } + + for _, url = range l.urls { + ok = in(url, newUrls) + if !ok { + event := ®istry.ServiceEvent{Action: remoting.EventTypeDel, Service: url} + events = append(events, event) + } + } + + for _, url = range newUrls { + ok = in(url, l.urls) + if !ok { + event := ®istry.ServiceEvent{Action: remoting.EventTypeAdd, Service: url} + events = append(events, event) + } + } + + l.urls = newUrls + for _, event = range events { + l.eventCh <- event + } +} + +func (l *consulListener) Next() (*registry.ServiceEvent, error) { + select { + case event := <-l.eventCh: + return event, nil + case err := <-l.errCh: + return nil, err + } +} + +func (l *consulListener) Close() { + close(l.done) + l.plan.Stop() + close(l.eventCh) + close(l.errCh) + l.wg.Wait() +} diff --git a/registry/consul/listener_test.go b/registry/consul/listener_test.go new file mode 100644 index 0000000000000000000000000000000000000000..7dccbaa9f590e08d9aab539789b8348999672fde --- /dev/null +++ b/registry/consul/listener_test.go @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package consul + +import ( + "github.com/stretchr/testify/assert" +) + +import ( + "github.com/apache/dubbo-go/remoting" +) + +func (suite *consulRegistryTestSuite) testListener(action remoting.EventType) { + event, err := suite.listener.Next() + assert.NoError(suite.t, err) + assert.Equal(suite.t, action, event.Action) + assert.True(suite.t, suite.providerUrl.URLEqual(event.Service)) +} diff --git a/registry/consul/registry.go b/registry/consul/registry.go new file mode 100644 index 0000000000000000000000000000000000000000..e01879ec2dc570354de5b297515f96cb5e83d801 --- /dev/null +++ b/registry/consul/registry.go @@ -0,0 +1,143 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package consul + +import ( + "strconv" +) + +import ( + consul "github.com/hashicorp/consul/api" +) + +import ( + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/registry" +) + +func init() { + extension.SetRegistry("consul", newConsulRegistry) +} + +// Consul registry wraps the consul client, to +// register and subscribe service. +type consulRegistry struct { + // Registry url. + *common.URL + + // Consul client. + client *consul.Client + + // Done field represents whether + // consul registry is closed. + done chan struct{} +} + +func newConsulRegistry(url *common.URL) (registry.Registry, error) { + config := &consul.Config{Address: url.Location} + client, err := consul.NewClient(config) + if err != nil { + return nil, err + } + + r := &consulRegistry{ + URL: url, + client: client, + done: make(chan struct{}), + } + + return r, nil +} + +func (r *consulRegistry) Register(url common.URL) error { + var err error + + role, _ := strconv.Atoi(r.URL.GetParam(constant.ROLE_KEY, "")) + if role == common.PROVIDER { + err = r.register(url) + if err != nil { + return err + } + } + return nil +} + +func (r *consulRegistry) register(url common.URL) error { + service, err := buildService(url) + if err != nil { + return err + } + return r.client.Agent().ServiceRegister(service) +} + +func (r *consulRegistry) Unregister(url common.URL) error { + var err error + + role, _ := strconv.Atoi(r.URL.GetParam(constant.ROLE_KEY, "")) + if role == common.PROVIDER { + err = r.unregister(url) + if err != nil { + return err + } + } + return nil +} + +func (r *consulRegistry) unregister(url common.URL) error { + return r.client.Agent().ServiceDeregister(buildId(url)) +} + +func (r *consulRegistry) Subscribe(url common.URL) (registry.Listener, error) { + var ( + listener registry.Listener + err error + ) + + role, _ := strconv.Atoi(r.URL.GetParam(constant.ROLE_KEY, "")) + if role == common.CONSUMER { + listener, err = r.getListener(url) + if err != nil { + return nil, err + } + } + return listener, nil +} + +func (r *consulRegistry) getListener(url common.URL) (registry.Listener, error) { + listener, err := newConsulListener(*r.URL, url) + return listener, err +} + +func (r *consulRegistry) GetUrl() common.URL { + return *r.URL +} + +func (r *consulRegistry) IsAvailable() bool { + select { + case <-r.done: + return false + default: + return true + } +} + +func (r *consulRegistry) Destroy() { + close(r.done) +} diff --git a/registry/consul/registry_test.go b/registry/consul/registry_test.go new file mode 100644 index 0000000000000000000000000000000000000000..8ec80c83d13946d238fe5db44b7b0c7b7b4335c9 --- /dev/null +++ b/registry/consul/registry_test.go @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package consul + +import ( + "github.com/stretchr/testify/assert" +) + +func (suite *consulRegistryTestSuite) testNewProviderRegistry() { + providerRegistryUrl := newProviderRegistryUrl(registryHost, registryPort) + providerRegistry, err := newConsulRegistry(providerRegistryUrl) + assert.NoError(suite.t, err) + suite.providerRegistry = providerRegistry +} + +func (suite *consulRegistryTestSuite) testNewConsumerRegistry() { + consumerRegistryUrl := newConsumerRegistryUrl(registryHost, registryPort) + consumerRegistry, err := newConsulRegistry(consumerRegistryUrl) + assert.NoError(suite.t, err) + suite.consumerRegistry = consumerRegistry +} + +func (suite *consulRegistryTestSuite) testRegister() { + providerUrl := newProviderUrl(providerHost, providerPort, service, protocol) + suite.providerUrl = providerUrl + err := suite.providerRegistry.Register(providerUrl) + assert.NoError(suite.t, err) +} + +func (suite *consulRegistryTestSuite) testUnregister() { + consulProviderRegistry, _ := suite.providerRegistry.(*consulRegistry) + err := consulProviderRegistry.Unregister(suite.providerUrl) + assert.NoError(suite.t, err) +} + +func (suite *consulRegistryTestSuite) testSubscribe() { + consumerUrl := newConsumerUrl(consumerHost, consumerPort, service, protocol) + suite.consumerUrl = consumerUrl + listener, err := suite.consumerRegistry.Subscribe(consumerUrl) + assert.NoError(suite.t, err) + suite.listener = listener +} diff --git a/registry/consul/utils.go b/registry/consul/utils.go new file mode 100644 index 0000000000000000000000000000000000000000..6ecb0573ec5683d66795f539a8beb2eff5b6be2c --- /dev/null +++ b/registry/consul/utils.go @@ -0,0 +1,114 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package consul + +import ( + "context" + "crypto/md5" + "encoding/hex" + "fmt" + "strconv" +) + +import ( + consul "github.com/hashicorp/consul/api" + perrors "github.com/pkg/errors" +) + +import ( + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/utils" +) + +func buildId(url common.URL) string { + t := md5.Sum([]byte(url.String())) + return hex.EncodeToString(t[:]) +} + +func buildService(url common.URL) (*consul.AgentServiceRegistration, error) { + var err error + + // id + id := buildId(url) + + // address + if url.Ip == "" { + url.Ip, _ = utils.GetLocalIP() + } + + // port + port, err := strconv.Atoi(url.Port) + if err != nil { + return nil, err + } + + // tcp + tcp := fmt.Sprintf("%s:%d", url.Ip, port) + + // tags + tags := make([]string, 0, 8) + for k := range url.Params { + tags = append(tags, k+"="+url.Params.Get(k)) + } + tags = append(tags, "dubbo") + + // meta + meta := make(map[string]string, 8) + meta["url"] = url.String() + + // check + check := &consul.AgentServiceCheck{ + TCP: tcp, + Interval: url.GetParam("consul-check-interval", "10s"), + Timeout: url.GetParam("consul-check-timeout", "1s"), + DeregisterCriticalServiceAfter: url.GetParam("consul-deregister-critical-service-after", "20s"), + } + + service := &consul.AgentServiceRegistration{ + Name: url.Service(), + ID: id, + Address: url.Ip, + Port: port, + Tags: tags, + Meta: meta, + Check: check, + } + + return service, nil +} + +func retrieveURL(service *consul.ServiceEntry) (common.URL, error) { + url, ok := service.Service.Meta["url"] + if !ok { + return common.URL{}, perrors.New("retrieve url fails with no url key in service meta") + } + url1, err := common.NewURL(context.Background(), url) + if err != nil { + return common.URL{}, perrors.WithStack(err) + } + return url1, nil +} + +func in(url common.URL, urls []common.URL) bool { + for _, url1 := range urls { + if url.URLEqual(url1) { + return true + } + } + return false +} diff --git a/registry/consul/utils_test.go b/registry/consul/utils_test.go new file mode 100644 index 0000000000000000000000000000000000000000..36b2b354ed44ce2dc05fe4ddafd983aa4dc7c731 --- /dev/null +++ b/registry/consul/utils_test.go @@ -0,0 +1,226 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package consul + +import ( + "fmt" + "io/ioutil" + "net" + "net/url" + "os" + "strconv" + "sync" + "testing" +) + +import ( + "github.com/hashicorp/consul/agent" +) + +import ( + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/registry" + "github.com/apache/dubbo-go/remoting" +) + +var ( + registryHost = "localhost" + registryPort = 8500 + providerHost = "localhost" + providerPort = 8000 + consumerHost = "localhost" + consumerPort = 8001 + service = "HelloWorld" + protocol = "tcp" +) + +func newProviderRegistryUrl(host string, port int) *common.URL { + url1 := common.NewURLWithOptions( + common.WithIp(host), + common.WithPort(strconv.Itoa(port)), + common.WithParams(url.Values{}), + common.WithParamsValue(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER)), + ) + return url1 +} + +func newConsumerRegistryUrl(host string, port int) *common.URL { + url1 := common.NewURLWithOptions( + common.WithIp(host), + common.WithPort(strconv.Itoa(port)), + common.WithParams(url.Values{}), + common.WithParamsValue(constant.ROLE_KEY, strconv.Itoa(common.CONSUMER)), + ) + return url1 +} + +func newProviderUrl(host string, port int, service string, protocol string) common.URL { + url1 := common.NewURLWithOptions( + common.WithIp(host), + common.WithPort(strconv.Itoa(port)), + common.WithPath(service), + common.WithProtocol(protocol), + ) + return *url1 +} + +func newConsumerUrl(host string, port int, service string, protocol string) common.URL { + url1 := common.NewURLWithOptions( + common.WithIp(host), + common.WithPort(strconv.Itoa(port)), + common.WithPath(service), + common.WithProtocol(protocol), + ) + return *url1 +} + +type testConsulAgent struct { + dataDir string + testAgent *agent.TestAgent +} + +func newConsulAgent(t *testing.T, port int) *testConsulAgent { + dataDir, _ := ioutil.TempDir("./", "agent") + hcl := ` + ports { + http = ` + strconv.Itoa(port) + ` + } + data_dir = "` + dataDir + `" + ` + testAgent := &agent.TestAgent{Name: t.Name(), DataDir: dataDir, HCL: hcl} + testAgent.Start(t) + + consulAgent := &testConsulAgent{ + dataDir: dataDir, + testAgent: testAgent, + } + return consulAgent +} + +func (consulAgent *testConsulAgent) close() { + consulAgent.testAgent.Shutdown() + os.RemoveAll(consulAgent.dataDir) +} + +type testServer struct { + listener net.Listener + wg sync.WaitGroup + done chan struct{} +} + +func newServer(host string, port int) *testServer { + addr := fmt.Sprintf("%s:%d", host, port) + tcpAddr, _ := net.ResolveTCPAddr("tcp", addr) + listener, _ := net.ListenTCP("tcp", tcpAddr) + + server := &testServer{ + listener: listener, + done: make(chan struct{}), + } + + server.wg.Add(1) + go server.serve() + return server +} + +func (server *testServer) serve() { + defer server.wg.Done() + for { + select { + case <-server.done: + return + default: + conn, err := server.listener.Accept() + if err != nil { + continue + } + conn.Write([]byte("Hello World")) + conn.Close() + } + } +} + +func (server *testServer) close() { + close(server.done) + server.listener.Close() + server.wg.Wait() +} + +type consulRegistryTestSuite struct { + t *testing.T + providerRegistry registry.Registry + consumerRegistry registry.Registry + listener registry.Listener + providerUrl common.URL + consumerUrl common.URL +} + +func newConsulRegistryTestSuite(t *testing.T) *consulRegistryTestSuite { + suite := &consulRegistryTestSuite{t: t} + return suite +} + +func (suite *consulRegistryTestSuite) close() { + suite.listener.Close() + suite.providerRegistry.Destroy() + suite.consumerRegistry.Destroy() +} + +// register -> subscribe -> unregister +func test1(t *testing.T) { + consulAgent := newConsulAgent(t, registryPort) + defer consulAgent.close() + + server := newServer(providerHost, providerPort) + defer server.close() + + suite := newConsulRegistryTestSuite(t) + defer suite.close() + + suite.testNewProviderRegistry() + suite.testRegister() + suite.testNewConsumerRegistry() + suite.testSubscribe() + suite.testListener(remoting.EventTypeAdd) + suite.testUnregister() + suite.testListener(remoting.EventTypeDel) +} + +// subscribe -> register +func test2(t *testing.T) { + consulAgent := newConsulAgent(t, registryPort) + defer consulAgent.close() + + server := newServer(providerHost, providerPort) + defer server.close() + + suite := newConsulRegistryTestSuite(t) + defer suite.close() + + suite.testNewConsumerRegistry() + suite.testSubscribe() + suite.testNewProviderRegistry() + suite.testRegister() + suite.testListener(remoting.EventTypeAdd) +} + +func TestConsulRegistry(t *testing.T) { + t.Run("test1", test1) + t.Run("test2", test2) +} diff --git a/registry/directory/directory.go b/registry/directory/directory.go index 11687f82ee5fe0dba6f2bca38b6454ee9c666d91..0ef5023c619d27cc4dc1daf5129be0186b90e903 100644 --- a/registry/directory/directory.go +++ b/registry/directory/directory.go @@ -55,7 +55,6 @@ type registryDirectory struct { serviceType string registry registry.Registry cacheInvokersMap *sync.Map //use sync.map - //cacheInvokersMap map[string]protocol.Invoker Options } @@ -80,7 +79,7 @@ func NewRegistryDirectory(url *common.URL, registry registry.Registry, opts ...O }, nil } -//subscibe from registry +//subscribe from registry func (dir *registryDirectory) Subscribe(url common.URL) { for { if !dir.registry.IsAvailable() { @@ -115,16 +114,13 @@ func (dir *registryDirectory) Subscribe(url common.URL) { } } -//subscribe service from registry , and update the cacheServices +//subscribe service from registry, and update the cacheServices func (dir *registryDirectory) update(res *registry.ServiceEvent) { if res == nil { return } - logger.Debugf("registry update, result{%s}", res) - logger.Debugf("update service name: %s!", res.Service) - dir.refreshInvokers(res) } @@ -150,7 +146,6 @@ func (dir *registryDirectory) refreshInvokers(res *registry.ServiceEvent) { } func (dir *registryDirectory) toGroupInvokers() []protocol.Invoker { - newInvokersList := []protocol.Invoker{} groupInvokersMap := make(map[string][]protocol.Invoker) groupInvokersList := []protocol.Invoker{} diff --git a/registry/etcdv3/listener.go b/registry/etcdv3/listener.go new file mode 100644 index 0000000000000000000000000000000000000000..a8f2facc1aa43db4daea77c03f332df16f302431 --- /dev/null +++ b/registry/etcdv3/listener.go @@ -0,0 +1,88 @@ +package etcdv3 + +import ( + "context" + "strings" +) + +import ( + perrors "github.com/pkg/errors" +) + +import ( + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/logger" + "github.com/apache/dubbo-go/registry" + "github.com/apache/dubbo-go/remoting" +) + +type dataListener struct { + interestedURL []*common.URL + listener remoting.ConfigurationListener +} + +func NewRegistryDataListener(listener remoting.ConfigurationListener) *dataListener { + return &dataListener{listener: listener, interestedURL: []*common.URL{}} +} + +func (l *dataListener) AddInterestedURL(url *common.URL) { + l.interestedURL = append(l.interestedURL, url) +} + +func (l *dataListener) DataChange(eventType remoting.Event) bool { + + url := eventType.Path[strings.Index(eventType.Path, "/providers/")+len("/providers/"):] + serviceURL, err := common.NewURL(context.Background(), url) + if err != nil { + logger.Warnf("Listen NewURL(r{%s}) = error{%v}", eventType.Path, err) + return false + } + + for _, v := range l.interestedURL { + if serviceURL.URLEqual(*v) { + l.listener.Process(&remoting.ConfigChangeEvent{Key: eventType.Path, Value: serviceURL, ConfigType: eventType.Action}) + return true + } + } + + return false +} + +type configurationListener struct { + registry *etcdV3Registry + events chan *remoting.ConfigChangeEvent +} + +func NewConfigurationListener(reg *etcdV3Registry) *configurationListener { + // add a new waiter + reg.wg.Add(1) + return &configurationListener{registry: reg, events: make(chan *remoting.ConfigChangeEvent, 32)} +} +func (l *configurationListener) Process(configType *remoting.ConfigChangeEvent) { + l.events <- configType +} + +func (l *configurationListener) Next() (*registry.ServiceEvent, error) { + for { + select { + case <-l.registry.done: + logger.Warnf("listener's etcd client connection is broken, so etcd event listener exit now.") + return nil, perrors.New("listener stopped") + + case e := <-l.events: + logger.Infof("got etcd event %#v", e) + if e.ConfigType == remoting.EventTypeDel { + select { + case <-l.registry.done: + logger.Warnf("update @result{%s}. But its connection to registry is invalid", e.Value) + default: + } + continue + } + return ®istry.ServiceEvent{Action: e.ConfigType, Service: e.Value.(common.URL)}, nil + } + } +} +func (l *configurationListener) Close() { + l.registry.wg.Done() +} diff --git a/registry/etcdv3/listener_test.go b/registry/etcdv3/listener_test.go new file mode 100644 index 0000000000000000000000000000000000000000..0ac8fc475e454e737e0ea03301709457561e961c --- /dev/null +++ b/registry/etcdv3/listener_test.go @@ -0,0 +1,71 @@ +package etcdv3 + +import ( + "context" + "testing" + "time" +) + +import ( + "github.com/dubbogo/getty" + "github.com/stretchr/testify/suite" + "go.etcd.io/etcd/embed" +) + +import ( + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/remoting" +) + +type RegistryTestSuite struct { + suite.Suite + etcd *embed.Etcd +} + +// start etcd server +func (suite *RegistryTestSuite) SetupSuite() { + + t := suite.T() + + cfg := embed.NewConfig() + cfg.Dir = "/tmp/default.etcd" + e, err := embed.StartEtcd(cfg) + if err != nil { + t.Fatal(err) + } + select { + case <-e.Server.ReadyNotify(): + t.Log("Server is ready!") + case <-getty.GetTimeWheel().After(60 * time.Second): + e.Server.Stop() // trigger a shutdown + t.Logf("Server took too long to start!") + } + + suite.etcd = e + return +} + +// stop etcd server +func (suite *RegistryTestSuite) TearDownSuite() { + suite.etcd.Close() +} + +func (suite *RegistryTestSuite) TestDataChange() { + + t := suite.T() + + listener := NewRegistryDataListener(&MockDataListener{}) + url, _ := common.NewURL(context.Background(), "jsonrpc%3A%2F%2F127.0.0.1%3A20001%2Fcom.ikurento.user.UserProvider%3Fanyhost%3Dtrue%26app.version%3D0.0.1%26application%3DBDTService%26category%3Dproviders%26cluster%3Dfailover%26dubbo%3Ddubbo-provider-golang-2.6.0%26environment%3Ddev%26group%3D%26interface%3Dcom.ikurento.user.UserProvider%26ip%3D10.32.20.124%26loadbalance%3Drandom%26methods.GetUser.loadbalance%3Drandom%26methods.GetUser.retries%3D1%26methods.GetUser.weight%3D0%26module%3Ddubbogo%2Buser-info%2Bserver%26name%3DBDTService%26organization%3Dikurento.com%26owner%3DZX%26pid%3D74500%26retries%3D0%26service.filter%3Decho%26side%3Dprovider%26timestamp%3D1560155407%26version%3D%26warmup%3D100") + listener.AddInterestedURL(&url) + if !listener.DataChange(remoting.Event{Path: "/dubbo/com.ikurento.user.UserProvider/providers/jsonrpc%3A%2F%2F127.0.0.1%3A20001%2Fcom.ikurento.user.UserProvider%3Fanyhost%3Dtrue%26app.version%3D0.0.1%26application%3DBDTService%26category%3Dproviders%26cluster%3Dfailover%26dubbo%3Ddubbo-provider-golang-2.6.0%26environment%3Ddev%26group%3D%26interface%3Dcom.ikurento.user.UserProvider%26ip%3D10.32.20.124%26loadbalance%3Drandom%26methods.GetUser.loadbalance%3Drandom%26methods.GetUser.retries%3D1%26methods.GetUser.weight%3D0%26module%3Ddubbogo%2Buser-info%2Bserver%26name%3DBDTService%26organization%3Dikurento.com%26owner%3DZX%26pid%3D74500%26retries%3D0%26service.filter%3Decho%26side%3Dprovider%26timestamp%3D1560155407%26version%3D%26warmup%3D100"}) { + t.Fatal("data change not ok") + } +} + +func TestRegistrySuite(t *testing.T) { + suite.Run(t, &RegistryTestSuite{}) +} + +type MockDataListener struct{} + +func (*MockDataListener) Process(configType *remoting.ConfigChangeEvent) {} diff --git a/registry/etcdv3/registry.go b/registry/etcdv3/registry.go new file mode 100644 index 0000000000000000000000000000000000000000..5802142989e5d8297f027ddecff3d7780070729f --- /dev/null +++ b/registry/etcdv3/registry.go @@ -0,0 +1,325 @@ +package etcdv3 + +import ( + "fmt" + "net/url" + "os" + "path" + "strconv" + "strings" + "sync" + "time" +) + +import ( + perrors "github.com/pkg/errors" +) + +import ( + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/common/logger" + "github.com/apache/dubbo-go/common/utils" + "github.com/apache/dubbo-go/registry" + "github.com/apache/dubbo-go/remoting/etcdv3" +) + +var ( + processID = "" + localIP = "" +) + +const Name = "etcdv3" + +func init() { + processID = fmt.Sprintf("%d", os.Getpid()) + localIP, _ = utils.GetLocalIP() + extension.SetRegistry(Name, newETCDV3Registry) +} + +type etcdV3Registry struct { + *common.URL + birth int64 // time of file birth, seconds since Epoch; 0 if unknown + + cltLock sync.Mutex + client *etcdv3.Client + services map[string]common.URL // service name + protocol -> service config + + listenerLock sync.Mutex + listener *etcdv3.EventListener + dataListener *dataListener + configListener *configurationListener + + wg sync.WaitGroup // wg+done for etcd client restart + done chan struct{} +} + +func (r *etcdV3Registry) Client() *etcdv3.Client { + return r.client +} +func (r *etcdV3Registry) SetClient(client *etcdv3.Client) { + r.client = client +} +func (r *etcdV3Registry) ClientLock() *sync.Mutex { + return &r.cltLock +} +func (r *etcdV3Registry) WaitGroup() *sync.WaitGroup { + return &r.wg +} +func (r *etcdV3Registry) GetDone() chan struct{} { + return r.done +} +func (r *etcdV3Registry) RestartCallBack() bool { + + services := []common.URL{} + for _, confIf := range r.services { + services = append(services, confIf) + } + + flag := true + for _, confIf := range services { + err := r.Register(confIf) + if err != nil { + logger.Errorf("(etcdV3ProviderRegistry)register(conf{%#v}) = error{%#v}", + confIf, perrors.WithStack(err)) + flag = false + break + } + logger.Infof("success to re-register service :%v", confIf.Key()) + } + return flag +} + +func newETCDV3Registry(url *common.URL) (registry.Registry, error) { + + timeout, err := time.ParseDuration(url.GetParam(constant.REGISTRY_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT)) + if err != nil { + logger.Errorf("timeout config %v is invalid ,err is %v", + url.GetParam(constant.REGISTRY_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT), err.Error()) + return nil, perrors.WithMessagef(err, "new etcd registry(address:%+v)", url.Location) + } + + logger.Infof("etcd address is: %v, timeout is: %s", url.Location, timeout.String()) + + r := &etcdV3Registry{ + URL: url, + birth: time.Now().UnixNano(), + done: make(chan struct{}), + services: make(map[string]common.URL), + } + + if err := etcdv3.ValidateClient( + r, + etcdv3.WithName(etcdv3.RegistryETCDV3Client), + etcdv3.WithTimeout(timeout), + etcdv3.WithEndpoints(url.Location), + ); err != nil { + return nil, err + } + + r.wg.Add(1) + go etcdv3.HandleClientRestart(r) + + r.listener = etcdv3.NewEventListener(r.client) + r.configListener = NewConfigurationListener(r) + r.dataListener = NewRegistryDataListener(r.configListener) + + return r, nil +} + +func (r *etcdV3Registry) GetUrl() common.URL { + return *r.URL +} + +func (r *etcdV3Registry) IsAvailable() bool { + + select { + case <-r.done: + return false + default: + return true + } +} + +func (r *etcdV3Registry) Destroy() { + + if r.configListener != nil { + r.configListener.Close() + } + r.stop() +} + +func (r *etcdV3Registry) stop() { + + close(r.done) + + // close current client + r.client.Close() + + r.cltLock.Lock() + r.client = nil + r.services = nil + r.cltLock.Unlock() +} + +func (r *etcdV3Registry) Register(svc common.URL) error { + + role, err := strconv.Atoi(r.URL.GetParam(constant.ROLE_KEY, "")) + if err != nil { + return perrors.WithMessage(err, "get registry role") + } + + r.cltLock.Lock() + if _, ok := r.services[svc.Key()]; ok { + r.cltLock.Unlock() + return perrors.New(fmt.Sprintf("Path{%s} has been registered", svc.Path)) + } + r.cltLock.Unlock() + + switch role { + case common.PROVIDER: + logger.Debugf("(provider register )Register(conf{%#v})", svc) + if err := r.registerProvider(svc); err != nil { + return perrors.WithMessage(err, "register provider") + } + case common.CONSUMER: + logger.Debugf("(consumer register )Register(conf{%#v})", svc) + if err := r.registerConsumer(svc); err != nil { + return perrors.WithMessage(err, "register consumer") + } + default: + return perrors.New(fmt.Sprintf("unknown role %d", role)) + } + + r.cltLock.Lock() + r.services[svc.Key()] = svc + r.cltLock.Unlock() + return nil +} + +func (r *etcdV3Registry) createDirIfNotExist(k string) error { + + var tmpPath string + for _, str := range strings.Split(k, "/")[1:] { + tmpPath = path.Join(tmpPath, "/", str) + if err := r.client.Create(tmpPath, ""); err != nil { + return perrors.WithMessagef(err, "create path %s in etcd", tmpPath) + } + } + + return nil +} + +func (r *etcdV3Registry) registerConsumer(svc common.URL) error { + + consumersNode := fmt.Sprintf("/dubbo/%s/%s", svc.Service(), common.DubboNodes[common.CONSUMER]) + if err := r.createDirIfNotExist(consumersNode); err != nil { + logger.Errorf("etcd client create path %s: %v", consumersNode, err) + return perrors.WithMessage(err, "etcd create consumer nodes") + } + providersNode := fmt.Sprintf("/dubbo/%s/%s", svc.Service(), common.DubboNodes[common.PROVIDER]) + if err := r.createDirIfNotExist(providersNode); err != nil { + return perrors.WithMessage(err, "create provider node") + } + + params := url.Values{} + + params.Add("protocol", svc.Protocol) + + params.Add("category", (common.RoleType(common.CONSUMER)).String()) + params.Add("dubbo", "dubbogo-consumer-"+constant.Version) + + encodedURL := url.QueryEscape(fmt.Sprintf("consumer://%s%s?%s", localIP, svc.Path, params.Encode())) + dubboPath := fmt.Sprintf("/dubbo/%s/%s", svc.Service(), (common.RoleType(common.CONSUMER)).String()) + if err := r.client.Create(path.Join(dubboPath, encodedURL), ""); err != nil { + return perrors.WithMessagef(err, "create k/v in etcd (path:%s, url:%s)", dubboPath, encodedURL) + } + + return nil +} + +func (r *etcdV3Registry) registerProvider(svc common.URL) error { + + if len(svc.Path) == 0 || len(svc.Methods) == 0 { + return perrors.New(fmt.Sprintf("service path %s or service method %s", svc.Path, svc.Methods)) + } + + var ( + urlPath string + encodedURL string + dubboPath string + ) + + providersNode := fmt.Sprintf("/dubbo/%s/%s", svc.Service(), common.DubboNodes[common.PROVIDER]) + if err := r.createDirIfNotExist(providersNode); err != nil { + return perrors.WithMessage(err, "create provider node") + } + + params := url.Values{} + for k, v := range svc.Params { + params[k] = v + } + + params.Add("pid", processID) + params.Add("ip", localIP) + params.Add("anyhost", "true") + params.Add("category", (common.RoleType(common.PROVIDER)).String()) + params.Add("dubbo", "dubbo-provider-golang-"+constant.Version) + params.Add("side", (common.RoleType(common.PROVIDER)).Role()) + + if len(svc.Methods) == 0 { + params.Add("methods", strings.Join(svc.Methods, ",")) + } + + logger.Debugf("provider url params:%#v", params) + var host string + if len(svc.Ip) == 0 { + host = localIP + ":" + svc.Port + } else { + host = svc.Ip + ":" + svc.Port + } + + urlPath = svc.Path + + encodedURL = url.QueryEscape(fmt.Sprintf("%s://%s%s?%s", svc.Protocol, host, urlPath, params.Encode())) + dubboPath = fmt.Sprintf("/dubbo/%s/%s", svc.Service(), (common.RoleType(common.PROVIDER)).String()) + + if err := r.client.Create(path.Join(dubboPath, encodedURL), ""); err != nil { + return perrors.WithMessagef(err, "create k/v in etcd (path:%s, url:%s)", dubboPath, encodedURL) + } + + return nil +} + +func (r *etcdV3Registry) Subscribe(svc common.URL) (registry.Listener, error) { + + var ( + configListener *configurationListener + ) + + r.listenerLock.Lock() + configListener = r.configListener + r.listenerLock.Unlock() + if r.listener == nil { + r.cltLock.Lock() + client := r.client + r.cltLock.Unlock() + if client == nil { + return nil, perrors.New("etcd client broken") + } + + // new client & listener + listener := etcdv3.NewEventListener(r.client) + + r.listenerLock.Lock() + r.listener = listener + r.listenerLock.Unlock() + } + + //register the svc to dataListener + r.dataListener.AddInterestedURL(&svc) + go r.listener.ListenServiceEvent(fmt.Sprintf("/dubbo/%s/providers", svc.Service()), r.dataListener) + + return configListener, nil +} diff --git a/registry/etcdv3/registry_test.go b/registry/etcdv3/registry_test.go new file mode 100644 index 0000000000000000000000000000000000000000..26204c74ad4305278e33d9c8b50199cfa578bf8a --- /dev/null +++ b/registry/etcdv3/registry_test.go @@ -0,0 +1,112 @@ +package etcdv3 + +import ( + "context" + "strconv" + "testing" + "time" +) + +import ( + "github.com/stretchr/testify/assert" +) + +import ( + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" +) + +func initRegistry(t *testing.T) *etcdV3Registry { + + regurl, err := common.NewURL(context.Background(), "registry://127.0.0.1:2379", common.WithParamsValue(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER))) + if err != nil { + t.Fatal(err) + } + + reg, err := newETCDV3Registry(®url) + if err != nil { + t.Fatal(err) + } + + out := reg.(*etcdV3Registry) + out.client.CleanKV() + return out +} + +func (suite *RegistryTestSuite) TestRegister() { + + t := suite.T() + + url, _ := common.NewURL(context.Background(), "dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider", common.WithParamsValue(constant.CLUSTER_KEY, "mock"), common.WithMethods([]string{"GetUser", "AddUser"})) + + reg := initRegistry(t) + err := reg.Register(url) + children, _, err := reg.client.GetChildrenKVList("/dubbo/com.ikurento.user.UserProvider/providers") + if err != nil { + t.Fatal(err) + } + assert.Regexp(t, ".*dubbo%3A%2F%2F127.0.0.1%3A20000%2Fcom.ikurento.user.UserProvider%3Fanyhost%3Dtrue%26category%3Dproviders%26cluster%3Dmock%26dubbo%3Ddubbo-provider-golang-2.6.0%26.*provider", children) + assert.NoError(t, err) +} + +func (suite *RegistryTestSuite) TestSubscribe() { + + t := suite.T() + regurl, _ := common.NewURL(context.Background(), "registry://127.0.0.1:1111", common.WithParamsValue(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER))) + url, _ := common.NewURL(context.Background(), "dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider", common.WithParamsValue(constant.CLUSTER_KEY, "mock"), common.WithMethods([]string{"GetUser", "AddUser"})) + + reg := initRegistry(t) + //provider register + err := reg.Register(url) + if err != nil { + t.Fatal(err) + } + + //consumer register + regurl.Params.Set(constant.ROLE_KEY, strconv.Itoa(common.CONSUMER)) + reg2 := initRegistry(t) + + reg2.Register(url) + listener, err := reg2.Subscribe(url) + if err != nil { + t.Fatal(err) + } + + serviceEvent, err := listener.Next() + if err != nil { + t.Fatal(err) + } + assert.Regexp(t, ".*ServiceEvent{Action{add}.*", serviceEvent.String()) +} + +func (suite *RegistryTestSuite) TestConsumerDestory() { + + t := suite.T() + url, _ := common.NewURL(context.Background(), "dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider", common.WithParamsValue(constant.CLUSTER_KEY, "mock"), common.WithMethods([]string{"GetUser", "AddUser"})) + + reg := initRegistry(t) + _, err := reg.Subscribe(url) + if err != nil { + t.Fatal(err) + } + + //listener.Close() + time.Sleep(1e9) + reg.Destroy() + + assert.Equal(t, false, reg.IsAvailable()) + +} + +func (suite *RegistryTestSuite) TestProviderDestory() { + + t := suite.T() + reg := initRegistry(t) + url, _ := common.NewURL(context.Background(), "dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider", common.WithParamsValue(constant.CLUSTER_KEY, "mock"), common.WithMethods([]string{"GetUser", "AddUser"})) + reg.Register(url) + + //listener.Close() + time.Sleep(1e9) + reg.Destroy() + assert.Equal(t, false, reg.IsAvailable()) +} diff --git a/registry/nacos/listener.go b/registry/nacos/listener.go new file mode 100644 index 0000000000000000000000000000000000000000..0cb48e076452941ae0162a737b5ba1fb85f84def --- /dev/null +++ b/registry/nacos/listener.go @@ -0,0 +1,199 @@ +package nacos + +import ( + "bytes" + "net/url" + "reflect" + "strconv" + "sync" +) + +import ( + "github.com/nacos-group/nacos-sdk-go/clients/naming_client" + "github.com/nacos-group/nacos-sdk-go/model" + "github.com/nacos-group/nacos-sdk-go/vo" + perrors "github.com/pkg/errors" +) + +import ( + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/common/logger" + "github.com/apache/dubbo-go/registry" + "github.com/apache/dubbo-go/remoting" +) + +type nacosListener struct { + namingClient naming_client.INamingClient + listenUrl common.URL + events chan *remoting.ConfigChangeEvent + instanceMap map[string]model.Instance + cacheLock sync.Mutex + done chan struct{} + subscribeParam *vo.SubscribeParam +} + +func NewNacosListener(url common.URL, namingClient naming_client.INamingClient) (*nacosListener, error) { + listener := &nacosListener{ + namingClient: namingClient, + listenUrl: url, events: make(chan *remoting.ConfigChangeEvent, 32), + instanceMap: map[string]model.Instance{}, + done: make(chan struct{}), + } + err := listener.startListen() + return listener, err +} + +func generateInstance(ss model.SubscribeService) model.Instance { + return model.Instance{ + InstanceId: ss.InstanceId, + Ip: ss.Ip, + Port: ss.Port, + ServiceName: ss.ServiceName, + Valid: ss.Valid, + Enable: ss.Enable, + Weight: ss.Weight, + Metadata: ss.Metadata, + ClusterName: ss.ClusterName, + } +} + +func generateUrl(instance model.Instance) *common.URL { + if instance.Metadata == nil { + logger.Errorf("nacos instance metadata is empty,instance:%+v", instance) + return nil + } + path := instance.Metadata["path"] + myInterface := instance.Metadata["interface"] + if len(path) == 0 && len(myInterface) == 0 { + logger.Errorf("nacos instance metadata does not have both path key and interface key,instance:%+v", instance) + return nil + } + if len(path) == 0 && len(myInterface) != 0 { + path = "/" + myInterface + } + protocol := instance.Metadata["protocol"] + if len(protocol) == 0 { + logger.Errorf("nacos instance metadata does not have protocol key,instance:%+v", instance) + return nil + } + urlMap := url.Values{} + for k, v := range instance.Metadata { + urlMap.Set(k, v) + } + return common.NewURLWithOptions( + common.WithIp(instance.Ip), + common.WithPort(strconv.Itoa(int(instance.Port))), + common.WithProtocol(protocol), + common.WithParams(urlMap), + common.WithPath(path), + ) +} + +func (nl *nacosListener) Callback(services []model.SubscribeService, err error) { + if err != nil { + logger.Errorf("nacos subscribe callback error:%s , subscribe:%+v ", err.Error(), nl.subscribeParam) + return + } + nl.cacheLock.Lock() + defer nl.cacheLock.Unlock() + addInstances := make([]model.Instance, 0, len(services)) + delInstances := make([]model.Instance, 0, len(services)) + updateInstances := make([]model.Instance, 0, len(services)) + + newInstanceMap := make(map[string]model.Instance, len(services)) + + for i := range services { + if !services[i].Enable || !services[i].Valid { + // instance is not available,so ignore it + continue + } + host := services[i].Ip + ":" + strconv.Itoa(int(services[i].Port)) + instance := generateInstance(services[i]) + newInstanceMap[host] = instance + if old, ok := nl.instanceMap[host]; !ok { + //instance is not exsit in cache,add it to cache + addInstances = append(addInstances, instance) + } else { + //instance is not different from cache,update it to cache + if !reflect.DeepEqual(old, instance) { + updateInstances = append(updateInstances, instance) + } + } + } + + for host, inst := range nl.instanceMap { + if _, ok := newInstanceMap[host]; !ok { + //cache instance is not exsit in new instance list, remove it from cache + delInstances = append(delInstances, inst) + } + } + + nl.instanceMap = newInstanceMap + + for i := range addInstances { + newUrl := generateUrl(addInstances[i]) + if newUrl != nil { + nl.process(&remoting.ConfigChangeEvent{Value: *newUrl, ConfigType: remoting.EventTypeAdd}) + } + } + for i := range delInstances { + newUrl := generateUrl(delInstances[i]) + if newUrl != nil { + nl.process(&remoting.ConfigChangeEvent{Value: *newUrl, ConfigType: remoting.EventTypeDel}) + } + } + + for i := range updateInstances { + newUrl := generateUrl(updateInstances[i]) + if newUrl != nil { + nl.process(&remoting.ConfigChangeEvent{Value: *newUrl, ConfigType: remoting.EventTypeUpdate}) + } + } +} + +func getSubscribeName(url common.URL) string { + var buffer bytes.Buffer + + buffer.Write([]byte(common.DubboNodes[common.PROVIDER])) + appendParam(&buffer, url, constant.INTERFACE_KEY) + appendParam(&buffer, url, constant.VERSION_KEY) + appendParam(&buffer, url, constant.GROUP_KEY) + return buffer.String() +} + +func (nl *nacosListener) startListen() error { + if nl.namingClient == nil { + return perrors.New("nacos naming client stopped") + } + serviceName := getSubscribeName(nl.listenUrl) + nl.subscribeParam = &vo.SubscribeParam{ServiceName: serviceName, SubscribeCallback: nl.Callback} + return nl.namingClient.Subscribe(nl.subscribeParam) +} + +func (nl *nacosListener) stopListen() error { + return nl.namingClient.Unsubscribe(nl.subscribeParam) +} + +func (nl *nacosListener) process(configType *remoting.ConfigChangeEvent) { + nl.events <- configType +} + +func (nl *nacosListener) Next() (*registry.ServiceEvent, error) { + for { + select { + case <-nl.done: + logger.Warnf("nacos listener is close!listenUrl:%+v", nl.listenUrl) + return nil, perrors.New("listener stopped") + + case e := <-nl.events: + logger.Debugf("got nacos event %s", e) + return ®istry.ServiceEvent{Action: e.ConfigType, Service: e.Value.(common.URL)}, nil + } + } +} + +func (nl *nacosListener) Close() { + nl.stopListen() + close(nl.done) +} diff --git a/registry/nacos/registry.go b/registry/nacos/registry.go new file mode 100644 index 0000000000000000000000000000000000000000..bf86ead7a31f5873078b9dc4acd3f0dcf6aec783 --- /dev/null +++ b/registry/nacos/registry.go @@ -0,0 +1,176 @@ +package nacos + +import ( + "bytes" + "net" + "strconv" + "strings" + "time" +) +import ( + "github.com/nacos-group/nacos-sdk-go/clients" + "github.com/nacos-group/nacos-sdk-go/clients/naming_client" + nacosConstant "github.com/nacos-group/nacos-sdk-go/common/constant" + "github.com/nacos-group/nacos-sdk-go/vo" + perrors "github.com/pkg/errors" +) + +import ( + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/common/utils" + "github.com/apache/dubbo-go/registry" +) + +var ( + localIP = "" +) + +func init() { + localIP, _ = utils.GetLocalIP() + extension.SetRegistry(constant.NACOS_KEY, newNacosRegistry) +} + +type nacosRegistry struct { + *common.URL + namingClient naming_client.INamingClient +} + +func getNacosConfig(url *common.URL) (map[string]interface{}, error) { + if url == nil { + return nil, perrors.New("url is empty!") + } + if len(url.Location) == 0 { + return nil, perrors.New("url.location is empty!") + } + configMap := make(map[string]interface{}, 2) + + addresses := strings.Split(url.Location, ",") + serverConfigs := make([]nacosConstant.ServerConfig, 0, len(addresses)) + for _, addr := range addresses { + ip, portStr, err := net.SplitHostPort(addr) + if err != nil { + return nil, perrors.WithMessagef(err, "split [%s] ", addr) + } + port, _ := strconv.Atoi(portStr) + serverConfigs = append(serverConfigs, nacosConstant.ServerConfig{ + IpAddr: ip, + Port: uint64(port), + }) + } + configMap["serverConfigs"] = serverConfigs + + var clientConfig nacosConstant.ClientConfig + timeout, err := time.ParseDuration(url.GetParam(constant.REGISTRY_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT)) + if err != nil { + return nil, err + } + clientConfig.TimeoutMs = uint64(timeout.Seconds() * 1000) + clientConfig.ListenInterval = 2 * clientConfig.TimeoutMs + clientConfig.CacheDir = url.GetParam(constant.NACOS_CACHE_DIR_KEY, "") + clientConfig.LogDir = url.GetParam(constant.NACOS_LOG_DIR_KEY, "") + clientConfig.Endpoint = url.GetParam(constant.NACOS_ENDPOINT, "") + clientConfig.NotLoadCacheAtStart = true + configMap["clientConfig"] = clientConfig + + return configMap, nil +} + +func newNacosRegistry(url *common.URL) (registry.Registry, error) { + nacosConfig, err := getNacosConfig(url) + if err != nil { + return nil, err + } + client, err := clients.CreateNamingClient(nacosConfig) + if err != nil { + return nil, err + } + registry := nacosRegistry{ + URL: url, + namingClient: client, + } + return ®istry, nil +} + +func getCategory(url common.URL) string { + role, _ := strconv.Atoi(url.GetParam(constant.ROLE_KEY, strconv.Itoa(constant.NACOS_DEFAULT_ROLETYPE))) + category := common.DubboNodes[role] + return category +} + +func getServiceName(url common.URL) string { + var buffer bytes.Buffer + + buffer.Write([]byte(getCategory(url))) + appendParam(&buffer, url, constant.INTERFACE_KEY) + appendParam(&buffer, url, constant.VERSION_KEY) + appendParam(&buffer, url, constant.GROUP_KEY) + return buffer.String() +} + +func appendParam(target *bytes.Buffer, url common.URL, key string) { + value := url.GetParam(key, "") + if strings.TrimSpace(value) != "" { + target.Write([]byte(constant.NACOS_SERVICE_NAME_SEPARATOR)) + target.Write([]byte(value)) + } +} + +func createRegisterParam(url common.URL, serviceName string) vo.RegisterInstanceParam { + category := getCategory(url) + params := make(map[string]string, len(url.Params)+3) + for k := range url.Params { + params[k] = url.Params.Get(k) + } + params[constant.NACOS_CATEGORY_KEY] = category + params[constant.NACOS_PROTOCOL_KEY] = url.Protocol + params[constant.NACOS_PATH_KEY] = url.Path + if len(url.Ip) == 0 { + url.Ip = localIP + } + if len(url.Port) == 0 || url.Port == "0" { + url.Port = "80" + } + port, _ := strconv.Atoi(url.Port) + instance := vo.RegisterInstanceParam{ + Ip: url.Ip, + Port: uint64(port), + Metadata: params, + Weight: 1, + Enable: true, + Healthy: true, + Ephemeral: true, + ServiceName: serviceName, + } + return instance +} + +func (nr *nacosRegistry) Register(url common.URL) error { + serviceName := getServiceName(url) + param := createRegisterParam(url, serviceName) + isRegistry, err := nr.namingClient.RegisterInstance(param) + if err != nil { + return err + } + if !isRegistry { + return perrors.New("registry [" + serviceName + "] to nacos failed") + } + return nil +} + +func (nr *nacosRegistry) Subscribe(conf common.URL) (registry.Listener, error) { + return NewNacosListener(conf, nr.namingClient) +} + +func (nr *nacosRegistry) GetUrl() common.URL { + return *nr.URL +} + +func (nr *nacosRegistry) IsAvailable() bool { + return true +} + +func (nr *nacosRegistry) Destroy() { + return +} diff --git a/registry/nacos/registry_test.go b/registry/nacos/registry_test.go new file mode 100644 index 0000000000000000000000000000000000000000..9ce9dcfe4d9f7d3974a3d07e093f59888e73a91d --- /dev/null +++ b/registry/nacos/registry_test.go @@ -0,0 +1,174 @@ +package nacos + +import ( + "context" + "encoding/json" + "net/url" + "strconv" + "testing" +) + +import ( + "github.com/nacos-group/nacos-sdk-go/vo" + "github.com/stretchr/testify/assert" +) + +import ( + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" +) + +func TestNacosRegistry_Register(t *testing.T) { + regurl, _ := common.NewURL(context.TODO(), "registry://console.nacos.io:80", common.WithParamsValue(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER))) + urlMap := url.Values{} + urlMap.Set(constant.GROUP_KEY, "guangzhou-idc") + urlMap.Set(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER)) + urlMap.Set(constant.INTERFACE_KEY, "com.ikurento.user.UserProvider") + urlMap.Set(constant.VERSION_KEY, "1.0.0") + urlMap.Set(constant.CLUSTER_KEY, "mock") + url, _ := common.NewURL(context.TODO(), "dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider", common.WithParams(urlMap), common.WithMethods([]string{"GetUser", "AddUser"})) + + reg, err := newNacosRegistry(®url) + assert.Nil(t, err) + if err != nil { + t.Errorf("new nacos registry error:%s \n", err.Error()) + return + } + err = reg.Register(url) + assert.Nil(t, err) + if err != nil { + t.Errorf("register error:%s \n", err.Error()) + return + } + nacosReg := reg.(*nacosRegistry) + service, _ := nacosReg.namingClient.GetService(vo.GetServiceParam{ServiceName: "providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc"}) + data, _ := json.Marshal(service) + t.Logf(string(data)) + assert.Equal(t, 1, len(service.Hosts)) +} + +func TestNacosRegistry_Subscribe(t *testing.T) { + regurl, _ := common.NewURL(context.TODO(), "registry://console.nacos.io:80", common.WithParamsValue(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER))) + urlMap := url.Values{} + urlMap.Set(constant.GROUP_KEY, "guangzhou-idc") + urlMap.Set(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER)) + urlMap.Set(constant.INTERFACE_KEY, "com.ikurento.user.UserProvider") + urlMap.Set(constant.VERSION_KEY, "1.0.0") + urlMap.Set(constant.CLUSTER_KEY, "mock") + urlMap.Set(constant.NACOS_PATH_KEY, "") + url, _ := common.NewURL(context.TODO(), "dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider", common.WithParams(urlMap), common.WithMethods([]string{"GetUser", "AddUser"})) + + reg, _ := newNacosRegistry(®url) + err := reg.Register(url) + assert.Nil(t, err) + if err != nil { + t.Errorf("new nacos registry error:%s \n", err.Error()) + return + } + + regurl.Params.Set(constant.ROLE_KEY, strconv.Itoa(common.CONSUMER)) + reg2, _ := newNacosRegistry(®url) + listener, err := reg2.Subscribe(url) + assert.Nil(t, err) + if err != nil { + t.Errorf("subscribe error:%s \n", err.Error()) + return + } + serviceEvent, _ := listener.Next() + assert.NoError(t, err) + if err != nil { + t.Errorf("listener error:%s \n", err.Error()) + return + } + t.Logf("serviceEvent:%+v \n", serviceEvent) + assert.Regexp(t, ".*ServiceEvent{Action{add}.*", serviceEvent.String()) + +} + +func TestNacosRegistry_Subscribe_del(t *testing.T) { + regurl, _ := common.NewURL(context.TODO(), "registry://console.nacos.io:80", common.WithParamsValue(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER))) + urlMap := url.Values{} + urlMap.Set(constant.GROUP_KEY, "guangzhou-idc") + urlMap.Set(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER)) + urlMap.Set(constant.INTERFACE_KEY, "com.ikurento.user.UserProvider") + urlMap.Set(constant.VERSION_KEY, "2.0.0") + urlMap.Set(constant.CLUSTER_KEY, "mock") + urlMap.Set(constant.NACOS_PATH_KEY, "") + url1, _ := common.NewURL(context.TODO(), "dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider", common.WithParams(urlMap), common.WithMethods([]string{"GetUser", "AddUser"})) + url2, _ := common.NewURL(context.TODO(), "dubbo://127.0.0.2:20000/com.ikurento.user.UserProvider", common.WithParams(urlMap), common.WithMethods([]string{"GetUser", "AddUser"})) + + reg, _ := newNacosRegistry(®url) + err := reg.Register(url1) + assert.Nil(t, err) + if err != nil { + t.Errorf("register1 error:%s \n", err.Error()) + return + } + err = reg.Register(url2) + assert.Nil(t, err) + if err != nil { + t.Errorf("register2 error:%s \n", err.Error()) + return + } + + regurl.Params.Set(constant.ROLE_KEY, strconv.Itoa(common.CONSUMER)) + reg2, _ := newNacosRegistry(®url) + listener, err := reg2.Subscribe(url1) + assert.Nil(t, err) + if err != nil { + t.Errorf("subscribe error:%s \n", err.Error()) + return + } + + serviceEvent1, _ := listener.Next() + assert.NoError(t, err) + if err != nil { + t.Errorf("listener1 error:%s \n", err.Error()) + return + } + t.Logf("serviceEvent1:%+v \n", serviceEvent1) + assert.Regexp(t, ".*ServiceEvent{Action{add}.*", serviceEvent1.String()) + + serviceEvent2, _ := listener.Next() + assert.NoError(t, err) + if err != nil { + t.Errorf("listener2 error:%s \n", err.Error()) + return + } + t.Logf("serviceEvent2:%+v \n", serviceEvent2) + assert.Regexp(t, ".*ServiceEvent{Action{add}.*", serviceEvent2.String()) + + nacosReg := reg.(*nacosRegistry) + //deregister instance to mock instance offline + nacosReg.namingClient.DeregisterInstance(vo.DeregisterInstanceParam{Ip: "127.0.0.2", Port: 20000, ServiceName: "providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc"}) + + serviceEvent3, _ := listener.Next() + assert.NoError(t, err) + if err != nil { + return + } + t.Logf("serviceEvent3:%+v \n", serviceEvent3) + assert.Regexp(t, ".*ServiceEvent{Action{delete}.*", serviceEvent3.String()) +} + +func TestNacosListener_Close(t *testing.T) { + regurl, _ := common.NewURL(context.TODO(), "registry://console.nacos.io:80", common.WithParamsValue(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER))) + urlMap := url.Values{} + urlMap.Set(constant.GROUP_KEY, "guangzhou-idc") + urlMap.Set(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER)) + urlMap.Set(constant.INTERFACE_KEY, "com.ikurento.user.UserProvider2") + urlMap.Set(constant.VERSION_KEY, "1.0.0") + urlMap.Set(constant.CLUSTER_KEY, "mock") + urlMap.Set(constant.NACOS_PATH_KEY, "") + url1, _ := common.NewURL(context.TODO(), "dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider2", common.WithParams(urlMap), common.WithMethods([]string{"GetUser", "AddUser"})) + reg, _ := newNacosRegistry(®url) + listener, err := reg.Subscribe(url1) + assert.Nil(t, err) + if err != nil { + t.Errorf("subscribe error:%s \n", err.Error()) + return + } + listener.Close() + _, err = listener.Next() + assert.NotNil(t, err) +} diff --git a/registry/zookeeper/listener.go b/registry/zookeeper/listener.go index 67f20370602a0a9c5c3d87ef93b1bafed3449d36..7d58cee1220b9aedba353d929ca1e936cf9366f2 100644 --- a/registry/zookeeper/listener.go +++ b/registry/zookeeper/listener.go @@ -45,11 +45,16 @@ func (l *RegistryDataListener) AddInterestedURL(url *common.URL) { } func (l *RegistryDataListener) DataChange(eventType remoting.Event) bool { - //鎴彇鏈€鍚庝竴浣� - url := eventType.Path[strings.Index(eventType.Path, "/providers/")+len("/providers/"):] + // Intercept the last bit + index := strings.Index(eventType.Path, "/providers/") + if index == -1 { + logger.Warn("Listen with no url, event.path={%v}", eventType.Path) + return false + } + url := eventType.Path[index+len("/providers/"):] serviceURL, err := common.NewURL(context.TODO(), url) if err != nil { - logger.Errorf("Listen NewURL(r{%s}) = error{%v}", url, err) + logger.Errorf("Listen NewURL(r{%s}) = error{%v} eventType.Path={%v}", url, err, eventType.Path) return false } for _, v := range l.interestedURL { diff --git a/registry/zookeeper/registry.go b/registry/zookeeper/registry.go index c272c5bba615c68c452f36819edef0f2a821a5dc..ff57eb638aa8919720b9eeed1cb4603cc2928cf2 100644 --- a/registry/zookeeper/registry.go +++ b/registry/zookeeper/registry.go @@ -41,7 +41,6 @@ import ( "github.com/apache/dubbo-go/common/utils" "github.com/apache/dubbo-go/registry" "github.com/apache/dubbo-go/remoting/zookeeper" - "github.com/apache/dubbo-go/version" ) const ( @@ -230,10 +229,11 @@ func (r *zkRegistry) Register(conf common.URL) error { case common.PROVIDER: - // 妫€楠屾湇鍔℃槸鍚﹀凡缁忔敞鍐岃繃 + // Check if the service has been registered r.cltLock.Lock() - // 娉ㄦ剰姝ゅ涓巆onsumerZookeeperRegistry鐨勫樊寮傦紝consumer鐢ㄧ殑鏄痗onf.Path锛� - // 鍥犱负consumer瑕佹彁渚泈atch鍔熻兘缁檚elector浣跨敤, provider鍏佽娉ㄥ唽鍚屼竴涓猻ervice鐨勫涓猤roup or version + // Note the difference between consumer and consumerZookeeperRegistry (consumer use conf.Path). + // Because the consumer wants to provide monitoring functions for the selector, + // the provider allows multiple groups or versions of the same service to be registered. _, ok = r.services[conf.Key()] r.cltLock.Unlock() if ok { @@ -298,11 +298,12 @@ func (r *zkRegistry) register(c common.URL) error { } params.Add("anyhost", "true") - // dubbo java consumer鏉ュ惎鍔ㄦ壘provider url鏃讹紝鍥犱负category涓嶅尮閰嶏紝浼氭壘涓嶅埌provider锛屽鑷碿onsumer鍚姩涓嶄簡,鎵€浠ヤ娇鐢╟onsumers&providers + // Dubbo java consumer to start looking for the provider url,because the category does not match, + // the provider will not find, causing the consumer can not start, so we use consumers. // DubboRole = [...]string{"consumer", "", "", "provider"} // params.Add("category", (RoleType(PROVIDER)).Role()) params.Add("category", (common.RoleType(common.PROVIDER)).String()) - params.Add("dubbo", "dubbo-provider-golang-"+version.Version) + params.Add("dubbo", "dubbo-provider-golang-"+constant.Version) params.Add("side", (common.RoleType(common.PROVIDER)).Role()) @@ -320,7 +321,7 @@ func (r *zkRegistry) register(c common.URL) error { rawURL = fmt.Sprintf("%s://%s%s?%s", c.Protocol, host, c.Path, params.Encode()) encodedURL = url.QueryEscape(rawURL) - // 鎶婅嚜宸辨敞鍐宻ervice providers + // Print your own registration service providers. dubboPath = fmt.Sprintf("/dubbo/%s/%s", c.Service(), (common.RoleType(common.PROVIDER)).String()) logger.Debugf("provider path:%s, url:%s", dubboPath, rawURL) @@ -345,7 +346,7 @@ func (r *zkRegistry) register(c common.URL) error { params.Add("protocol", c.Protocol) params.Add("category", (common.RoleType(common.CONSUMER)).String()) - params.Add("dubbo", "dubbogo-consumer-"+version.Version) + params.Add("dubbo", "dubbogo-consumer-"+constant.Version) rawURL = fmt.Sprintf("consumer://%s%s?%s", localIP, c.Path, params.Encode()) encodedURL = url.QueryEscape(rawURL) @@ -380,7 +381,11 @@ func (r *zkRegistry) registerTempZookeeperNode(root string, node string) error { } zkPath, err = r.client.RegisterTemp(root, node) if err != nil { - logger.Errorf("RegisterTempNode(root{%s}, node{%s}) = error{%v}", root, node, perrors.WithStack(err)) + if err == zk.ErrNodeExists { + logger.Warnf("RegisterTempNode(root{%s}, node{%s}) = error{%v}", root, node, perrors.WithStack(err)) + } else { + logger.Errorf("RegisterTempNode(root{%s}, node{%s}) = error{%v}", root, node, perrors.WithStack(err)) + } return perrors.WithMessagef(err, "RegisterTempNode(root{%s}, node{%s})", root, node) } logger.Debugf("create a zookeeper node:%s", zkPath) @@ -416,7 +421,7 @@ func (r *zkRegistry) getListener(conf common.URL) (*RegistryConfigurationListene r.listenerLock.Unlock() } - //娉ㄥ唽鍒癲ataconfig鐨刬nterested + //Interested register to dataconfig. r.dataListener.AddInterestedURL(&conf) go r.listener.ListenServiceEvent(fmt.Sprintf("/dubbo/%s/providers", conf.Service()), r.dataListener) @@ -428,7 +433,7 @@ func (r *zkRegistry) closeRegisters() { r.cltLock.Lock() defer r.cltLock.Unlock() logger.Infof("begin to close provider zk client") - // 鍏堝叧闂棫client锛屼互鍏抽棴tmp node + // Close the old client first to close the tmp node. r.client.Close() r.client = nil r.services = nil diff --git a/registry/zookeeper/zookeeper-4unitest/contrib/fatjar/zookeeper-3.4.9-fatjar.jar b/registry/zookeeper/zookeeper-4unitest/contrib/fatjar/zookeeper-3.4.9-fatjar.jar deleted file mode 100644 index 839531b8b8762a9c19e334a5cbf79314cb16f945..0000000000000000000000000000000000000000 Binary files a/registry/zookeeper/zookeeper-4unitest/contrib/fatjar/zookeeper-3.4.9-fatjar.jar and /dev/null differ diff --git a/remoting/etcdv3/client.go b/remoting/etcdv3/client.go new file mode 100644 index 0000000000000000000000000000000000000000..57d1211fe30e00dcb1ad16733f36b7969ebaf505 --- /dev/null +++ b/remoting/etcdv3/client.go @@ -0,0 +1,480 @@ +package etcdv3 + +import ( + "context" + "path" + "sync" + "time" +) + +import ( + "github.com/coreos/etcd/clientv3" + "github.com/coreos/etcd/clientv3/concurrency" + perrors "github.com/pkg/errors" + "google.golang.org/grpc" +) + +import ( + "github.com/apache/dubbo-go/common/logger" +) + +const ( + ConnDelay = 3 + MaxFailTimes = 15 + RegistryETCDV3Client = "etcd registry" +) + +var ( + ErrNilETCDV3Client = perrors.New("etcd raw client is nil") // full describe the ERR + ErrKVPairNotFound = perrors.New("k/v pair not found") +) + +type Options struct { + name string + endpoints []string + client *Client + timeout time.Duration + heartbeat int // heartbeat second +} + +type Option func(*Options) + +func WithEndpoints(endpoints ...string) Option { + return func(opt *Options) { + opt.endpoints = endpoints + } +} +func WithName(name string) Option { + return func(opt *Options) { + opt.name = name + } +} +func WithTimeout(timeout time.Duration) Option { + return func(opt *Options) { + opt.timeout = timeout + } +} + +func WithHeartbeat(heartbeat int) Option { + return func(opt *Options) { + opt.heartbeat = heartbeat + } +} + +func ValidateClient(container clientFacade, opts ...Option) error { + + options := &Options{ + heartbeat: 1, // default heartbeat + } + for _, opt := range opts { + opt(options) + } + + lock := container.ClientLock() + lock.Lock() + defer lock.Unlock() + + // new Client + if container.Client() == nil { + newClient, err := newClient(options.name, options.endpoints, options.timeout, options.heartbeat) + if err != nil { + logger.Warnf("new etcd client (name{%s}, etcd addresses{%v}, timeout{%d}) = error{%v}", + options.name, options.endpoints, options.timeout, err) + return perrors.WithMessagef(err, "new client (address:%+v)", options.endpoints) + } + container.SetClient(newClient) + } + + // Client lose connection with etcd server + if container.Client().rawClient == nil { + + newClient, err := newClient(options.name, options.endpoints, options.timeout, options.heartbeat) + if err != nil { + logger.Warnf("new etcd client (name{%s}, etcd addresses{%v}, timeout{%d}) = error{%v}", + options.name, options.endpoints, options.timeout, err) + return perrors.WithMessagef(err, "new client (address:%+v)", options.endpoints) + } + container.SetClient(newClient) + } + + return nil +} + +type Client struct { + lock sync.RWMutex + + // these properties are only set once when they are started. + name string + endpoints []string + timeout time.Duration + heartbeat int + + ctx context.Context // if etcd server connection lose, the ctx.Done will be sent msg + cancel context.CancelFunc // cancel the ctx, all watcher will stopped + rawClient *clientv3.Client + + exit chan struct{} + Wait sync.WaitGroup +} + +func newClient(name string, endpoints []string, timeout time.Duration, heartbeat int) (*Client, error) { + + ctx, cancel := context.WithCancel(context.Background()) + rawClient, err := clientv3.New(clientv3.Config{ + Context: ctx, + Endpoints: endpoints, + DialTimeout: timeout, + DialOptions: []grpc.DialOption{grpc.WithBlock()}, + }) + if err != nil { + return nil, perrors.WithMessage(err, "new raw client block connect to server") + } + + c := &Client{ + + name: name, + timeout: timeout, + endpoints: endpoints, + heartbeat: heartbeat, + + ctx: ctx, + cancel: cancel, + rawClient: rawClient, + + exit: make(chan struct{}), + } + + if err := c.maintenanceStatus(); err != nil { + return nil, perrors.WithMessage(err, "client maintenance status") + } + return c, nil +} + +// NOTICE: need to get the lock before calling this method +func (c *Client) clean() { + + // close raw client + c.rawClient.Close() + + // cancel ctx for raw client + c.cancel() + + // clean raw client + c.rawClient = nil +} + +func (c *Client) stop() bool { + + select { + case <-c.exit: + return true + default: + close(c.exit) + } + return false +} + +func (c *Client) Close() { + + if c == nil { + return + } + + // stop the client + c.stop() + + // wait client maintenance status stop + c.Wait.Wait() + + c.lock.Lock() + if c.rawClient != nil { + c.clean() + } + c.lock.Unlock() + logger.Warnf("etcd client{name:%s, endpoints:%s} exit now.", c.name, c.endpoints) +} + +func (c *Client) maintenanceStatus() error { + + s, err := concurrency.NewSession(c.rawClient, concurrency.WithTTL(c.heartbeat)) + if err != nil { + return perrors.WithMessage(err, "new session with server") + } + + // must add wg before go maintenance status goroutine + c.Wait.Add(1) + go c.maintenanceStatusLoop(s) + return nil +} + +func (c *Client) maintenanceStatusLoop(s *concurrency.Session) { + + defer func() { + c.Wait.Done() + logger.Infof("etcd client {endpoints:%v, name:%s} maintenance goroutine game over.", c.endpoints, c.name) + }() + + for { + select { + case <-c.Done(): + // Client be stopped, will clean the client hold resources + return + case <-s.Done(): + logger.Warn("etcd server stopped") + c.lock.Lock() + // when etcd server stopped, cancel ctx, stop all watchers + c.clean() + // when connection lose, stop client, trigger reconnect to etcd + c.stop() + c.lock.Unlock() + return + } + } +} + +// if k not exist will put k/v in etcd +// if k is already exist in etcd, return nil +func (c *Client) put(k string, v string, opts ...clientv3.OpOption) error { + + c.lock.RLock() + defer c.lock.RUnlock() + + if c.rawClient == nil { + return ErrNilETCDV3Client + } + + _, err := c.rawClient.Txn(c.ctx). + If(clientv3.Compare(clientv3.Version(k), "<", 1)). + Then(clientv3.OpPut(k, v, opts...)). + Commit() + if err != nil { + return err + + } + return nil +} + +func (c *Client) delete(k string) error { + + c.lock.RLock() + defer c.lock.RUnlock() + + if c.rawClient == nil { + return ErrNilETCDV3Client + } + + _, err := c.rawClient.Delete(c.ctx, k) + if err != nil { + return err + + } + return nil +} + +func (c *Client) get(k string) (string, error) { + + c.lock.RLock() + defer c.lock.RUnlock() + + if c.rawClient == nil { + return "", ErrNilETCDV3Client + } + + resp, err := c.rawClient.Get(c.ctx, k) + if err != nil { + return "", err + } + + if len(resp.Kvs) == 0 { + return "", ErrKVPairNotFound + } + + return string(resp.Kvs[0].Value), nil +} + +func (c *Client) CleanKV() error { + + c.lock.RLock() + defer c.lock.RUnlock() + + if c.rawClient == nil { + return ErrNilETCDV3Client + } + + _, err := c.rawClient.Delete(c.ctx, "", clientv3.WithPrefix()) + if err != nil { + return err + } + + return nil +} + +func (c *Client) getChildren(k string) ([]string, []string, error) { + + c.lock.RLock() + defer c.lock.RUnlock() + + if c.rawClient == nil { + return nil, nil, ErrNilETCDV3Client + } + + resp, err := c.rawClient.Get(c.ctx, k, clientv3.WithPrefix()) + if err != nil { + return nil, nil, err + } + + if len(resp.Kvs) == 0 { + return nil, nil, ErrKVPairNotFound + } + + var ( + kList []string + vList []string + ) + + for _, kv := range resp.Kvs { + kList = append(kList, string(kv.Key)) + vList = append(vList, string(kv.Value)) + } + + return kList, vList, nil +} + +func (c *Client) watchWithPrefix(prefix string) (clientv3.WatchChan, error) { + + c.lock.RLock() + defer c.lock.RUnlock() + + if c.rawClient == nil { + return nil, ErrNilETCDV3Client + } + + return c.rawClient.Watch(c.ctx, prefix, clientv3.WithPrefix()), nil +} + +func (c *Client) watch(k string) (clientv3.WatchChan, error) { + + c.lock.RLock() + defer c.lock.RUnlock() + + if c.rawClient == nil { + return nil, ErrNilETCDV3Client + } + + return c.rawClient.Watch(c.ctx, k), nil +} + +func (c *Client) keepAliveKV(k string, v string) error { + + c.lock.RLock() + defer c.lock.RUnlock() + + if c.rawClient == nil { + return ErrNilETCDV3Client + } + + lease, err := c.rawClient.Grant(c.ctx, int64(time.Second.Seconds())) + if err != nil { + return perrors.WithMessage(err, "grant lease") + } + + keepAlive, err := c.rawClient.KeepAlive(c.ctx, lease.ID) + if err != nil || keepAlive == nil { + c.rawClient.Revoke(c.ctx, lease.ID) + return perrors.WithMessage(err, "keep alive lease") + } + + _, err = c.rawClient.Put(c.ctx, k, v, clientv3.WithLease(lease.ID)) + if err != nil { + return perrors.WithMessage(err, "put k/v with lease") + } + return nil +} + +func (c *Client) Done() <-chan struct{} { + return c.exit +} + +func (c *Client) Valid() bool { + select { + case <-c.exit: + return false + default: + } + + c.lock.RLock() + if c.rawClient == nil { + c.lock.RUnlock() + return false + } + c.lock.RUnlock() + return true +} + +func (c *Client) Create(k string, v string) error { + + err := c.put(k, v) + if err != nil { + return perrors.WithMessagef(err, "put k/v (key: %s value %s)", k, v) + } + return nil +} + +func (c *Client) Delete(k string) error { + + err := c.delete(k) + if err != nil { + return perrors.WithMessagef(err, "delete k/v (key %s)", k) + } + + return nil +} + +func (c *Client) RegisterTemp(basePath string, node string) (string, error) { + + completeKey := path.Join(basePath, node) + + err := c.keepAliveKV(completeKey, "") + if err != nil { + return "", perrors.WithMessagef(err, "keepalive kv (key %s)", completeKey) + } + + return completeKey, nil +} + +func (c *Client) GetChildrenKVList(k string) ([]string, []string, error) { + + kList, vList, err := c.getChildren(k) + if err != nil { + return nil, nil, perrors.WithMessagef(err, "get key children (key %s)", k) + } + return kList, vList, nil +} + +func (c *Client) Get(k string) (string, error) { + + v, err := c.get(k) + if err != nil { + return "", perrors.WithMessagef(err, "get key value (key %s)", k) + } + + return v, nil +} + +func (c *Client) Watch(k string) (clientv3.WatchChan, error) { + + wc, err := c.watch(k) + if err != nil { + return nil, perrors.WithMessagef(err, "watch prefix (key %s)", k) + } + return wc, nil +} + +func (c *Client) WatchWithPrefix(prefix string) (clientv3.WatchChan, error) { + + wc, err := c.watchWithPrefix(prefix) + if err != nil { + return nil, perrors.WithMessagef(err, "watch prefix (key %s)", prefix) + } + return wc, nil +} diff --git a/remoting/etcdv3/client_test.go b/remoting/etcdv3/client_test.go new file mode 100644 index 0000000000000000000000000000000000000000..187789e0abfac6a0e195bebd68ce4b91e0f9bdec --- /dev/null +++ b/remoting/etcdv3/client_test.go @@ -0,0 +1,366 @@ +package etcdv3 + +import ( + "fmt" + "net/url" + "path" + "reflect" + "strings" + "sync" + "testing" + "time" +) + +import ( + "github.com/coreos/etcd/mvcc/mvccpb" + perrors "github.com/pkg/errors" + "github.com/stretchr/testify/suite" + "go.etcd.io/etcd/embed" + "google.golang.org/grpc/connectivity" +) + +// tests dataset +var tests = []struct { + input struct { + k string + v string + } +}{ + {input: struct { + k string + v string + }{k: "name", v: "scott.wang"}}, + {input: struct { + k string + v string + }{k: "namePrefix", v: "prefix.scott.wang"}}, + {input: struct { + k string + v string + }{k: "namePrefix1", v: "prefix1.scott.wang"}}, + {input: struct { + k string + v string + }{k: "age", v: "27"}}, +} + +// test dataset prefix +const prefix = "name" + +type ClientTestSuite struct { + suite.Suite + + etcdConfig struct { + name string + endpoints []string + timeout time.Duration + heartbeat int + } + + etcd *embed.Etcd + + client *Client +} + +// start etcd server +func (suite *ClientTestSuite) SetupSuite() { + + t := suite.T() + + DefaultListenPeerURLs := "http://localhost:2382" + DefaultListenClientURLs := "http://localhost:2381" + lpurl, _ := url.Parse(DefaultListenPeerURLs) + lcurl, _ := url.Parse(DefaultListenClientURLs) + cfg := embed.NewConfig() + cfg.LPUrls = []url.URL{*lpurl} + cfg.LCUrls = []url.URL{*lcurl} + cfg.Dir = "/tmp/default.etcd" + e, err := embed.StartEtcd(cfg) + if err != nil { + t.Fatal(err) + } + select { + case <-e.Server.ReadyNotify(): + t.Log("Server is ready!") + case <-time.After(60 * time.Second): + e.Server.Stop() // trigger a shutdown + t.Logf("Server took too long to start!") + } + + suite.etcd = e + return +} + +// stop etcd server +func (suite *ClientTestSuite) TearDownSuite() { + suite.etcd.Close() +} + +func (suite *ClientTestSuite) setUpClient() *Client { + c, err := newClient(suite.etcdConfig.name, + suite.etcdConfig.endpoints, + suite.etcdConfig.timeout, + suite.etcdConfig.heartbeat) + if err != nil { + suite.T().Fatal(err) + } + return c +} + +// set up a client for suite +func (suite *ClientTestSuite) SetupTest() { + c := suite.setUpClient() + c.CleanKV() + suite.client = c + return +} + +func (suite *ClientTestSuite) TestClientClose() { + + fmt.Println("called client close") + + c := suite.client + t := suite.T() + + defer c.Close() + if c.rawClient.ActiveConnection().GetState() != connectivity.Ready { + t.Fatal(suite.client.rawClient.ActiveConnection().GetState()) + } +} + +func (suite *ClientTestSuite) TestClientValid() { + + fmt.Println("called client valid") + + c := suite.client + t := suite.T() + + if c.Valid() != true { + t.Fatal("client is not valid") + } + c.Close() + if suite.client.Valid() != false { + t.Fatal("client is valid") + } +} + +func (suite *ClientTestSuite) TestClientDone() { + + c := suite.client + + go func() { + time.Sleep(2 * time.Second) + c.Close() + }() + + c.Wait.Wait() +} + +func (suite *ClientTestSuite) TestClientCreateKV() { + + tests := tests + + c := suite.client + t := suite.T() + + defer suite.client.Close() + + for _, tc := range tests { + + k := tc.input.k + v := tc.input.v + expect := tc.input.v + + if err := c.Create(k, v); err != nil { + t.Fatal(err) + } + + value, err := c.Get(k) + if err != nil { + t.Fatal(err) + } + + if value != expect { + t.Fatalf("expect %v but get %v", expect, value) + } + + } +} + +func (suite *ClientTestSuite) TestClientDeleteKV() { + + tests := tests + c := suite.client + t := suite.T() + + defer c.Close() + + for _, tc := range tests { + + k := tc.input.k + v := tc.input.v + expect := ErrKVPairNotFound + + if err := c.Create(k, v); err != nil { + t.Fatal(err) + } + + if err := c.Delete(k); err != nil { + t.Fatal(err) + } + + _, err := c.Get(k) + if perrors.Cause(err) == expect { + continue + } + + if err != nil { + t.Fatal(err) + } + } + +} + +func (suite *ClientTestSuite) TestClientGetChildrenKVList() { + + tests := tests + + c := suite.client + t := suite.T() + + var expectKList []string + var expectVList []string + + for _, tc := range tests { + + k := tc.input.k + v := tc.input.v + + if strings.Contains(k, prefix) { + expectKList = append(expectKList, k) + expectVList = append(expectVList, v) + } + + if err := c.Create(k, v); err != nil { + t.Fatal(err) + } + } + + kList, vList, err := c.GetChildrenKVList(prefix) + if err != nil { + t.Fatal(err) + } + + if reflect.DeepEqual(expectKList, kList) && reflect.DeepEqual(expectVList, vList) { + return + } + + t.Fatalf("expect keylist %v but got %v expect valueList %v but got %v ", expectKList, kList, expectVList, vList) + +} + +func (suite *ClientTestSuite) TestClientWatch() { + + tests := tests + + c := suite.client + t := suite.T() + + wg := sync.WaitGroup{} + wg.Add(1) + + go func() { + + defer wg.Done() + + wc, err := c.watch(prefix) + if err != nil { + t.Fatal(err) + } + + for e := range wc { + + for _, event := range e.Events { + t.Logf("type IsCreate %v k %s v %s", event.IsCreate(), event.Kv.Key, event.Kv.Value) + } + } + + }() + + for _, tc := range tests { + + k := tc.input.k + v := tc.input.v + + if err := c.Create(k, v); err != nil { + t.Fatal(err) + } + + if err := c.delete(k); err != nil { + t.Fatal(err) + } + } + + c.Close() + + wg.Wait() + +} + +func (suite *ClientTestSuite) TestClientRegisterTemp() { + + c := suite.client + observeC := suite.setUpClient() + t := suite.T() + + wg := sync.WaitGroup{} + wg.Add(1) + + go func() { + completePath := path.Join("scott", "wang") + wc, err := observeC.watch(completePath) + if err != nil { + t.Fatal(err) + } + + for e := range wc { + + for _, event := range e.Events { + + if event.Type == mvccpb.DELETE { + t.Logf("complete key (%s) is delete", completePath) + wg.Done() + observeC.Close() + return + } + t.Logf("type IsCreate %v k %s v %s", event.IsCreate(), event.Kv.Key, event.Kv.Value) + } + } + }() + + _, err := c.RegisterTemp("scott", "wang") + if err != nil { + t.Fatal(err) + } + + time.Sleep(2 * time.Second) + c.Close() + + wg.Wait() +} + +func TestClientSuite(t *testing.T) { + suite.Run(t, &ClientTestSuite{ + etcdConfig: struct { + name string + endpoints []string + timeout time.Duration + heartbeat int + }{ + name: "test", + endpoints: []string{"localhost:2381"}, + timeout: time.Second, + heartbeat: 1, + }, + }) +} diff --git a/remoting/etcdv3/facade.go b/remoting/etcdv3/facade.go new file mode 100644 index 0000000000000000000000000000000000000000..e75b39d6bcd7f67f7606c6b212f59e7a42178fd8 --- /dev/null +++ b/remoting/etcdv3/facade.go @@ -0,0 +1,82 @@ +package etcdv3 + +import ( + "sync" + "time" +) + +import ( + "github.com/dubbogo/getty" + perrors "github.com/pkg/errors" +) + +import ( + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/common/logger" +) + +type clientFacade interface { + Client() *Client + SetClient(*Client) + ClientLock() *sync.Mutex + WaitGroup() *sync.WaitGroup //for wait group control, etcd client listener & etcd client container + GetDone() chan struct{} //for etcd client control + RestartCallBack() bool + common.Node +} + +func HandleClientRestart(r clientFacade) { + + var ( + err error + failTimes int + ) + + defer r.WaitGroup().Done() +LOOP: + for { + select { + case <-r.GetDone(): + logger.Warnf("(ETCDV3ProviderRegistry)reconnectETCDV3 goroutine exit now...") + break LOOP + // re-register all services + case <-r.Client().Done(): + r.ClientLock().Lock() + clientName := RegistryETCDV3Client + timeout, _ := time.ParseDuration(r.GetUrl().GetParam(constant.REGISTRY_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT)) + endpoint := r.GetUrl().Location + r.Client().Close() + r.SetClient(nil) + r.ClientLock().Unlock() + + // try to connect to etcd, + failTimes = 0 + for { + select { + case <-r.GetDone(): + logger.Warnf("(ETCDV3ProviderRegistry)reconnectETCDRegistry goroutine exit now...") + break LOOP + case <-getty.GetTimeWheel().After(timeSecondDuration(failTimes * ConnDelay)): // avoid connect frequent + } + err = ValidateClient( + r, + WithName(clientName), + WithEndpoints(endpoint), + WithTimeout(timeout), + ) + logger.Infof("ETCDV3ProviderRegistry.validateETCDV3Client(etcd Addr{%s}) = error{%#v}", + endpoint, perrors.WithStack(err)) + if err == nil { + if r.RestartCallBack() { + break + } + } + failTimes++ + if MaxFailTimes <= failTimes { + failTimes = MaxFailTimes + } + } + } + } +} diff --git a/remoting/etcdv3/listener.go b/remoting/etcdv3/listener.go new file mode 100644 index 0000000000000000000000000000000000000000..f5401917e208f41d3ea84e47c46f535b344e2784 --- /dev/null +++ b/remoting/etcdv3/listener.go @@ -0,0 +1,217 @@ +package etcdv3 + +import ( + "sync" + "time" +) + +import ( + "github.com/coreos/etcd/clientv3" + "github.com/coreos/etcd/mvcc/mvccpb" + perrors "github.com/pkg/errors" +) + +import ( + "github.com/apache/dubbo-go/common/logger" + "github.com/apache/dubbo-go/remoting" +) + +type EventListener struct { + client *Client + keyMapLock sync.Mutex + keyMap map[string]struct{} + wg sync.WaitGroup +} + +func NewEventListener(client *Client) *EventListener { + return &EventListener{ + client: client, + keyMap: make(map[string]struct{}), + } +} + +// Listen on a spec key +// this method will return true when spec key deleted, +// this method will return false when deep layer connection lose +func (l *EventListener) ListenServiceNodeEvent(key string, listener ...remoting.DataListener) bool { + l.wg.Add(1) + defer l.wg.Done() + for { + wc, err := l.client.Watch(key) + if err != nil { + logger.Warnf("WatchExist{key:%s} = error{%v}", key, err) + return false + } + + select { + + // client stopped + case <-l.client.Done(): + logger.Warnf("etcd client stopped") + return false + + // client ctx stop + case <-l.client.ctx.Done(): + logger.Warnf("etcd client ctx cancel") + return false + + // handle etcd events + case e, ok := <-wc: + if !ok { + logger.Warnf("etcd watch-chan closed") + return false + } + + if e.Err() != nil { + logger.Errorf("etcd watch ERR {err: %s}", e.Err()) + continue + } + for _, event := range e.Events { + if l.handleEvents(event, listener...) { + // if event is delete + return true + } + } + } + } + + return false +} + +// return true mean the event type is DELETE +// return false mean the event type is CREATE || UPDATE +func (l *EventListener) handleEvents(event *clientv3.Event, listeners ...remoting.DataListener) bool { + + logger.Infof("got a etcd event {type: %s, key: %s}", event.Type, event.Kv.Key) + + switch event.Type { + // the etcdv3 event just include PUT && DELETE + case mvccpb.PUT: + for _, listener := range listeners { + switch event.IsCreate() { + case true: + logger.Infof("etcd get event (key{%s}) = event{EventNodeDataCreated}", event.Kv.Key) + listener.DataChange(remoting.Event{ + Path: string(event.Kv.Key), + Action: remoting.EventTypeAdd, + Content: string(event.Kv.Value), + }) + case false: + logger.Infof("etcd get event (key{%s}) = event{EventNodeDataChanged}", event.Kv.Key) + listener.DataChange(remoting.Event{ + Path: string(event.Kv.Key), + Action: remoting.EventTypeUpdate, + Content: string(event.Kv.Value), + }) + } + } + return false + case mvccpb.DELETE: + logger.Warnf("etcd get event (key{%s}) = event{EventNodeDeleted}", event.Kv.Key) + return true + + default: + return false + } + + panic("unreachable") +} + +// Listen on a set of key with spec prefix +func (l *EventListener) ListenServiceNodeEventWithPrefix(prefix string, listener ...remoting.DataListener) { + + l.wg.Add(1) + defer l.wg.Done() + for { + wc, err := l.client.WatchWithPrefix(prefix) + if err != nil { + logger.Warnf("listenDirEvent(key{%s}) = error{%v}", prefix, err) + } + + select { + + // client stopped + case <-l.client.Done(): + logger.Warnf("etcd client stopped") + return + + // client ctx stop + case <-l.client.ctx.Done(): + logger.Warnf("etcd client ctx cancel") + return + + // etcd event stream + case e, ok := <-wc: + + if !ok { + logger.Warnf("etcd watch-chan closed") + return + } + + if e.Err() != nil { + logger.Errorf("etcd watch ERR {err: %s}", e.Err()) + continue + } + for _, event := range e.Events { + l.handleEvents(event, listener...) + } + } + } +} + +func timeSecondDuration(sec int) time.Duration { + return time.Duration(sec) * time.Second +} + +// this func is invoked by etcdv3 ConsumerRegistry::Registe/ etcdv3 ConsumerRegistry::get/etcdv3 ConsumerRegistry::getListener +// registry.go:Listen -> listenServiceEvent -> listenDirEvent -> ListenServiceNodeEvent +// | +// --------> ListenServiceNodeEvent +func (l *EventListener) ListenServiceEvent(key string, listener remoting.DataListener) { + + l.keyMapLock.Lock() + _, ok := l.keyMap[key] + l.keyMapLock.Unlock() + if ok { + logger.Warnf("etcdv3 key %s has already been listened.", key) + return + } + + l.keyMapLock.Lock() + l.keyMap[key] = struct{}{} + l.keyMapLock.Unlock() + + keyList, valueList, err := l.client.getChildren(key) + if err != nil { + logger.Errorf("Get new node path {%v} 's content error,message is {%v}", key, perrors.WithMessage(err, "get children")) + } + + logger.Infof("get key children list %s, keys %v values %v", key, keyList, valueList) + + for i, k := range keyList { + logger.Infof("got children list key -> %s", k) + listener.DataChange(remoting.Event{ + Path: k, + Action: remoting.EventTypeAdd, + Content: valueList[i], + }) + } + + logger.Infof("listen dubbo provider key{%s} event and wait to get all provider etcdv3 nodes", key) + go func(key string, listener remoting.DataListener) { + l.ListenServiceNodeEventWithPrefix(key, listener) + logger.Warnf("listenDirEvent(key{%s}) goroutine exit now", key) + }(key, listener) + + logger.Infof("listen dubbo service key{%s}", key) + go func(key string) { + if l.ListenServiceNodeEvent(key) { + listener.DataChange(remoting.Event{Path: key, Action: remoting.EventTypeDel}) + } + logger.Warnf("listenSelf(etcd key{%s}) goroutine exit now", key) + }(key) +} + +func (l *EventListener) Close() { + l.wg.Wait() +} diff --git a/remoting/etcdv3/listener_test.go b/remoting/etcdv3/listener_test.go new file mode 100644 index 0000000000000000000000000000000000000000..33904a21345ec0ac7ee1adbb239a0a7a44852387 --- /dev/null +++ b/remoting/etcdv3/listener_test.go @@ -0,0 +1,87 @@ +package etcdv3 + +import ( + "time" +) + +import ( + "github.com/stretchr/testify/assert" +) + +import ( + "github.com/apache/dubbo-go/remoting" +) + +var changedData = ` + dubbo.consumer.request_timeout=3s + dubbo.consumer.connect_timeout=5s + dubbo.application.organization=ikurento.com + dubbo.application.name=BDTService + dubbo.application.module=dubbogo user-info server + dubbo.application.version=0.0.1 + dubbo.application.owner=ZX + dubbo.application.environment=dev + dubbo.registries.hangzhouzk.protocol=zookeeper + dubbo.registries.hangzhouzk.timeout=3s + dubbo.registries.hangzhouzk.address=127.0.0.1:2181 + dubbo.registries.shanghaizk.protocol=zookeeper + dubbo.registries.shanghaizk.timeout=3s + dubbo.registries.shanghaizk.address=127.0.0.1:2182 + dubbo.service.com.ikurento.user.UserProvider.protocol=dubbo + dubbo.service.com.ikurento.user.UserProvider.interface=com.ikurento.user.UserProvider + dubbo.service.com.ikurento.user.UserProvider.loadbalance=random + dubbo.service.com.ikurento.user.UserProvider.warmup=100 + dubbo.service.com.ikurento.user.UserProvider.cluster=failover +` + +func (suite *ClientTestSuite) TestListener() { + + var tests = []struct { + input struct { + k string + v string + } + }{ + {input: struct { + k string + v string + }{k: "/dubbo", v: changedData}}, + } + + c := suite.client + t := suite.T() + + listener := NewEventListener(c) + dataListener := &mockDataListener{client: c, changedData: changedData, rc: make(chan remoting.Event)} + listener.ListenServiceEvent("/dubbo", dataListener) + + // NOTICE: direct listen will lose create msg + time.Sleep(time.Second) + for _, tc := range tests { + + k := tc.input.k + v := tc.input.v + if err := c.Create(k, v); err != nil { + t.Fatal(err) + } + + } + msg := <-dataListener.rc + assert.Equal(t, changedData, msg.Content) +} + +type mockDataListener struct { + eventList []remoting.Event + client *Client + changedData string + + rc chan remoting.Event +} + +func (m *mockDataListener) DataChange(eventType remoting.Event) bool { + m.eventList = append(m.eventList, eventType) + if eventType.Content == m.changedData { + m.rc <- eventType + } + return true +} diff --git a/remoting/listener.go b/remoting/listener.go index da30f6989dbaae5668ad189b4fdef945d622fd9b..b94ba26980b50db99e766fcc8febb07d6b554274 100644 --- a/remoting/listener.go +++ b/remoting/listener.go @@ -46,12 +46,13 @@ type EventType int const ( EventTypeAdd = iota EventTypeDel - EvnetTypeUpdate + EventTypeUpdate ) var serviceEventTypeStrings = [...]string{ "add", "delete", + "update", } func (t EventType) String() string { diff --git a/remoting/zookeeper/client.go b/remoting/zookeeper/client.go index 008848ea61ba2deb1a70aba5c29da097c3c48da9..a7fc568f567d720448d0be63c592fae5f8df9bbf 100644 --- a/remoting/zookeeper/client.go +++ b/remoting/zookeeper/client.go @@ -65,7 +65,7 @@ func StateToString(state zk.State) string { case zk.StateConnectedReadOnly: return "zookeeper connect readonly" case zk.StateSaslAuthenticated: - return "zookeeper sasl authenticaed" + return "zookeeper sasl authenticated" case zk.StateExpired: return "zookeeper connection expired" case zk.StateConnected: @@ -118,7 +118,7 @@ func ValidateZookeeperClient(container zkClientFacade, opts ...Option) error { defer lock.Unlock() if container.ZkClient() == nil { - //in dubbp ,every registry only connect one node ,so this is []string{r.Address} + //in dubbo ,every registry only connect one node ,so this is []string{r.Address} timeout, err := time.ParseDuration(url.GetParam(constant.REGISTRY_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT)) if err != nil { logger.Errorf("timeout config %v is invalid ,err is %v", @@ -128,7 +128,7 @@ func ValidateZookeeperClient(container zkClientFacade, opts ...Option) error { zkAddresses := strings.Split(url.Location, ",") newClient, err := newZookeeperClient(opions.zkName, zkAddresses, timeout) if err != nil { - logger.Warnf("newZookeeperClient(name{%s}, zk addresss{%v}, timeout{%d}) = error{%v}", + logger.Warnf("newZookeeperClient(name{%s}, zk address{%v}, timeout{%d}) = error{%v}", opions.zkName, url.Location, timeout.String(), err) return perrors.WithMessagef(err, "newZookeeperClient(address:%+v)", url.Location) } diff --git a/remoting/zookeeper/facade.go b/remoting/zookeeper/facade.go index 4eace5e9d540ac86ca01683963b19ae547c7c732..cdc7ead61226906a629fdb99b6b966ada5ee5253 100644 --- a/remoting/zookeeper/facade.go +++ b/remoting/zookeeper/facade.go @@ -63,14 +63,14 @@ LOOP: r.SetZkClient(nil) r.ZkClientLock().Unlock() - // 鎺k锛岀洿鑷虫垚鍔� + // Connect zk until success. failTimes = 0 for { select { case <-r.GetDone(): logger.Warnf("(ZkProviderRegistry)reconnectZkRegistry goroutine exit now...") break LOOP - case <-getty.GetTimeWheel().After(timeSecondDuration(failTimes * ConnDelay)): // 闃叉鐤媯閲嶈繛zk + case <-getty.GetTimeWheel().After(timeSecondDuration(failTimes * ConnDelay)): // Prevent crazy reconnection zk. } err = ValidateZookeeperClient(r, WithZkName(zkName)) logger.Infof("ZkProviderRegistry.validateZookeeperClient(zkAddr{%s}) = error{%#v}", diff --git a/remoting/zookeeper/facade_test.go b/remoting/zookeeper/facade_test.go index 46edd49bf7cd22011bd7dfc8b89227257c5ad2ab..58e0d69dcfd9bf645c147f6e920e56ed5f3951eb 100644 --- a/remoting/zookeeper/facade_test.go +++ b/remoting/zookeeper/facade_test.go @@ -75,7 +75,7 @@ func (r *mockFacade) IsAvailable() bool { return true } -func Test_Fascade(t *testing.T) { +func Test_Facade(t *testing.T) { ts, z, event, err := NewMockZookeeperClient("test", 15*time.Second) assert.NoError(t, err) defer ts.Stop() diff --git a/remoting/zookeeper/listener.go b/remoting/zookeeper/listener.go index 3df87ed4f603956a653cec692031dee94639de16..9521ea749027582c015ac998a6f6f68d350cc3bc 100644 --- a/remoting/zookeeper/listener.go +++ b/remoting/zookeeper/listener.go @@ -47,9 +47,11 @@ func NewZkEventListener(client *ZookeeperClient) *ZkEventListener { pathMap: make(map[string]struct{}), } } + func (l *ZkEventListener) SetClient(client *ZookeeperClient) { l.client = client } + func (l *ZkEventListener) ListenServiceNodeEvent(zkPath string, listener ...remoting.DataListener) bool { l.wg.Add(1) defer l.wg.Done() @@ -70,9 +72,8 @@ func (l *ZkEventListener) ListenServiceNodeEvent(zkPath string, listener ...remo logger.Warnf("zk.ExistW(key{%s}) = event{EventNodeDataChanged}", zkPath) if len(listener) > 0 { content, _, _ := l.client.Conn.Get(zkEvent.Path) - listener[0].DataChange(remoting.Event{Path: zkEvent.Path, Action: remoting.EvnetTypeUpdate, Content: string(content)}) + listener[0].DataChange(remoting.Event{Path: zkEvent.Path, Action: remoting.EventTypeUpdate, Content: string(content)}) } - case zk.EventNodeCreated: logger.Warnf("zk.ExistW(key{%s}) = event{EventNodeCreated}", zkPath) if len(listener) > 0 { @@ -100,7 +101,6 @@ func (l *ZkEventListener) handleZkNodeEvent(zkPath string, children []string, li return true } } - return false } @@ -130,14 +130,14 @@ func (l *ZkEventListener) handleZkNodeEvent(zkPath string, children []string, li continue } // listen l service node - go func(node string) { + go func(node string, zkPath string, listener remoting.DataListener) { logger.Infof("delete zkNode{%s}", node) if l.ListenServiceNodeEvent(node, listener) { logger.Infof("delete content{%s}", node) listener.DataChange(remoting.Event{Path: zkPath, Action: remoting.EventTypeDel}) } logger.Warnf("listenSelf(zk path{%s}) goroutine exit now", zkPath) - }(newNode) + }(newNode, zkPath, listener) } // old node was deleted @@ -205,9 +205,22 @@ func (l *ZkEventListener) listenDirEvent(zkPath string, listener remoting.DataLi } failTimes = 0 for _, c := range children { - // listen l service node dubboPath := path.Join(zkPath, c) + + //Save the path to avoid listen repeatedly + l.pathMapLock.Lock() + _, ok := l.pathMap[dubboPath] + l.pathMapLock.Unlock() + if ok { + logger.Warnf("@zkPath %s has already been listened.", zkPath) + continue + } + + l.pathMapLock.Lock() + l.pathMap[dubboPath] = struct{}{} + l.pathMapLock.Unlock() + content, _, err := l.client.Conn.Get(dubboPath) if err != nil { logger.Errorf("Get new node path {%v} 's content error,message is {%v}", dubboPath, perrors.WithStack(err)) @@ -217,14 +230,14 @@ func (l *ZkEventListener) listenDirEvent(zkPath string, listener remoting.DataLi continue } logger.Infof("listen dubbo service key{%s}", dubboPath) - go func(zkPath string) { - if l.ListenServiceNodeEvent(dubboPath) { - listener.DataChange(remoting.Event{Path: dubboPath, Action: remoting.EventTypeDel}) + go func(zkPath string, listener remoting.DataListener) { + if l.ListenServiceNodeEvent(zkPath) { + listener.DataChange(remoting.Event{Path: zkPath, Action: remoting.EventTypeDel}) } logger.Warnf("listenSelf(zk path{%s}) goroutine exit now", zkPath) - }(dubboPath) + }(dubboPath, listener) - //liten sub path recursive + //listen sub path recursive go func(zkPath string, listener remoting.DataListener) { l.listenDirEvent(zkPath, listener) logger.Warnf("listenDirEvent(zkPath{%s}) goroutine exit now", zkPath) @@ -245,72 +258,11 @@ func (l *ZkEventListener) listenDirEvent(zkPath string, listener remoting.DataLi } } -// -//func (l *ZkEventListener) listenFileEvent(zkPath string, listener remoting.DataListener) { -// l.wg.EventTypeAdd(1) -// defer l.wg.Done() -// -// var ( -// failTimes int -// event chan struct{} -// zkEvent zk.Event -// ) -// event = make(chan struct{}, 4) -// defer close(event) -// for { -// // get current children for a zkPath -// content,_, eventCh, err := l.client.Conn.GetW(zkPath) -// if err != nil { -// failTimes++ -// if MaxFailTimes <= failTimes { -// failTimes = MaxFailTimes -// } -// logger.Errorf("listenFileEvent(path{%s}) = error{%v}", zkPath, err) -// // clear the event channel -// CLEAR: -// for { -// select { -// case <-event: -// default: -// break CLEAR -// } -// } -// l.client.RegisterEvent(zkPath, &event) -// select { -// case <-time.After(timeSecondDuration(failTimes * ConnDelay)): -// l.client.UnregisterEvent(zkPath, &event) -// continue -// case <-l.client.Done(): -// l.client.UnregisterEvent(zkPath, &event) -// logger.Warnf("client.done(), listen(path{%s}) goroutine exit now...", zkPath) -// return -// case <-event: -// logger.Infof("get zk.EventNodeDataChange notify event") -// l.client.UnregisterEvent(zkPath, &event) -// l.handleZkNodeEvent(zkPath, nil, listener) -// continue -// } -// } -// failTimes = 0 -// -// select { -// case zkEvent = <-eventCh: -// logger.Warnf("get a zookeeper zkEvent{type:%s, server:%s, path:%s, state:%d-%s, err:%s}", -// zkEvent.Type.String(), zkEvent.Server, zkEvent.Path, zkEvent.State, StateToString(zkEvent.State), zkEvent.Err) -// -// l.handleZkNodeEvent(zkEvent.Path, children, listener) -// case <-l.client.Done(): -// logger.Warnf("client.done(), listen(path{%s}) goroutine exit now...", zkPath) -// return -// } -// } -//} - func timeSecondDuration(sec int) time.Duration { return time.Duration(sec) * time.Second } -// this func is invoked by ZkConsumerRegistry::Registe/ZkConsumerRegistry::get/ZkConsumerRegistry::getListener +// this func is invoked by ZkConsumerRegistry::Register/ZkConsumerRegistry::get/ZkConsumerRegistry::getListener // registry.go:Listen -> listenServiceEvent -> listenDirEvent -> ListenServiceNodeEvent // | // --------> ListenServiceNodeEvent @@ -341,7 +293,6 @@ func (l *ZkEventListener) ListenServiceEvent(zkPath string, listener remoting.Da } for _, c := range children { - // listen l service node dubboPath = path.Join(zkPath, c) content, _, err := l.client.Conn.Get(dubboPath) @@ -352,12 +303,12 @@ func (l *ZkEventListener) ListenServiceEvent(zkPath string, listener remoting.Da continue } logger.Infof("listen dubbo service key{%s}", dubboPath) - go func(zkPath string) { - if l.ListenServiceNodeEvent(dubboPath) { - listener.DataChange(remoting.Event{Path: dubboPath, Action: remoting.EventTypeDel}) + go func(zkPath string, listener remoting.DataListener) { + if l.ListenServiceNodeEvent(zkPath) { + listener.DataChange(remoting.Event{Path: zkPath, Action: remoting.EventTypeDel}) } logger.Warnf("listenSelf(zk path{%s}) goroutine exit now", zkPath) - }(dubboPath) + }(dubboPath, listener) } logger.Infof("listen dubbo path{%s}", zkPath) diff --git a/remoting/zookeeper/zookeeper-4unitest/contrib/fatjar/zookeeper-3.4.9-fatjar.jar b/remoting/zookeeper/zookeeper-4unitest/contrib/fatjar/zookeeper-3.4.9-fatjar.jar deleted file mode 100644 index 839531b8b8762a9c19e334a5cbf79314cb16f945..0000000000000000000000000000000000000000 Binary files a/remoting/zookeeper/zookeeper-4unitest/contrib/fatjar/zookeeper-3.4.9-fatjar.jar and /dev/null differ