summaryrefslogtreecommitdiffstats
path: root/rulemgt/src
diff options
context:
space:
mode:
authorGuangrongFu <fu.guangrong@zte.com.cn>2022-03-03 11:33:59 +0800
committerGuangrongFu <fu.guangrong@zte.com.cn>2022-03-03 11:33:59 +0800
commit3502d780735b537f29ec398745a7ed264805ac9b (patch)
tree6d1223cb304d88c6ccda41854bfe335666a65bb0 /rulemgt/src
parentecf54e8ad1182aa14b5f942160e1834725a432f9 (diff)
bugfix - fixed the healthcheck problem
Issue-ID: HOLMES-512 Signed-off-by: GuangrongFu <fu.guangrong@zte.com.cn> Change-Id: I4393c649468157c00f3ea57568056b087b76554c
Diffstat (limited to 'rulemgt/src')
-rw-r--r--rulemgt/src/main/java/org/onap/holmes/rulemgt/Initializer.java19
-rw-r--r--rulemgt/src/test/java/org/onap/holmes/rulemgt/InitializerTest.java2
2 files changed, 13 insertions, 8 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 812ee48..3995e4c 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.Executors;
import java.util.concurrent.TimeUnit;
import static org.onap.holmes.common.utils.CommonUtils.getEnv;
@@ -38,7 +39,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 volatile static boolean readyForMsbReg = false;
private MsbRegister msbRegister;
@Inject
@@ -48,17 +49,19 @@ public class Initializer {
@PostConstruct
private void init() {
- waitUntilReady();
- try {
- msbRegister.register2Msb(createMicroServiceInfo());
- } catch (CorrelationException e) {
- logger.error(e.getMessage(), e);
- }
+ Executors.newSingleThreadExecutor().execute(() -> {
+ waitUntilReady();
+ try {
+ msbRegister.register2Msb(createMicroServiceInfo());
+ } catch (CorrelationException e) {
+ logger.error(e.getMessage(), e);
+ }
+ });
}
private void waitUntilReady() {
int count = 1;
- while(!readyForMsbReg) {
+ while (!readyForMsbReg) {
if (count > 20) {
break;
}
diff --git a/rulemgt/src/test/java/org/onap/holmes/rulemgt/InitializerTest.java b/rulemgt/src/test/java/org/onap/holmes/rulemgt/InitializerTest.java
index f658d35..8e4a6fe 100644
--- a/rulemgt/src/test/java/org/onap/holmes/rulemgt/InitializerTest.java
+++ b/rulemgt/src/test/java/org/onap/holmes/rulemgt/InitializerTest.java
@@ -51,6 +51,8 @@ public class InitializerTest {
WhiteboxImpl.invokeMethod(initializer, "init");
+ TimeUnit.SECONDS.sleep(6);
+
PowerMock.verifyAll();
}