Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
discovery
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陈文顺
discovery
Commits
cd16c8c4
Commit
cd16c8c4
authored
Feb 18, 2019
by
Nepxion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
支持跨机房区域路由,支持跨版本路由
parent
5701da08
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
8 deletions
+30
-8
discovery-plugin-strategy/src/main/java/com/nepxion/discovery/plugin/strategy/adapter/AbstractDiscoveryEnabledAdapter.java
+30
-8
No files found.
discovery-plugin-strategy/src/main/java/com/nepxion/discovery/plugin/strategy/adapter/AbstractDiscoveryEnabledAdapter.java
View file @
cd16c8c4
...
...
@@ -51,25 +51,33 @@ public abstract class AbstractDiscoveryEnabledAdapter implements DiscoveryEnable
return
true
;
}
String
serviceId
=
server
.
getMetaInfo
().
getAppName
().
toLowerCase
();
String
version
=
metadata
.
get
(
DiscoveryConstant
.
VERSION
);
if
(
StringUtils
.
isEmpty
(
version
))
{
return
false
;
}
Map
<
String
,
String
>
versionMap
=
JsonUtil
.
fromJson
(
versionValue
,
Map
.
class
);
String
versions
=
versionMap
.
get
(
serviceId
);
if
(
versions
==
null
)
{
String
versions
=
null
;
try
{
Map
<
String
,
String
>
versionMap
=
JsonUtil
.
fromJson
(
versionValue
,
Map
.
class
);
String
serviceId
=
server
.
getMetaInfo
().
getAppName
().
toLowerCase
();
versions
=
versionMap
.
get
(
serviceId
);
}
catch
(
Exception
e
)
{
versions
=
versionValue
;
}
if
(
StringUtils
.
isEmpty
(
versions
))
{
return
true
;
}
if
(
versions
.
contains
(
version
))
{
List
<
String
>
versionList
=
StringUtil
.
splitToList
(
versions
,
DiscoveryConstant
.
SEPARATE
);
if
(
versionList
.
contains
(
version
))
{
return
true
;
}
return
false
;
}
@SuppressWarnings
(
"unchecked"
)
private
boolean
applyRegion
(
Server
server
,
Map
<
String
,
String
>
metadata
)
{
String
regionValue
=
getRegionValue
(
server
);
if
(
StringUtils
.
isEmpty
(
regionValue
))
{
...
...
@@ -81,7 +89,21 @@ public abstract class AbstractDiscoveryEnabledAdapter implements DiscoveryEnable
return
false
;
}
if
(
StringUtils
.
equals
(
regionValue
,
region
))
{
String
regions
=
null
;
try
{
Map
<
String
,
String
>
regionMap
=
JsonUtil
.
fromJson
(
regionValue
,
Map
.
class
);
String
serviceId
=
server
.
getMetaInfo
().
getAppName
().
toLowerCase
();
regions
=
regionMap
.
get
(
serviceId
);
}
catch
(
Exception
e
)
{
regions
=
regionValue
;
}
if
(
StringUtils
.
isEmpty
(
regions
))
{
return
true
;
}
List
<
String
>
regionList
=
StringUtil
.
splitToList
(
regions
,
DiscoveryConstant
.
SEPARATE
);
if
(
regionList
.
contains
(
region
))
{
return
true
;
}
...
...
@@ -95,10 +117,10 @@ public abstract class AbstractDiscoveryEnabledAdapter implements DiscoveryEnable
return
true
;
}
String
serviceId
=
server
.
getMetaInfo
().
getAppName
().
toLowerCase
();
Map
<
String
,
String
>
addressMap
=
JsonUtil
.
fromJson
(
addressValue
,
Map
.
class
);
String
serviceId
=
server
.
getMetaInfo
().
getAppName
().
toLowerCase
();
String
addresses
=
addressMap
.
get
(
serviceId
);
if
(
addresses
==
null
)
{
if
(
StringUtils
.
isEmpty
(
addresses
)
)
{
return
true
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment