Code Review
/
nonrtric.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Fixed concurrency problems
[nonrtric.git]
/
policy-agent
/
src
/
main
/
java
/
org
/
oransc
/
policyagent
/
tasks
/
RefreshConfigTask.java
diff --git
a/policy-agent/src/main/java/org/oransc/policyagent/tasks/RefreshConfigTask.java
b/policy-agent/src/main/java/org/oransc/policyagent/tasks/RefreshConfigTask.java
index
1ab5fc9
..
4080b37
100644
(file)
--- a/
policy-agent/src/main/java/org/oransc/policyagent/tasks/RefreshConfigTask.java
+++ b/
policy-agent/src/main/java/org/oransc/policyagent/tasks/RefreshConfigTask.java
@@
-81,9
+81,9
@@
public class RefreshConfigTask {
stop();
loadConfigurationFromFile();
refreshTask = createRefreshTask() //
stop();
loadConfigurationFromFile();
refreshTask = createRefreshTask() //
- .subscribe(notUsed -> logger.
info
("Refreshed configuration data"),
+ .subscribe(notUsed -> logger.
debug
("Refreshed configuration data"),
throwable -> logger.error("Configuration refresh terminated due to exception", throwable),
throwable -> logger.error("Configuration refresh terminated due to exception", throwable),
- () -> logger.
error("Configuration refresh termina
ted"));
+ () -> logger.
debug("Configuration refresh comple
ted"));
}
public void stop() {
}
public void stop() {
@@
-116,8
+116,9
@@
public class RefreshConfigTask {
return cbsClient.updates(getConfigRequest, initialDelay, refreshPeriod);
}
return cbsClient.updates(getConfigRequest, initialDelay, refreshPeriod);
}
- private <R> Mono<R> onErrorResume(Throwable trowable) {
- logger.error("Could not refresh application configuration {}", trowable.toString());
+ private <R> Mono<R> onErrorResume(Throwable throwable) {
+ String errMsg = throwable.toString();
+ logger.error("Could not refresh application configuration. {}", errMsg);
return Mono.empty();
}
return Mono.empty();
}
@@
-136,7
+137,7
@@
public class RefreshConfigTask {
/**
* Reads the configuration from file.
*/
/**
* Reads the configuration from file.
*/
-
public
void loadConfigurationFromFile() {
+ void loadConfigurationFromFile() {
String filepath = appConfig.getLocalConfigurationFilePath();
if (filepath == null) {
logger.debug("No localconfiguration file used");
String filepath = appConfig.getLocalConfigurationFilePath();
if (filepath == null) {
logger.debug("No localconfiguration file used");
@@
-146,11
+147,7
@@
public class RefreshConfigTask {
ServiceLoader.load(TypeAdapterFactory.class).forEach(gsonBuilder::registerTypeAdapterFactory);
try (InputStream inputStream = createInputStream(filepath)) {
ServiceLoader.load(TypeAdapterFactory.class).forEach(gsonBuilder::registerTypeAdapterFactory);
try (InputStream inputStream = createInputStream(filepath)) {
- JsonParser parser = new JsonParser();
- JsonObject rootObject = getJsonElement(parser, inputStream).getAsJsonObject();
- if (rootObject == null) {
- throw new JsonSyntaxException("Root is not a json object");
- }
+ JsonObject rootObject = getJsonElement(inputStream).getAsJsonObject();
ApplicationConfigParser appParser = new ApplicationConfigParser();
appParser.parse(rootObject);
appConfig.setConfiguration(appParser.getRicConfigs(), appParser.getDmaapPublisherConfig(),
ApplicationConfigParser appParser = new ApplicationConfigParser();
appParser.parse(rootObject);
appConfig.setConfiguration(appParser.getRicConfigs(), appParser.getDmaapPublisherConfig(),
@@
-161,8
+158,8
@@
public class RefreshConfigTask {
}
}
}
}
- JsonElement getJsonElement(
JsonParser parser,
InputStream inputStream) {
- return
parser.parse
(new InputStreamReader(inputStream));
+ JsonElement getJsonElement(InputStream inputStream) {
+ return
JsonParser.parseReader
(new InputStreamReader(inputStream));
}
InputStream createInputStream(@NotNull String filepath) throws IOException {
}
InputStream createInputStream(@NotNull String filepath) throws IOException {