diff options
author | Fiete Ostkamp <Fiete.Ostkamp@telekom.de> | 2024-05-16 08:54:54 +0200 |
---|---|---|
committer | Fiete Ostkamp <Fiete.Ostkamp@telekom.de> | 2024-05-16 08:59:11 +0200 |
commit | c4208db72297836601e1e4a579b60f96960bbdf3 (patch) | |
tree | ade19694865508d2089e3d0bdee85ae9953867a4 /src/main | |
parent | a61b2948f9cbe25d0ec6cd957671d51d83c62a1a (diff) |
Stop sdc-distribution-client upon service shutdown
- restore old behaviour by calling distributionClient.stop()
- downgrade sdc-distribution-client version to 2.0.0
Issue-ID: AAI-3848
Change-Id: Id252f4d8e387a916dcbdebd5110b46432858ee6b
Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/org/onap/aai/modelloader/config/DistributionClientStartupConfig.java | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/main/java/org/onap/aai/modelloader/config/DistributionClientStartupConfig.java b/src/main/java/org/onap/aai/modelloader/config/DistributionClientStartupConfig.java index cd9d919..937c62d 100644 --- a/src/main/java/org/onap/aai/modelloader/config/DistributionClientStartupConfig.java +++ b/src/main/java/org/onap/aai/modelloader/config/DistributionClientStartupConfig.java @@ -23,6 +23,8 @@ import java.util.Date; import java.util.Timer; import java.util.TimerTask; +import javax.annotation.PreDestroy; + import org.onap.aai.cl.api.Logger; import org.onap.aai.cl.eelf.LoggerFactory; import org.onap.aai.modelloader.notification.EventCallback; @@ -42,13 +44,13 @@ public class DistributionClientStartupConfig { private static final Logger logger = LoggerFactory.getInstance().getLogger(DistributionClientStartupConfig.class); - private final IDistributionClient client; + private final IDistributionClient distributionClient; private final ModelLoaderConfig config; private final EventCallback eventCallback; - public DistributionClientStartupConfig(IDistributionClient client, ModelLoaderConfig config, + public DistributionClientStartupConfig(IDistributionClient distributionClient, ModelLoaderConfig config, EventCallback eventCallback) { - this.client = client; + this.distributionClient = distributionClient; this.config = config; this.eventCallback = eventCallback; } @@ -58,12 +60,12 @@ public class DistributionClientStartupConfig { // Initialize distribution client logger.debug(ModelLoaderMsgs.INITIALIZING, "Initializing distribution client..."); IDistributionClientResult initResult = null; - initResult = client.init(config, eventCallback); + initResult = distributionClient.init(config, eventCallback); if (initResult.getDistributionActionResult() == DistributionActionResultEnum.SUCCESS) { // Start distribution client logger.debug(ModelLoaderMsgs.INITIALIZING, "Starting distribution client..."); - IDistributionClientResult startResult = client.start(); + IDistributionClientResult startResult = distributionClient.start(); if (startResult.getDistributionActionResult() == DistributionActionResultEnum.SUCCESS) { logger.info(ModelLoaderMsgs.INITIALIZING, "Connection to SDC established"); } else { @@ -72,7 +74,7 @@ public class DistributionClientStartupConfig { // Kick off a timer to retry the SDC connection Timer timer = new Timer(); - TimerTask task = new SdcConnectionJob(client, config, eventCallback, timer); + TimerTask task = new SdcConnectionJob(distributionClient, config, eventCallback, timer); timer.schedule(task, new Date(), 60000); } } else { @@ -81,8 +83,16 @@ public class DistributionClientStartupConfig { // Kick off a timer to retry the SDC connection Timer timer = new Timer(); - TimerTask task = new SdcConnectionJob(client, config, eventCallback, timer); + TimerTask task = new SdcConnectionJob(distributionClient, config, eventCallback, timer); timer.schedule(task, new Date(), 60000); } } + + @PreDestroy + public void destroy() { + logger.info(ModelLoaderMsgs.STOPPING_CLIENT); + if (distributionClient != null) { + distributionClient.stop(); + } + } } |