Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2
22a7f0099
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Summer2022
22a7f0099
Commits
e73d5cc7
Commit
e73d5cc7
authored
4 years ago
by
xg.gao
Browse files
Options
Downloads
Patches
Plain Diff
format
parent
2aa91c13
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
config/service_config.go
+1
-1
1 addition, 1 deletion
config/service_config.go
registry/protocol/protocol.go
+7
-9
7 additions, 9 deletions
registry/protocol/protocol.go
with
8 additions
and
10 deletions
config/service_config.go
+
1
−
1
View file @
e73d5cc7
...
...
@@ -133,7 +133,7 @@ func getRandomPort(protocolConfigs []*ProtocolConfig) *list.List {
tcp
,
err
:=
gxnet
.
ListenOnTCPRandomPort
(
proto
.
Ip
)
if
err
!=
nil
{
panic
(
perrors
.
New
(
fmt
.
Sprintf
(
"Get tcp port error,err is {%v}"
,
err
)))
panic
(
perrors
.
New
(
fmt
.
Sprintf
(
"Get tcp port error,
err is {%v}"
,
err
)))
}
defer
tcp
.
Close
()
ports
.
PushBack
(
strings
.
Split
(
tcp
.
Addr
()
.
String
(),
":"
)[
1
])
...
...
This diff is collapsed.
Click to expand it.
registry/protocol/protocol.go
+
7
−
9
View file @
e73d5cc7
...
...
@@ -22,6 +22,7 @@ import (
"strings"
"sync"
)
import
(
gxset
"github.com/dubbogo/gost/container/set"
)
...
...
@@ -54,9 +55,10 @@ var (
type
registryProtocol
struct
{
invokers
[]
protocol
.
Invoker
// Registry
Map<RegistryAddress, Registry>
// Registry Map<RegistryAddress, Registry>
registries
*
sync
.
Map
// To solve the problem of RMI repeated exposure port conflicts, the services that have been exposed are no longer exposed.
// To solve the problem of RMI repeated exposure port conflicts,
// the services that have been exposed are no longer exposed.
// providerurl <--> exporter
bounds
*
sync
.
Map
overrideListeners
*
sync
.
Map
...
...
@@ -100,7 +102,6 @@ func getUrlToRegistry(providerUrl *common.URL, registryUrl *common.URL) *common.
// filterHideKey filter the parameters that do not need to be output in url(Starting with .)
func
filterHideKey
(
url
*
common
.
URL
)
*
common
.
URL
{
// be careful params maps in url is map type
removeSet
:=
gxset
.
NewSet
()
for
k
,
_
:=
range
url
.
GetParams
()
{
...
...
@@ -127,7 +128,6 @@ func (proto *registryProtocol) Refer(url common.URL) protocol.Invoker {
}
var
reg
registry
.
Registry
if
regI
,
loaded
:=
proto
.
registries
.
Load
(
registryUrl
.
Key
());
!
loaded
{
reg
=
getRegistry
(
&
registryUrl
)
proto
.
registries
.
Store
(
registryUrl
.
Key
(),
reg
)
...
...
@@ -138,7 +138,7 @@ func (proto *registryProtocol) Refer(url common.URL) protocol.Invoker {
// new registry directory for store service url from registry
directory
,
err
:=
extension
.
GetDefaultRegistryDirectory
(
&
registryUrl
,
reg
)
if
err
!=
nil
{
logger
.
Errorf
(
"consumer service %v
create registry directory
error, error message is %s, and will return nil invoker!"
,
logger
.
Errorf
(
"consumer service %v create registry directory error, error message is %s, and will return nil invoker!"
,
serviceUrl
.
String
(),
err
.
Error
())
return
nil
}
...
...
@@ -151,7 +151,6 @@ func (proto *registryProtocol) Refer(url common.URL) protocol.Invoker {
// new cluster invoker
cluster
:=
extension
.
GetCluster
(
serviceUrl
.
GetParam
(
constant
.
CLUSTER_KEY
,
constant
.
DEFAULT_CLUSTER
))
invoker
:=
cluster
.
Join
(
directory
)
proto
.
invokers
=
append
(
proto
.
invokers
,
invoker
)
return
invoker
...
...
@@ -192,7 +191,7 @@ func (proto *registryProtocol) Export(invoker protocol.Invoker) protocol.Exporte
}
key
:=
getCacheKey
(
providerUrl
)
logger
.
Infof
(
"The cached exporter keys is %v
!"
,
key
)
logger
.
Infof
(
"The cached exporter keys is %v!"
,
key
)
cachedExporter
,
loaded
:=
proto
.
bounds
.
Load
(
key
)
if
loaded
{
logger
.
Infof
(
"The exporter has been cached, and will return cached exporter!"
)
...
...
@@ -216,7 +215,6 @@ func (proto *registryProtocol) reExport(invoker protocol.Invoker, newUrl *common
proto
.
bounds
.
Delete
(
key
)
proto
.
Export
(
wrappedNewInvoker
)
// TODO: unregister & unsubscribe
}
}
...
...
@@ -353,7 +351,7 @@ func (proto *registryProtocol) Destroy() {
func
getRegistryUrl
(
invoker
protocol
.
Invoker
)
*
common
.
URL
{
// here add * for return a new url
url
:=
invoker
.
GetUrl
()
// if the protocol == registry
,set protocol the registry value in url.params
// if the protocol == registry,
set protocol the registry value in url.params
if
url
.
Protocol
==
constant
.
REGISTRY_PROTOCOL
{
protocol
:=
url
.
GetParam
(
constant
.
REGISTRY_KEY
,
""
)
url
.
Protocol
=
protocol
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment