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) <dtimoney@att.com>
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 c025f3b..4f2de1c 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 @@
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 @@
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);