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
b764713f
Commit
b764713f
authored
Jul 20, 2018
by
Nepxion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
开启和关闭通过Rest方式对规则配置的控制和推送
parent
36b0e5e5
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
0 deletions
+22
-0
discovery-plugin-admin-center/src/main/java/com/nepxion/discovery/plugin/admincenter/endpoint/ConfigEndpoint.java
+10
-0
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/constant/PluginConstant.java
+1
-0
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/context/PluginContextAware.java
+9
-0
discovery-springcloud-example/src/main/resources/bootstrap.properties
+2
-0
No files found.
discovery-plugin-admin-center/src/main/java/com/nepxion/discovery/plugin/admincenter/endpoint/ConfigEndpoint.java
View file @
b764713f
...
...
@@ -69,6 +69,11 @@ public class ConfigEndpoint {
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
"Discovery control is disabled"
);
}
Boolean
isConfigRestControlEnabled
=
pluginContextAware
.
isConfigRestControlEnabled
();
if
(!
isConfigRestControlEnabled
)
{
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
"Config rest control is disabled"
);
}
pluginEventWapper
.
fireRuleCleared
(
new
RuleClearedEvent
(),
true
);
return
ResponseEntity
.
ok
().
body
(
"OK"
);
...
...
@@ -105,6 +110,11 @@ public class ConfigEndpoint {
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
"Discovery control is disabled"
);
}
Boolean
isConfigRestControlEnabled
=
pluginContextAware
.
isConfigRestControlEnabled
();
if
(!
isConfigRestControlEnabled
)
{
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
"Config rest control is disabled"
);
}
try
{
InputStream
inputStream
=
IOUtils
.
toInputStream
(
config
,
PluginConstant
.
ENCODING_UTF_8
);
pluginEventWapper
.
fireRuleUpdated
(
new
RuleUpdatedEvent
(
inputStream
),
async
);
...
...
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/constant/PluginConstant.java
View file @
b764713f
...
...
@@ -14,6 +14,7 @@ public class PluginConstant {
public
static
final
String
SPRING_APPLICATION_REGISTER_CONTROL_ENABLED
=
"spring.application.register.control.enabled"
;
public
static
final
String
SPRING_APPLICATION_DISCOVERY_CONTROL_ENABLED
=
"spring.application.discovery.control.enabled"
;
public
static
final
String
SPRING_APPLICATION_CONFIG_REST_CONTROL_ENABLED
=
"spring.application.config.rest.control.enabled"
;
public
static
final
String
SPRING_APPLICATION_NAME
=
"spring.application.name"
;
public
static
final
String
SERVICE_ID
=
"serviceId"
;
...
...
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/context/PluginContextAware.java
View file @
b764713f
...
...
@@ -92,6 +92,10 @@ public class PluginContextAware implements ApplicationContextAware {
return
isDiscoveryControlEnabled
(
environment
);
}
public
Boolean
isConfigRestControlEnabled
()
{
return
isConfigRestControlEnabled
(
environment
);
}
public
static
Boolean
isRegisterControlEnabled
(
Environment
environment
)
{
return
environment
.
getProperty
(
PluginConstant
.
SPRING_APPLICATION_REGISTER_CONTROL_ENABLED
,
Boolean
.
class
,
Boolean
.
TRUE
);
}
...
...
@@ -99,4 +103,8 @@ public class PluginContextAware implements ApplicationContextAware {
public
static
Boolean
isDiscoveryControlEnabled
(
Environment
environment
)
{
return
environment
.
getProperty
(
PluginConstant
.
SPRING_APPLICATION_DISCOVERY_CONTROL_ENABLED
,
Boolean
.
class
,
Boolean
.
TRUE
);
}
public
static
Boolean
isConfigRestControlEnabled
(
Environment
environment
)
{
return
environment
.
getProperty
(
PluginConstant
.
SPRING_APPLICATION_CONFIG_REST_CONTROL_ENABLED
,
Boolean
.
class
,
Boolean
.
TRUE
);
}
}
\ No newline at end of file
discovery-springcloud-example/src/main/resources/bootstrap.properties
View file @
b764713f
...
...
@@ -27,6 +27,8 @@ management.security.enabled=false
spring.application.register.control.enabled
=
true
# 开启和关闭服务发现层面的控制。一旦关闭,服务多版本调用的控制功能将失效,动态屏蔽指定IP地址的服务实例被发现的功能将失效。缺失则默认为true
spring.application.discovery.control.enabled
=
true
# 开启和关闭通过Rest方式对规则配置的控制和推送。一旦关闭,只能通过远程配置中心来控制和推送。缺失则默认为true
spring.application.config.rest.control.enabled
=
true
# Swagger config
swagger.service.base.package
=
com.nepxion.discovery.plugin.admincenter.endpoint
...
...
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