X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=holmes-actions%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fholmes%2Fcommon%2Futils%2FMSBRegisterUtil.java;h=1cd481e42fd401f463803d0f761bb2e578365a29;hb=9d2cccba20f32fe54e4ccf1f433f68b5cee95bd5;hp=8052f783b24797ed1cec7caf14182b910f73d510;hpb=8eedabbb6faf3bc2ba10df850e68cf719cd6c8ad;p=holmes%2Fcommon.git diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/utils/MSBRegisterUtil.java b/holmes-actions/src/main/java/org/onap/holmes/common/utils/MSBRegisterUtil.java index 8052f78..1cd481e 100644 --- a/holmes-actions/src/main/java/org/onap/holmes/common/utils/MSBRegisterUtil.java +++ b/holmes-actions/src/main/java/org/onap/holmes/common/utils/MSBRegisterUtil.java @@ -35,44 +35,12 @@ import org.onap.msb.sdk.httpclient.msb.MSBServiceClient; @Service public class MSBRegisterUtil { - public void register(ServiceRegisterEntity entity) throws IOException { - log.info("Start register Holmes Service to MSB..."); - boolean flag = false; - int retry = 0; - while (!flag && retry < 20) { - log.info("Holmes Service Registration. Retry: " + retry); - retry++; - flag = innerRegister(entity); - if (!flag) { - log.warn("Failed to register the service to MSB. Sleep 30s and try again."); - threadSleep(30000); - } else { - log.info("Registration succeeded!"); - break; - } - } - log.info("Service registration completed."); - } - - private boolean innerRegister(ServiceRegisterEntity entity) { - try { - log.info("msbServerAddr:" + MicroServiceConfig.getMsbServerAddr()); - log.info("entity:" + entity); - MicroserviceBusRest resourceserviceproxy = ConsumerFactory.createConsumer( - MicroServiceConfig.getMsbServerAddr(), MicroserviceBusRest.class); - resourceserviceproxy.registerServce("false", entity); - } catch (Exception error) { - log.error("Micro-service registration failed!" + error.getMessage(), error); - return false; - } - return true; - } - public void register2Msb(MicroServiceInfo msinfo) throws CorrelationException { - MSBServiceClient msbClient = new MSBServiceClient(MicroServiceConfig.getMsbServerIp(), - MicroServiceConfig.getMsbServerPort()); + String[] msbAddrInfo = MicroServiceConfig.getMsbAddrInfo(); + MSBServiceClient msbClient = new MSBServiceClient(msbAddrInfo[0], + Integer.parseInt(msbAddrInfo[1])); - log.info("Start register Holmes Service to MSB..."); + log.info("Start to register Holmes Service to MSB..."); MicroServiceFullInfo microServiceFullInfo = null; int retry = 0; while (null == microServiceFullInfo && retry < 20) {