Commit 1297f53e by Nepxion

修复解析远程配置文件的Bug

parent 86e860b1
...@@ -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(config); RuleEntity ruleEntity = configParser.parse(localConfig);
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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment