X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=dmaap-dsa%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fholmes%2Fdsa%2Fdmaap%2FDmaapDsaActiveApp.java;h=a74910c86c926e2cc6d504498e1f60bc5ef2b290;hb=02477312f805d819b9b71ce91bcbebea98697fb5;hp=50e7fc495e976999ae89f38c86ce74f97113c4fa;hpb=1db590a6b07cfd0ab8c1718b0b760a25fe4dd60f;p=holmes%2Fdsa.git diff --git a/dmaap-dsa/src/main/java/org/onap/holmes/dsa/dmaap/DmaapDsaActiveApp.java b/dmaap-dsa/src/main/java/org/onap/holmes/dsa/dmaap/DmaapDsaActiveApp.java index 50e7fc4..a74910c 100644 --- a/dmaap-dsa/src/main/java/org/onap/holmes/dsa/dmaap/DmaapDsaActiveApp.java +++ b/dmaap-dsa/src/main/java/org/onap/holmes/dsa/dmaap/DmaapDsaActiveApp.java @@ -16,13 +16,18 @@ package org.onap.holmes.dsa.dmaap; +import static jdk.nashorn.internal.runtime.regexp.joni.Config.log; + import io.dropwizard.setup.Environment; -import java.io.IOException; +import java.util.HashSet; +import java.util.Set; import lombok.extern.slf4j.Slf4j; -import org.onap.holmes.common.api.entity.ServiceRegisterEntity; import org.onap.holmes.common.config.MicroServiceConfig; import org.onap.holmes.common.dropwizard.ioc.bundle.IOCApplication; +import org.onap.holmes.common.exception.CorrelationException; import org.onap.holmes.common.utils.MSBRegisterUtil; +import org.onap.msb.sdk.discovery.entity.MicroServiceInfo; +import org.onap.msb.sdk.discovery.entity.Node; @Slf4j public class DmaapDsaActiveApp extends IOCApplication { @@ -33,22 +38,27 @@ public class DmaapDsaActiveApp extends IOCApplication { @Override public void run(DmaapDsaConfig configuration, Environment environment) throws Exception { super.run(configuration, environment); - try { - new MSBRegisterUtil().register(initServiceEntity()); - } catch (IOException e) { - log.warn("Micro service registry httpclient close failure", e); + new MSBRegisterUtil().register2Msb(createMicroServiceInfo()); + } catch (CorrelationException e) { + log.warn(e.getMessage(), e); } } - private ServiceRegisterEntity initServiceEntity() { - ServiceRegisterEntity serviceRegisterEntity = new ServiceRegisterEntity(); - serviceRegisterEntity.setServiceName("holmes-dmaap-dsa"); - serviceRegisterEntity.setProtocol("REST"); - serviceRegisterEntity.setVersion("v1"); - serviceRegisterEntity.setUrl("/onapapi/holmes-dmaap-dsa/v1/"); - serviceRegisterEntity.setSingleNode(MicroServiceConfig.getServiceIp(), "9103", 0); - serviceRegisterEntity.setVisualRange("1|0"); - return serviceRegisterEntity; + private MicroServiceInfo createMicroServiceInfo() { + String[] serviceAddrInfo = MicroServiceConfig.getMicroServiceIpAndPort(); + MicroServiceInfo msinfo = new MicroServiceInfo(); + msinfo.setServiceName("holmes-dmaap-dsa"); + msinfo.setVersion("v1"); + msinfo.setUrl("/api/holmes-dmaap-dsa/v1/"); + msinfo.setProtocol("REST"); + msinfo.setVisualRange("0|1"); + Set nodes = new HashSet<>(); + Node node = new Node(); + node.setIp(serviceAddrInfo[0]); + node.setPort(serviceAddrInfo[1]); + nodes.add(node); + msinfo.setNodes(nodes); + return msinfo; } }