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
de17df63
Commit
de17df63
authored
Jun 23, 2018
by
Nepxion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
重构类结构
parent
c45e7f5b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
5 deletions
+15
-5
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/strategy/DiscoveryControlStrategy.java
+15
-5
No files found.
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/strategy/DiscoveryControlStrategy.java
View file @
de17df63
...
@@ -51,21 +51,31 @@ public class DiscoveryControlStrategy {
...
@@ -51,21 +51,31 @@ public class DiscoveryControlStrategy {
}
}
private
void
applyIpAddressFilter
(
String
providerServiceId
,
List
<
ServiceInstance
>
instances
)
{
private
void
applyIpAddressFilter
(
String
providerServiceId
,
List
<
ServiceInstance
>
instances
)
{
String
ipAddress
=
pluginCache
.
get
(
providerServiceId
);
String
filterIpAddress
=
pluginCache
.
get
(
providerServiceId
);
if
(
StringUtils
.
isNotEmpty
(
ipAddress
))
{
if
(
StringUtils
.
isNotEmpty
(
filterIpAddress
))
{
String
[]
filterArray
=
StringUtils
.
split
(
ipAddress
,
PluginConstant
.
SEPARATE
);
List
<
String
>
filterList
=
Arrays
.
asList
(
filterArray
);
Iterator
<
ServiceInstance
>
iterator
=
instances
.
iterator
();
Iterator
<
ServiceInstance
>
iterator
=
instances
.
iterator
();
while
(
iterator
.
hasNext
())
{
while
(
iterator
.
hasNext
())
{
ServiceInstance
serviceInstance
=
iterator
.
next
();
ServiceInstance
serviceInstance
=
iterator
.
next
();
String
host
=
serviceInstance
.
getHost
();
String
host
=
serviceInstance
.
getHost
();
if
(
filterList
.
contains
(
host
))
{
boolean
valid
=
validateBlacklist
(
filterIpAddress
,
host
);
if
(
valid
)
{
iterator
.
remove
();
iterator
.
remove
();
}
}
}
}
}
}
}
}
private
boolean
validateBlacklist
(
String
filterIpAddress
,
String
ipAddress
)
{
String
[]
filterArray
=
StringUtils
.
split
(
ipAddress
,
PluginConstant
.
SEPARATE
);
for
(
String
filter
:
filterArray
)
{
if
(
ipAddress
.
startsWith
(
filter
))
{
return
true
;
}
}
return
false
;
}
private
void
applyVersionFilter
(
String
consumerServiceId
,
String
consumerServiceVersion
,
String
providerServiceId
,
List
<
ServiceInstance
>
instances
)
{
private
void
applyVersionFilter
(
String
consumerServiceId
,
String
consumerServiceVersion
,
String
providerServiceId
,
List
<
ServiceInstance
>
instances
)
{
// 如果消费端未配置版本号,那么它可以调用提供端所有服务,需要符合规范,极力避免该情况发生
// 如果消费端未配置版本号,那么它可以调用提供端所有服务,需要符合规范,极力避免该情况发生
if
(
StringUtils
.
isEmpty
(
consumerServiceVersion
))
{
if
(
StringUtils
.
isEmpty
(
consumerServiceVersion
))
{
...
...
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