From 25bb156451b5603f53f3db125c7876a7de571bd8 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Wed, 31 Oct 2018 15:50:33 -0400 Subject: Fix error handling Recreate client objects after failure is returned by SDC before retrying. Change-Id: Ib165fc1220a010a0443a7dab4014aaba8c9f29f8 Issue-ID: SDNC-472 Signed-off-by: Timoney, Dan (dt5972) --- .../ccsdk/sli/northbound/uebclient/SdncUebClient.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'ueb-listener/src/main') diff --git a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebClient.java b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebClient.java index c025f3b05..4f2de1cc1 100644 --- a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebClient.java +++ b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebClient.java @@ -34,13 +34,12 @@ public class SdncUebClient { private static final Logger LOG = LoggerFactory.getLogger(SdncUebConfiguration.class); public static void main(String[] args) { - IDistributionClient client = DistributionClientFactory.createDistributionClient(); SdncUebConfiguration config = new SdncUebConfiguration(); + IDistributionClient client = DistributionClientFactory.createDistributionClient(); SdncUebCallback cb = new SdncUebCallback(client, config); - LOG.info("Scanning for local distribution artifacts before starting client"); cb.deployDownloadedFiles(null, null, null); @@ -67,6 +66,21 @@ public class SdncUebClient { if (start.getDistributionActionResult() == DistributionActionResultEnum.SUCCESS) { keepWaiting = false; + } else { + LOG.info("SDC returned "+start.getDistributionActionResult().toString()+" - will retry"); + try { + client.stop(); + } catch(Exception e1) { + // Ignore exception on stop + } + client = DistributionClientFactory.createDistributionClient(); + cb = new SdncUebCallback(client, config); + LOG.info("Initializing ASDC distribution client"); + + result = client.init(config, cb); + + LOG.info("Initialized ASDC distribution client - results = {}", result.getDistributionMessageResult()); + } } catch(Exception e) { LOG.info("Client startup failure", e); -- cgit 1.2.3-korg