diff options
author | Timoney, Dan (dt5972) <dtimoney@att.com> | 2018-11-06 11:30:49 -0500 |
---|---|---|
committer | Dan Timoney <dtimoney@att.com> | 2018-11-06 16:33:23 +0000 |
commit | d411beeeb5b407c170a98ad98c18ab85d5281833 (patch) | |
tree | 67c682c6ad9d7ada2cbf1d79423105351291ee36 /ueb-listener | |
parent | 29e7063b7f1832d14fd92642914e6917da45c18c (diff) |
Fix misplaced if
Updated main loop of ueb-listener to recreate client on each iteration
rather than using client created outside loop.
Change-Id: I5c5b9f26e472dfbffefdd49a870a293159f72b10
Issue-ID: SDNC-472
Signed-off-by: Timoney, Dan (dt5972) <dtimoney@att.com>
Diffstat (limited to 'ueb-listener')
-rw-r--r-- | ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebClient.java | 59 |
1 files changed, 26 insertions, 33 deletions
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 2078a798f..e5dec14c7 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 @@ -37,66 +37,59 @@ public class SdncUebClient { 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); - - LOG.info("Initializing ASDC distribution client"); - - IDistributionClientResult result = client.init(config, cb); - - LOG.info("Initialized ASDC distribution client - results = {}", result.getDistributionMessageResult()); - long startTm = System.currentTimeMillis(); int sleepTm = config.getPollingInterval() * 1000; long maxWaitTm = config.getClientStartupTimeout() * 1000L; boolean keepWaiting = true; boolean listenerStarted = false; + boolean processDownloads = true; while (keepWaiting) { + LOG.info("Initializing ASDC distribution client"); + + IDistributionClient client = DistributionClientFactory.createDistributionClient(); + SdncUebCallback cb = new SdncUebCallback(client, config); + IDistributionClientResult result = client.init(config, cb); + LOG.info("Initialized ASDC distribution client - results = {}", result.getDistributionMessageResult()); + if (result.getDistributionActionResult() == DistributionActionResultEnum.SUCCESS) { + if (processDownloads) { + LOG.info("Scanning for local distribution artifacts before starting client"); + cb.deployDownloadedFiles(null, null, null); + processDownloads = false; + } LOG.info("Starting client..."); try { IDistributionClientResult start = client.start(); LOG.info("Client startup result = {}", start.getDistributionMessageResult()); - + // Only stop waiting if the result is success if (start.getDistributionActionResult() == DistributionActionResultEnum.SUCCESS) { - + keepWaiting = false; listenerStarted = true; } else { - LOG.info("SDC returned {} - exitting",start.getDistributionActionResult().toString()); + LOG.info("SDC returned {} - exitting", start.getDistributionActionResult().toString()); try { client.stop(); - } catch(Exception e1) { + } 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) { + } catch (Exception e) { LOG.info("Client startup failure", e); } + } - if (System.currentTimeMillis() - startTm < maxWaitTm) { - keepWaiting = false; - } else { + if (System.currentTimeMillis() - startTm < maxWaitTm) { + keepWaiting = false; + } else { - try { - Thread.sleep(sleepTm); - } catch (InterruptedException e) { - // Ignore - } + try { + Thread.sleep(sleepTm); + } catch (InterruptedException e) { + // Ignore } } |