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
1bbda364
Commit
1bbda364
authored
Jun 30, 2018
by
Nepxion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修正拼写错误
parent
b02f1dc4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
22 deletions
+30
-22
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/decorator/DiscoveryClientDecorator.java
+10
-2
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/event/RegisterFailureEvent.java
+11
-12
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/listener/impl/IpAddressFilterRegisterListener.java
+5
-5
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/extension/MySubscriber.java
+4
-3
No files found.
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/decorator/DiscoveryClientDecorator.java
View file @
1bbda364
...
@@ -32,7 +32,7 @@ public class DiscoveryClientDecorator implements DiscoveryClient {
...
@@ -32,7 +32,7 @@ public class DiscoveryClientDecorator implements DiscoveryClient {
@Override
@Override
public
List
<
ServiceInstance
>
getInstances
(
String
serviceId
)
{
public
List
<
ServiceInstance
>
getInstances
(
String
serviceId
)
{
List
<
ServiceInstance
>
instances
=
discoveryClient
.
get
Instances
(
serviceId
);
List
<
ServiceInstance
>
instances
=
getReal
Instances
(
serviceId
);
Boolean
discoveryControlEnabled
=
PluginContextAware
.
isDiscoveryControlEnabled
(
environment
);
Boolean
discoveryControlEnabled
=
PluginContextAware
.
isDiscoveryControlEnabled
(
environment
);
if
(
discoveryControlEnabled
)
{
if
(
discoveryControlEnabled
)
{
...
@@ -43,9 +43,13 @@ public class DiscoveryClientDecorator implements DiscoveryClient {
...
@@ -43,9 +43,13 @@ public class DiscoveryClientDecorator implements DiscoveryClient {
return
instances
;
return
instances
;
}
}
public
List
<
ServiceInstance
>
getRealInstances
(
String
serviceId
)
{
return
discoveryClient
.
getInstances
(
serviceId
);
}
@Override
@Override
public
List
<
String
>
getServices
()
{
public
List
<
String
>
getServices
()
{
List
<
String
>
services
=
discoveryClient
.
get
Services
();
List
<
String
>
services
=
getReal
Services
();
Boolean
discoveryControlEnabled
=
PluginContextAware
.
isDiscoveryControlEnabled
(
environment
);
Boolean
discoveryControlEnabled
=
PluginContextAware
.
isDiscoveryControlEnabled
(
environment
);
if
(
discoveryControlEnabled
)
{
if
(
discoveryControlEnabled
)
{
...
@@ -56,6 +60,10 @@ public class DiscoveryClientDecorator implements DiscoveryClient {
...
@@ -56,6 +60,10 @@ public class DiscoveryClientDecorator implements DiscoveryClient {
return
services
;
return
services
;
}
}
public
List
<
String
>
getRealServices
()
{
return
discoveryClient
.
getServices
();
}
@Deprecated
@Deprecated
@Override
@Override
public
ServiceInstance
getLocalServiceInstance
()
{
public
ServiceInstance
getLocalServiceInstance
()
{
...
...
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/event/RegisterFaiureEvent.java
→
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/event/RegisterFai
l
ureEvent.java
View file @
1bbda364
...
@@ -11,36 +11,34 @@ package com.nepxion.discovery.plugin.framework.event;
...
@@ -11,36 +11,34 @@ package com.nepxion.discovery.plugin.framework.event;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
com.nepxion.discovery.plugin.framework.entity.FilterType
;
public
class
RegisterFailureEvent
implements
Serializable
{
public
class
RegisterFaiureEvent
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
1343084923958294246L
;
private
static
final
long
serialVersionUID
=
-
1343084923958294246L
;
private
FilterType
filter
Type
;
private
String
event
Type
;
private
String
serviceId
;
private
String
serviceId
;
private
String
ipAddress
;
private
String
ipAddress
;
private
int
port
;
private
int
port
;
public
RegisterFai
ureEvent
(
FilterType
filter
Type
,
String
serviceId
,
String
ipAddress
,
int
port
)
{
public
RegisterFai
lureEvent
(
String
event
Type
,
String
serviceId
,
String
ipAddress
,
int
port
)
{
this
.
filterType
=
filter
Type
;
this
.
eventType
=
event
Type
;
this
.
serviceId
=
serviceId
;
this
.
serviceId
=
serviceId
;
this
.
ipAddress
=
ipAddress
;
this
.
ipAddress
=
ipAddress
;
this
.
port
=
port
;
this
.
port
=
port
;
}
}
public
String
get
IpAddress
()
{
public
String
get
EventType
()
{
return
ipAddress
;
return
eventType
;
}
}
public
String
getServiceId
()
{
public
String
getServiceId
()
{
return
serviceId
;
return
serviceId
;
}
}
public
int
getPort
()
{
public
String
getIpAddress
()
{
return
port
;
return
ipAddress
;
}
}
public
FilterType
getFilterType
()
{
public
int
getPort
()
{
return
filterType
;
return
port
;
}
}
}
}
\ No newline at end of file
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/listener/impl/IpAddressFilterRegisterListener.java
View file @
1bbda364
...
@@ -24,7 +24,7 @@ import com.nepxion.discovery.plugin.framework.entity.FilterType;
...
@@ -24,7 +24,7 @@ import com.nepxion.discovery.plugin.framework.entity.FilterType;
import
com.nepxion.discovery.plugin.framework.entity.RegisterEntity
;
import
com.nepxion.discovery.plugin.framework.entity.RegisterEntity
;
import
com.nepxion.discovery.plugin.framework.entity.RuleEntity
;
import
com.nepxion.discovery.plugin.framework.entity.RuleEntity
;
import
com.nepxion.discovery.plugin.framework.event.PluginPublisher
;
import
com.nepxion.discovery.plugin.framework.event.PluginPublisher
;
import
com.nepxion.discovery.plugin.framework.event.RegisterFaiureEvent
;
import
com.nepxion.discovery.plugin.framework.event.RegisterFai
l
ureEvent
;
import
com.nepxion.discovery.plugin.framework.exception.PluginException
;
import
com.nepxion.discovery.plugin.framework.exception.PluginException
;
import
com.nepxion.discovery.plugin.framework.listener.AbstractRegisterListener
;
import
com.nepxion.discovery.plugin.framework.listener.AbstractRegisterListener
;
...
@@ -86,7 +86,7 @@ public class IpAddressFilterRegisterListener extends AbstractRegisterListener {
...
@@ -86,7 +86,7 @@ public class IpAddressFilterRegisterListener extends AbstractRegisterListener {
private
void
validateBlacklist
(
FilterType
filterType
,
List
<
String
>
allFilterValueList
,
String
serviceId
,
String
ipAddress
,
int
port
)
{
private
void
validateBlacklist
(
FilterType
filterType
,
List
<
String
>
allFilterValueList
,
String
serviceId
,
String
ipAddress
,
int
port
)
{
for
(
String
filterValue
:
allFilterValueList
)
{
for
(
String
filterValue
:
allFilterValueList
)
{
if
(
ipAddress
.
startsWith
(
filterValue
))
{
if
(
ipAddress
.
startsWith
(
filterValue
))
{
onRegisterFaiure
(
filterType
,
allFilterValueList
,
serviceId
,
ipAddress
,
port
);
onRegisterFai
l
ure
(
filterType
,
allFilterValueList
,
serviceId
,
ipAddress
,
port
);
}
}
}
}
}
}
...
@@ -101,14 +101,14 @@ public class IpAddressFilterRegisterListener extends AbstractRegisterListener {
...
@@ -101,14 +101,14 @@ public class IpAddressFilterRegisterListener extends AbstractRegisterListener {
}
}
if
(
matched
)
{
if
(
matched
)
{
onRegisterFaiure
(
filterType
,
allFilterValueList
,
serviceId
,
ipAddress
,
port
);
onRegisterFai
l
ure
(
filterType
,
allFilterValueList
,
serviceId
,
ipAddress
,
port
);
}
}
}
}
private
void
onRegisterFaiure
(
FilterType
filterType
,
List
<
String
>
allFilterValueList
,
String
serviceId
,
String
ipAddress
,
int
port
)
{
private
void
onRegisterFai
l
ure
(
FilterType
filterType
,
List
<
String
>
allFilterValueList
,
String
serviceId
,
String
ipAddress
,
int
port
)
{
Boolean
registerFailureEventEnabled
=
environment
.
getProperty
(
PluginConstant
.
SPRING_APPLICATION_REGISTER_FAILURE_EVENT_ENABLED
,
Boolean
.
class
,
Boolean
.
FALSE
);
Boolean
registerFailureEventEnabled
=
environment
.
getProperty
(
PluginConstant
.
SPRING_APPLICATION_REGISTER_FAILURE_EVENT_ENABLED
,
Boolean
.
class
,
Boolean
.
FALSE
);
if
(
registerFailureEventEnabled
)
{
if
(
registerFailureEventEnabled
)
{
pluginPublisher
.
asyncPublish
(
new
RegisterFai
ureEvent
(
filterType
,
serviceId
,
ipAddress
,
port
));
pluginPublisher
.
asyncPublish
(
new
RegisterFai
lureEvent
(
filterType
.
toString
()
,
serviceId
,
ipAddress
,
port
));
}
}
throw
new
PluginException
(
ipAddress
+
" isn't allowed to register to Register server, not match IP address "
+
filterType
+
"="
+
allFilterValueList
);
throw
new
PluginException
(
ipAddress
+
" isn't allowed to register to Register server, not match IP address "
+
filterType
+
"="
+
allFilterValueList
);
...
...
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/extension/MySubscriber.java
View file @
1bbda364
...
@@ -10,13 +10,13 @@ package com.nepxion.discovery.plugin.example.extension;
...
@@ -10,13 +10,13 @@ package com.nepxion.discovery.plugin.example.extension;
*/
*/
import
com.google.common.eventbus.Subscribe
;
import
com.google.common.eventbus.Subscribe
;
import
com.nepxion.discovery.plugin.framework.event.RegisterFaiureEvent
;
import
com.nepxion.discovery.plugin.framework.event.RegisterFai
l
ureEvent
;
import
com.nepxion.eventbus.annotation.EventBus
;
import
com.nepxion.eventbus.annotation.EventBus
;
@EventBus
@EventBus
public
class
MySubscriber
{
public
class
MySubscriber
{
@Subscribe
@Subscribe
public
void
subscribeRegisterFai
ure
(
RegisterFaiureEvent
registerFai
ureEvent
)
{
public
void
subscribeRegisterFai
lure
(
RegisterFailureEvent
registerFail
ureEvent
)
{
System
.
out
.
println
(
"========== 注册失败:
filterType="
+
registerFaiureEvent
.
getFilterType
()
+
", serviceId="
+
registerFaiureEvent
.
getServiceId
()
+
", ipAddress="
+
registerFaiureEvent
.
getIpAddress
()
+
", port="
+
registerFai
ureEvent
.
getPort
());
System
.
out
.
println
(
"========== 注册失败:
eventType="
+
registerFailureEvent
.
getEventType
()
+
", serviceId="
+
registerFailureEvent
.
getServiceId
()
+
", ipAddress="
+
registerFailureEvent
.
getIpAddress
()
+
", port="
+
registerFail
ureEvent
.
getPort
());
}
}
}
}
\ No newline at end of file
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