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
1297f53e
Commit
1297f53e
authored
Jul 25, 2018
by
Nepxion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复解析远程配置文件的Bug
parent
86e860b1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
11 deletions
+26
-11
discovery-plugin-config-center/src/main/java/com/nepxion/discovery/plugin/configcenter/ConfigInitializer.java
+26
-11
No files found.
discovery-plugin-config-center/src/main/java/com/nepxion/discovery/plugin/configcenter/ConfigInitializer.java
View file @
1297f53e
...
@@ -53,23 +53,35 @@ public class ConfigInitializer {
...
@@ -53,23 +53,35 @@ public class ConfigInitializer {
LOG
.
info
(
"Rule starts to initialize..."
);
LOG
.
info
(
"Rule starts to initialize..."
);
String
config
=
getConfig
();
String
remoteConfig
=
getRemoteConfig
();
if
(
StringUtils
.
isEmpty
(
config
))
{
if
(
StringUtils
.
isNotEmpty
(
remoteConfig
))
{
return
;
try
{
RuleEntity
ruleEntity
=
configParser
.
parse
(
remoteConfig
);
pluginAdapter
.
setDynamicRule
(
ruleEntity
);
}
catch
(
Exception
e
)
{
LOG
.
error
(
"Parse rule xml failed"
,
e
);
}
}
}
String
localConfig
=
getLocalConfig
();
if
(
StringUtils
.
isNotEmpty
(
localConfig
))
{
try
{
try
{
RuleEntity
ruleEntity
=
configParser
.
parse
(
c
onfig
);
RuleEntity
ruleEntity
=
configParser
.
parse
(
localC
onfig
);
pluginAdapter
.
setLocalRule
(
ruleEntity
);
pluginAdapter
.
setLocalRule
(
ruleEntity
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
LOG
.
error
(
"Parse rule xml failed"
,
e
);
LOG
.
error
(
"Parse rule xml failed"
,
e
);
}
}
}
}
public
String
getConfig
()
{
if
(
StringUtils
.
isEmpty
(
remoteConfig
)
&&
StringUtils
.
isEmpty
(
localConfig
))
{
String
config
=
null
;
LOG
.
info
(
"No config is retrieved"
);
}
}
private
String
getRemoteConfig
()
{
if
(
remoteConfigLoader
!=
null
)
{
if
(
remoteConfigLoader
!=
null
)
{
String
config
=
null
;
try
{
try
{
config
=
remoteConfigLoader
.
getConfig
();
config
=
remoteConfigLoader
.
getConfig
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -81,12 +93,18 @@ public class ConfigInitializer {
...
@@ -81,12 +93,18 @@ public class ConfigInitializer {
return
config
;
return
config
;
}
else
{
}
else
{
LOG
.
info
(
"Remote config isn't retrieved
, use local config loader
"
);
LOG
.
info
(
"Remote config isn't retrieved"
);
}
}
}
else
{
}
else
{
LOG
.
info
(
"Remote config loader isn't provided, use local config loader"
);
LOG
.
info
(
"Remote config loader isn't provided"
);
}
return
null
;
}
}
private
String
getLocalConfig
()
{
String
config
=
null
;
try
{
try
{
config
=
localConfigLoader
.
getConfig
();
config
=
localConfigLoader
.
getConfig
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -101,8 +119,6 @@ public class ConfigInitializer {
...
@@ -101,8 +119,6 @@ public class ConfigInitializer {
LOG
.
info
(
"Local config isn't retrieved"
);
LOG
.
info
(
"Local config isn't retrieved"
);
}
}
LOG
.
info
(
"No config is retrieved"
);
return
null
;
return
null
;
}
}
}
}
\ 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