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
7415f908
Commit
7415f908
authored
Jun 24, 2018
by
Nepxion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化过滤算法
parent
661238d1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
74 additions
and
73 deletions
+74
-73
discovery-plugin-config-center/src/main/java/com/nepxion/discovery/plugin/configcenter/ConfigParser.java
+26
-9
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/entity/DiscoveryServiceEntity.java
+11
-10
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/entity/RegisterEntity.java
+9
-8
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/strategy/DiscoveryControlStrategy.java
+8
-23
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/strategy/RegisterControlStrategy.java
+20
-23
No files found.
discovery-plugin-config-center/src/main/java/com/nepxion/discovery/plugin/configcenter/ConfigParser.java
View file @
7415f908
...
@@ -10,6 +10,7 @@ package com.nepxion.discovery.plugin.configcenter;
...
@@ -10,6 +10,7 @@ package com.nepxion.discovery.plugin.configcenter;
*/
*/
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -24,11 +25,12 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -24,11 +25,12 @@ import org.springframework.beans.factory.annotation.Autowired;
import
com.nepxion.discovery.plugin.configcenter.constant.ConfigConstant
;
import
com.nepxion.discovery.plugin.configcenter.constant.ConfigConstant
;
import
com.nepxion.discovery.plugin.configcenter.xml.Dom4JParser
;
import
com.nepxion.discovery.plugin.configcenter.xml.Dom4JParser
;
import
com.nepxion.discovery.plugin.framework.constant.PluginConstant
;
import
com.nepxion.discovery.plugin.framework.entity.DiscoveryEntity
;
import
com.nepxion.discovery.plugin.framework.entity.DiscoveryEntity
;
import
com.nepxion.discovery.plugin.framework.entity.DiscoveryServiceEntity
;
import
com.nepxion.discovery.plugin.framework.entity.DiscoveryServiceEntity
;
import
com.nepxion.discovery.plugin.framework.entity.RuleEntity
;
import
com.nepxion.discovery.plugin.framework.entity.RegisterEntity
;
import
com.nepxion.discovery.plugin.framework.entity.RegisterEntity
;
import
com.nepxion.discovery.plugin.framework.entity.RegisterFilterType
;
import
com.nepxion.discovery.plugin.framework.entity.RegisterFilterType
;
import
com.nepxion.discovery.plugin.framework.entity.RuleEntity
;
import
com.nepxion.discovery.plugin.framework.exception.PluginException
;
import
com.nepxion.discovery.plugin.framework.exception.PluginException
;
public
class
ConfigParser
extends
Dom4JParser
{
public
class
ConfigParser
extends
Dom4JParser
{
...
@@ -43,7 +45,7 @@ public class ConfigParser extends Dom4JParser {
...
@@ -43,7 +45,7 @@ public class ConfigParser extends Dom4JParser {
@SuppressWarnings
(
"rawtypes"
)
@SuppressWarnings
(
"rawtypes"
)
@Override
@Override
protected
void
parseRoot
(
Element
element
)
{
protected
void
parseRoot
(
Element
element
)
{
LOG
.
info
(
"Start to parse
plugin
xml..."
);
LOG
.
info
(
"Start to parse
rule
xml..."
);
int
registerElementCount
=
element
.
elements
(
ConfigConstant
.
REGISTER_ELEMENT_NAME
).
size
();
int
registerElementCount
=
element
.
elements
(
ConfigConstant
.
REGISTER_ELEMENT_NAME
).
size
();
if
(
registerElementCount
>
1
)
{
if
(
registerElementCount
>
1
)
{
...
@@ -96,10 +98,11 @@ public class ConfigParser extends Dom4JParser {
...
@@ -96,10 +98,11 @@ public class ConfigParser extends Dom4JParser {
Attribute
globalFilterAttribute
=
element
.
attribute
(
ConfigConstant
.
FILTER_VALUE_ATTRIBUTE_NAME
);
Attribute
globalFilterAttribute
=
element
.
attribute
(
ConfigConstant
.
FILTER_VALUE_ATTRIBUTE_NAME
);
if
(
globalFilterAttribute
!=
null
)
{
if
(
globalFilterAttribute
!=
null
)
{
String
globalFilterValue
=
globalFilterAttribute
.
getData
().
toString
().
trim
();
String
globalFilterValue
=
globalFilterAttribute
.
getData
().
toString
().
trim
();
registerEntity
.
setFilterValue
(
globalFilterValue
);
List
<
String
>
globalFilterValueList
=
parseList
(
globalFilterValue
);
registerEntity
.
setFilterValueList
(
globalFilterValueList
);
}
}
Map
<
String
,
String
>
filterMap
=
registerEntity
.
getFilterMap
();
Map
<
String
,
List
<
String
>
>
filterMap
=
registerEntity
.
getFilterMap
();
for
(
Iterator
elementIterator
=
element
.
elementIterator
();
elementIterator
.
hasNext
();)
{
for
(
Iterator
elementIterator
=
element
.
elementIterator
();
elementIterator
.
hasNext
();)
{
Object
childElementObject
=
elementIterator
.
next
();
Object
childElementObject
=
elementIterator
.
next
();
...
@@ -113,11 +116,12 @@ public class ConfigParser extends Dom4JParser {
...
@@ -113,11 +116,12 @@ public class ConfigParser extends Dom4JParser {
String
serviceName
=
serviceNameAttribute
.
getData
().
toString
().
trim
();
String
serviceName
=
serviceNameAttribute
.
getData
().
toString
().
trim
();
Attribute
filterValueAttribute
=
childElement
.
attribute
(
ConfigConstant
.
FILTER_VALUE_ATTRIBUTE_NAME
);
Attribute
filterValueAttribute
=
childElement
.
attribute
(
ConfigConstant
.
FILTER_VALUE_ATTRIBUTE_NAME
);
String
filterValue
=
null
;
List
<
String
>
filterValueList
=
null
;
if
(
filterValueAttribute
!=
null
)
{
if
(
filterValueAttribute
!=
null
)
{
filterValue
=
filterValueAttribute
.
getData
().
toString
().
trim
();
String
filterValue
=
filterValueAttribute
.
getData
().
toString
().
trim
();
filterValueList
=
parseList
(
filterValue
);
}
}
filterMap
.
put
(
serviceName
,
filterValue
);
filterMap
.
put
(
serviceName
,
filterValue
List
);
}
}
}
}
}
}
...
@@ -149,13 +153,15 @@ public class ConfigParser extends Dom4JParser {
...
@@ -149,13 +153,15 @@ public class ConfigParser extends Dom4JParser {
Attribute
consumerVersionValueAttribute
=
childElement
.
attribute
(
ConfigConstant
.
CONSUMER_VERSION_VALUE_ATTRIBUTE_NAME
);
Attribute
consumerVersionValueAttribute
=
childElement
.
attribute
(
ConfigConstant
.
CONSUMER_VERSION_VALUE_ATTRIBUTE_NAME
);
if
(
consumerVersionValueAttribute
!=
null
)
{
if
(
consumerVersionValueAttribute
!=
null
)
{
String
consumerVersionValue
=
consumerVersionValueAttribute
.
getData
().
toString
().
trim
();
String
consumerVersionValue
=
consumerVersionValueAttribute
.
getData
().
toString
().
trim
();
serviceEntity
.
setConsumerVersionValue
(
consumerVersionValue
);
List
<
String
>
consumerVersionValueList
=
parseList
(
consumerVersionValue
);
serviceEntity
.
setConsumerVersionValueList
(
consumerVersionValueList
);
}
}
Attribute
providerVersionValueAttribute
=
childElement
.
attribute
(
ConfigConstant
.
PROVIDER_VERSION_VALUE_ATTRIBUTE_NAME
);
Attribute
providerVersionValueAttribute
=
childElement
.
attribute
(
ConfigConstant
.
PROVIDER_VERSION_VALUE_ATTRIBUTE_NAME
);
if
(
providerVersionValueAttribute
!=
null
)
{
if
(
providerVersionValueAttribute
!=
null
)
{
String
providerVersionValue
=
providerVersionValueAttribute
.
getData
().
toString
().
trim
();
String
providerVersionValue
=
providerVersionValueAttribute
.
getData
().
toString
().
trim
();
serviceEntity
.
setProviderVersionValue
(
providerVersionValue
);
List
<
String
>
providerVersionValueList
=
parseList
(
providerVersionValue
);
serviceEntity
.
setProviderVersionValueList
(
providerVersionValueList
);
}
}
List
<
DiscoveryServiceEntity
>
serviceEntityList
=
serviceEntityMap
.
get
(
consumerServiceName
);
List
<
DiscoveryServiceEntity
>
serviceEntityList
=
serviceEntityMap
.
get
(
consumerServiceName
);
...
@@ -168,4 +174,14 @@ public class ConfigParser extends Dom4JParser {
...
@@ -168,4 +174,14 @@ public class ConfigParser extends Dom4JParser {
}
}
}
}
}
}
private
List
<
String
>
parseList
(
String
value
)
{
if
(
StringUtils
.
isEmpty
(
value
))
{
return
null
;
}
String
[]
valueArray
=
StringUtils
.
split
(
value
,
PluginConstant
.
SEPARATE
);
return
Arrays
.
asList
(
valueArray
);
}
}
}
\ No newline at end of file
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/entity/DiscoveryServiceEntity.java
View file @
7415f908
...
@@ -10,6 +10,7 @@ package com.nepxion.discovery.plugin.framework.entity;
...
@@ -10,6 +10,7 @@ package com.nepxion.discovery.plugin.framework.entity;
*/
*/
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.util.List
;
import
org.apache.commons.lang3.builder.EqualsBuilder
;
import
org.apache.commons.lang3.builder.EqualsBuilder
;
import
org.apache.commons.lang3.builder.HashCodeBuilder
;
import
org.apache.commons.lang3.builder.HashCodeBuilder
;
...
@@ -21,8 +22,8 @@ public class DiscoveryServiceEntity implements Serializable {
...
@@ -21,8 +22,8 @@ public class DiscoveryServiceEntity implements Serializable {
private
String
consumerServiceName
;
private
String
consumerServiceName
;
private
String
providerServiceName
;
private
String
providerServiceName
;
private
String
consumerVersionValue
;
private
List
<
String
>
consumerVersionValueList
;
private
String
providerVersionValue
;
private
List
<
String
>
providerVersionValueList
;
public
DiscoveryServiceEntity
()
{
public
DiscoveryServiceEntity
()
{
...
@@ -44,20 +45,20 @@ public class DiscoveryServiceEntity implements Serializable {
...
@@ -44,20 +45,20 @@ public class DiscoveryServiceEntity implements Serializable {
this
.
providerServiceName
=
providerServiceName
;
this
.
providerServiceName
=
providerServiceName
;
}
}
public
String
getConsumerVersionValue
()
{
public
List
<
String
>
getConsumerVersionValueList
()
{
return
consumerVersionValue
;
return
consumerVersionValue
List
;
}
}
public
void
setConsumerVersionValue
(
String
consumerVersionValue
)
{
public
void
setConsumerVersionValue
List
(
List
<
String
>
consumerVersionValueList
)
{
this
.
consumerVersionValue
=
consumerVersionValue
;
this
.
consumerVersionValue
List
=
consumerVersionValueList
;
}
}
public
String
getProviderVersionValue
()
{
public
List
<
String
>
getProviderVersionValueList
()
{
return
providerVersionValue
;
return
providerVersionValue
List
;
}
}
public
void
setProviderVersionValue
(
String
providerVersionValue
)
{
public
void
setProviderVersionValue
List
(
List
<
String
>
providerVersionValueList
)
{
this
.
providerVersionValue
=
providerVersionValue
;
this
.
providerVersionValue
List
=
providerVersionValueList
;
}
}
@Override
@Override
...
...
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/entity/RegisterEntity.java
View file @
7415f908
...
@@ -11,6 +11,7 @@ package com.nepxion.discovery.plugin.framework.entity;
...
@@ -11,6 +11,7 @@ package com.nepxion.discovery.plugin.framework.entity;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.util.LinkedHashMap
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
org.apache.commons.lang3.builder.EqualsBuilder
;
import
org.apache.commons.lang3.builder.EqualsBuilder
;
...
@@ -22,8 +23,8 @@ public class RegisterEntity implements Serializable {
...
@@ -22,8 +23,8 @@ public class RegisterEntity implements Serializable {
private
static
final
long
serialVersionUID
=
-
2097322826969006191L
;
private
static
final
long
serialVersionUID
=
-
2097322826969006191L
;
private
RegisterFilterType
filterType
;
private
RegisterFilterType
filterType
;
private
String
filterValue
;
private
List
<
String
>
filterValueList
;
private
Map
<
String
,
String
>
filterMap
=
new
LinkedHashMap
<
String
,
String
>();
private
Map
<
String
,
List
<
String
>>
filterMap
=
new
LinkedHashMap
<
String
,
List
<
String
>
>();
public
RegisterEntity
()
{
public
RegisterEntity
()
{
...
@@ -37,19 +38,19 @@ public class RegisterEntity implements Serializable {
...
@@ -37,19 +38,19 @@ public class RegisterEntity implements Serializable {
this
.
filterType
=
filterType
;
this
.
filterType
=
filterType
;
}
}
public
String
getFilterValue
()
{
public
List
<
String
>
getFilterValueList
()
{
return
filterValue
;
return
filterValue
List
;
}
}
public
void
setFilterValue
(
String
filterValue
)
{
public
void
setFilterValue
List
(
List
<
String
>
filterValueList
)
{
this
.
filterValue
=
filterValue
;
this
.
filterValue
List
=
filterValueList
;
}
}
public
Map
<
String
,
String
>
getFilterMap
()
{
public
Map
<
String
,
List
<
String
>
>
getFilterMap
()
{
return
filterMap
;
return
filterMap
;
}
}
public
void
setFilterMap
(
Map
<
String
,
String
>
filterMap
)
{
public
void
setFilterMap
(
Map
<
String
,
List
<
String
>
>
filterMap
)
{
this
.
filterMap
=
filterMap
;
this
.
filterMap
=
filterMap
;
}
}
...
...
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/strategy/DiscoveryControlStrategy.java
View file @
7415f908
...
@@ -10,7 +10,6 @@ package com.nepxion.discovery.plugin.framework.strategy;
...
@@ -10,7 +10,6 @@ package com.nepxion.discovery.plugin.framework.strategy;
*/
*/
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -98,27 +97,24 @@ public class DiscoveryControlStrategy {
...
@@ -98,27 +97,24 @@ public class DiscoveryControlStrategy {
}
}
// 当前版本的消费端所能调用提供端的版本号列表
// 当前版本的消费端所能调用提供端的版本号列表
List
<
String
>
allFilterV
ersions
=
new
ArrayList
<
String
>();
List
<
String
>
allFilterV
alueList
=
new
ArrayList
<
String
>();
for
(
DiscoveryServiceEntity
serviceEntity
:
serviceEntityList
)
{
for
(
DiscoveryServiceEntity
serviceEntity
:
serviceEntityList
)
{
String
providerServiceName
=
serviceEntity
.
getProviderServiceName
();
String
providerServiceName
=
serviceEntity
.
getProviderServiceName
();
if
(
StringUtils
.
equals
(
providerServiceName
,
providerServiceId
))
{
if
(
StringUtils
.
equals
(
providerServiceName
,
providerServiceId
))
{
String
consumerVersionValue
=
serviceEntity
.
getConsumerVersionValue
();
List
<
String
>
consumerVersionValueList
=
serviceEntity
.
getConsumerVersionValueList
();
String
providerVersionValue
=
serviceEntity
.
getProviderVersionValue
();
List
<
String
>
providerVersionValueList
=
serviceEntity
.
getProviderVersionValueList
();
List
<
String
>
consumerVersionList
=
getVersionList
(
consumerVersionValue
);
List
<
String
>
providerVersionList
=
getVersionList
(
providerVersionValue
);
// 判断consumer-version-value值是否包含当前消费端的版本号
// 判断consumer-version-value值是否包含当前消费端的版本号
if
(
CollectionUtils
.
isNotEmpty
(
consumerVersion
List
)
&&
consumerVersion
List
.
contains
(
consumerServiceVersion
))
{
if
(
CollectionUtils
.
isNotEmpty
(
consumerVersion
ValueList
)
&&
consumerVersionValue
List
.
contains
(
consumerServiceVersion
))
{
if
(
CollectionUtils
.
isNotEmpty
(
providerVersionList
))
{
if
(
CollectionUtils
.
isNotEmpty
(
providerVersion
Value
List
))
{
allFilterV
ersions
.
addAll
(
providerVersion
List
);
allFilterV
alueList
.
addAll
(
providerVersionValue
List
);
}
}
}
}
}
}
}
}
// 未找到相应的版本定义或者未定义
// 未找到相应的版本定义或者未定义
if
(
CollectionUtils
.
isEmpty
(
allFilterV
ersions
))
{
if
(
CollectionUtils
.
isEmpty
(
allFilterV
alueList
))
{
return
;
return
;
}
}
...
@@ -126,19 +122,9 @@ public class DiscoveryControlStrategy {
...
@@ -126,19 +122,9 @@ public class DiscoveryControlStrategy {
while
(
iterator
.
hasNext
())
{
while
(
iterator
.
hasNext
())
{
ServiceInstance
serviceInstance
=
iterator
.
next
();
ServiceInstance
serviceInstance
=
iterator
.
next
();
String
metaDataVersion
=
serviceInstance
.
getMetadata
().
get
(
PluginConstant
.
VRESION
);
String
metaDataVersion
=
serviceInstance
.
getMetadata
().
get
(
PluginConstant
.
VRESION
);
if
(!
allFilterV
ersions
.
contains
(
metaDataVersion
))
{
if
(!
allFilterV
alueList
.
contains
(
metaDataVersion
))
{
iterator
.
remove
();
iterator
.
remove
();
}
}
}
}
}
}
private
List
<
String
>
getVersionList
(
String
versionValue
)
{
if
(
StringUtils
.
isEmpty
(
versionValue
))
{
return
null
;
}
String
[]
versionArray
=
StringUtils
.
split
(
versionValue
,
PluginConstant
.
SEPARATE
);
return
Arrays
.
asList
(
versionArray
);
}
}
}
\ No newline at end of file
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/strategy/RegisterControlStrategy.java
View file @
7415f908
...
@@ -9,18 +9,19 @@ package com.nepxion.discovery.plugin.framework.strategy;
...
@@ -9,18 +9,19 @@ package com.nepxion.discovery.plugin.framework.strategy;
* @version 1.0
* @version 1.0
*/
*/
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.concurrent.locks.ReentrantReadWriteLock
;
import
java.util.concurrent.locks.ReentrantReadWriteLock
;
import
org.apache.commons.
lang3.String
Utils
;
import
org.apache.commons.
collections4.Collection
Utils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
com.nepxion.discovery.plugin.framework.constant.PluginConstant
;
import
com.nepxion.discovery.plugin.framework.entity.RuleEntity
;
import
com.nepxion.discovery.plugin.framework.entity.RegisterEntity
;
import
com.nepxion.discovery.plugin.framework.entity.RegisterEntity
;
import
com.nepxion.discovery.plugin.framework.entity.RegisterFilterType
;
import
com.nepxion.discovery.plugin.framework.entity.RegisterFilterType
;
import
com.nepxion.discovery.plugin.framework.entity.RuleEntity
;
import
com.nepxion.discovery.plugin.framework.exception.PluginException
;
import
com.nepxion.discovery.plugin.framework.exception.PluginException
;
public
class
RegisterControlStrategy
{
public
class
RegisterControlStrategy
{
...
@@ -49,48 +50,44 @@ public class RegisterControlStrategy {
...
@@ -49,48 +50,44 @@ public class RegisterControlStrategy {
}
}
RegisterFilterType
filterType
=
registerEntity
.
getFilterType
();
RegisterFilterType
filterType
=
registerEntity
.
getFilterType
();
List
<
String
>
globalFilterValueList
=
registerEntity
.
getFilterValueList
();
Map
<
String
,
List
<
String
>>
filterMap
=
registerEntity
.
getFilterMap
();
List
<
String
>
filterValueList
=
filterMap
.
get
(
serviceId
);
String
globalFilterValue
=
registerEntity
.
getFilterValue
();
List
<
String
>
allFilterValueList
=
new
ArrayList
<
String
>();
if
(
CollectionUtils
.
isNotEmpty
(
globalFilterValueList
))
{
Map
<
String
,
String
>
filterMap
=
registerEntity
.
getFilterMap
();
allFilterValueList
.
addAll
(
globalFilterValueList
);
String
filterValue
=
filterMap
.
get
(
serviceId
);
String
allFilterIpAddress
=
""
;
if
(
StringUtils
.
isNotEmpty
(
globalFilterValue
))
{
allFilterIpAddress
+=
globalFilterValue
;
}
}
if
(
StringUtils
.
isNotEmpty
(
filterValue
))
{
if
(
CollectionUtils
.
isNotEmpty
(
filterValueList
))
{
allFilter
IpAddress
+=
StringUtils
.
isEmpty
(
allFilterIpAddress
)
?
filterValue
:
PluginConstant
.
SEPARATE
+
filterValue
;
allFilter
ValueList
.
addAll
(
filterValueList
)
;
}
}
switch
(
filterType
)
{
switch
(
filterType
)
{
case
BLACKLIST:
case
BLACKLIST:
validateBlacklist
(
allFilter
IpAddress
,
ipAddress
);
validateBlacklist
(
allFilter
ValueList
,
ipAddress
);
break
;
break
;
case
WHITELIST:
case
WHITELIST:
validateWhitelist
(
allFilter
IpAddress
,
ipAddress
);
validateWhitelist
(
allFilter
ValueList
,
ipAddress
);
break
;
break
;
}
}
}
}
private
void
validateBlacklist
(
String
filterIpAddress
,
String
ipAddress
)
{
private
void
validateBlacklist
(
List
<
String
>
allFilterValueList
,
String
ipAddress
)
{
LOG
.
info
(
"********** IP address blacklist={}, current ip address={} **********"
,
filterIpAddress
,
ipAddress
);
LOG
.
info
(
"********** IP address blacklist={}, current ip address={} **********"
,
allFilterValueList
,
ipAddress
);
String
[]
filterArray
=
StringUtils
.
split
(
filterIpAddress
,
PluginConstant
.
SEPARATE
);
for
(
String
filter
:
allFilterValueList
)
{
for
(
String
filter
:
filterArray
)
{
if
(
ipAddress
.
startsWith
(
filter
))
{
if
(
ipAddress
.
startsWith
(
filter
))
{
throw
new
PluginException
(
ipAddress
+
" isn't allowed to register to Eureka server, because it is in blacklist"
);
throw
new
PluginException
(
ipAddress
+
" isn't allowed to register to Eureka server, because it is in blacklist"
);
}
}
}
}
}
}
private
void
validateWhitelist
(
String
filterIpAddress
,
String
ipAddress
)
{
private
void
validateWhitelist
(
List
<
String
>
allFilterValueList
,
String
ipAddress
)
{
LOG
.
info
(
"********** IP address whitelist={}, current ip address={} **********"
,
filterIpAddress
,
ipAddress
);
LOG
.
info
(
"********** IP address whitelist={}, current ip address={} **********"
,
allFilterValueList
,
ipAddress
);
boolean
valid
=
false
;
boolean
valid
=
false
;
String
[]
filterArray
=
StringUtils
.
split
(
filterIpAddress
,
PluginConstant
.
SEPARATE
);
for
(
String
filter
:
allFilterValueList
)
{
for
(
String
filter
:
filterArray
)
{
if
(
ipAddress
.
startsWith
(
filter
))
{
if
(
ipAddress
.
startsWith
(
filter
))
{
valid
=
true
;
valid
=
true
;
break
;
break
;
...
...
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