From 373aa4076b59a63eae8440a338e2836902e9ebe4 Mon Sep 17 00:00:00 2001 From: Piotr Marcinkiewicz Date: Tue, 24 Aug 2021 11:20:54 +0200 Subject: Update DCAE SDK library Issue-ID: DCAEGEN2-2719 Signed-off-by: Piotr Marcinkiewicz Change-Id: If4086ddf60747b4d87c5067a68df748a7dc2c689 --- .../dcae/ApplicationConfigurationListener.java | 22 +++++++++++----------- src/main/java/org/onap/dcae/VesApplication.java | 6 +++--- .../dcae/configuration/ConfigurationHandler.java | 20 ++++++++++---------- 3 files changed, 24 insertions(+), 24 deletions(-) (limited to 'src/main/java/org/onap') diff --git a/src/main/java/org/onap/dcae/ApplicationConfigurationListener.java b/src/main/java/org/onap/dcae/ApplicationConfigurationListener.java index b86bc1ec..c847cddc 100644 --- a/src/main/java/org/onap/dcae/ApplicationConfigurationListener.java +++ b/src/main/java/org/onap/dcae/ApplicationConfigurationListener.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * VES Collector * ================================================================================ - * Copyright (C) 2020 Nokia. All rights reserved. + * Copyright (C) 2020-2021 Nokia. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ import reactor.core.Disposable; import java.time.Duration; /** - * ApplicationConfigurationListener is used to listen at notifications with configuration updates send from Consul. + * ApplicationConfigurationListener is used to listen at notifications with configuration updates. */ public class ApplicationConfigurationListener implements Runnable { @@ -42,7 +42,7 @@ public class ApplicationConfigurationListener implements Runnable { /** * Constructor * @param interval defines period of time when notification can come - * @param configurationHandler handles notifications send by Consul + * @param configurationHandler handles notifications */ public ApplicationConfigurationListener(Duration interval, ConfigurationHandler configurationHandler) { this.interval = interval; @@ -50,7 +50,7 @@ public class ApplicationConfigurationListener implements Runnable { } /** - * Reload listener to start listening for Consul notifications with defined interval. + * Reload listener to start listening for configurations notifications with defined interval. * @param interval defines period of time when notification can come */ public synchronized void reload(Duration interval) { @@ -64,23 +64,23 @@ public class ApplicationConfigurationListener implements Runnable { } /** - * Start listening for Consul notification. + * Start listening for configurations notification. */ @Override public void run() { - Disposable consulListener = null; + Disposable configListener = null; do { try { - consulListener = listenForConfigurationUpdates(); + configListener = listenForConfigurationUpdates(); synchronized (this) { - log.info("Switch to configuration handler thread. Active waiting for configuration from Consul."); + log.info("Switch to configuration handler thread. Active waiting for configuration."); this.wait(); } } catch (Exception e) { - log.error("Unexpected error occurred during handling data from Consul.", e); + log.error("Unexpected error occurred during handling data.", e); terminate(); } finally { - stopListeningForConfigurationUpdates(consulListener); + stopListeningForConfigurationUpdates(configListener); } } while (!this.terminate); } @@ -95,7 +95,7 @@ public class ApplicationConfigurationListener implements Runnable { /** * Release resources when there is a need to stop listener - * @param consulListener Handler to Consul listener + * @param consulListener Handler to configurations listener */ void stopListeningForConfigurationUpdates(Disposable consulListener) { if (consulListener != null) { diff --git a/src/main/java/org/onap/dcae/VesApplication.java b/src/main/java/org/onap/dcae/VesApplication.java index f8cd74ad..75fd4594 100644 --- a/src/main/java/org/onap/dcae/VesApplication.java +++ b/src/main/java/org/onap/dcae/VesApplication.java @@ -3,7 +3,7 @@ * PROJECT * ================================================================================ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright (C) 2020 Nokia. All rights reserved. + * Copyright (C) 2020-2021 Nokia. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -66,7 +66,7 @@ public class VesApplication { applicationLock.lock(); try { startApplication(args); - startListeningForApplicationConfigurationStoredInConsul(); + startListeningForApplicationConfiguration(); } finally { applicationLock.unlock(); } @@ -110,7 +110,7 @@ public class VesApplication { context = SpringApplication.run(VesApplication.class); } - private static void startListeningForApplicationConfigurationStoredInConsul() { + private static void startListeningForApplicationConfiguration() { ConfigurationHandler cbsHandler = new ConfigurationHandler(new CbsClientConfigurationProvider(), configUpdater); ApplicationConfigurationListener applicationConfigProvider = new ApplicationConfigurationListener(Duration.ofMinutes(DEFAULT_CONFIGURATION_FETCH_PERIOD), cbsHandler); diff --git a/src/main/java/org/onap/dcae/configuration/ConfigurationHandler.java b/src/main/java/org/onap/dcae/configuration/ConfigurationHandler.java index ebdf0474..aa3561b6 100644 --- a/src/main/java/org/onap/dcae/configuration/ConfigurationHandler.java +++ b/src/main/java/org/onap/dcae/configuration/ConfigurationHandler.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * VES Collector * ================================================================================ - * Copyright (C) 2020 Nokia. All rights reserved.s + * Copyright (C) 2020-2021 Nokia. All rights reserved.s * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,8 +37,8 @@ import reactor.core.publisher.Mono; import java.time.Duration; /** - * ConfigurationHandler is responsible for receiving configuration updates from Consul. - * Any change made in the Consul will be reported as a notification. + * ConfigurationHandler is responsible for receiving configuration updates from config file or Consul (if config file doesn't exist). + * Any change made in the configuration will be reported as a notification. */ public class ConfigurationHandler { @@ -61,12 +61,12 @@ public class ConfigurationHandler { /** * Start listen for application configuration notifications with configuration changes * @param interval defines period of time when notification can come - * @return {@link Disposable} handler to close Consul listener at the end + * @return {@link Disposable} handler to close configuration listener at the end */ public Disposable startListen(Duration interval) { - log.info("Start listening for configuration from Consul ..."); - log.info(String.format("Consul configuration will be fetched in %s period.", interval)); + log.info("Start listening for configuration ..."); + log.info(String.format("Configuration will be fetched in %s period.", interval)); // Polling properties final Duration initialDelay = Duration.ofSeconds(5); @@ -78,7 +78,7 @@ public class ConfigurationHandler { return createCbsClient(cbsClientConfiguration) .flatMapMany(cbsClient -> cbsClient.updates(request, initialDelay, period)) .subscribe( - this::handleConfigurationFromConsul, + this::handleConfiguration, this::handleError ); } @@ -87,8 +87,8 @@ public class ConfigurationHandler { return CbsClientFactory.createCbsClient(cbsClientConfiguration); } - void handleConfigurationFromConsul(JsonObject jsonObject) { - log.info("Configuration update from Consul {}", jsonObject); + void handleConfiguration(JsonObject jsonObject) { + log.info("Configuration update {}", jsonObject); if(jsonObject.has(CONFIG_DICT)) { JsonObject config = jsonObject.getAsJsonObject(CONFIG_DICT); JSONObject jObject = new JSONObject(config.toString()); @@ -99,7 +99,7 @@ public class ConfigurationHandler { } private void handleError(Throwable throwable) { - log.error("Unexpected error occurred during fetching configuration from Consul", throwable); + log.error("Unexpected error occurred during fetching configuration", throwable); } private CbsRequest createCbsRequest() { -- cgit 1.2.3-korg