summaryrefslogtreecommitdiffstats
path: root/rulemgt/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'rulemgt/src/main')
-rw-r--r--rulemgt/src/main/java/org/onap/holmes/rulemgt/Initializer.java23
-rw-r--r--rulemgt/src/main/java/org/onap/holmes/rulemgt/RuleActiveApp.java2
2 files changed, 25 insertions, 0 deletions
diff --git a/rulemgt/src/main/java/org/onap/holmes/rulemgt/Initializer.java b/rulemgt/src/main/java/org/onap/holmes/rulemgt/Initializer.java
index c39de60..812ee48 100644
--- a/rulemgt/src/main/java/org/onap/holmes/rulemgt/Initializer.java
+++ b/rulemgt/src/main/java/org/onap/holmes/rulemgt/Initializer.java
@@ -30,6 +30,7 @@ import javax.annotation.PostConstruct;
import javax.inject.Inject;
import java.util.HashSet;
import java.util.Set;
+import java.util.concurrent.TimeUnit;
import static org.onap.holmes.common.utils.CommonUtils.getEnv;
import static org.onap.holmes.common.utils.CommonUtils.isIpAddress;
@@ -37,6 +38,7 @@ import static org.onap.holmes.common.utils.CommonUtils.isIpAddress;
@Service
public class Initializer {
private static final Logger logger = LoggerFactory.getLogger(Initializer.class);
+ private static boolean readyForMsbReg = false;
private MsbRegister msbRegister;
@Inject
@@ -46,6 +48,7 @@ public class Initializer {
@PostConstruct
private void init() {
+ waitUntilReady();
try {
msbRegister.register2Msb(createMicroServiceInfo());
} catch (CorrelationException e) {
@@ -53,6 +56,26 @@ public class Initializer {
}
}
+ private void waitUntilReady() {
+ int count = 1;
+ while(!readyForMsbReg) {
+ if (count > 20) {
+ break;
+ }
+ int interval = 5 * count++;
+ logger.info("Not ready for MSB registration. Try again after {} seconds...", interval);
+ try {
+ TimeUnit.SECONDS.sleep(interval);
+ } catch (InterruptedException e) {
+ logger.info(e.getMessage(), e);
+ }
+ }
+ }
+
+ public static void setReadyForMsbReg(boolean readyForMsbReg) {
+ Initializer.readyForMsbReg = readyForMsbReg;
+ }
+
private MicroServiceInfo createMicroServiceInfo() {
String[] serviceIpAndPort = MicroServiceConfig.getMicroServiceIpAndPort();
MicroServiceInfo msinfo = new MicroServiceInfo();
diff --git a/rulemgt/src/main/java/org/onap/holmes/rulemgt/RuleActiveApp.java b/rulemgt/src/main/java/org/onap/holmes/rulemgt/RuleActiveApp.java
index a9a78c8..cedcde0 100644
--- a/rulemgt/src/main/java/org/onap/holmes/rulemgt/RuleActiveApp.java
+++ b/rulemgt/src/main/java/org/onap/holmes/rulemgt/RuleActiveApp.java
@@ -45,6 +45,8 @@ public class RuleActiveApp extends IOCApplication<RuleAppConfig> {
environment.servlets().addFilter("customFilter", new TransactionIdFilter()).addMappingForUrlPatterns(EnumSet
.allOf(DispatcherType.class), true, "/*");
+
+ Initializer.setReadyForMsbReg(true);
}
}