summaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authorEric Debeau <eric.debeau@orange.com>2018-09-19 20:56:56 +0000
committerGerrit Code Review <gerrit@onap.org>2018-09-19 20:56:56 +0000
commitda5dacff85f9f6056be23c10b369d761703afa69 (patch)
tree313ad9f91a8c52c37d0dca4d7747d37ca2e33e3e /src/main/java/org
parent8385036969ef8d3e5b0f6c9ef2c6750305d7a4de (diff)
parent192430657e40fc09f619737c8253e5d647ce90fd (diff)
Merge "adjust msb integration"
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/onap/nbi/ServiceRegisterRunner.java36
1 files changed, 29 insertions, 7 deletions
diff --git a/src/main/java/org/onap/nbi/ServiceRegisterRunner.java b/src/main/java/org/onap/nbi/ServiceRegisterRunner.java
index 5e0c711..8c10e56 100644
--- a/src/main/java/org/onap/nbi/ServiceRegisterRunner.java
+++ b/src/main/java/org/onap/nbi/ServiceRegisterRunner.java
@@ -46,6 +46,12 @@ public class ServiceRegisterRunner implements CommandLineRunner {
@Value("${msb.discovery.port}")
private int DISCOVERY_PORT;
+ @Value("${msb.discovery.retry}")
+ private int RETRY;
+
+ @Value("${msb.discovery.retry_interval}")
+ private int RETRY_INTERVAL;
+
@Value("${msb.service.host}")
private String SERVICE_HOST;
@@ -75,7 +81,10 @@ public class ServiceRegisterRunner implements CommandLineRunner {
@Override
public void run(String... strings) throws Exception {
- if (!IS_ENABLED) return;
+ if (!IS_ENABLED) {
+ logger.info("Registration with msb discovery is not enabled");
+ return;
+ }
MicroServiceInfo msinfo = new MicroServiceInfo();
msinfo.setServiceName(SERVICE_NAME);
@@ -99,21 +108,34 @@ public class ServiceRegisterRunner implements CommandLineRunner {
msinfo.setNodes(nodes);
logger.info(
- "Register this service with msb discovery (" + DISCOVERY_HOST + ":" + DISCOVERY_PORT + "):\n"
+ "Registering with msb discovery (" + DISCOVERY_HOST + ":" + DISCOVERY_PORT + "):\n"
+ " - host: [" + thisNode.getIp() + "]\n"
+ " - port: [" + thisNode.getPort() + "]\n"
+ " - name: [" + msinfo.getServiceName() + "]\n"
+ " - version: [" + msinfo.getVersion() + "]\n"
+ " - url: [" + msinfo.getUrl() + "]\n"
+ " - path: [" + msinfo.getPath() + "]\n"
- + " - protocol: [" + msinfo.getProtocol() + "]\n"
+ + " - protocol: [" + msinfo.getProtocol() + "]g\n"
+ " - visualRange: [" + msinfo.getVisualRange() + "]\n"
+ " - enableSSL: [" + SERVICE_ENABLE_SSL + "]\n"
);
- MSBServiceClient msbClient = new MSBServiceClient(DISCOVERY_HOST, DISCOVERY_PORT);
- MicroServiceFullInfo microServiceFullInfo = msbClient.registerMicroServiceInfo(msinfo);
-
- logger.debug("microServiceFullInfo = {}", microServiceFullInfo.toString());
+ int attempt = 0;
+ while (true) {
+ attempt += 1;
+ try {
+ logger.info("Registration with msb discovery (attempt {}/{})", attempt, RETRY);
+ MSBServiceClient msbClient = new MSBServiceClient(DISCOVERY_HOST, DISCOVERY_PORT);
+ MicroServiceFullInfo microServiceFullInfo = msbClient.registerMicroServiceInfo(msinfo);
+ logger.debug("Registration with msb discovery done, microServiceFullInfo = {}", microServiceFullInfo.toString());
+ break;
+ } catch (Exception ex) {
+ if (attempt == RETRY) {
+ throw new Exception("Registration with msb discovery FAILED");
+ }
+ }
+ logger.info("Registration with msb discovery (attempt {}/{}) FAILED. Sleep {}ms", attempt, RETRY, RETRY_INTERVAL);
+ Thread.sleep(RETRY_INTERVAL);
+ }
}
}