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
381689dc
Commit
381689dc
authored
Jul 15, 2018
by
Nepxion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化事件机制
parent
ce17ec18
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
19 additions
and
18 deletions
+19
-18
README.md
+2
-2
discovery-plugin-admin-center/src/main/java/com/nepxion/discovery/plugin/admincenter/endpoint/ConfigEndpoint.java
+2
-2
discovery-plugin-config-center/src/main/java/com/nepxion/discovery/plugin/configcenter/ConfigAdapter.java
+4
-3
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/event/PluginEventWapper.java
+3
-3
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/event/PluginSubscriber.java
+5
-5
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/event/RuleUpdatedEvent.java
+2
-2
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/adapter/MyConfigAdapter.java
+1
-1
No files found.
README.md
View file @
381689dc
...
@@ -290,9 +290,9 @@ public class DiscoveryConfigAdapter extends ConfigAdapter {
...
@@ -290,9 +290,9 @@ public class DiscoveryConfigAdapter extends ConfigAdapter {
// 订阅远程配置中心的规则更新(推送策略自己决定,可以所有服务都只对应一个规则信息,也可以根据服务名获取对应的规则信息)
// 订阅远程配置中心的规则更新(推送策略自己决定,可以所有服务都只对应一个规则信息,也可以根据服务名获取对应的规则信息)
@PostConstruct
@PostConstruct
public
void
publish
()
{
public
void
update
()
{
InputStream
inputStream
=
...;
InputStream
inputStream
=
...;
fireRule
Changed
(
new
RuleChang
edEvent
(
inputStream
),
true
);
fireRule
Updated
(
new
RuleUpdat
edEvent
(
inputStream
),
true
);
}
}
}
}
```
```
...
...
discovery-plugin-admin-center/src/main/java/com/nepxion/discovery/plugin/admincenter/endpoint/ConfigEndpoint.java
View file @
381689dc
...
@@ -31,7 +31,7 @@ import com.nepxion.discovery.plugin.framework.constant.PluginConstant;
...
@@ -31,7 +31,7 @@ import com.nepxion.discovery.plugin.framework.constant.PluginConstant;
import
com.nepxion.discovery.plugin.framework.context.PluginContextAware
;
import
com.nepxion.discovery.plugin.framework.context.PluginContextAware
;
import
com.nepxion.discovery.plugin.framework.entity.RuleEntity
;
import
com.nepxion.discovery.plugin.framework.entity.RuleEntity
;
import
com.nepxion.discovery.plugin.framework.event.PluginEventWapper
;
import
com.nepxion.discovery.plugin.framework.event.PluginEventWapper
;
import
com.nepxion.discovery.plugin.framework.event.Rule
Chang
edEvent
;
import
com.nepxion.discovery.plugin.framework.event.Rule
Updat
edEvent
;
@RestController
@RestController
@Api
(
tags
=
{
"配置接口"
})
@Api
(
tags
=
{
"配置接口"
})
...
@@ -80,7 +80,7 @@ public class ConfigEndpoint {
...
@@ -80,7 +80,7 @@ public class ConfigEndpoint {
try
{
try
{
InputStream
inputStream
=
IOUtils
.
toInputStream
(
config
,
PluginConstant
.
ENCODING_UTF_8
);
InputStream
inputStream
=
IOUtils
.
toInputStream
(
config
,
PluginConstant
.
ENCODING_UTF_8
);
pluginEventWapper
.
fireRule
Changed
(
new
RuleChang
edEvent
(
inputStream
),
async
);
pluginEventWapper
.
fireRule
Updated
(
new
RuleUpdat
edEvent
(
inputStream
),
async
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
return
toExceptionResponseEntity
(
e
,
true
);
return
toExceptionResponseEntity
(
e
,
true
);
}
}
...
...
discovery-plugin-config-center/src/main/java/com/nepxion/discovery/plugin/configcenter/ConfigAdapter.java
View file @
381689dc
...
@@ -13,13 +13,13 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -13,13 +13,13 @@ import org.springframework.beans.factory.annotation.Autowired;
import
com.nepxion.discovery.plugin.configcenter.loader.AbstractConfigLoader
;
import
com.nepxion.discovery.plugin.configcenter.loader.AbstractConfigLoader
;
import
com.nepxion.discovery.plugin.framework.event.PluginEventWapper
;
import
com.nepxion.discovery.plugin.framework.event.PluginEventWapper
;
import
com.nepxion.discovery.plugin.framework.event.Rule
Chang
edEvent
;
import
com.nepxion.discovery.plugin.framework.event.Rule
Updat
edEvent
;
public
abstract
class
ConfigAdapter
extends
AbstractConfigLoader
{
public
abstract
class
ConfigAdapter
extends
AbstractConfigLoader
{
@Autowired
@Autowired
private
PluginEventWapper
pluginEventWapper
;
private
PluginEventWapper
pluginEventWapper
;
public
void
fireRule
Changed
(
RuleChangedEvent
ruleChang
edEvent
,
boolean
async
)
{
public
void
fireRule
Updated
(
RuleUpdatedEvent
ruleUpdat
edEvent
,
boolean
async
)
{
pluginEventWapper
.
fireRule
Changed
(
ruleChang
edEvent
,
async
);
pluginEventWapper
.
fireRule
Updated
(
ruleUpdat
edEvent
,
async
);
}
}
}
}
\ No newline at end of file
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/event/PluginEventWapper.java
View file @
381689dc
...
@@ -18,11 +18,11 @@ public class PluginEventWapper {
...
@@ -18,11 +18,11 @@ public class PluginEventWapper {
@Autowired
@Autowired
private
PluginSubscriber
pluginSubscriber
;
private
PluginSubscriber
pluginSubscriber
;
public
void
fireRule
Changed
(
RuleChangedEvent
ruleChang
edEvent
,
boolean
async
)
{
public
void
fireRule
Updated
(
RuleUpdatedEvent
ruleUpdat
edEvent
,
boolean
async
)
{
if
(
async
)
{
if
(
async
)
{
pluginPublisher
.
asyncPublish
(
rule
Chang
edEvent
);
pluginPublisher
.
asyncPublish
(
rule
Updat
edEvent
);
}
else
{
}
else
{
pluginSubscriber
.
onRule
Changed
(
ruleChang
edEvent
);
pluginSubscriber
.
onRule
Updated
(
ruleUpdat
edEvent
);
}
}
}
}
...
...
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/event/PluginSubscriber.java
View file @
381689dc
...
@@ -42,7 +42,7 @@ public class PluginSubscriber {
...
@@ -42,7 +42,7 @@ public class PluginSubscriber {
private
LoadBalanceListenerExecutor
loadBalanceListenerExecutor
;
private
LoadBalanceListenerExecutor
loadBalanceListenerExecutor
;
@Subscribe
@Subscribe
public
void
onRule
Changed
(
RuleChangedEvent
ruleChang
edEvent
)
{
public
void
onRule
Updated
(
RuleUpdatedEvent
ruleUpdat
edEvent
)
{
Boolean
discoveryControlEnabled
=
pluginContextAware
.
isDiscoveryControlEnabled
();
Boolean
discoveryControlEnabled
=
pluginContextAware
.
isDiscoveryControlEnabled
();
Boolean
remoteConfigEnabled
=
pluginContextAware
.
isRemoteConfigEnabled
();
Boolean
remoteConfigEnabled
=
pluginContextAware
.
isRemoteConfigEnabled
();
...
@@ -58,13 +58,13 @@ public class PluginSubscriber {
...
@@ -58,13 +58,13 @@ public class PluginSubscriber {
return
;
return
;
}
}
LOG
.
info
(
"********** Remote
config chang
ing has been triggered **********"
);
LOG
.
info
(
"********** Remote
rule updat
ing has been triggered **********"
);
if
(
rule
Chang
edEvent
==
null
)
{
if
(
rule
Updat
edEvent
==
null
)
{
throw
new
PluginException
(
"Rule
Chang
edEvent can't be null"
);
throw
new
PluginException
(
"Rule
Updat
edEvent can't be null"
);
}
}
InputStream
inputStream
=
rule
Chang
edEvent
.
getInputStream
();
InputStream
inputStream
=
rule
Updat
edEvent
.
getInputStream
();
try
{
try
{
pluninConfigParser
.
parse
(
inputStream
);
pluninConfigParser
.
parse
(
inputStream
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
...
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/event/Rule
Chang
edEvent.java
→
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/event/Rule
Updat
edEvent.java
View file @
381689dc
...
@@ -12,12 +12,12 @@ package com.nepxion.discovery.plugin.framework.event;
...
@@ -12,12 +12,12 @@ package com.nepxion.discovery.plugin.framework.event;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.io.Serializable
;
import
java.io.Serializable
;
public
class
Rule
Chang
edEvent
implements
Serializable
{
public
class
Rule
Updat
edEvent
implements
Serializable
{
private
static
final
long
serialVersionUID
=
2315578803987663866L
;
private
static
final
long
serialVersionUID
=
2315578803987663866L
;
private
InputStream
inputStream
;
private
InputStream
inputStream
;
public
Rule
Chang
edEvent
(
InputStream
inputStream
)
{
public
Rule
Updat
edEvent
(
InputStream
inputStream
)
{
this
.
inputStream
=
inputStream
;
this
.
inputStream
=
inputStream
;
}
}
...
...
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/adapter/MyConfigAdapter.java
View file @
381689dc
...
@@ -48,7 +48,7 @@ public class MyConfigAdapter extends ConfigAdapter {
...
@@ -48,7 +48,7 @@ public class MyConfigAdapter extends ConfigAdapter {
public void publish() {
public void publish() {
try {
try {
InputStream inputStream = FileUtils.openInputStream(new File("src/main/resources/rule.xml"));
InputStream inputStream = FileUtils.openInputStream(new File("src/main/resources/rule.xml"));
fireRule
Changed(new RuleChang
edEvent(inputStream), true);
fireRule
Updated(new RuleUpdat
edEvent(inputStream), true);
} catch (IOException e) {
} catch (IOException e) {
e.printStackTrace();
e.printStackTrace();
}
}
...
...
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