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
5f29ed3b
Commit
5f29ed3b
authored
Jul 09, 2018
by
Nepxion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化类结构
parent
eda35bf7
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
30 additions
and
39 deletions
+30
-39
discovery-plugin-framework-consul/src/main/java/com/nepxion/discovery/plugin/framework/adapter/ConsulAdapter.java
+1
-6
discovery-plugin-framework-eureka/src/main/java/com/nepxion/discovery/plugin/framework/adapter/EurekaAdapter.java
+2
-6
discovery-plugin-framework-zookeeper/src/main/java/com/nepxion/discovery/plugin/framework/adapter/ZookeeperAdapter.java
+2
-6
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/adapter/AbstractPluginAdapter.java
+14
-1
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/listener/BasicListener.java
+6
-13
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/listener/Listener.java
+3
-5
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/listener/register/CountFilterRegisterListener.java
+1
-1
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/listener/register/IpAddressFilterRegisterListener.java
+1
-1
No files found.
discovery-plugin-framework-consul/src/main/java/com/nepxion/discovery/plugin/framework/adapter/ConsulAdapter.java
View file @
5f29ed3b
...
...
@@ -13,11 +13,9 @@ import javax.annotation.PostConstruct;
import
org.apache.commons.lang3.ArrayUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cloud.client.serviceregistry.Registration
;
import
org.springframework.cloud.consul.discovery.ConsulServer
;
import
org.springframework.cloud.consul.serviceregistry.ConsulRegistration
;
import
org.springframework.core.env.ConfigurableEnvironment
;
import
com.nepxion.discovery.plugin.framework.constant.ConsulConstant
;
import
com.nepxion.discovery.plugin.framework.constant.PluginConstant
;
...
...
@@ -25,14 +23,11 @@ import com.nepxion.discovery.plugin.framework.exception.PluginException;
import
com.netflix.loadbalancer.Server
;
public
class
ConsulAdapter
extends
AbstractPluginAdapter
{
@Autowired
private
ConfigurableEnvironment
environment
;
private
String
version
;
@PostConstruct
private
void
initialize
()
{
String
value
=
environment
.
getProperty
(
ConsulConstant
.
METADATA_VERSION
);
String
value
=
pluginContextAware
.
getEnvironment
()
.
getProperty
(
ConsulConstant
.
METADATA_VERSION
);
if
(
StringUtils
.
isEmpty
(
value
))
{
return
;
}
...
...
discovery-plugin-framework-eureka/src/main/java/com/nepxion/discovery/plugin/framework/adapter/EurekaAdapter.java
View file @
5f29ed3b
...
...
@@ -9,10 +9,8 @@ package com.nepxion.discovery.plugin.framework.adapter;
* @version 1.0
*/
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cloud.client.serviceregistry.Registration
;
import
org.springframework.cloud.netflix.eureka.serviceregistry.EurekaRegistration
;
import
org.springframework.core.env.ConfigurableEnvironment
;
import
com.nepxion.discovery.plugin.framework.constant.EurekaConstant
;
import
com.nepxion.discovery.plugin.framework.constant.PluginConstant
;
...
...
@@ -21,9 +19,6 @@ import com.netflix.loadbalancer.Server;
import
com.netflix.niws.loadbalancer.DiscoveryEnabledServer
;
public
class
EurekaAdapter
extends
AbstractPluginAdapter
{
@Autowired
private
ConfigurableEnvironment
environment
;
@Override
public
String
getIpAddress
(
Registration
registration
)
{
if
(
registration
instanceof
EurekaRegistration
)
{
...
...
@@ -59,6 +54,6 @@ public class EurekaAdapter extends AbstractPluginAdapter {
@Override
public
String
getLocalVersion
()
{
return
environment
.
getProperty
(
EurekaConstant
.
METADATA_VERSION
);
return
pluginContextAware
.
getEnvironment
()
.
getProperty
(
EurekaConstant
.
METADATA_VERSION
);
}
}
\ No newline at end of file
discovery-plugin-framework-zookeeper/src/main/java/com/nepxion/discovery/plugin/framework/adapter/ZookeeperAdapter.java
View file @
5f29ed3b
...
...
@@ -9,11 +9,9 @@ package com.nepxion.discovery.plugin.framework.adapter;
* @version 1.0
*/
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cloud.client.serviceregistry.Registration
;
import
org.springframework.cloud.zookeeper.discovery.ZookeeperServer
;
import
org.springframework.cloud.zookeeper.serviceregistry.ZookeeperRegistration
;
import
org.springframework.core.env.ConfigurableEnvironment
;
import
com.nepxion.discovery.plugin.framework.constant.PluginConstant
;
import
com.nepxion.discovery.plugin.framework.constant.ZookeeperConstant
;
...
...
@@ -21,9 +19,6 @@ import com.nepxion.discovery.plugin.framework.exception.PluginException;
import
com.netflix.loadbalancer.Server
;
public
class
ZookeeperAdapter
extends
AbstractPluginAdapter
{
@Autowired
private
ConfigurableEnvironment
environment
;
@Override
public
String
getIpAddress
(
Registration
registration
)
{
if
(
registration
instanceof
ZookeeperRegistration
)
{
...
...
@@ -59,6 +54,6 @@ public class ZookeeperAdapter extends AbstractPluginAdapter {
@Override
public
String
getLocalVersion
()
{
return
environment
.
getProperty
(
ZookeeperConstant
.
METADATA_VERSION
);
return
pluginContextAware
.
getEnvironment
()
.
getProperty
(
ZookeeperConstant
.
METADATA_VERSION
);
}
}
\ No newline at end of file
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/adapter/AbstractPluginAdapter.java
View file @
5f29ed3b
...
...
@@ -14,10 +14,14 @@ import org.springframework.beans.factory.annotation.Autowired;
import
com.nepxion.discovery.plugin.framework.cache.PluginCache
;
import
com.nepxion.discovery.plugin.framework.constant.PluginConstant
;
import
com.nepxion.discovery.plugin.framework.context.PluginContextAware
;
public
abstract
class
AbstractPluginAdapter
implements
PluginAdapter
{
@Autowired
private
PluginCache
pluginCache
;
protected
PluginContextAware
pluginContextAware
;
@Autowired
protected
PluginCache
pluginCache
;
@Override
public
String
getVersion
()
{
...
...
@@ -43,4 +47,12 @@ public abstract class AbstractPluginAdapter implements PluginAdapter {
public
void
clearDynamicVersion
()
{
pluginCache
.
clear
(
PluginConstant
.
VERSION
);
}
public
PluginContextAware
getPluginContextAware
()
{
return
pluginContextAware
;
}
public
PluginCache
getPluginCache
()
{
return
pluginCache
;
}
}
\ No newline at end of file
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/listener/BasicListener.java
View file @
5f29ed3b
...
...
@@ -10,23 +10,15 @@ package com.nepxion.discovery.plugin.framework.listener;
*/
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.core.env.ConfigurableEnvironment
;
public
class
BasicListener
implements
Listener
{
@Autowired
protected
ConfigurableApplicationContext
applicationContext
;
import
com.nepxion.discovery.plugin.framework.context.PluginContextAware
;
public
class
BasicListener
implements
Listener
{
@Autowired
protected
ConfigurableEnvironment
environment
;
@Override
public
ConfigurableApplicationContext
getApplicationContext
()
{
return
applicationContext
;
}
protected
PluginContextAware
pluginContextAware
;
@Override
public
ConfigurableEnvironment
getEnvironment
()
{
return
environment
;
public
PluginContextAware
getPluginContextAware
()
{
return
pluginContextAware
;
}
}
\ No newline at end of file
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/listener/Listener.java
View file @
5f29ed3b
...
...
@@ -9,11 +9,8 @@ package com.nepxion.discovery.plugin.framework.listener;
* @version 1.0
*/
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.core.env.ConfigurableEnvironment
;
import
com.nepxion.discovery.plugin.framework.context.PluginContextAware
;
public
interface
Listener
{
ConfigurableApplicationContext
getApplicationContext
();
ConfigurableEnvironment
getEnvironment
();
PluginContextAware
getPluginContextAware
();
}
\ No newline at end of file
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/listener/register/CountFilterRegisterListener.java
View file @
5f29ed3b
...
...
@@ -88,7 +88,7 @@ public class CountFilterRegisterListener extends AbstractRegisterListener {
private
void
onRegisterFailure
(
int
maxCount
,
String
serviceId
,
String
ipAddress
,
int
port
)
{
String
description
=
ipAddress
+
" isn't allowed to register to Register server, reach max limited count="
+
maxCount
;
Boolean
registerFailureEventEnabled
=
environment
.
getProperty
(
PluginConstant
.
SPRING_APPLICATION_REGISTER_FAILURE_EVENT_ENABLED
,
Boolean
.
class
,
Boolean
.
FALSE
);
Boolean
registerFailureEventEnabled
=
pluginContextAware
.
getEnvironment
()
.
getProperty
(
PluginConstant
.
SPRING_APPLICATION_REGISTER_FAILURE_EVENT_ENABLED
,
Boolean
.
class
,
Boolean
.
FALSE
);
if
(
registerFailureEventEnabled
)
{
pluginPublisher
.
asyncPublish
(
new
RegisterFailureEvent
(
PluginConstant
.
REACH_MAX_LIMITED_COUNT
,
description
,
serviceId
,
ipAddress
,
port
));
}
...
...
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/listener/register/IpAddressFilterRegisterListener.java
View file @
5f29ed3b
...
...
@@ -113,7 +113,7 @@ public class IpAddressFilterRegisterListener extends AbstractRegisterListener {
private
void
onRegisterFailure
(
FilterType
filterType
,
List
<
String
>
allFilterValueList
,
String
serviceId
,
String
ipAddress
,
int
port
)
{
String
description
=
ipAddress
+
" isn't allowed to register to Register server, not match IP address "
+
filterType
+
"="
+
allFilterValueList
;
Boolean
registerFailureEventEnabled
=
environment
.
getProperty
(
PluginConstant
.
SPRING_APPLICATION_REGISTER_FAILURE_EVENT_ENABLED
,
Boolean
.
class
,
Boolean
.
FALSE
);
Boolean
registerFailureEventEnabled
=
pluginContextAware
.
getEnvironment
()
.
getProperty
(
PluginConstant
.
SPRING_APPLICATION_REGISTER_FAILURE_EVENT_ENABLED
,
Boolean
.
class
,
Boolean
.
FALSE
);
if
(
registerFailureEventEnabled
)
{
pluginPublisher
.
asyncPublish
(
new
RegisterFailureEvent
(
filterType
.
toString
(),
description
,
serviceId
,
ipAddress
,
port
));
}
...
...
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